Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/main/environment/ecd_ci.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ beneficiaryEditUrl =@env.COMMON_API@/beneficiary/update
logging.file.name=@env.ECD_API_LOGGING_FILE_NAME@


springdoc.api-docs.enabled=false
springdoc.swagger-ui.enabled=false
springdoc.api-docs.enabled=@env.SWAGGER_DOC_ENABLED@
springdoc.swagger-ui.enabled=@env.SWAGGER_DOC_ENABLED@

4 changes: 4 additions & 0 deletions src/main/environment/ecd_example.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ registerBeneficiaryUrl=https:localhost:8083/beneficiary/create

##Beneficiary Edit Url
beneficiaryEditUrl =https:localhost:8083/beneficiary/update

springdoc.api-docs.enabled=true
springdoc.swagger-ui.enabled=true

1 change: 1 addition & 0 deletions src/main/environment/ecd_uat.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ jwt.secret=
springdoc.api-docs.enabled=true
springdoc.swagger-ui.enabled=true


Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ public interface ChildRecordRepo extends CrudRepository<ChildRecord, Long> {
public List<ChildRecord> findByIsAllocatedAndWhomPhoneNoAndCreatedDateBetween(Boolean isAllocated, String phoneType,
Timestamp fromDate, Timestamp toDate);

@Query(value = " SELECT * FROM t_childvaliddata WHERE IsAllocated is false AND "
+ " CreatedDate BETWEEN :fDate AND :tDate AND Phone_No_of =:phoneType AND preferredLanguage =:preferredLanguage LIMIT :recordLimit ", nativeQuery = true)
public List<ChildRecord> getChildRecordForAllocation(@Param("fDate") Timestamp fDate,
@Param("tDate") Timestamp tDate, @Param("phoneType") String phoneType,
@Param("recordLimit") int recordLimit, @Param("preferredLanguage") String preferredLanguage);

@Query(value = " SELECT * FROM t_childvaliddata WHERE IsAllocated is false AND "
+ " CreatedDate BETWEEN :fDate AND :tDate AND Phone_No_of =:phoneType LIMIT :recordLimit ", nativeQuery = true)
public List<ChildRecord> getChildRecordForAllocation(@Param("fDate") Timestamp fDate,
@Param("tDate") Timestamp tDate, @Param("phoneType") String phoneType,
@Param("recordLimit") int recordLimit);

@Modifying
@Transactional
@Query(" UPDATE ChildRecord SET isAllocated = true WHERE ecdIdNoChildId IN :childId ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,18 @@ public interface MotherRecordRepo extends CrudRepository<MotherRecord, Long> {
public List<MotherRecord> findByIsAllocatedAndWhomPhoneNoAndCreatedDateBetween(Boolean isAllocated,
String phoneType, Timestamp fromDate, Timestamp toDate);

@Query(value = " SELECT * FROM t_mothervalidrecord WHERE IsAllocated is false AND "
+ " CreatedDate BETWEEN :fDate AND :tDate AND PhoneNo_Of_Whom =:phoneType AND preferredLanguage = :preferredLanguage LIMIT :recordLimit ", nativeQuery = true)
public List<MotherRecord> getMotherRecordForAllocation(@Param("fDate") Timestamp fDate,
@Param("tDate") Timestamp tDate, @Param("phoneType") String phoneType,
@Param("recordLimit") int recordLimit, @Param("preferredLanguage") String preferredLanguage);

@Query(value = " SELECT * FROM t_mothervalidrecord WHERE IsAllocated is false AND "
+ " CreatedDate BETWEEN :fDate AND :tDate AND PhoneNo_Of_Whom =:phoneType LIMIT :recordLimit ", nativeQuery = true)
public List<MotherRecord> getMotherRecordForAllocation(@Param("fDate") Timestamp fDate,
@Param("tDate") Timestamp tDate, @Param("phoneType") String phoneType,
@Param("recordLimit") int recordLimit);

@Modifying
@Transactional
@Query(" UPDATE MotherRecord SET isAllocated = true WHERE ecdIdNo IN :motherId ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,23 @@ public interface OutboundCallsRepo extends CrudRepository<OutboundCalls, Long> {
+ " t.childId IS NULL AND t.motherId IS NOT NULL AND (t.isHighRisk = false OR t.isHighRisk IS NULL ) AND mv.preferredLanguage = :preferredLanguage")
Page<OutboundCalls> getMotherRecordsForANM(Pageable pageable, @Param("allocationStatus") String allocationStatus,
@Param("psmId") Integer psmId, @Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("preferredLanguage") String preferredLanguage);

@Query(value = " SELECT t FROM OutboundCalls AS t INNER JOIN MotherRecord 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 "
+ " t.childId IS NULL AND t.motherId IS NOT NULL AND (t.isHighRisk = false OR t.isHighRisk IS NULL ) AND mv.preferredLanguage = :preferredLanguage")
Page<OutboundCalls> getMotherRecordsForAssociate(Pageable pageable,@Param("allocationStatus") String allocationStatus,
@Param("psmId") Integer psmId, @Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("preferredLanguage") String preferredLanguage);

@Query(value = " SELECT t FROM OutboundCalls AS t INNER JOIN ChildRecord cv ON t.childId = cv.ecdIdNoChildId 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 "
+ " t.childId IS NOT NULL AND (t.isHrni = false OR t.isHrni IS NULL ) AND cv.preferredLanguage = :preferredLanguage")
Page<OutboundCalls> getChildRecordsForANM(Pageable pageable, @Param("allocationStatus") String allocationStatus,
@Param("psmId") Integer psmId, @Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("preferredLanguage") String preferredLanguage);

@Query(value = " SELECT t FROM OutboundCalls AS t INNER JOIN ChildRecord cv ON t.childId = cv.ecdIdNoChildId 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 "
+ " t.childId IS NOT NULL AND (t.isHrni = false OR t.isHrni IS NULL ) AND cv.preferredLanguage = :preferredLanguage")
Page<OutboundCalls> getChildRecordsForAssociate(Pageable pageable, @Param("allocationStatus") String allocationStatus,
@Param("psmId") Integer psmId, @Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("preferredLanguage") String preferredLanguage);
@Query(value = " SELECT t FROM OutboundCalls AS t WHERE t.allocationStatus =:allocationStatus AND "
+ " t.psmId=:psmId AND "
+ " t.childId IS NULL AND t.motherId IS NOT NULL AND t.isHighRisk = true ")
Expand Down Expand Up @@ -152,6 +162,20 @@ int getAllocatedRecordsCountMotherUser(@Param("allocatedUserId") Integer allocat
int getAllocatedRecordsCountMotherUserANM(@Param("allocatedUserId") Integer allocatedUserId,
@Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("callStatus") String callStatus,
@Param("phoneNoType") String phoneNoType,@Param("preferredLanguage") String preferredLanguage);

@Query(value = " SELECT COUNT(1) FROM OutboundCalls AS t INNER JOIN MotherRecord AS mv ON t.motherId = mv.ecdIdNo WHERE t.allocatedUserId=:allocatedUserId AND "
+ " ((:fDate between t.callDateFrom AND t.callDateTo) OR (:tDate between t.callDateFrom AND t.callDateTo)) AND t.callStatus=:callStatus "
+ " AND t.phoneNumberType=:phoneNoType AND t.childId IS NULL AND t.motherId IS NOT NULL AND mv.preferredLanguage = :preferredLanguage")
int getAllocatedRecordsCountMotherUserAssociateWithPreferredLanguage(@Param("allocatedUserId") Integer allocatedUserId,
@Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("callStatus") String callStatus,
@Param("phoneNoType") String phoneNoType,@Param("preferredLanguage") String preferredLanguage);

@Query(value = " SELECT COUNT(1) FROM OutboundCalls AS t INNER JOIN MotherRecord AS mv ON t.motherId = mv.ecdIdNo WHERE t.allocatedUserId=:allocatedUserId AND "
+ " ((:fDate between t.callDateFrom AND t.callDateTo) OR (:tDate between t.callDateFrom AND t.callDateTo)) AND t.callStatus=:callStatus "
+ " AND t.phoneNumberType=:phoneNoType AND t.childId IS NULL AND t.motherId IS NOT NULL")
int getAllocatedRecordsCountMotherUserAssociate(@Param("allocatedUserId") Integer allocatedUserId,
@Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("callStatus") String callStatus,
@Param("phoneNoType") String phoneNoType);

// get users allocated calls count mother , not completed
// @Query(value = " SELECT COUNT(1) FROM OutboundCalls AS t WHERE t.allocatedUserId=:allocatedUserId AND "
Expand All @@ -173,7 +197,20 @@ int getAllocatedRecordsCountChildUser(@Param("allocatedUserId") Integer allocate
int getAllocatedRecordsCountChildUserANM(@Param("allocatedUserId") Integer allocatedUserId,
@Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("callStatus") String callStatus,
@Param("phoneNoType") String phoneNoType, @Param("preferredLanguage") String preferredLanguage);

@Query(value = " SELECT COUNT(1) FROM OutboundCalls AS t INNER JOIN ChildRecord AS cv ON t.childId = cv.ecdIdNoChildId WHERE t.allocatedUserId=:allocatedUserId AND "
+ " ((:fDate between t.callDateFrom AND t.callDateTo) OR (:tDate between t.callDateFrom AND t.callDateTo)) AND t.callStatus=:callStatus "
+ " AND t.phoneNumberType=:phoneNoType AND t.childId IS NOT NULL AND cv.preferredLanguage = :preferredLanguage ")
int getAllocatedRecordsCountChildUserAssociate(@Param("allocatedUserId") Integer allocatedUserId,
@Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("callStatus") String callStatus,
@Param("phoneNoType") String phoneNoType, @Param("preferredLanguage") String preferredLanguage);

@Query(value = " SELECT COUNT(1) FROM OutboundCalls AS t INNER JOIN ChildRecord AS cv ON t.childId = cv.ecdIdNoChildId WHERE t.allocatedUserId=:allocatedUserId AND "
+ " ((:fDate between t.callDateFrom AND t.callDateTo) OR (:tDate between t.callDateFrom AND t.callDateTo)) AND t.callStatus=:callStatus "
+ " AND t.phoneNumberType=:phoneNoType AND t.childId IS NOT NULL ")
int getAllocatedRecordsCountChildUserAssociate(@Param("allocatedUserId") Integer allocatedUserId,
@Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("callStatus") String callStatus,
@Param("phoneNoType") String phoneNoType);
// users allocated calls, Mother, by RecordType And PhoneType
// @Query(value = " SELECT t FROM OutboundCalls AS t WHERE t.allocatedUserId=:allocatedUserId AND "
// + " t.callStatus=:callStatus AND t.phoneNumberType=:phoneNoType AND t.callDateFrom >= :fDate "
Expand All @@ -197,7 +234,22 @@ Page<OutboundCalls> getAllocatedRecordsUserByRecordTypeAndPhoneTypeMotherANM(Pag
@Param("allocatedUserId") Integer allocatedUserId, @Param("callStatus") String callStatus,
@Param("phoneNoType") String phoneNoType, @Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("preferredLanguage") String preferredLanguage);

// // users allocated calls, Child, by RecordType And PhoneType
@Query(value = " SELECT t FROM OutboundCalls AS t INNER JOIN MotherRecord AS mv ON t.motherId = mv.ecdIdNo WHERE t.allocatedUserId=:allocatedUserId AND "
+ " t.callStatus=:callStatus AND t.phoneNumberType=:phoneNoType "
+ " AND ((:fDate between t.callDateFrom AND t.callDateTo) OR (:tDate between t.callDateFrom AND t.callDateTo)) AND "
+ " t.childId IS NULL AND t.motherId IS NOT NULL AND mv.preferredLanguage = :preferredLanguage")
Page<OutboundCalls> getAllocatedRecordsUserByRecordTypeAndPhoneTypeMotherAssociate(Pageable pageable,
@Param("allocatedUserId") Integer allocatedUserId, @Param("callStatus") String callStatus,
@Param("phoneNoType") String phoneNoType, @Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate, @Param("preferredLanguage") String preferredLanguage);

@Query(value = " SELECT t FROM OutboundCalls AS t INNER JOIN MotherRecord AS mv ON t.motherId = mv.ecdIdNo WHERE t.allocatedUserId=:allocatedUserId AND "
+ " t.callStatus=:callStatus AND t.phoneNumberType=:phoneNoType "
+ " AND ((:fDate between t.callDateFrom AND t.callDateTo) OR (:tDate between t.callDateFrom AND t.callDateTo)) AND "
+ " t.childId IS NULL AND t.motherId IS NOT NULL ")
Page<OutboundCalls> getAllocatedRecordsUserByRecordTypeAndPhoneTypeMotherAssociate(Pageable pageable,
@Param("allocatedUserId") Integer allocatedUserId, @Param("callStatus") String callStatus,
@Param("phoneNoType") String phoneNoType, @Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate);
// // users allocated calls, Child, by RecordType And PhoneType
// @Query(value = " SELECT t FROM OutboundCalls AS t WHERE t.allocatedUserId=:allocatedUserId AND "
// + " t.callStatus=:callStatus AND t.phoneNumberType=:phoneNoType "
// + " AND t.callDateFrom >= :fDate AND t.callDateTo <= :tDate AND t.childId IS NOT NULL ")
Expand All @@ -217,7 +269,21 @@ Page<OutboundCalls> getAllocatedRecordsUserByRecordTypeAndPhoneTypeChild(Pageabl
Page<OutboundCalls> getAllocatedRecordsUserByRecordTypeAndPhoneTypeChildANM(Pageable pageable,
@Param("allocatedUserId") Integer allocatedUserId, @Param("callStatus") String callStatus,
@Param("phoneNoType") String phoneNoType, @Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate,@Param("preferredLanguage") String preferredLanguage);

@Query(value = " SELECT t FROM OutboundCalls AS t INNER JOIN ChildRecord AS cv ON t.childId = cv.ecdIdNoChildId WHERE t.allocatedUserId=:allocatedUserId AND "
+ " t.callStatus=:callStatus AND t.phoneNumberType=:phoneNoType "
+ " AND ((:fDate between t.callDateFrom AND t.callDateTo) OR (:tDate between t.callDateFrom AND t.callDateTo)) AND t.childId IS NOT NULL AND cv.preferredLanguage = :preferredLanguage ")
Page<OutboundCalls> getAllocatedRecordsUserByRecordTypeAndPhoneTypeChildAssociate(Pageable pageable,
@Param("allocatedUserId") Integer allocatedUserId, @Param("callStatus") String callStatus,
@Param("phoneNoType") String phoneNoType, @Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate,@Param("preferredLanguage") String preferredLanguage);

@Query(value = " SELECT t FROM OutboundCalls AS t INNER JOIN ChildRecord AS cv ON t.childId = cv.ecdIdNoChildId WHERE t.allocatedUserId=:allocatedUserId AND "
+ " t.callStatus=:callStatus AND t.phoneNumberType=:phoneNoType "
+ " AND ((:fDate between t.callDateFrom AND t.callDateTo) OR (:tDate between t.callDateFrom AND t.callDateTo)) AND t.childId IS NOT NULL ")
Page<OutboundCalls> getAllocatedRecordsUserByRecordTypeAndPhoneTypeChildAssociate(Pageable pageable,
@Param("allocatedUserId") Integer allocatedUserId, @Param("callStatus") String callStatus,
@Param("phoneNoType") String phoneNoType, @Param("fDate") Timestamp fDate, @Param("tDate") Timestamp tDate);

@Modifying
@Transactional
@Query(" UPDATE OutboundCalls obc SET beneficiaryRegId = :beneficiaryRegId, phoneNumberType = :phoneNumberType WHERE motherId = :motherId AND childId IS NULL ")
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/com/iemr/ecd/service/associate/CallClosureImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

import com.google.gson.Gson;
import com.iemr.ecd.dao.CallConfiguration;
Expand Down Expand Up @@ -156,17 +157,20 @@ public String closeCall(CallClosureDTO request) {
callConfigurationDetail = callConfigurationDetails.get(0);
}

if (obj.getIsCallAnswered() != null && obj.getIsCallAnswered()) {
callObj.setCallStatus("Completed");
if ("introductory".equalsIgnoreCase(callObj.getEcdCallType()) && Boolean.TRUE.equals(obj.getIsCallDisconnected()) && StringUtils.hasText(request.getPreferredLanguage())) {
callObj.setCallStatus(Constants.OPEN);
callObj.setAllocationStatus(Constants.UNALLOCATED);
}else if(Boolean.TRUE.equals(obj.getIsCallAnswered())){
callObj.setCallStatus(Constants.COMPLETED);
}

if (obj.getIsFurtherCallRequired() != null && !obj.getIsFurtherCallRequired()) {
callObj.setCallStatus("Completed");
callObj.setCallStatus(Constants.COMPLETED);
} else {
if (obj.getIsCallDisconnected() != null && obj.getIsCallDisconnected()) {
callObj.setCallStatus("Open");
callObj.setCallStatus(Constants.OPEN);
} else {
callObj.setCallStatus("Completed");
callObj.setCallStatus(Constants.COMPLETED);
createEcdCallRecordsInOutboundCalls(request, callConfigurationDetails,
callObj.getPhoneNumberType());
}
Expand Down Expand Up @@ -210,6 +214,9 @@ public String closeCall(CallClosureDTO request) {
callObj.setIsHighRisk(request.getIsHrp());
if(obj.getReceivedRoleName().equalsIgnoreCase(Constants.ANM)){
callObj.setCallStatus(Constants.OPEN);
callObj.setAllocatedUserId(null);
callObj.setAllocationStatus(Constants.UNALLOCATED);
callObj.setCallAttemptNo(0);
}
}
outboundCallsRepo.save(callObj);
Expand Down
Loading
Loading