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 @@ -48,6 +48,7 @@ public class FetchMotherOutboundWorklist {
private String phoneNoOfWhom;
private String whomPhoneNo;
private Boolean highRisk;
private String highRiskReason;

private String husbandName;
private String address;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public interface OutboundCallsRepo extends CrudRepository<OutboundCalls, Long> {

OutboundCalls findByObCallId(Long obCallId);

@Query("SELECT ob.obCallId, ob.highRiskReason FROM OutboundCalls ob WHERE ob.obCallId IN :obCallIds AND ob.highRiskReason IS NOT NULL")
List<Object[]> getHighRiskReasonByObCallIds(@Param("obCallIds") List<Long> obCallIds);

@Query(value = "call PR_FetchECDMotherOutboundWorklist(:allocatedUserID)", nativeQuery = true)
List<String[]> getAgentAllocatedMotherList(@Param("allocatedUserID") Integer allocatedUserID);

Expand Down Expand Up @@ -371,8 +374,8 @@ List<OutboundCalls> getIntroductoryRecordsUser(@Param("psmId") Integer psmId,

@Modifying
@Transactional
@Query(" UPDATE OutboundCalls SET isHighRisk = :isHighRisk WHERE motherId = :motherId AND childId IS NULL AND callDateTo>current_date()")
public int updateHRPForUpcomingCall(@Param("motherId") Long motherId, @Param("isHighRisk") Boolean isHighRisk);
@Query(" UPDATE OutboundCalls SET isHighRisk = :isHighRisk, highRiskReason = :highRiskReason WHERE motherId = :motherId AND childId IS NULL AND callDateTo>current_date()")
public int updateHRPForUpcomingCall(@Param("motherId") Long motherId, @Param("isHighRisk") Boolean isHighRisk, @Param("highRiskReason") String highRiskReason);

@Query(value = " SELECT COUNT(1) FROM OutboundCalls AS t INNER JOIN MotherRecord AS mv ON t.motherId = mv.ecdIdNo WHERE t.allocationStatus =:allocationStatus AND "
+ " t.psmId=:psmId AND ((:fDate between t.callDateFrom AND t.callDateTo) OR (:tDate between t.callDateFrom AND t.callDateTo)) AND "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public interface ECDCallResponseRepo extends JpaRepository<ECDCallResponse, Long
@Query(value = "call Pr_GetHRPDetails(:motherId, :childId)", nativeQuery = true)
List<String[]> getHrpHrniDetailsOld(@Param("motherId") Long motherId, @Param("childId") Long childId);

@Query(value = " SELECT t FROM ECDCallResponse t WHERE t.motherId=:motherId AND t.reasonsForHrpDB IS NOT NULL ORDER BY 1 DESC ")
@Query(value = " SELECT t FROM ECDCallResponse t WHERE t.motherId=:motherId AND t.reasonsForHrpDB IS NOT NULL ORDER BY t.createdDate DESC ")
Page<ECDCallResponse> getHrpDetailsMother(Pageable pageable, @Param("motherId") Long motherId);

@Query(value = " SELECT t FROM ECDCallResponse t WHERE t.childId=:childId AND t.reasonsForHrniDB IS NOT NULL ORDER BY 1 DESC ")
@Query(value = " SELECT t FROM ECDCallResponse t WHERE t.childId=:childId AND t.reasonsForHrniDB IS NOT NULL ORDER BY t.createdDate DESC ")
Page<ECDCallResponse> getHrniDetailsChild(Pageable pageable, @Param("childId") Long childId);

@Query(value = "call PR_UpdateHRP_HRniReasons(:benCallId, :obCallId)", nativeQuery = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,13 @@ public ECDCallResponse getHrpHrniDetails(Long motherId, Long childId) {

if (childId != null) {
Page<ECDCallResponse> page = ecdCallResponseRepo.getHrniDetailsChild(pageable, childId);
if (page.getSize() > 0) {
List<ECDCallResponse> objLIst = page.getContent();
obj = objLIst.get(0);

if (page.hasContent()) {
obj = page.getContent().get(0);
}
} else if (motherId != null) {
Page<ECDCallResponse> page = ecdCallResponseRepo.getHrpDetailsMother(pageable, motherId);
if (page.getSize() > 0) {
List<ECDCallResponse> objLIst = page.getContent();
obj = objLIst.get(0);

if (page.hasContent()) {
obj = page.getContent().get(0);
}
} else
throw new InvalidRequestException("NULL motherId/childId", "send valid motherId or childId");
Expand Down
27 changes: 24 additions & 3 deletions src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,20 +211,41 @@ public String closeCall(CallClosureDTO request) {
boolean isHrp = request.getIsHrp();
callObj.setIsHighRisk(isHrp);

// Check if the role should be changed to MO
// ANM marks HRP = true β†’ move to MO (high risk) bucket
if (isHrp && obj.getReceivedRoleName().equalsIgnoreCase(Constants.ANM)) {
callObj.setCallStatus(Constants.OPEN);
callObj.setAllocatedUserId(null);
callObj.setAllocationStatus(Constants.UNALLOCATED);
callObj.setCallAttemptNo(0);
}

// MO marks HRP = false β†’ move to ANM (low risk) bucket
else if (!isHrp && obj.getReceivedRoleName().equalsIgnoreCase("MO")) {
callObj.setCallStatus(Constants.OPEN);
callObj.setAllocatedUserId(null);
callObj.setAllocationStatus(Constants.UNALLOCATED);
callObj.setCallAttemptNo(0);
}

else if (!isHrp && !obj.getIsCallDisconnected()) {
callObj.setCallStatus(Constants.COMPLETED);
}
}


if (request.getIsHrni() != null) {
boolean isHrni = request.getIsHrni();
callObj.setIsHrni(isHrni);

// MO marks HRNI = false β†’ move to ANM (low risk) bucket
if (!isHrni && obj.getReceivedRoleName().equalsIgnoreCase("MO")) {
callObj.setCallStatus(Constants.OPEN);
callObj.setAllocatedUserId(null);
callObj.setAllocationStatus(Constants.UNALLOCATED);
callObj.setCallAttemptNo(0);
}
}


outboundCallsRepo.save(callObj);
} else
throw new ECDException(
Expand All @@ -238,7 +259,7 @@ else if (!isHrp && !obj.getIsCallDisconnected()) {
} else if (callObj.getMotherId() != null && callObj.getChildId() == null
&& callObj.getIsHighRisk() != null) {
// Mother
outboundCallsRepo.updateHRPForUpcomingCall(callObj.getMotherId(), callObj.getIsHighRisk());
outboundCallsRepo.updateHRPForUpcomingCall(callObj.getMotherId(), callObj.getIsHighRisk(), callObj.getHighRiskReason());
}
}
if (null != obj.getIsFurtherCallRequired()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class OutboundWorkListServiceImpl {
public List<FetchMotherOutboundWorklist> getMotherWorkList(Integer userId) {
try {
List<String[]> motherList = outboundCallsRepo.getAgentAllocatedMotherList(userId);

return getMotherDtoList(motherList);
} catch (Exception e) {
throw new ECDException(e);
Expand Down