Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ public class BeneficiaryCall {
@Transient
private Boolean isTransfered;

@Column(name = "IsDispositionSentToCTI")
private Boolean isDispositionSentToCTI = false;

public BeneficiaryCall() {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,12 @@ public ArrayList<BeneficiaryCall> getExistingBCByCallIDAndAgentID(@Param("callID
@Query("SELECT b.remarks FROM BeneficiaryCall b WHERE b.benCallID = :benCallID")
List<Object[]> fetchBenCallRemarks(@Param("benCallID") Long benCallID);

@Transactional
@Modifying
@Query("update BeneficiaryCall set isDispositionSentToCTI = true where benCallID = :benCallID")
int updateDispositionSentFlag(@Param("benCallID") Long benCallID);

@Query("SELECT b.isDispositionSentToCTI FROM BeneficiaryCall b WHERE b.benCallID = :benCallID")
Boolean isDispositionAlreadySent(@Param("benCallID") Long benCallID);

}
Original file line number Diff line number Diff line change
Expand Up @@ -408,12 +408,9 @@ public Integer closeCall(String request, String ipAddress) throws Exception {
benificiaryCallAtClose.getCallReceivedUserID(), benificiaryCallAtClose.getCallID())
+ " rows where session ID was " + benificiaryCallAtClose.getCallID());

if (benificiaryCall.getIsTransfered() == null || benificiaryCall.getIsTransfered() == false) {
updateCallDisposition(benificiaryCall, benificiaryCall.getAgentIPAddress());

Thread.sleep(1000);
disconnectCallInCTI(benificiaryCall);
}
updateCallDisposition(benificiaryCall, benificiaryCall.getAgentIPAddress());
Thread.sleep(1000);
disconnectCallInCTI(benificiaryCall);
}

return updateCounts;
Expand Down Expand Up @@ -518,9 +515,14 @@ private void disconnectCallInCTI(BeneficiaryCall callToClose) {
}
}

@Async
private void updateCallDisposition(BeneficiaryCall benCall, String agentIP) {
try {
Boolean alreadySent = beneficiaryCallRepository.isDispositionAlreadySent(benCall.getBenCallID());
if (Boolean.TRUE.equals(alreadySent)) {
logger.info("Disposition already sent to CTI for benCallID: " + benCall.getBenCallID() + ", skipping duplicate");
return;
}

BeneficiaryCall callData = beneficiaryCallRepository.findCallDetails(benCall.getBenCallID());
JSONObject dispRequestObj = new JSONObject();
dispRequestObj.put("session_id", callData.getCallID());
Expand All @@ -531,11 +533,15 @@ private void updateCallDisposition(BeneficiaryCall benCall, String agentIP) {
if (null != callData.getCallTypeObj() && null != callData.getCallTypeObj().getCallGroupType()) {
dispRequestObj.put("category", callData.getCallTypeObj().getCallGroupType());
}
logger.info(
ctiService.setCallDisposition(dispRequestObj.toString(), benCall.getAgentIPAddress()).toString());

logger.info("Sending disposition to CTI for benCallID: " + benCall.getBenCallID()
+ ", sessionID: " + callData.getCallID() + ", agentID: " + callData.getAgentID());
String ctiResponse = ctiService.setCallDisposition(dispRequestObj.toString(), benCall.getAgentIPAddress()).toString();
logger.info("CTI disposition response for benCallID " + benCall.getBenCallID() + ": " + ctiResponse);

beneficiaryCallRepository.updateDispositionSentFlag(benCall.getBenCallID());
} catch (Exception e) {
logger.error("updateCallDisposition failed with error " + e.getMessage(), e);
logger.error("updateCallDisposition failed for benCallID " + benCall.getBenCallID() + " with error: " + e.getMessage(), e);
}
}

Expand Down
18 changes: 13 additions & 5 deletions src/main/java/com/iemr/common/service/cti/CTIServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down Expand Up @@ -903,21 +902,30 @@ public OutputResponse transferCall(String request, String remoteAddr) throws IEM
return output;
}

@Async
private void updateCallDisposition(TransferCall transferCall, String agentIP) {
try {
Boolean alreadySent = beneficiaryCallRepository.isDispositionAlreadySent(transferCall.getBenCallID());
if (Boolean.TRUE.equals(alreadySent)) {
logger.info("Disposition already sent to CTI for benCallID: " + transferCall.getBenCallID() + ", skipping duplicate");
return;
}

CallType callTypeData = iemrCalltypeRepositoryImplCustom.getCallTypeDetails(transferCall.getCallTypeID());
BeneficiaryCall callData = beneficiaryCallRepository.findCallDetails(transferCall.getBenCallID());
JSONObject dispRequestObj = new JSONObject();
dispRequestObj.put("session_id", callData.getCallID());
dispRequestObj.put("cust_disp", callTypeData.getCallType());
dispRequestObj.put("agent_id", callData.getAgentID());
dispRequestObj.put("category", callTypeData.getCallGroupType());
logger.info("call disposition log : " + ctiService
.setCallDisposition(dispRequestObj.toString(), transferCall.getAgentIPAddress()).toString());

logger.info("Sending disposition to CTI for benCallID: " + transferCall.getBenCallID()
+ ", sessionID: " + callData.getCallID() + ", agentID: " + callData.getAgentID());
String ctiResponse = ctiService.setCallDisposition(dispRequestObj.toString(), transferCall.getAgentIPAddress()).toString();
logger.info("CTI disposition response for benCallID " + transferCall.getBenCallID() + ": " + ctiResponse);

beneficiaryCallRepository.updateDispositionSentFlag(transferCall.getBenCallID());
} catch (Exception e) {
logger.error("updateCallDisposition failed with error " + e.getMessage(), e);
logger.error("updateCallDisposition failed for benCallID " + transferCall.getBenCallID() + " with error: " + e.getMessage(), e);
}
}

Expand Down