Skip to content

Commit 46195c5

Browse files
authored
fix: AMM-1701 callcounter issue fix (#254)
* fix: AMM-1677 - rendering only grievances who have consent * fix: AMM-1701 callcounter issue fix
1 parent 2f902f8 commit 46195c5

1 file changed

Lines changed: 33 additions & 26 deletions

File tree

src/main/java/com/iemr/common/service/grievance/GrievanceDataSyncImpl.java

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -579,41 +579,48 @@ public String completeGrievanceCall(String request) throws Exception {
579579

580580
// Logic for reattempt based on call group type and call type
581581
boolean isRetryNeeded = grievanceCallStatus.getRetryNeeded();
582-
if ((null != grievanceCallStatus.getComplaintResolution()
583-
&& grievanceCallStatus.getComplaintResolution().equalsIgnoreCase("Resolved")) || (callGroupType.equalsIgnoreCase("Valid") && (callType.equalsIgnoreCase("Valid") || callType.equals("Test Call")))) {
582+
boolean isResolved = grievanceCallStatus.getComplaintResolution() != null
583+
&& grievanceCallStatus.getComplaintResolution().equalsIgnoreCase("Resolved");
584+
boolean isValidGroup = callGroupType.equalsIgnoreCase("Valid")
585+
&& (callType.equalsIgnoreCase("Valid") || callType.equals("Test Call"));
586+
boolean isInvalidGroup = callGroupType.equalsIgnoreCase("Invalid")
587+
&& (callType.equalsIgnoreCase("Wrong Number") || callType.equalsIgnoreCase("Invalid Call"));
588+
589+
if (isResolved) {
590+
// 1) Any resolved call → complete, no retry
584591
isRetryNeeded = false;
585592
updateCount = grievanceDataRepo.updateCompletedStatusInCall(true, false, complaintID, userID, beneficiaryRegID);
586-
}
587-
else if (callGroupType.equalsIgnoreCase("Invalid") && (callType.equalsIgnoreCase("Wrong Number") || callType.equalsIgnoreCase("Invalid Call"))) {
593+
594+
} else if (isValidGroup) {
595+
// 2) Valid but not resolved → leave open, retry allowed
596+
isRetryNeeded = true;
597+
updateCount = grievanceDataRepo.updateCompletedStatusInCall(false, true, complaintID, userID, beneficiaryRegID);
598+
599+
} else if (isInvalidGroup) {
600+
// 3) Invalid calls → complete, no retry
588601
isRetryNeeded = false;
589-
updateCount = grievanceDataRepo.updateCompletedStatusInCall(true, isRetryNeeded, complaintID, userID,
590-
beneficiaryRegID);
591-
}else {
602+
updateCount = grievanceDataRepo.updateCompletedStatusInCall(true, false, complaintID, userID, beneficiaryRegID);
603+
604+
} else {
605+
// 4) All other cases (e.g. unreachable) → leave open, retry allowed
592606
isRetryNeeded = true;
593-
updateCount = grievanceDataRepo.updateCompletedStatusInCall(false, isRetryNeeded, complaintID,
594-
userID, beneficiaryRegID);
607+
updateCount = grievanceDataRepo.updateCompletedStatusInCall(false, true, complaintID, userID, beneficiaryRegID);
595608
}
596-
// Check if max attempts (3) are reached
609+
610+
//Call counter update
597611
if (isRetryNeeded && grievanceCallStatus.getCallCounter() < grievanceAllocationRetryConfiguration) {
598612
grievanceCallStatus.setCallCounter(grievanceCallStatus.getCallCounter() + 1);
599-
updateCallCounter = grievanceDataRepo.updateCallCounter(grievanceCallStatus.getCallCounter(),
600-
isRetryNeeded, grievanceCallRequest.getComplaintID(),
601-
grievanceCallRequest.getBeneficiaryRegID(),
602-
grievanceCallRequest.getUserID());
603-
if (updateCallCounter > 0)
604-
response = "Successfully closing call";
605-
else {
606-
response = "failure in closing call";
607-
}
608-
} else if (grievanceCallStatus.getCallCounter() == grievanceAllocationRetryConfiguration) {
609-
// Max attempts reached, no further reattempt
613+
updateCallCounter = grievanceDataRepo.updateCallCounter(
614+
grievanceCallStatus.getCallCounter(), true, complaintID, beneficiaryRegID, userID);
615+
response = (updateCallCounter > 0) ? "Successfully closing call" : "failure in closing call";
616+
617+
} else if (grievanceCallStatus.getCallCounter() >= grievanceAllocationRetryConfiguration) {
618+
// Max attempts reached → treated as “complete”
610619
isRetryNeeded = false;
611-
// isCompleted = true;
612-
updateCount = grievanceDataRepo.updateCompletedStatusInCall(isCompleted, isRetryNeeded, complaintID,
613-
userID, beneficiaryRegID);
614-
response = "max_attempts_reached"; // Indicate that max attempts are reached
620+
updateCount = grievanceDataRepo.updateCompletedStatusInCall(true, false, complaintID, userID, beneficiaryRegID);
621+
response = "max_attempts_reached";
615622

616-
}else if(updateCount > 0) {
623+
} else if (updateCount > 0) {
617624
response = "Successfully closing call";
618625
}
619626

0 commit comments

Comments
 (0)