Skip to content

Commit 2bef6ee

Browse files
getEligibleRecordsLanguageInfo API logic changed Extra parameter added
i.e role to filter count
1 parent 6feedda commit 2bef6ee

3 files changed

Lines changed: 57 additions & 17 deletions

File tree

src/main/java/com/iemr/ecd/controller/callallocation/CallAllocationController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ public ResponseEntity<String> insertRecordsInOutboundCalls(@RequestBody Outbound
153153
@ApiResponse(responseCode = CustomExceptionResponse.BAD_REQUEST_SC_V, description = CustomExceptionResponse.BAD_REQUEST_SC) })
154154
public ResponseEntity<ResponseEligibleCallRecordsDTO> getEligibleRecordsLanguageInfo(@PathVariable int psmId,
155155
@PathVariable String phoneNoType, @PathVariable String recordType, @PathVariable String fDate,
156-
@PathVariable String tDate, @PathVariable String preferredLanguage) throws ECDException {
156+
@PathVariable String tDate, @PathVariable String preferredLanguage,@PathVariable String role) throws ECDException {
157157
return new ResponseEntity<>(
158-
callAllocationImpl.getEligibleRecordsLanguageInfo(psmId, phoneNoType, recordType, fDate, tDate, preferredLanguage), HttpStatus.OK);
158+
callAllocationImpl.getEligibleRecordsLanguageInfo(psmId, phoneNoType, recordType, fDate, tDate, preferredLanguage,role), HttpStatus.OK);
159159

160160
}
161161

src/main/java/com/iemr/ecd/repo/call_conf_allocation/OutboundCallsRepo.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,18 +349,38 @@ List<OutboundCalls> getIntroductoryRecordsUser(@Param("psmId") Integer psmId,
349349
@Query(value = " SELECT COUNT(1) FROM OutboundCalls AS t INNER JOIN MotherRecord AS mv ON t.motherId = mv.ecdIdNo WHERE t.allocationStatus =:allocationStatus AND "
350350
+ " t.psmId=:psmId AND ((:fDate between t.callDateFrom AND t.callDateTo) OR (:tDate between t.callDateFrom AND t.callDateTo)) AND "
351351
+ " t.childId IS NULL AND t.motherId IS NOT NULL AND (t.isHighRisk = false OR t.isHighRisk IS NULL ) "
352-
+ " AND t.phoneNumberType=:phoneNoType AND t.deleted = false AND mv.preferredLanguage = :preferredLanguage AND (t.isFurtherCallRequired = true OR t.isFurtherCallRequired IS NULL ) ")
352+
+ " AND t.phoneNumberType=:phoneNoType AND t.deleted = false AND mv.preferredLanguage = :preferredLanguage AND"
353+
+ " t.displayEcdCallType != 'introductory' AND (t.isFurtherCallRequired = true OR t.isFurtherCallRequired IS NULL ) ")
353354
int getMotherUnAllocatedCountLRByLanguage(@Param("allocationStatus") String allocationStatus, @Param("psmId") Integer psmId,
354355
@Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("phoneNoType") String phoneNoType, @Param("preferredLanguage") String preferredLanguage);
355356

357+
@Query(value = " SELECT COUNT(1) FROM OutboundCalls AS t INNER JOIN MotherRecord AS mv ON t.motherId = mv.ecdIdNo WHERE t.allocationStatus =:allocationStatus AND "
358+
+ " t.psmId=:psmId AND ((:fDate between t.callDateFrom AND t.callDateTo) OR (:tDate between t.callDateFrom AND t.callDateTo)) AND "
359+
+ " t.childId IS NULL AND t.motherId IS NOT NULL AND (t.isHighRisk = false OR t.isHighRisk IS NULL ) "
360+
+ " AND t.phoneNumberType=:phoneNoType AND t.deleted = false AND mv.preferredLanguage = :preferredLanguage AND"
361+
+ " t.displayEcdCallType = 'introductory' AND (t.isFurtherCallRequired = true OR t.isFurtherCallRequired IS NULL ) ")
362+
int getMotherUnAllocatedCountIntroductoryByLanguage(@Param("allocationStatus") String allocationStatus, @Param("psmId") Integer psmId,
363+
@Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("phoneNoType") String phoneNoType, @Param("preferredLanguage") String preferredLanguage);
364+
356365
// un-allocated, child low risk,
357366
@Query(value = " SELECT COUNT(1) FROM OutboundCalls AS t INNER JOIN ChildRecord AS cv ON t.childId = cv.ecdIdNoChildId WHERE t.allocationStatus =:allocationStatus AND "
358367
+ " t.psmId=:psmId AND ((:fDate between t.callDateFrom AND t.callDateTo) OR (:tDate between t.callDateFrom AND t.callDateTo)) AND "
359368
+ " t.childId IS NOT NULL AND (t.isHrni = false OR t.isHrni IS NULL ) "
360-
+ " AND t.phoneNumberType=:phoneNoType AND t.deleted = false AND cv.preferredLanguage = :preferredLanguage AND (t.isFurtherCallRequired = true OR t.isFurtherCallRequired IS NULL )")
369+
+ " AND t.phoneNumberType=:phoneNoType AND t.deleted = false AND cv.preferredLanguage = :preferredLanguage AND"
370+
+ " t.displayEcdCallType != 'introductory' AND (t.isFurtherCallRequired = true OR t.isFurtherCallRequired IS NULL )")
361371
int getChildUnAllocatedCountLRByLanguage(@Param("allocationStatus") String allocationStatus, @Param("psmId") Integer psmId,
362372
@Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("phoneNoType") String phoneNoType, @Param("preferredLanguage") String preferredLanguage);
363373

374+
375+
@Query(value = " SELECT COUNT(1) FROM OutboundCalls AS t INNER JOIN ChildRecord AS cv ON t.childId = cv.ecdIdNoChildId WHERE t.allocationStatus =:allocationStatus AND "
376+
+ " t.psmId=:psmId AND ((:fDate between t.callDateFrom AND t.callDateTo) OR (:tDate between t.callDateFrom AND t.callDateTo)) AND "
377+
+ " t.childId IS NOT NULL AND (t.isHrni = false OR t.isHrni IS NULL ) "
378+
+ " AND t.phoneNumberType=:phoneNoType AND t.deleted = false AND cv.preferredLanguage = :preferredLanguage AND"
379+
+ " t.displayEcdCallType = 'introductory' AND (t.isFurtherCallRequired = true OR t.isFurtherCallRequired IS NULL )")
380+
int getChildUnAllocatedCountIntroductoryByLanguage(@Param("allocationStatus") String allocationStatus, @Param("psmId") Integer psmId,
381+
@Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("phoneNoType") String phoneNoType, @Param("preferredLanguage") String preferredLanguage);
382+
383+
364384
@Modifying
365385
@Transactional
366386
@Query(" UPDATE OutboundCalls SET isFurtherCallRequired = :isFurtherCallRequired WHERE childId = :childId AND motherId IS NOT NULL AND callDateTo>current_date()")

src/main/java/com/iemr/ecd/service/call_conf_allocation/CallAllocationImpl.java

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,34 +1054,54 @@ public String insertRecordsInOutboundCalls(OutboundCallsDTO outboundCallsDTO) {
10541054
}
10551055
}
10561056

1057-
public ResponseEligibleCallRecordsDTO getEligibleRecordsLanguageInfo(int psmId, String phoneNoType, String recordType, String fDate,
1058-
String tDate, String preferredLanguage) {
1057+
public ResponseEligibleCallRecordsDTO getEligibleRecordsLanguageInfo(int psmId, String phoneNoType,
1058+
String recordType, String fDate, String tDate, String preferredLanguage, String role) {
10591059
try {
10601060
if (preferredLanguage == null || preferredLanguage.trim().isEmpty()) {
10611061
throw new InvalidRequestException("preferred language is required");
10621062
}
10631063
Timestamp tempFDateStamp = null;
10641064
Timestamp tempTDateStamp = null;
10651065
if (fDate != null && tDate != null) {
1066-
tempFDateStamp = getTimestampFromString(fDate.split(Constants.T)[0].concat(Constants.TIME_FORMAT_START_TIME));
1067-
tempTDateStamp = getTimestampFromString(tDate.split(Constants.T)[0].concat(Constants.TIME_FORMAT_END_TIME));
1066+
tempFDateStamp = getTimestampFromString(
1067+
fDate.split(Constants.T)[0].concat(Constants.TIME_FORMAT_START_TIME));
1068+
tempTDateStamp = getTimestampFromString(
1069+
tDate.split(Constants.T)[0].concat(Constants.TIME_FORMAT_END_TIME));
10681070
} else
10691071
throw new InvalidRequestException(Constants.FROM_DATE_TO_DATE_IS_NULL);
10701072

10711073
ResponseEligibleCallRecordsDTO responseEligibleCallRecordsDTO = new ResponseEligibleCallRecordsDTO();
10721074
int totalLowRisk = 0;
1073-
if (recordType != null && recordType.equalsIgnoreCase(Constants.MOTHER)) {
1074-
totalLowRisk = outboundCallsRepo.getMotherUnAllocatedCountLRByLanguage(Constants.UNALLOCATED, psmId, tempFDateStamp,
1075-
tempTDateStamp, phoneNoType, preferredLanguage);
1076-
} else if (recordType != null && recordType.equalsIgnoreCase(Constants.CHILD)) {
1077-
totalLowRisk = outboundCallsRepo.getChildUnAllocatedCountLRByLanguage(Constants.UNALLOCATED, psmId, tempFDateStamp,
1078-
tempTDateStamp, phoneNoType, preferredLanguage);
1075+
int totalIntroductoryCount = 0;
1076+
if (recordType != null && recordType.equalsIgnoreCase(Constants.MOTHER)
1077+
&& role.equalsIgnoreCase(Constants.ANM)) {
1078+
totalLowRisk = outboundCallsRepo.getMotherUnAllocatedCountLRByLanguage(Constants.UNALLOCATED, psmId,
1079+
tempFDateStamp, tempTDateStamp, phoneNoType, preferredLanguage);
1080+
responseEligibleCallRecordsDTO.setTotalLowRiskRecord(totalLowRisk);
1081+
return responseEligibleCallRecordsDTO;
1082+
} else if (recordType != null && recordType.equalsIgnoreCase(Constants.CHILD)
1083+
&& role.equalsIgnoreCase(Constants.ANM)) {
1084+
totalLowRisk = outboundCallsRepo.getChildUnAllocatedCountLRByLanguage(Constants.UNALLOCATED, psmId,
1085+
tempFDateStamp, tempTDateStamp, phoneNoType, preferredLanguage);
1086+
responseEligibleCallRecordsDTO.setTotalLowRiskRecord(totalLowRisk);
1087+
return responseEligibleCallRecordsDTO;
1088+
} else if (recordType != null && recordType.equalsIgnoreCase(Constants.MOTHER)
1089+
&& role.equalsIgnoreCase(Constants.ASSOCIATE)) {
1090+
totalIntroductoryCount = outboundCallsRepo.getMotherUnAllocatedCountIntroductoryByLanguage(
1091+
Constants.UNALLOCATED, psmId, tempFDateStamp, tempTDateStamp, phoneNoType, preferredLanguage);
1092+
responseEligibleCallRecordsDTO.setTotalIntroductoryRecord(totalIntroductoryCount);
1093+
return responseEligibleCallRecordsDTO;
1094+
} else if (recordType != null && recordType.equalsIgnoreCase(Constants.CHILD)
1095+
&& role.equalsIgnoreCase(Constants.ASSOCIATE)) {
1096+
totalIntroductoryCount = outboundCallsRepo.getChildUnAllocatedCountIntroductoryByLanguage(
1097+
Constants.UNALLOCATED, psmId, tempFDateStamp, tempTDateStamp, phoneNoType, preferredLanguage);
1098+
responseEligibleCallRecordsDTO.setTotalIntroductoryRecord(totalIntroductoryCount);
1099+
return responseEligibleCallRecordsDTO;
10791100
}
1080-
responseEligibleCallRecordsDTO.setTotalLowRiskRecord(totalLowRisk);
1081-
return responseEligibleCallRecordsDTO;
1101+
10821102
} catch (Exception e) {
10831103
throw new ECDException(e);
10841104
}
1085-
1105+
return null;
10861106
}
10871107
}

0 commit comments

Comments
 (0)