Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
indraniBan authored Dec 18, 2023
2 parents 656ee2d + 00d44c2 commit 328398d
Show file tree
Hide file tree
Showing 14 changed files with 178 additions and 10 deletions.
8 changes: 8 additions & 0 deletions src/main/environment/common_ci.properties
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ spring.mail.properties.mail.smtp.starttls.enable=true
start-email-scheduler=true
cron-scheduler-email=0 0/1 * * * ? *

###cti data check with call detail report Scheduler
#Runs at everyday 12:10AM
start-ctidatacheck-scheduler=true
cron-scheduler-ctidatacheck=0 10 00 * * *

### generate Beneficiary Config
genben-api= @env.BEN_GEN_API_URL@

Expand All @@ -55,6 +60,8 @@ spring.redis.host=localhost
#snomedcti
snomedCTPageSize=10

##missing commits

carestream_socket_ip = @env.CARESTREAM_SOCKET_IP@
carestream_socket_port = @env.CARESTREAM_SOCKET_PORT@

Expand Down Expand Up @@ -100,3 +107,4 @@ biometric.deviceInfo.url = @env.BIOMETRIC_URL@/rd/info
biometric.capture.url = @env.BIOMETRIC_URL@/rd/capture
eAusadhaUrl=https://dlc.kar.nic.in/e-services/api/DWInstituteInward
authorization=Basic a3Ntc2NsOktzbXNjbCMxMjM=

5 changes: 5 additions & 0 deletions src/main/environment/common_dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ cron-scheduler-email=0 0/1 * * * ? *
start-ctidatasync-scheduler=false
cron-scheduler-ctidatasync=0 00 01 * * ? *

###cti data check with call detail report Scheduler
#Runs at everyday 12:10AM
start-ctidatacheck-scheduler=true
cron-scheduler-ctidatacheck=0 10 00 * * *

#### Registration schedular for Avni
start-avni-scheduler=false
cron-avni-registration=0 0/1 * * * ? *
Expand Down
7 changes: 7 additions & 0 deletions src/main/environment/common_test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ cron-scheduler-email=0 0/1 * * * ? *

start-ctidatasync-scheduler=false
cron-scheduler-ctidatasync=0 00 01 * * ? *

##-------------------------------###cti data check with call detail report Scheduler------------------------------------------------------

#Runs at everyday 12:10AM
start-ctidatacheck-scheduler=true
cron-scheduler-ctidatacheck=0 10 00 * * *

##---------------------------------#### Registration schedular for Avni------------------------------------------------------------------------------

start-avni-scheduler=false
Expand Down
5 changes: 5 additions & 0 deletions src/main/environment/common_uat.properties
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ spring.mail.properties.mail.smtp.starttls.enable=true
start-email-scheduler=true
cron-scheduler-email=0 0/1 * * * ? *

###cti data check with call detail report Scheduler
#Runs at everyday 12:10AM
start-ctidatacheck-scheduler=true
cron-scheduler-ctidatacheck=0 10 00 * * *

### generate Beneficiary IDs URL
genben-api=<Enter your socket address here>/bengenapi-v1.0

Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/iemr/common/config/PrimaryDBConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class PrimaryDBConfig {

Logger logger = LoggerFactory.getLogger(this.getClass().getName());


@Primary
@Bean(name = "dataSource")
@ConfigurationProperties(prefix = "spring.datasource")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public String startCall(
if (remoteAddress == null || remoteAddress.trim().length() == 0) {
remoteAddress = fromRequest.getRemoteAddr();
}
logger.info("Start Call req Obj - " + request);
BeneficiaryCall startedCall = beneficiaryCallService.createCall(request, remoteAddress);
response.setResponse(startedCall.toString());
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package com.iemr.common.controller.nhmdashboard;

import java.sql.Date;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.List;

import org.apache.xml.security.stax.config.ConfigurationProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import com.iemr.common.data.callhandling.BeneficiaryCall;
import com.iemr.common.data.nhm_dashboard.DetailedCallReport;
import com.iemr.common.repository.nhm_dashboard.DetailedCallReportRepo;
import com.iemr.common.repository.report.CallReportRepo;
import com.iemr.common.utils.config.ConfigProperties;

@EnableScheduling
@Configuration
public class NHMDetailCallReportScheduler {

@Autowired
private DetailedCallReportRepo detailedCallReportRepo;

@Autowired
private CallReportRepo callReportRepo;

Logger logger = LoggerFactory.getLogger(this.getClass().getName());

@Value("${start-ctidatacheck-scheduler}")
private boolean startCtiDataCheckFlag;


@Scheduled(cron = "${cron-scheduler-ctidatacheck}")
public void detailedCallReport() {
if (startCtiDataCheckFlag) {
try {
String endDate = null;
String fromDate = null;
LocalDateTime date = null;
date = LocalDateTime.now().minusDays(1);
String[] dateArr = date.toString().split("T");
endDate = dateArr[0].concat(" 23:59:59");
fromDate = dateArr[0].concat(" 00:00:01");

Timestamp fromTime = Timestamp.valueOf(fromDate);
Timestamp endTime = Timestamp.valueOf(endDate);
logger.info("Call detailed report check request - FromTime -" + fromTime + "Endtime - " + endTime);
List<DetailedCallReport> findByCallStartTimeBetween = detailedCallReportRepo
.findByCallStartTimeBetween(fromTime, endTime);
for (DetailedCallReport detailedCallReport : findByCallStartTimeBetween) {
String phoneNo = detailedCallReport.getPHONE();
String sessionID = detailedCallReport.getSession_ID();
int existRecord = callReportRepo.getBenCallDetailsBySessionIDAndPhone(sessionID, phoneNo);
if (existRecord != 0) {
logger.info("Record already present in t_bencall table with sessionID : " + sessionID
+ " phoneNo : " + phoneNo);
if (null != detailedCallReport.getOrientation_Type()
&& detailedCallReport.getOrientation_Type().equalsIgnoreCase("OUTBOUND")) {
callReportRepo.updateIsOutboundForCall(true, sessionID, phoneNo );
} else {
callReportRepo.updateIsOutboundForCall(false, sessionID, phoneNo );
}
} else {
logger.info("Record missed in t_bencall table with sessionID : " + sessionID + " phoneNo : "
+ phoneNo);
BeneficiaryCall callDetail = getCallDetail(detailedCallReport);
callReportRepo.save(callDetail);
}
}
} catch (Exception e) {
logger.error("Error while fetching call detailed report " + e.getMessage());
}

}

}

private BeneficiaryCall getCallDetail(DetailedCallReport detailedCallReport) {
BeneficiaryCall beneficiaryCall = new BeneficiaryCall();
beneficiaryCall.setCallID(detailedCallReport.getSession_ID());
beneficiaryCall.setPhoneNo(detailedCallReport.getPHONE());
beneficiaryCall.setCalledServiceID(null);
beneficiaryCall.setRemarks("missed records - Failure");
beneficiaryCall.setReceivedRoleName(detailedCallReport.getCampaign_Name());
beneficiaryCall.setAgentID(String.valueOf(detailedCallReport.getAgent_ID()));

beneficiaryCall.setCallEndTime(detailedCallReport.getCallEndTime());
beneficiaryCall.setCallDuration(String.valueOf(detailedCallReport.getCall_Duration()));
if (null != detailedCallReport.getOrientation_Type()
&& detailedCallReport.getOrientation_Type().equalsIgnoreCase("OUTBOUND")) {
beneficiaryCall.setIsOutbound(true);
} else {
beneficiaryCall.setIsOutbound(false);
}
beneficiaryCall.setCallTime(detailedCallReport.getCallStartTime());
beneficiaryCall.setCallEndTime(detailedCallReport.getCallEndTime());
beneficiaryCall.setCreatedBy("Admin");

beneficiaryCall.setCallDuration(String.valueOf(detailedCallReport.getCall_Duration()));

return beneficiaryCall;

}
}
2 changes: 1 addition & 1 deletion src/main/java/com/iemr/common/data/report/CallReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public class CallReport implements Serializable

@Expose
@Column(name = "IsOutbound")
private Boolean isOutbound;
private boolean isOutbound;

@Expose
@Column(name = "IsCalledEarlier")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.iemr.common.repository.eausadha;


import java.util.List;


import org.springframework.data.repository.CrudRepository;
import org.springframework.data.rest.core.annotation.RestResource;
import org.springframework.stereotype.Repository;
Expand All @@ -12,6 +14,7 @@
@RestResource(exported = false)
public interface ItemMasterRepo extends CrudRepository<ItemMaster, Integer> {


List<ItemMaster> findByItemCode(String drugId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
import java.sql.Timestamp;
import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RestResource;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.iemr.common.data.callhandling.BeneficiaryCall;
import com.iemr.common.data.report.CallDetailsReport;
Expand All @@ -41,4 +43,14 @@ public interface CallReportRepo extends CrudRepository<BeneficiaryCall, Integer>
+ "where (report.cZcallDuration is null or report.recordingPath is null) and report.agentID is not null and report.phoneNo!='undefined' and report.phoneNo is not null "
+ "and report.createdDate >= :startDate and report.createdDate <= :endDate ")
public List<BeneficiaryCall> getAllBenCallIDetails(@Param("startDate") Timestamp startDate, @Param("endDate") Timestamp endDate);//start date and end date as param for x days.

@Query("SELECT COUNT(*) FROM BeneficiaryCall call WHERE call.callID = :sessionID and call.phoneNo = :phoneNo")
public int getBenCallDetailsBySessionIDAndPhone(@Param("sessionID") String sessionID,@Param("phoneNo") String phoneNo);

@Transactional
@Modifying
@Query("update BeneficiaryCall set isOutbound= :isOutbound where callID = :callID and phoneNo= :phoneNo")
public int updateIsOutboundForCall(@Param("isOutbound") boolean isOutbound, @Param("callID") String callID, @Param("phoneNo") String phoneNo );
}


Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,11 @@ public String createEAusadha(EAusadhaDTO eAusadhaDTO, String Authorization) thro
batchNumber = obj.getString("Batch_number");
drugName = obj.getString("Drug_name");


List<ItemMaster> itemCodeList = itemMasterRepo.findByItemCode(drugId);
ItemMaster itemCode = itemCodeList.get(0);


Integer facilityId = eAusadhaDTO.getFacilityId();
if (itemCode != null && null != itemCode.getItemID()) {
Integer itemId = itemCode.getItemID();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,17 @@ else if (benCalls != null && benCalls.getPhoneNo() != null)
String agentID = s.getSessionObject(key);
if (!agentID.equalsIgnoreCase(benCalls.getAgentID())) {
s.setSessionObject(key, benCalls.getAgentID());
logger.info("Start call data to be saved in DB - " + benCalls);
savedCalls = beneficiaryCallRepository.save(benCalls);
logger.info("Start call data response after saving DB - " + savedCalls);
} else {
ArrayList<BeneficiaryCall> resultSetBC = beneficiaryCallRepository
.getExistingBCByCallIDAndAgentID(benCalls.getCallID(), benCalls.getAgentID());
if (resultSetBC != null && resultSetBC.size() > 0)
logger.info("start call query response for getExistingBCByCallIDAndAgentID - " + resultSetBC.size());
if (resultSetBC != null && resultSetBC.size() > 0) {
savedCalls = resultSetBC.get(resultSetBC.size() - 1);
logger.info("Start call data if agent id is not equals to request agent id - " + savedCalls);
}
// else
// savedCalls = beneficiaryCallRepository.save(benCalls);
}
Expand All @@ -351,8 +356,10 @@ else if (benCalls != null && benCalls.getPhoneNo() != null)
throw new IEMRException("unable to create ben_call_id : " + e.getMessage());
}

} else
throw new IEMRException("call id is null");
} else {
logger.error("Error in saving start call data - call id is null");
throw new IEMRException("call id is null");
}
/// end new code

return savedCalls;
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/com/iemr/common/service/cti/CTIServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,9 @@ public OutputResponse getVoiceFile(String request, String remoteAddr) throws IEM
disposition.setResponse(ctiResponse);
output.setResponse(disposition.toString());
} else {
output.setError(OutputResponse.GENERIC_FAILURE, ctiResponse.getReason(), ctiResponse.getStatus());
output.setResponse("path not found");
logger.info("URL " + ctiURI + " returned response " + response + " and saved response - path not found");;
// output.setError(OutputResponse.GENERIC_FAILURE, ctiResponse.getReason(), ctiResponse.getStatus());
}
return output;
}
Expand Down Expand Up @@ -603,8 +605,11 @@ public OutputResponse getVoiceFileNew(String request, String remoteAddr) throws
// }
if (response != null)
output.setResponse(response);
else
output.setError(OutputResponse.GENERIC_FAILURE, "path is null");
else {
output.setResponse("path is null");
logger.info("URL " + ctiURI + " returned response " + response + " and saved response - path is null");
// output.setError(OutputResponse.GENERIC_FAILURE, "path is null");
}
return output;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void ctiDataSync() {

logger.info("calling CTI API url: " + URL);
ctiResponse = this.callUrl(URL);
// logger.info("calling CTI API returned " + ctiResponse);
logger.info("calling CTI_CDR_CALL_INFO API returned " + ctiResponse);

CTIData data = InputMapper.gson().fromJson(ctiResponse, CTIData.class);
CTIResponse model = data.getResponse();
Expand All @@ -157,14 +157,14 @@ public void ctiDataSync() {
callEndTime = model.getCall_end_date_time();
callStartTime = model.getCall_start_date_time();
}

// call.setCallDuration(Integer.toString(getTimeInSeconds(callDuartion)));
if (callDuartion != null)
call.setCZcallDuration(Integer.parseInt(callDuartion));
call.setRecordingPath(recordingPath);
call.setCZcallEndTime(callEndTime);
call.setCZcallStartTime(callStartTime);
callReportRepo.save(call);

logger.info("calling CTI_CDR_CALL_INFO after API call save response " + call);
} catch (Exception e) {
logger.error("VoiceFile failed with error " + e.getMessage(), e);
}
Expand Down

0 comments on commit 328398d

Please sign in to comment.