diff --git a/src/main/java/com/iemr/mmu/repo/labModule/LabResultEntryRepo.java b/src/main/java/com/iemr/mmu/repo/labModule/LabResultEntryRepo.java index 33656333..cdf2ad4b 100644 --- a/src/main/java/com/iemr/mmu/repo/labModule/LabResultEntryRepo.java +++ b/src/main/java/com/iemr/mmu/repo/labModule/LabResultEntryRepo.java @@ -24,6 +24,7 @@ import java.math.BigInteger; import java.util.ArrayList; +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; @@ -31,6 +32,8 @@ import com.iemr.mmu.data.labModule.LabResultEntry; +import jakarta.transaction.Transactional; + @Repository public interface LabResultEntryRepo extends CrudRepository { @Query("SELECT procedureID FROM LabResultEntry WHERE beneficiaryRegID = :benRegID AND " @@ -46,4 +49,9 @@ ArrayList findProcedureListByBeneficiaryRegIDAndBenVisitID(@Param("benR ArrayList getLast_3_visitForLabTestDone(@Param("benRegID") Long benRegID, @Param("visitCode") Long visitCode); + @Transactional + @Modifying + @Query(" UPDATE LabResultEntry set vanSerialNo = :ID WHERE ID = :ID") + int updateVanSerialNo(@Param("ID") BigInteger ID); + } diff --git a/src/main/java/com/iemr/mmu/repo/quickConsultation/LabTestOrderDetailRepo.java b/src/main/java/com/iemr/mmu/repo/quickConsultation/LabTestOrderDetailRepo.java index 773021c4..4a7eb9c9 100644 --- a/src/main/java/com/iemr/mmu/repo/quickConsultation/LabTestOrderDetailRepo.java +++ b/src/main/java/com/iemr/mmu/repo/quickConsultation/LabTestOrderDetailRepo.java @@ -47,4 +47,8 @@ public ArrayList getLabTestOrderDetails(@Param("benRegID") Long benReg @Query(" Delete from LabTestOrderDetail WHERE beneficiaryRegID = :benRegID AND benVisitID = :benVisitID ") public int deleteExistingLabTestOrderDetail(@Param("benRegID") Long benRegID, @Param("benVisitID") Long benVisitID); + @Transactional + @Modifying + @Query(" UPDATE LabTestOrderDetail set vanSerialNo = :labTestOrderID WHERE labTestOrderID = :labTestOrderID") + int updateVanSerialNo(@Param("labTestOrderID") Long labTestOrderID); } diff --git a/src/main/java/com/iemr/mmu/service/anc/ANCNurseServiceImpl.java b/src/main/java/com/iemr/mmu/service/anc/ANCNurseServiceImpl.java index f1ad731a..1abc07bd 100644 --- a/src/main/java/com/iemr/mmu/service/anc/ANCNurseServiceImpl.java +++ b/src/main/java/com/iemr/mmu/service/anc/ANCNurseServiceImpl.java @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see https://www.gnu.org/licenses/. -*/ + */ package com.iemr.mmu.service.anc; import java.sql.Date; @@ -49,349 +49,366 @@ @Service public class ANCNurseServiceImpl implements ANCNurseService { - private ANCCareRepo ancCareRepo; - private ANCWomenVaccineRepo ancWomenVaccineRepo; - private BenAdherenceRepo benAdherenceRepo; - - private SysObstetricExaminationRepo sysObstetricExaminationRepo; - - private LabTestOrderDetailRepo labTestOrderDetailRepo; - - @Autowired - public void setLabTestOrderDetailRepo(LabTestOrderDetailRepo labTestOrderDetailRepo) { - this.labTestOrderDetailRepo = labTestOrderDetailRepo; - } - - @Autowired - public void setBenAdherenceRepo(BenAdherenceRepo benAdherenceRepo) { - this.benAdherenceRepo = benAdherenceRepo; - } - - @Autowired - public void setAncCareRepo(ANCCareRepo ancCareRepo) { - this.ancCareRepo = ancCareRepo; - } - - @Autowired - public void setAncWomenVaccineRepo(ANCWomenVaccineRepo ancWomenVaccineRepo) { - this.ancWomenVaccineRepo = ancWomenVaccineRepo; - } - - @Autowired - public void setSysObstetricExaminationRepo(SysObstetricExaminationRepo sysObstetricExaminationRepo) { - this.sysObstetricExaminationRepo = sysObstetricExaminationRepo; - } - - @Override - public Long saveBeneficiaryANCDetails(ANCCareDetails ancCareDetails) { - ANCCareDetails ancCareDetail = ancCareRepo.save(ancCareDetails); - Long ancCareID = null; - if (null != ancCareDetail && ancCareDetail.getID() > 0) { - ancCareID = ancCareDetail.getID(); + private ANCCareRepo ancCareRepo; + private ANCWomenVaccineRepo ancWomenVaccineRepo; + private BenAdherenceRepo benAdherenceRepo; + + private SysObstetricExaminationRepo sysObstetricExaminationRepo; + + private LabTestOrderDetailRepo labTestOrderDetailRepo; + + @Autowired + public void setLabTestOrderDetailRepo(LabTestOrderDetailRepo labTestOrderDetailRepo) { + this.labTestOrderDetailRepo = labTestOrderDetailRepo; + } + + @Autowired + public void setBenAdherenceRepo(BenAdherenceRepo benAdherenceRepo) { + this.benAdherenceRepo = benAdherenceRepo; + } + + @Autowired + public void setAncCareRepo(ANCCareRepo ancCareRepo) { + this.ancCareRepo = ancCareRepo; + } + + @Autowired + public void setAncWomenVaccineRepo(ANCWomenVaccineRepo ancWomenVaccineRepo) { + this.ancWomenVaccineRepo = ancWomenVaccineRepo; + } + + @Autowired + public void setSysObstetricExaminationRepo(SysObstetricExaminationRepo sysObstetricExaminationRepo) { + this.sysObstetricExaminationRepo = sysObstetricExaminationRepo; + } + + @Override + public Long saveBeneficiaryANCDetails(ANCCareDetails ancCareDetails) { + ANCCareDetails ancCareDetail = ancCareRepo.save(ancCareDetails); + Long ancCareID = null; + if (null != ancCareDetail && ancCareDetail.getID() > 0) { + ancCareID = ancCareDetail.getID(); + } + return ancCareID; + } + + @Override + public Long saveANCWomenVaccineDetails(List ancWomenVaccineDetails) { + Iterable listOfANCWomenVaccineDetail = ancWomenVaccineRepo + .saveAll(ancWomenVaccineDetails); + + Long ancWomenVaccineID = null; + if (!((List) listOfANCWomenVaccineDetail).isEmpty()) { + for (ANCWomenVaccineDetail ancWomenVaccine : listOfANCWomenVaccineDetail) { + ancWomenVaccineID = ancWomenVaccine.getID(); + } + } + return ancWomenVaccineID; + } + + public Integer saveBenInvestigationFromDoc(WrapperBenInvestigationANC wrapperBenInvestigationANC) { + int r = 0; + ArrayList LabTestOrderDetailList = new ArrayList<>(); + ArrayList investigationList = wrapperBenInvestigationANC.getLaboratoryList(); + if (investigationList != null && investigationList.size() > 0) { + + for (LabTestOrderDetail testData : investigationList) { + + testData.setBeneficiaryRegID(wrapperBenInvestigationANC.getBeneficiaryRegID()); + testData.setBenVisitID(wrapperBenInvestigationANC.getBenVisitID()); + testData.setProviderServiceMapID(wrapperBenInvestigationANC.getProviderServiceMapID()); + testData.setCreatedBy(wrapperBenInvestigationANC.getCreatedBy()); + testData.setPrescriptionID(wrapperBenInvestigationANC.getPrescriptionID()); + + LabTestOrderDetailList.add(testData); + } + ArrayList LabTestOrderDetailListRS = (ArrayList) labTestOrderDetailRepo + .saveAll(LabTestOrderDetailList); + + if (!LabTestOrderDetailListRS.isEmpty()) { + ArrayList labTestOrderDetailListRS + = (ArrayList) labTestOrderDetailRepo.saveAll(LabTestOrderDetailList); + + if (LabTestOrderDetailList.size() == labTestOrderDetailListRS.size()) { + for (LabTestOrderDetail detail : labTestOrderDetailListRS) { + if (detail.getLabTestOrderID() != null) { + labTestOrderDetailRepo.updateVanSerialNo(detail.getLabTestOrderID()); + } + } + r = 1; + } + + } else { + r = 1; + } } - return ancCareID; - } - - @Override - public Long saveANCWomenVaccineDetails(List ancWomenVaccineDetails) { - Iterable listOfANCWomenVaccineDetail = ancWomenVaccineRepo - .saveAll(ancWomenVaccineDetails); - - Long ancWomenVaccineID = null; - if (!((List) listOfANCWomenVaccineDetail).isEmpty()) { - for (ANCWomenVaccineDetail ancWomenVaccine : listOfANCWomenVaccineDetail) { - ancWomenVaccineID = ancWomenVaccine.getID(); - } - } - return ancWomenVaccineID; - } - - public Integer saveBenInvestigationFromDoc(WrapperBenInvestigationANC wrapperBenInvestigationANC) { - int r = 0; - ArrayList LabTestOrderDetailList = new ArrayList<>(); - ArrayList investigationList = wrapperBenInvestigationANC.getLaboratoryList(); - if (investigationList != null && investigationList.size() > 0) { - - for (LabTestOrderDetail testData : investigationList) { - - testData.setBeneficiaryRegID(wrapperBenInvestigationANC.getBeneficiaryRegID()); - testData.setBenVisitID(wrapperBenInvestigationANC.getBenVisitID()); - testData.setProviderServiceMapID(wrapperBenInvestigationANC.getProviderServiceMapID()); - testData.setCreatedBy(wrapperBenInvestigationANC.getCreatedBy()); - testData.setPrescriptionID(wrapperBenInvestigationANC.getPrescriptionID()); - - LabTestOrderDetailList.add(testData); - } - ArrayList LabTestOrderDetailListRS = (ArrayList) labTestOrderDetailRepo - .saveAll(LabTestOrderDetailList); - - if (!LabTestOrderDetailListRS.isEmpty()) { - r = 1; - } - } else { - r = 1; - } - return r; - } - - @Override - public Long saveBenAncCareDetails(ANCCareDetails ancCareDetailsOBJ) throws ParseException { - Long ancCareSuccessFlag = null; - if (ancCareDetailsOBJ.getLmpDate() != null && !ancCareDetailsOBJ.getLmpDate().isEmpty() - && ancCareDetailsOBJ.getLmpDate().length() >= 10) { - String lmpDate = ancCareDetailsOBJ.getLmpDate().split("T")[0]; - ancCareDetailsOBJ - .setLastMenstrualPeriod_LMP(new Date(new SimpleDateFormat("yyyy-MM-dd").parse(lmpDate).getTime())); - } - if (ancCareDetailsOBJ.getExpDelDt() != null && !ancCareDetailsOBJ.getExpDelDt().isEmpty() - && ancCareDetailsOBJ.getExpDelDt().length() >= 10) { - String edDate = ancCareDetailsOBJ.getExpDelDt().split("T")[0]; - ancCareDetailsOBJ - .setExpectedDateofDelivery(new Date(new SimpleDateFormat("yyyy-MM-dd").parse(edDate).getTime())); - } - ANCCareDetails ancCareDetailsRS = ancCareRepo.save(ancCareDetailsOBJ); - if (ancCareDetailsRS != null) { - ancCareDetailsRS.setVanSerialNo((ancCareDetailsRS.getID())); - ancCareSuccessFlag = ancCareDetailsRS.getID(); - } - return ancCareSuccessFlag; - } - - @Override - public Long saveAncImmunizationDetails(WrapperAncImmunization wrapperAncImmunizationOBJ) throws ParseException { - Long successFlag = null; - List ancWomenVaccineDetailList = getANCWomenVaccineDetail(wrapperAncImmunizationOBJ); - List ancWomenVaccineDetailRSList = (List) ancWomenVaccineRepo - .saveAll(ancWomenVaccineDetailList); - if (!ancWomenVaccineDetailRSList.isEmpty()) { - ancWomenVaccineDetailRSList.get(0).setVanSerialNo(ancWomenVaccineDetailRSList.get(0).getID()); - successFlag = ancWomenVaccineDetailRSList.get(0).getID(); - } - return successFlag; - } - - private List getANCWomenVaccineDetail(WrapperAncImmunization wrapperAncImmunizationOBJ) - throws ParseException { - List ancWomenVaccineDetailList = new ArrayList(); - ANCWomenVaccineDetail ancWomenVaccineDetail; - if (wrapperAncImmunizationOBJ != null) { - - // TT-1 details - ancWomenVaccineDetail = new ANCWomenVaccineDetail(); - ancWomenVaccineDetail.setBeneficiaryRegID(wrapperAncImmunizationOBJ.getBeneficiaryRegID()); - ancWomenVaccineDetail.setBenVisitID(wrapperAncImmunizationOBJ.getBenVisitID()); - ancWomenVaccineDetail.setVisitCode(wrapperAncImmunizationOBJ.getVisitCode()); - ancWomenVaccineDetail.setProviderServiceMapID(wrapperAncImmunizationOBJ.getProviderServiceMapID()); - ancWomenVaccineDetail.setVanID(wrapperAncImmunizationOBJ.getVanID()); - ancWomenVaccineDetail.setParkingPlaceID(wrapperAncImmunizationOBJ.getParkingPlaceID()); - ancWomenVaccineDetail.setCreatedBy(wrapperAncImmunizationOBJ.getCreatedBy()); - ancWomenVaccineDetail.setID(wrapperAncImmunizationOBJ.gettT1ID()); - ancWomenVaccineDetail.setVaccineName("TT-1"); - ancWomenVaccineDetail.setStatus(wrapperAncImmunizationOBJ.gettT_1Status()); - if (wrapperAncImmunizationOBJ.getDateReceivedForTT_1() != null - && wrapperAncImmunizationOBJ.getDateReceivedForTT_1().length() >= 10) { - String TT_1 = wrapperAncImmunizationOBJ.getDateReceivedForTT_1().split("T")[0]; - ancWomenVaccineDetail - .setReceivedDate(new Date(new SimpleDateFormat("yyyy-MM-dd").parse(TT_1).getTime())); - } - ancWomenVaccineDetail.setReceivedFacilityName(wrapperAncImmunizationOBJ.getFacilityNameOfTT_1()); - ancWomenVaccineDetail.setModifiedBy(wrapperAncImmunizationOBJ.getModifiedBy()); - ancWomenVaccineDetailList.add(ancWomenVaccineDetail); - - // TT-2 details - ancWomenVaccineDetail = new ANCWomenVaccineDetail(); - ancWomenVaccineDetail.setBeneficiaryRegID(wrapperAncImmunizationOBJ.getBeneficiaryRegID()); - ancWomenVaccineDetail.setBenVisitID(wrapperAncImmunizationOBJ.getBenVisitID()); - ancWomenVaccineDetail.setProviderServiceMapID(wrapperAncImmunizationOBJ.getProviderServiceMapID()); - ancWomenVaccineDetail.setVanID(wrapperAncImmunizationOBJ.getVanID()); - ancWomenVaccineDetail.setParkingPlaceID(wrapperAncImmunizationOBJ.getParkingPlaceID()); - ancWomenVaccineDetail.setVisitCode(wrapperAncImmunizationOBJ.getVisitCode()); - ancWomenVaccineDetail.setCreatedBy(wrapperAncImmunizationOBJ.getCreatedBy()); - ancWomenVaccineDetail.setID(wrapperAncImmunizationOBJ.gettT2ID()); - ancWomenVaccineDetail.setVaccineName("TT-2"); - ancWomenVaccineDetail.setStatus(wrapperAncImmunizationOBJ.gettT_2Status()); - if (wrapperAncImmunizationOBJ.getDateReceivedForTT_2() != null - && wrapperAncImmunizationOBJ.getDateReceivedForTT_2().length() >= 10) { - String TT_2 = wrapperAncImmunizationOBJ.getDateReceivedForTT_2().split("T")[0]; - ancWomenVaccineDetail - .setReceivedDate(new Date(new SimpleDateFormat("yyyy-MM-dd").parse(TT_2).getTime())); - } - ancWomenVaccineDetail.setReceivedFacilityName(wrapperAncImmunizationOBJ.getFacilityNameOfTT_2()); - ancWomenVaccineDetail.setModifiedBy(wrapperAncImmunizationOBJ.getModifiedBy()); - ancWomenVaccineDetailList.add(ancWomenVaccineDetail); - - // TT-3 (Booster) details - ancWomenVaccineDetail = new ANCWomenVaccineDetail(); - ancWomenVaccineDetail.setBeneficiaryRegID(wrapperAncImmunizationOBJ.getBeneficiaryRegID()); - ancWomenVaccineDetail.setBenVisitID(wrapperAncImmunizationOBJ.getBenVisitID()); - ancWomenVaccineDetail.setProviderServiceMapID(wrapperAncImmunizationOBJ.getProviderServiceMapID()); - ancWomenVaccineDetail.setVanID(wrapperAncImmunizationOBJ.getVanID()); - ancWomenVaccineDetail.setParkingPlaceID(wrapperAncImmunizationOBJ.getParkingPlaceID()); - ancWomenVaccineDetail.setVisitCode(wrapperAncImmunizationOBJ.getVisitCode()); - ancWomenVaccineDetail.setCreatedBy(wrapperAncImmunizationOBJ.getCreatedBy()); - ancWomenVaccineDetail.setID(wrapperAncImmunizationOBJ.gettT3ID()); - ancWomenVaccineDetail.setVaccineName("TT-Booster"); - ancWomenVaccineDetail.setStatus(wrapperAncImmunizationOBJ.gettT_3Status()); - if (wrapperAncImmunizationOBJ.getDateReceivedForTT_3() != null - && wrapperAncImmunizationOBJ.getDateReceivedForTT_3().length() >= 10) { - String TT_3 = wrapperAncImmunizationOBJ.getDateReceivedForTT_3().split("T")[0]; - ancWomenVaccineDetail - .setReceivedDate(new Date(new SimpleDateFormat("yyyy-MM-dd").parse(TT_3).getTime())); - } - ancWomenVaccineDetail.setReceivedFacilityName(wrapperAncImmunizationOBJ.getFacilityNameOfTT_3()); - ancWomenVaccineDetail.setModifiedBy(wrapperAncImmunizationOBJ.getModifiedBy()); - ancWomenVaccineDetailList.add(ancWomenVaccineDetail); - - } - return ancWomenVaccineDetailList; - } - - @Override - public Long saveSysObstetricExamination(SysObstetricExamination obstetricExamination) { - // TODO Auto-generated method stub - Long r = null; - SysObstetricExamination obstetricExaminationRS = sysObstetricExaminationRepo.save(obstetricExamination); - if (obstetricExaminationRS != null) - r = obstetricExaminationRS.getID(); - return r; - } - - public SysObstetricExamination getSysObstetricExamination(Long benRegID, Long visitCode) { - SysObstetricExamination sysObstetricExaminationData = sysObstetricExaminationRepo - .getSysObstetricExaminationData(benRegID, visitCode); - - return sysObstetricExaminationData; - } - - @Override - public String getANCCareDetails(Long beneficiaryRegID, Long visitCode) { - ArrayList resList = ancCareRepo.getANCCareDetails(beneficiaryRegID, visitCode); - ANCCareDetails ancCareDetails = ANCCareDetails.getANCCareDetails(resList); - return new Gson().toJson(ancCareDetails); - } - - @Override - public String getANCWomenVaccineDetails(Long beneficiaryRegID, Long visitCode) { - ArrayList resList = ancWomenVaccineRepo.getANCWomenVaccineDetails(beneficiaryRegID, visitCode); - WrapperAncImmunization ancWomenVaccineDetails = ANCWomenVaccineDetail.getANCWomenVaccineDetails(resList); - return new Gson().toJson(ancWomenVaccineDetails); - } - - @Override - public int updateBenAdherenceDetails(BenAdherence benAdherence) { - int r = 0; - String processed = benAdherenceRepo.getBenAdherenceDetailsStatus(benAdherence.getBeneficiaryRegID(), - benAdherence.getBenVisitID(), benAdherence.getID()); - if (null != processed && !"N".equals(processed)) { - processed = "U"; - } else { - processed = "N"; - } - r = benAdherenceRepo.updateBenAdherence(benAdherence.getToDrugs(), benAdherence.getDrugReason(), - benAdherence.getToReferral(), benAdherence.getReferralReason(), benAdherence.getProgress(), - benAdherence.getModifiedBy(), processed, benAdherence.getBeneficiaryRegID(), - benAdherence.getBenVisitID(), benAdherence.getID()); - /* + return r; + } + + + @Override + public Long saveBenAncCareDetails + (ANCCareDetails ancCareDetailsOBJ) throws ParseException { + Long ancCareSuccessFlag = null; + if (ancCareDetailsOBJ.getLmpDate() != null && !ancCareDetailsOBJ.getLmpDate().isEmpty() + && ancCareDetailsOBJ.getLmpDate().length() >= 10) { + String lmpDate = ancCareDetailsOBJ.getLmpDate().split("T")[0]; + ancCareDetailsOBJ + .setLastMenstrualPeriod_LMP(new Date(new SimpleDateFormat("yyyy-MM-dd").parse(lmpDate).getTime())); + } + if (ancCareDetailsOBJ.getExpDelDt() != null && !ancCareDetailsOBJ.getExpDelDt().isEmpty() + && ancCareDetailsOBJ.getExpDelDt().length() >= 10) { + String edDate = ancCareDetailsOBJ.getExpDelDt().split("T")[0]; + ancCareDetailsOBJ + .setExpectedDateofDelivery(new Date(new SimpleDateFormat("yyyy-MM-dd").parse(edDate).getTime())); + } + ANCCareDetails ancCareDetailsRS = ancCareRepo.save(ancCareDetailsOBJ); + if (ancCareDetailsRS != null) { + ancCareDetailsRS.setVanSerialNo((ancCareDetailsRS.getID())); + ancCareSuccessFlag = ancCareDetailsRS.getID(); + } + return ancCareSuccessFlag; + } + + @Override + public Long saveAncImmunizationDetails + (WrapperAncImmunization wrapperAncImmunizationOBJ) throws ParseException { + Long successFlag = null; + List ancWomenVaccineDetailList = getANCWomenVaccineDetail(wrapperAncImmunizationOBJ); + List ancWomenVaccineDetailRSList = (List) ancWomenVaccineRepo + .saveAll(ancWomenVaccineDetailList); + if (!ancWomenVaccineDetailRSList.isEmpty()) { + ancWomenVaccineDetailRSList.get(0).setVanSerialNo(ancWomenVaccineDetailRSList.get(0).getID()); + successFlag = ancWomenVaccineDetailRSList.get(0).getID(); + } + return successFlag; + } + + + + private List getANCWomenVaccineDetail(WrapperAncImmunization wrapperAncImmunizationOBJ) + throws ParseException { + List ancWomenVaccineDetailList = new ArrayList(); + ANCWomenVaccineDetail ancWomenVaccineDetail; + if (wrapperAncImmunizationOBJ != null) { + + // TT-1 details + ancWomenVaccineDetail = new ANCWomenVaccineDetail(); + ancWomenVaccineDetail.setBeneficiaryRegID(wrapperAncImmunizationOBJ.getBeneficiaryRegID()); + ancWomenVaccineDetail.setBenVisitID(wrapperAncImmunizationOBJ.getBenVisitID()); + ancWomenVaccineDetail.setVisitCode(wrapperAncImmunizationOBJ.getVisitCode()); + ancWomenVaccineDetail.setProviderServiceMapID(wrapperAncImmunizationOBJ.getProviderServiceMapID()); + ancWomenVaccineDetail.setVanID(wrapperAncImmunizationOBJ.getVanID()); + ancWomenVaccineDetail.setParkingPlaceID(wrapperAncImmunizationOBJ.getParkingPlaceID()); + ancWomenVaccineDetail.setCreatedBy(wrapperAncImmunizationOBJ.getCreatedBy()); + ancWomenVaccineDetail.setID(wrapperAncImmunizationOBJ.gettT1ID()); + ancWomenVaccineDetail.setVaccineName("TT-1"); + ancWomenVaccineDetail.setStatus(wrapperAncImmunizationOBJ.gettT_1Status()); + if (wrapperAncImmunizationOBJ.getDateReceivedForTT_1() != null + && wrapperAncImmunizationOBJ.getDateReceivedForTT_1().length() >= 10) { + String TT_1 = wrapperAncImmunizationOBJ.getDateReceivedForTT_1().split("T")[0]; + ancWomenVaccineDetail + .setReceivedDate(new Date(new SimpleDateFormat("yyyy-MM-dd").parse(TT_1).getTime())); + } + ancWomenVaccineDetail.setReceivedFacilityName(wrapperAncImmunizationOBJ.getFacilityNameOfTT_1()); + ancWomenVaccineDetail.setModifiedBy(wrapperAncImmunizationOBJ.getModifiedBy()); + ancWomenVaccineDetailList.add(ancWomenVaccineDetail); + + // TT-2 details + ancWomenVaccineDetail = new ANCWomenVaccineDetail(); + ancWomenVaccineDetail.setBeneficiaryRegID(wrapperAncImmunizationOBJ.getBeneficiaryRegID()); + ancWomenVaccineDetail.setBenVisitID(wrapperAncImmunizationOBJ.getBenVisitID()); + ancWomenVaccineDetail.setProviderServiceMapID(wrapperAncImmunizationOBJ.getProviderServiceMapID()); + ancWomenVaccineDetail.setVanID(wrapperAncImmunizationOBJ.getVanID()); + ancWomenVaccineDetail.setParkingPlaceID(wrapperAncImmunizationOBJ.getParkingPlaceID()); + ancWomenVaccineDetail.setVisitCode(wrapperAncImmunizationOBJ.getVisitCode()); + ancWomenVaccineDetail.setCreatedBy(wrapperAncImmunizationOBJ.getCreatedBy()); + ancWomenVaccineDetail.setID(wrapperAncImmunizationOBJ.gettT2ID()); + ancWomenVaccineDetail.setVaccineName("TT-2"); + ancWomenVaccineDetail.setStatus(wrapperAncImmunizationOBJ.gettT_2Status()); + if (wrapperAncImmunizationOBJ.getDateReceivedForTT_2() != null + && wrapperAncImmunizationOBJ.getDateReceivedForTT_2().length() >= 10) { + String TT_2 = wrapperAncImmunizationOBJ.getDateReceivedForTT_2().split("T")[0]; + ancWomenVaccineDetail + .setReceivedDate(new Date(new SimpleDateFormat("yyyy-MM-dd").parse(TT_2).getTime())); + } + ancWomenVaccineDetail.setReceivedFacilityName(wrapperAncImmunizationOBJ.getFacilityNameOfTT_2()); + ancWomenVaccineDetail.setModifiedBy(wrapperAncImmunizationOBJ.getModifiedBy()); + ancWomenVaccineDetailList.add(ancWomenVaccineDetail); + + // TT-3 (Booster) details + ancWomenVaccineDetail = new ANCWomenVaccineDetail(); + ancWomenVaccineDetail.setBeneficiaryRegID(wrapperAncImmunizationOBJ.getBeneficiaryRegID()); + ancWomenVaccineDetail.setBenVisitID(wrapperAncImmunizationOBJ.getBenVisitID()); + ancWomenVaccineDetail.setProviderServiceMapID(wrapperAncImmunizationOBJ.getProviderServiceMapID()); + ancWomenVaccineDetail.setVanID(wrapperAncImmunizationOBJ.getVanID()); + ancWomenVaccineDetail.setParkingPlaceID(wrapperAncImmunizationOBJ.getParkingPlaceID()); + ancWomenVaccineDetail.setVisitCode(wrapperAncImmunizationOBJ.getVisitCode()); + ancWomenVaccineDetail.setCreatedBy(wrapperAncImmunizationOBJ.getCreatedBy()); + ancWomenVaccineDetail.setID(wrapperAncImmunizationOBJ.gettT3ID()); + ancWomenVaccineDetail.setVaccineName("TT-Booster"); + ancWomenVaccineDetail.setStatus(wrapperAncImmunizationOBJ.gettT_3Status()); + if (wrapperAncImmunizationOBJ.getDateReceivedForTT_3() != null + && wrapperAncImmunizationOBJ.getDateReceivedForTT_3().length() >= 10) { + String TT_3 = wrapperAncImmunizationOBJ.getDateReceivedForTT_3().split("T")[0]; + ancWomenVaccineDetail + .setReceivedDate(new Date(new SimpleDateFormat("yyyy-MM-dd").parse(TT_3).getTime())); + } + ancWomenVaccineDetail.setReceivedFacilityName(wrapperAncImmunizationOBJ.getFacilityNameOfTT_3()); + ancWomenVaccineDetail.setModifiedBy(wrapperAncImmunizationOBJ.getModifiedBy()); + ancWomenVaccineDetailList.add(ancWomenVaccineDetail); + + } + return ancWomenVaccineDetailList; + } + + @Override + public Long saveSysObstetricExamination(SysObstetricExamination obstetricExamination) { + // TODO Auto-generated method stub + Long r = null; + SysObstetricExamination obstetricExaminationRS = sysObstetricExaminationRepo.save(obstetricExamination); + if (obstetricExaminationRS != null) { + r = obstetricExaminationRS.getID(); + } + return r; + } + + public SysObstetricExamination getSysObstetricExamination(Long benRegID, Long visitCode) { + SysObstetricExamination sysObstetricExaminationData = sysObstetricExaminationRepo + .getSysObstetricExaminationData(benRegID, visitCode); + + return sysObstetricExaminationData; + } + + @Override + public String getANCCareDetails(Long beneficiaryRegID, Long visitCode) { + ArrayList resList = ancCareRepo.getANCCareDetails(beneficiaryRegID, visitCode); + ANCCareDetails ancCareDetails = ANCCareDetails.getANCCareDetails(resList); + return new Gson().toJson(ancCareDetails); + } + + @Override + public String getANCWomenVaccineDetails(Long beneficiaryRegID, Long visitCode) { + ArrayList resList = ancWomenVaccineRepo.getANCWomenVaccineDetails(beneficiaryRegID, visitCode); + WrapperAncImmunization ancWomenVaccineDetails = ANCWomenVaccineDetail.getANCWomenVaccineDetails(resList); + return new Gson().toJson(ancWomenVaccineDetails); + } + + @Override + public int updateBenAdherenceDetails(BenAdherence benAdherence) { + int r = 0; + String processed = benAdherenceRepo.getBenAdherenceDetailsStatus(benAdherence.getBeneficiaryRegID(), + benAdherence.getBenVisitID(), benAdherence.getID()); + if (null != processed && !"N".equals(processed)) { + processed = "U"; + } else { + processed = "N"; + } + r = benAdherenceRepo.updateBenAdherence(benAdherence.getToDrugs(), benAdherence.getDrugReason(), + benAdherence.getToReferral(), benAdherence.getReferralReason(), benAdherence.getProgress(), + benAdherence.getModifiedBy(), processed, benAdherence.getBeneficiaryRegID(), + benAdherence.getBenVisitID(), benAdherence.getID()); + /* * BenAdherence adherence= benAdherenceRepo.save(benAdherence); if(null * !=adherence){ r=1; } - */ - return r; - } - - @Override - public int updateBenAncCareDetails(ANCCareDetails ancCareDetailsOBJ) throws ParseException { - int r = 0; - - String processed = ancCareRepo.getBenANCCareDetailsStatus(ancCareDetailsOBJ.getBeneficiaryRegID(), - ancCareDetailsOBJ.getVisitCode()); - if (null != processed && !"N".equals(processed)) { - processed = "U"; - } else { - processed = "N"; - } - - if (ancCareDetailsOBJ.getLmpDate() != null && !ancCareDetailsOBJ.getLmpDate().isEmpty() - && ancCareDetailsOBJ.getLmpDate().length() >= 10) { - String lmpDate = ancCareDetailsOBJ.getLmpDate().split("T")[0]; - ancCareDetailsOBJ - .setLastMenstrualPeriod_LMP(new Date(new SimpleDateFormat("yyyy-MM-dd").parse(lmpDate).getTime())); - } - if (ancCareDetailsOBJ.getExpDelDt() != null && !ancCareDetailsOBJ.getExpDelDt().isEmpty() - && ancCareDetailsOBJ.getExpDelDt().length() >= 10) { - String edDate = ancCareDetailsOBJ.getExpDelDt().split("T")[0]; - ancCareDetailsOBJ - .setExpectedDateofDelivery(new Date(new SimpleDateFormat("yyyy-MM-dd").parse(edDate).getTime())); - } - - r = ancCareRepo.updateANCCareDetails(ancCareDetailsOBJ.getComolaintType(), ancCareDetailsOBJ.getDuration(), - ancCareDetailsOBJ.getDescription(), ancCareDetailsOBJ.getLastMenstrualPeriod_LMP(), - ancCareDetailsOBJ.getGestationalAgeOrPeriodofAmenorrhea_POA(), ancCareDetailsOBJ.getTrimesterNumber(), - ancCareDetailsOBJ.getExpectedDateofDelivery(), ancCareDetailsOBJ.getPrimiGravida(), - ancCareDetailsOBJ.getGravida_G(), ancCareDetailsOBJ.getTermDeliveries_T(), - ancCareDetailsOBJ.getPretermDeliveries_P(), ancCareDetailsOBJ.getAbortions_A(), - ancCareDetailsOBJ.getLivebirths_L(), ancCareDetailsOBJ.getBloodGroup(), - ancCareDetailsOBJ.getModifiedBy(), processed, ancCareDetailsOBJ.getBeneficiaryRegID(), - ancCareDetailsOBJ.getVisitCode(), ancCareDetailsOBJ.getStillBirth()); - return r; - } - - @Override - public int updateBenAncImmunizationDetails(WrapperAncImmunization wrapperAncImmunization) throws ParseException { - int r = 0; - - List ancWomenVaccineDetailList = getANCWomenVaccineDetail(wrapperAncImmunization); - - if (null != ancWomenVaccineDetailList) { - - String processed = "N"; - ANCWomenVaccineDetail ancWomenVaccine = ancWomenVaccineDetailList.get(0); - ArrayList ancWomenVaccineStatuses = ancWomenVaccineRepo - .getBenANCWomenVaccineStatus(ancWomenVaccine.getBeneficiaryRegID(), ancWomenVaccine.getVisitCode()); - Map womenVaccineStatuses = new HashMap(); - - for (Object[] obj : ancWomenVaccineStatuses) { - womenVaccineStatuses.put((String) obj[0], (String) obj[1]); - } - - for (ANCWomenVaccineDetail ancWomenVaccineDetail : ancWomenVaccineDetailList) { - processed = womenVaccineStatuses.get(ancWomenVaccineDetail.getVaccineName()); - if (null != processed && !processed.equals("N")) { - processed = "U"; - } else { - processed = "N"; - } - - r = ancWomenVaccineRepo.updateANCImmunizationDetails(ancWomenVaccineDetail.getStatus(), - ancWomenVaccineDetail.getReceivedDate(), ancWomenVaccineDetail.getReceivedFacilityName(), - ancWomenVaccineDetail.getModifiedBy(), processed, ancWomenVaccineDetail.getBeneficiaryRegID(), - ancWomenVaccineDetail.getVisitCode(), ancWomenVaccineDetail.getVaccineName()); - - } - } - return r; - } - - @Override - public int updateSysObstetricExamination(SysObstetricExamination obstetricExamination) { - int r = 0; - if (null != obstetricExamination) { - String processed = sysObstetricExaminationRepo.getBenObstetricExaminationStatus( - obstetricExamination.getBeneficiaryRegID(), obstetricExamination.getVisitCode()); - if (null != processed && !"N".equals(processed)) { - processed = "U"; - } else { - processed = "N"; - } - r = sysObstetricExaminationRepo.updateSysObstetricExamination(obstetricExamination.getFundalHeight(), - obstetricExamination.getfHAndPOA_Status(), obstetricExamination.getfHAndPOA_Interpretation(), - obstetricExamination.getFetalMovements(), obstetricExamination.getFetalHeartSounds(), - obstetricExamination.getFetalHeartRate_BeatsPerMinute(), - obstetricExamination.getFetalPositionOrLie(), obstetricExamination.getFetalPresentation(), - obstetricExamination.getAbdominalScars(), obstetricExamination.getModifiedBy(), - obstetricExamination.getSfh(), processed, obstetricExamination.getBeneficiaryRegID(), - obstetricExamination.getVisitCode()); - } - return r; - } + */ + return r; + } + + @Override + public int updateBenAncCareDetails(ANCCareDetails ancCareDetailsOBJ) throws ParseException { + int r = 0; + + String processed = ancCareRepo.getBenANCCareDetailsStatus(ancCareDetailsOBJ.getBeneficiaryRegID(), + ancCareDetailsOBJ.getVisitCode()); + if (null != processed && !"N".equals(processed)) { + processed = "U"; + } else { + processed = "N"; + } + + if (ancCareDetailsOBJ.getLmpDate() != null && !ancCareDetailsOBJ.getLmpDate().isEmpty() + && ancCareDetailsOBJ.getLmpDate().length() >= 10) { + String lmpDate = ancCareDetailsOBJ.getLmpDate().split("T")[0]; + ancCareDetailsOBJ + .setLastMenstrualPeriod_LMP(new Date(new SimpleDateFormat("yyyy-MM-dd").parse(lmpDate).getTime())); + } + if (ancCareDetailsOBJ.getExpDelDt() != null && !ancCareDetailsOBJ.getExpDelDt().isEmpty() + && ancCareDetailsOBJ.getExpDelDt().length() >= 10) { + String edDate = ancCareDetailsOBJ.getExpDelDt().split("T")[0]; + ancCareDetailsOBJ + .setExpectedDateofDelivery(new Date(new SimpleDateFormat("yyyy-MM-dd").parse(edDate).getTime())); + } + + r = ancCareRepo.updateANCCareDetails(ancCareDetailsOBJ.getComolaintType(), ancCareDetailsOBJ.getDuration(), + ancCareDetailsOBJ.getDescription(), ancCareDetailsOBJ.getLastMenstrualPeriod_LMP(), + ancCareDetailsOBJ.getGestationalAgeOrPeriodofAmenorrhea_POA(), ancCareDetailsOBJ.getTrimesterNumber(), + ancCareDetailsOBJ.getExpectedDateofDelivery(), ancCareDetailsOBJ.getPrimiGravida(), + ancCareDetailsOBJ.getGravida_G(), ancCareDetailsOBJ.getTermDeliveries_T(), + ancCareDetailsOBJ.getPretermDeliveries_P(), ancCareDetailsOBJ.getAbortions_A(), + ancCareDetailsOBJ.getLivebirths_L(), ancCareDetailsOBJ.getBloodGroup(), + ancCareDetailsOBJ.getModifiedBy(), processed, ancCareDetailsOBJ.getBeneficiaryRegID(), + ancCareDetailsOBJ.getVisitCode(), ancCareDetailsOBJ.getStillBirth()); + return r; + } + + @Override + public int updateBenAncImmunizationDetails(WrapperAncImmunization wrapperAncImmunization) throws ParseException { + int r = 0; + + List ancWomenVaccineDetailList = getANCWomenVaccineDetail(wrapperAncImmunization); + + if (null != ancWomenVaccineDetailList) { + + String processed = "N"; + ANCWomenVaccineDetail ancWomenVaccine = ancWomenVaccineDetailList.get(0); + ArrayList ancWomenVaccineStatuses = ancWomenVaccineRepo + .getBenANCWomenVaccineStatus(ancWomenVaccine.getBeneficiaryRegID(), ancWomenVaccine.getVisitCode()); + Map womenVaccineStatuses = new HashMap(); + + for (Object[] obj : ancWomenVaccineStatuses) { + womenVaccineStatuses.put((String) obj[0], (String) obj[1]); + } + + for (ANCWomenVaccineDetail ancWomenVaccineDetail : ancWomenVaccineDetailList) { + processed = womenVaccineStatuses.get(ancWomenVaccineDetail.getVaccineName()); + if (null != processed && !processed.equals("N")) { + processed = "U"; + } else { + processed = "N"; + } + + r = ancWomenVaccineRepo.updateANCImmunizationDetails(ancWomenVaccineDetail.getStatus(), + ancWomenVaccineDetail.getReceivedDate(), ancWomenVaccineDetail.getReceivedFacilityName(), + ancWomenVaccineDetail.getModifiedBy(), processed, ancWomenVaccineDetail.getBeneficiaryRegID(), + ancWomenVaccineDetail.getVisitCode(), ancWomenVaccineDetail.getVaccineName()); + + } + } + return r; + } + + @Override + public int updateSysObstetricExamination(SysObstetricExamination obstetricExamination) { + int r = 0; + if (null != obstetricExamination) { + String processed = sysObstetricExaminationRepo.getBenObstetricExaminationStatus( + obstetricExamination.getBeneficiaryRegID(), obstetricExamination.getVisitCode()); + if (null != processed && !"N".equals(processed)) { + processed = "U"; + } else { + processed = "N"; + } + r = sysObstetricExaminationRepo.updateSysObstetricExamination(obstetricExamination.getFundalHeight(), + obstetricExamination.getfHAndPOA_Status(), obstetricExamination.getfHAndPOA_Interpretation(), + obstetricExamination.getFetalMovements(), obstetricExamination.getFetalHeartSounds(), + obstetricExamination.getFetalHeartRate_BeatsPerMinute(), + obstetricExamination.getFetalPositionOrLie(), obstetricExamination.getFetalPresentation(), + obstetricExamination.getAbdominalScars(), obstetricExamination.getModifiedBy(), + obstetricExamination.getSfh(), processed, obstetricExamination.getBeneficiaryRegID(), + obstetricExamination.getVisitCode()); + } + return r; + } } diff --git a/src/main/java/com/iemr/mmu/service/labtechnician/LabTechnicianServiceImpl.java b/src/main/java/com/iemr/mmu/service/labtechnician/LabTechnicianServiceImpl.java index 138f626c..1026f63c 100644 --- a/src/main/java/com/iemr/mmu/service/labtechnician/LabTechnicianServiceImpl.java +++ b/src/main/java/com/iemr/mmu/service/labtechnician/LabTechnicianServiceImpl.java @@ -18,7 +18,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see https://www.gnu.org/licenses/. -*/ + */ package com.iemr.mmu.service.labtechnician; import java.util.ArrayList; @@ -42,248 +42,249 @@ @Service public class LabTechnicianServiceImpl implements LabTechnicianService { - private V_benLabTestOrderedDetailsRepo v_benLabTestOrderedDetailsRepo; - private LabResultEntryRepo labResultEntryRepo; - private CommonBenStatusFlowServiceImpl commonBenStatusFlowServiceImpl; - - @Autowired - public void setCommonBenStatusFlowServiceImpl(CommonBenStatusFlowServiceImpl commonBenStatusFlowServiceImpl) { - this.commonBenStatusFlowServiceImpl = commonBenStatusFlowServiceImpl; - } - - @Autowired - public void setLabResultEntryRepo(LabResultEntryRepo labResultEntryRepo) { - this.labResultEntryRepo = labResultEntryRepo; - } - - @Autowired - public void setV_benLabTestOrderedDetailsRepo(V_benLabTestOrderedDetailsRepo v_benLabTestOrderedDetailsRepo) { - this.v_benLabTestOrderedDetailsRepo = v_benLabTestOrderedDetailsRepo; - } - - public String getBenePrescribedProcedureDetails(Long benRegID, Long visitCode) throws Exception { - Map returnOBJ = new HashMap<>(); - - ArrayList radiologyList; - ArrayList laboratoryList; - - ArrayList resultEnteredProcList = new ArrayList<>(); - - ArrayList procedureResults = getLabResultDataForBen(benRegID, visitCode); - - if (procedureResults != null && procedureResults.size() > 0) { - for (LabResultEntry obj : procedureResults) { - resultEnteredProcList.add(obj.getProcedureID()); - } - } - resultEnteredProcList.add(0); - - ArrayList orderedLabTestListLab = v_benLabTestOrderedDetailsRepo - .findDistinctByBeneficiaryRegIDAndVisitCodeAndProcedureTypeAndProcedureIDNotInOrderByProcedureIDAscTestComponentIDAscResultValueAsc( - benRegID, visitCode, "Laboratory", resultEnteredProcList); - - ArrayList orderedLabTestListRadio = v_benLabTestOrderedDetailsRepo - .findDistinctByBeneficiaryRegIDAndVisitCodeAndProcedureTypeAndProcedureIDNotInOrderByProcedureIDAscTestComponentIDAscResultValueAsc( - benRegID, visitCode, "Radiology", resultEnteredProcList); - - radiologyList = getPrescribedLabTestInJsonFormatRadiology(orderedLabTestListRadio); - laboratoryList = getPrescribedLabTestInJsonFormatlaboratory(orderedLabTestListLab); - - returnOBJ.put("radiologyList", radiologyList); - returnOBJ.put("laboratoryList", laboratoryList); - returnOBJ.put("archive", procedureResults); - - return new Gson().toJson(returnOBJ); - } - - private ArrayList getPrescribedLabTestInJsonFormatlaboratory( - ArrayList orderedLabTestList) { - - ArrayList returnOBJ = new ArrayList<>(); - Map procDetails = null; - ArrayList compList = null; - Map compDetails = null; - Map compOption = null; - ArrayList compOptionList = null; - - if (orderedLabTestList != null && orderedLabTestList.size() > 0) { - for (V_benLabTestOrderedDetails obj : orderedLabTestList) { - - if (procDetails == null || (procDetails.containsKey("procedureID") - && !obj.getProcedureID().equals(procDetails.get("procedureID")))) { - procDetails = new HashMap<>(); - compList = new ArrayList<>(); - - procDetails.put("procedureID", obj.getProcedureID()); - procDetails.put("procedureName", obj.getProcedureName()); - procDetails.put("procedureDesc", obj.getProcedureDesc()); - procDetails.put("procedureType", "Laboratory"); - procDetails.put("prescriptionID", obj.getPrescriptionID()); - - procDetails.put("iotProcedureName", obj.getIotProcedureName()); - procDetails.put("procedureCode", obj.getProcedureCode()); - procDetails.put("procedureStartAPI", obj.getProcedureStartAPI()); - procDetails.put("procedureEndAPI", obj.getProcedureEndAPI()); - procDetails.put("procedureStatusAPI", obj.getProcedureStatusAPI()); - procDetails.put("isLabProcedure", obj.getIsLabProcedure()); - procDetails.put("discoveryCode", obj.getDiscoveryCode()); - procDetails.put("isMandatory", obj.getIsMandatory()); - procDetails.put("calibrationStartAPI", obj.getCalibrationStartAPI()); - procDetails.put("calibrationStatusAPI", obj.getCalibrationStatusAPI()); - procDetails.put("calibrationEndAPI", obj.getCalibrationEndAPI()); - // System.out.println(procDetails.get("procedureID")); + + private V_benLabTestOrderedDetailsRepo v_benLabTestOrderedDetailsRepo; + private LabResultEntryRepo labResultEntryRepo; + private CommonBenStatusFlowServiceImpl commonBenStatusFlowServiceImpl; + + @Autowired + public void setCommonBenStatusFlowServiceImpl(CommonBenStatusFlowServiceImpl commonBenStatusFlowServiceImpl) { + this.commonBenStatusFlowServiceImpl = commonBenStatusFlowServiceImpl; + } + + @Autowired + public void setLabResultEntryRepo(LabResultEntryRepo labResultEntryRepo) { + this.labResultEntryRepo = labResultEntryRepo; + } + + @Autowired + public void setV_benLabTestOrderedDetailsRepo(V_benLabTestOrderedDetailsRepo v_benLabTestOrderedDetailsRepo) { + this.v_benLabTestOrderedDetailsRepo = v_benLabTestOrderedDetailsRepo; + } + + public String getBenePrescribedProcedureDetails(Long benRegID, Long visitCode) throws Exception { + Map returnOBJ = new HashMap<>(); + + ArrayList radiologyList; + ArrayList laboratoryList; + + ArrayList resultEnteredProcList = new ArrayList<>(); + + ArrayList procedureResults = getLabResultDataForBen(benRegID, visitCode); + + if (procedureResults != null && procedureResults.size() > 0) { + for (LabResultEntry obj : procedureResults) { + resultEnteredProcList.add(obj.getProcedureID()); + } + } + resultEnteredProcList.add(0); + + ArrayList orderedLabTestListLab = v_benLabTestOrderedDetailsRepo + .findDistinctByBeneficiaryRegIDAndVisitCodeAndProcedureTypeAndProcedureIDNotInOrderByProcedureIDAscTestComponentIDAscResultValueAsc( + benRegID, visitCode, "Laboratory", resultEnteredProcList); + + ArrayList orderedLabTestListRadio = v_benLabTestOrderedDetailsRepo + .findDistinctByBeneficiaryRegIDAndVisitCodeAndProcedureTypeAndProcedureIDNotInOrderByProcedureIDAscTestComponentIDAscResultValueAsc( + benRegID, visitCode, "Radiology", resultEnteredProcList); + + radiologyList = getPrescribedLabTestInJsonFormatRadiology(orderedLabTestListRadio); + laboratoryList = getPrescribedLabTestInJsonFormatlaboratory(orderedLabTestListLab); + + returnOBJ.put("radiologyList", radiologyList); + returnOBJ.put("laboratoryList", laboratoryList); + returnOBJ.put("archive", procedureResults); + + return new Gson().toJson(returnOBJ); + } + + private ArrayList getPrescribedLabTestInJsonFormatlaboratory( + ArrayList orderedLabTestList) { + + ArrayList returnOBJ = new ArrayList<>(); + Map procDetails = null; + ArrayList compList = null; + Map compDetails = null; + Map compOption = null; + ArrayList compOptionList = null; + + if (orderedLabTestList != null && orderedLabTestList.size() > 0) { + for (V_benLabTestOrderedDetails obj : orderedLabTestList) { + + if (procDetails == null || (procDetails.containsKey("procedureID") + && !obj.getProcedureID().equals(procDetails.get("procedureID")))) { + procDetails = new HashMap<>(); + compList = new ArrayList<>(); + + procDetails.put("procedureID", obj.getProcedureID()); + procDetails.put("procedureName", obj.getProcedureName()); + procDetails.put("procedureDesc", obj.getProcedureDesc()); + procDetails.put("procedureType", "Laboratory"); + procDetails.put("prescriptionID", obj.getPrescriptionID()); + + procDetails.put("iotProcedureName", obj.getIotProcedureName()); + procDetails.put("procedureCode", obj.getProcedureCode()); + procDetails.put("procedureStartAPI", obj.getProcedureStartAPI()); + procDetails.put("procedureEndAPI", obj.getProcedureEndAPI()); + procDetails.put("procedureStatusAPI", obj.getProcedureStatusAPI()); + procDetails.put("isLabProcedure", obj.getIsLabProcedure()); + procDetails.put("discoveryCode", obj.getDiscoveryCode()); + procDetails.put("isMandatory", obj.getIsMandatory()); + procDetails.put("calibrationStartAPI", obj.getCalibrationStartAPI()); + procDetails.put("calibrationStatusAPI", obj.getCalibrationStatusAPI()); + procDetails.put("calibrationEndAPI", obj.getCalibrationEndAPI()); + // System.out.println(procDetails.get("procedureID")); // if (procDetails.get("procedureID") instanceof Integer // && obj.getProcedureID() == procDetails.get("procedureID")) { // //System.out.println("hello"); // } - if (procDetails.containsKey("compListDetails") == false) { - compList = new ArrayList<>(); - compDetails = new HashMap<>(); - compDetails.put("testComponentID", obj.getTestComponentID()); - compDetails.put("testComponentName", obj.getTestComponentName()); - compDetails.put("testComponentDesc", obj.getTestComponentDesc()); - compDetails.put("inputType", obj.getInputType()); - compDetails.put("measurementUnit", obj.getMeasurementUnit()); - compDetails.put("range_min", obj.getRange_min()); - compDetails.put("range_normal_min", obj.getRange_normal_min()); - compDetails.put("range_normal_max", obj.getRange_normal_max()); - compDetails.put("range_max", obj.getRange_max()); - compDetails.put("isDecimal", obj.getIsDecimal()); - - compDetails.put("iotComponentName", obj.getIOTComponentName()); - compDetails.put("componentCode", obj.getComponentCode()); - compDetails.put("iotProcedureID", obj.getIOTProcedureID()); - compDetails.put("componentUnit", obj.getComponentUnit()); - - compOption = new HashMap<>(); - compOptionList = new ArrayList<>(); - - compOption.put("name", obj.getResultValue()); - compOptionList.add(compOption); - - compDetails.put("compOpt", compOptionList); - - compList.add(compDetails); - procDetails.put("compListDetails", compList); - - } else { - compDetails = new HashMap<>(); - compDetails.put("testComponentID", obj.getTestComponentID()); - compDetails.put("testComponentName", obj.getTestComponentName()); - compDetails.put("testComponentDesc", obj.getTestComponentDesc()); - compDetails.put("inputType", obj.getInputType()); - compDetails.put("isDecimal", obj.getIsDecimal()); - compDetails.put("measurementUnit", obj.getMeasurementUnit()); - compDetails.put("range_min", obj.getRange_min()); - compDetails.put("range_normal_min", obj.getRange_normal_min()); - compDetails.put("range_normal_max", obj.getRange_normal_max()); - compDetails.put("range_max", obj.getRange_max()); - - compDetails.put("iotComponentName", obj.getIOTComponentName()); - compDetails.put("componentCode", obj.getComponentCode()); - compDetails.put("iotProcedureID", obj.getIOTProcedureID()); - compDetails.put("componentUnit", obj.getComponentUnit()); - - compOption = new HashMap<>(); - compOptionList = new ArrayList<>(); - - compOption.put("name", obj.getResultValue()); - compOptionList.add(compOption); - - compDetails.put("compOpt", compOptionList); - - compList.add(compDetails); - - } - - returnOBJ.add(procDetails); - - } else { - - if (compDetails == null || (compDetails.containsKey("testComponentID") - && !obj.getTestComponentID().equals(compDetails.get("testComponentID")))) { - - compDetails = new HashMap<>(); - compDetails.put("testComponentID", obj.getTestComponentID()); - compDetails.put("testComponentName", obj.getTestComponentName()); - compDetails.put("testComponentDesc", obj.getTestComponentDesc()); - compDetails.put("inputType", obj.getInputType()); - compDetails.put("isDecimal", obj.getIsDecimal()); - compDetails.put("measurementUnit", obj.getMeasurementUnit()); - compDetails.put("range_min", obj.getRange_min()); - compDetails.put("range_normal_min", obj.getRange_normal_min()); - compDetails.put("range_normal_max", obj.getRange_normal_max()); - compDetails.put("range_max", obj.getRange_max()); - - compDetails.put("iotComponentName", obj.getIOTComponentName()); - compDetails.put("componentCode", obj.getComponentCode()); - compDetails.put("iotProcedureID", obj.getIOTProcedureID()); - compDetails.put("componentUnit", obj.getComponentUnit()); - - compOption = new HashMap<>(); - compOptionList = new ArrayList<>(); - - compOption.put("name", obj.getResultValue()); - compOptionList.add(compOption); - - compDetails.put("compOpt", compOptionList); - - compList.add(compDetails); - } else { - compOption = new HashMap<>(); - compOption.put("name", obj.getResultValue()); - compOptionList.add(compOption); - } - - } - } - } - - return returnOBJ; - } - - public ArrayList getLabResultDataForBen(Long benRegID, Long visitCode) throws Exception { - ArrayList procedureResults = new ArrayList<>(); - procedureResults = labResultEntryRepo.findByBeneficiaryRegIDAndVisitCodeOrderByProcedureIDAsc(benRegID, - visitCode); - procedureResults = LabResultEntry.getLabResultEntry(procedureResults); - return procedureResults; - } + if (procDetails.containsKey("compListDetails") == false) { + compList = new ArrayList<>(); + compDetails = new HashMap<>(); + compDetails.put("testComponentID", obj.getTestComponentID()); + compDetails.put("testComponentName", obj.getTestComponentName()); + compDetails.put("testComponentDesc", obj.getTestComponentDesc()); + compDetails.put("inputType", obj.getInputType()); + compDetails.put("measurementUnit", obj.getMeasurementUnit()); + compDetails.put("range_min", obj.getRange_min()); + compDetails.put("range_normal_min", obj.getRange_normal_min()); + compDetails.put("range_normal_max", obj.getRange_normal_max()); + compDetails.put("range_max", obj.getRange_max()); + compDetails.put("isDecimal", obj.getIsDecimal()); + + compDetails.put("iotComponentName", obj.getIOTComponentName()); + compDetails.put("componentCode", obj.getComponentCode()); + compDetails.put("iotProcedureID", obj.getIOTProcedureID()); + compDetails.put("componentUnit", obj.getComponentUnit()); + + compOption = new HashMap<>(); + compOptionList = new ArrayList<>(); + + compOption.put("name", obj.getResultValue()); + compOptionList.add(compOption); + + compDetails.put("compOpt", compOptionList); + + compList.add(compDetails); + procDetails.put("compListDetails", compList); + + } else { + compDetails = new HashMap<>(); + compDetails.put("testComponentID", obj.getTestComponentID()); + compDetails.put("testComponentName", obj.getTestComponentName()); + compDetails.put("testComponentDesc", obj.getTestComponentDesc()); + compDetails.put("inputType", obj.getInputType()); + compDetails.put("isDecimal", obj.getIsDecimal()); + compDetails.put("measurementUnit", obj.getMeasurementUnit()); + compDetails.put("range_min", obj.getRange_min()); + compDetails.put("range_normal_min", obj.getRange_normal_min()); + compDetails.put("range_normal_max", obj.getRange_normal_max()); + compDetails.put("range_max", obj.getRange_max()); + + compDetails.put("iotComponentName", obj.getIOTComponentName()); + compDetails.put("componentCode", obj.getComponentCode()); + compDetails.put("iotProcedureID", obj.getIOTProcedureID()); + compDetails.put("componentUnit", obj.getComponentUnit()); + + compOption = new HashMap<>(); + compOptionList = new ArrayList<>(); + + compOption.put("name", obj.getResultValue()); + compOptionList.add(compOption); + + compDetails.put("compOpt", compOptionList); + + compList.add(compDetails); + + } + + returnOBJ.add(procDetails); + + } else { + + if (compDetails == null || (compDetails.containsKey("testComponentID") + && !obj.getTestComponentID().equals(compDetails.get("testComponentID")))) { + + compDetails = new HashMap<>(); + compDetails.put("testComponentID", obj.getTestComponentID()); + compDetails.put("testComponentName", obj.getTestComponentName()); + compDetails.put("testComponentDesc", obj.getTestComponentDesc()); + compDetails.put("inputType", obj.getInputType()); + compDetails.put("isDecimal", obj.getIsDecimal()); + compDetails.put("measurementUnit", obj.getMeasurementUnit()); + compDetails.put("range_min", obj.getRange_min()); + compDetails.put("range_normal_min", obj.getRange_normal_min()); + compDetails.put("range_normal_max", obj.getRange_normal_max()); + compDetails.put("range_max", obj.getRange_max()); + + compDetails.put("iotComponentName", obj.getIOTComponentName()); + compDetails.put("componentCode", obj.getComponentCode()); + compDetails.put("iotProcedureID", obj.getIOTProcedureID()); + compDetails.put("componentUnit", obj.getComponentUnit()); + + compOption = new HashMap<>(); + compOptionList = new ArrayList<>(); + + compOption.put("name", obj.getResultValue()); + compOptionList.add(compOption); + + compDetails.put("compOpt", compOptionList); + + compList.add(compDetails); + } else { + compOption = new HashMap<>(); + compOption.put("name", obj.getResultValue()); + compOptionList.add(compOption); + } + + } + } + } + + return returnOBJ; + } + + public ArrayList getLabResultDataForBen(Long benRegID, Long visitCode) throws Exception { + ArrayList procedureResults = new ArrayList<>(); + procedureResults = labResultEntryRepo.findByBeneficiaryRegIDAndVisitCodeOrderByProcedureIDAsc(benRegID, + visitCode); + procedureResults = LabResultEntry.getLabResultEntry(procedureResults); + return procedureResults; + } - private ArrayList getPrescribedLabTestInJsonFormatRadiology( - ArrayList orderedLabTestList) { - ArrayList returnOBJ = new ArrayList<>(); - Map procedureCompDetails; + private ArrayList getPrescribedLabTestInJsonFormatRadiology( + ArrayList orderedLabTestList) { + ArrayList returnOBJ = new ArrayList<>(); + Map procedureCompDetails; - Map compDetails; + Map compDetails; - if (orderedLabTestList != null && orderedLabTestList.size() > 0) { - for (V_benLabTestOrderedDetails obj : orderedLabTestList) { - procedureCompDetails = new HashMap<>(); - compDetails = new HashMap<>(); + if (orderedLabTestList != null && orderedLabTestList.size() > 0) { + for (V_benLabTestOrderedDetails obj : orderedLabTestList) { + procedureCompDetails = new HashMap<>(); + compDetails = new HashMap<>(); - procedureCompDetails.put("procedureID", obj.getProcedureID()); - procedureCompDetails.put("procedureName", obj.getProcedureName()); - procedureCompDetails.put("procedureDesc", obj.getProcedureDesc()); - procedureCompDetails.put("procedureType", "Radiology"); - procedureCompDetails.put("prescriptionID", obj.getPrescriptionID()); + procedureCompDetails.put("procedureID", obj.getProcedureID()); + procedureCompDetails.put("procedureName", obj.getProcedureName()); + procedureCompDetails.put("procedureDesc", obj.getProcedureDesc()); + procedureCompDetails.put("procedureType", "Radiology"); + procedureCompDetails.put("prescriptionID", obj.getPrescriptionID()); + + compDetails.put("testComponentID", obj.getTestComponentID()); + compDetails.put("testComponentName", obj.getTestComponentName()); + compDetails.put("testComponentDesc", obj.getTestComponentDesc()); + compDetails.put("inputType", "File"); - compDetails.put("testComponentID", obj.getTestComponentID()); - compDetails.put("testComponentName", obj.getTestComponentName()); - compDetails.put("testComponentDesc", obj.getTestComponentDesc()); - compDetails.put("inputType", "File"); + procedureCompDetails.put("compDetails", compDetails); - procedureCompDetails.put("compDetails", compDetails); + returnOBJ.add(procedureCompDetails); - returnOBJ.add(procedureCompDetails); + } + } - } - } + return returnOBJ; + } - return returnOBJ; - } - - /* + /* * @Transactional(rollbackFor = Exception.class) public Integer * saveLabTestResult(JsonObject requestOBJ) throws Exception { * @@ -330,193 +331,201 @@ private ArrayList getPrescribedLabTestInJsonFormatRadiology( * labResultsListNew.size() == labResultEntryRes.size()){ labResultSaveFlag = 1; * } }else{ labResultSaveFlag = 1; } }else{ labResultSaveFlag = 1; } return * labResultSaveFlag; } - */ - - @Transactional(rollbackFor = Exception.class) - public Integer saveLabTestResult(JsonObject requestOBJ) throws Exception { - - Integer labResultSaveFlag = null; - if (requestOBJ != null && requestOBJ.has("labTestResults") && null != requestOBJ.get("labTestResults") - && !requestOBJ.get("labTestResults").isJsonNull()) { - - WrapperLabResultEntry wrapperLabResults = InputMapper.gson().fromJson(requestOBJ, - WrapperLabResultEntry.class); - - labResultSaveFlag = saveLabTestResult(wrapperLabResults); - - if (labResultSaveFlag == 1) { - int i = updateBenFlowStatusFlagAfterLabResultEntry(wrapperLabResults.getLabCompleted(), - wrapperLabResults.getBenFlowID(), wrapperLabResults.getBeneficiaryRegID(), - wrapperLabResults.getVisitID(), wrapperLabResults.getNurseFlag(), - wrapperLabResults.getDoctorFlag(), wrapperLabResults.getSpecialist_flag()); - } - - } else { - labResultSaveFlag = 1; - } - - return labResultSaveFlag; - } - - private int updateBenFlowStatusFlagAfterLabResultEntry(Boolean isLabDone, Long benFlowID, Long benRegID, - Long benVisitID, Short nurseFlag, Short doctorFlag, Short specialistFlag) { - int returnOBJ = 0; - short labFlag = (short) 0; - - if (specialistFlag != null && specialistFlag == 2) { - if (isLabDone == true) { - specialistFlag = (short) 3; - } else { - labFlag = (short) 1; - } - - returnOBJ = commonBenStatusFlowServiceImpl.updateFlowAfterLabResultEntryForTCSpecialist(benFlowID, benRegID, - specialistFlag); - } else { - if (isLabDone == true) { - if (nurseFlag == 2) { - nurseFlag = 3; - doctorFlag = 1; - } else { - if (doctorFlag == 2) { - doctorFlag = 3; - } + */ + @Transactional(rollbackFor = Exception.class) + public Integer saveLabTestResult(JsonObject requestOBJ) throws Exception { + + Integer labResultSaveFlag = null; + if (requestOBJ != null && requestOBJ.has("labTestResults") && null != requestOBJ.get("labTestResults") + && !requestOBJ.get("labTestResults").isJsonNull()) { + + WrapperLabResultEntry wrapperLabResults = InputMapper.gson().fromJson(requestOBJ, + WrapperLabResultEntry.class); + + labResultSaveFlag = saveLabTestResult(wrapperLabResults); + + if (labResultSaveFlag == 1) { + int i = updateBenFlowStatusFlagAfterLabResultEntry(wrapperLabResults.getLabCompleted(), + wrapperLabResults.getBenFlowID(), wrapperLabResults.getBeneficiaryRegID(), + wrapperLabResults.getVisitID(), wrapperLabResults.getNurseFlag(), + wrapperLabResults.getDoctorFlag(), wrapperLabResults.getSpecialist_flag()); + } + + } else { + labResultSaveFlag = 1; + } + + return labResultSaveFlag; + } + + private int updateBenFlowStatusFlagAfterLabResultEntry(Boolean isLabDone, Long benFlowID, Long benRegID, + Long benVisitID, Short nurseFlag, Short doctorFlag, Short specialistFlag) { + int returnOBJ = 0; + short labFlag = (short) 0; + + if (specialistFlag != null && specialistFlag == 2) { + if (isLabDone == true) { + specialistFlag = (short) 3; + } else { + labFlag = (short) 1; + } + + returnOBJ = commonBenStatusFlowServiceImpl.updateFlowAfterLabResultEntryForTCSpecialist(benFlowID, benRegID, + specialistFlag); + } else { + if (isLabDone == true) { + if (nurseFlag == 2) { + nurseFlag = 3; + doctorFlag = 1; + } else { + if (doctorFlag == 2) { + doctorFlag = 3; + } + } + + labFlag = (short) 1; + } else { + labFlag = (short) 1; + } + returnOBJ = commonBenStatusFlowServiceImpl.updateFlowAfterLabResultEntry(benFlowID, benRegID, benVisitID, + nurseFlag, doctorFlag, labFlag); + } + + return returnOBJ; + } + + public Integer saveLabTestResult(WrapperLabResultEntry wrapperLabResults) { + Integer labResultSaveFlag = null; + Integer radiologyResultSaveFlag = null; + + List labResultsList = wrapperLabResults.getLabTestResults(); + + if ((null != labResultsList && labResultsList.size() > 0) + || (null != wrapperLabResults.getRadiologyTestResults() + && wrapperLabResults.getRadiologyTestResults().size() > 0)) { + List labResultsListNew = new ArrayList(); + for (LabResultEntry labResult : labResultsList) { + List> compResult = labResult.getCompList(); + if (null != compResult && compResult.size() > 0) { + for (Map comp : compResult) { + LabResultEntry labCompResult = new LabResultEntry(); + labCompResult.setPrescriptionID(labResult.getPrescriptionID()); + labCompResult.setProcedureID(labResult.getProcedureID()); + labCompResult.setStripsNotAvailable(labResult.getStripsNotAvailable()); + + if (null != comp.get("testComponentID") + && !String.valueOf(comp.get("testComponentID")).isEmpty() + && ((null != comp.get("testResultValue") + && !comp.get("testResultValue").toString().isEmpty()) + || (null != comp.get("stripsNotAvailable") && comp.get("stripsNotAvailable") + .toString().equalsIgnoreCase("true")))) { + labCompResult.setTestComponentID( + (int) Double.parseDouble(comp.get("testComponentID").toString())); + + if (comp.containsKey("testResultValue") && comp.get("testResultValue") != null + && !String.valueOf(comp.get("testResultValue")).isEmpty()) { + labCompResult.setTestResultValue(comp.get("testResultValue").toString()); + } + + if (comp.containsKey("testResultUnit") && comp.get("testResultUnit") != null + && !String.valueOf(comp.get("testResultUnit")).isEmpty()) { + labCompResult.setTestResultUnit(String.valueOf(comp.get("testResultUnit"))); + } + + if (comp.containsKey("remarks") && comp.get("remarks") != null + && !String.valueOf(comp.get("remarks")).isEmpty()) { + labCompResult.setRemarks(String.valueOf(comp.get("remarks"))); + } + + if (comp.containsKey("stripsNotAvailable") && comp.get("stripsNotAvailable") != null + && comp.get("stripsNotAvailable").toString().equalsIgnoreCase("true")) { + labCompResult.setStripsNotAvailable( + Boolean.valueOf(String.valueOf(comp.get("stripsNotAvailable")))); + } + + if (comp.containsKey("ecgAbnormalities") && comp.get("ecgAbnormalities") != null) { + List ecgAbnormalitiesList = (List) comp.get("ecgAbnormalities"); + // String[] ecgAbnormalities = (String[]) comp.get("ecgAbnormalities"); + + if (ecgAbnormalitiesList != null && ecgAbnormalitiesList.size() > 0) { + StringBuilder sb = new StringBuilder(); + for (String abnormility : ecgAbnormalitiesList) { + sb.append(abnormility).append("||"); + + } + if (sb.length() > 2) { + labCompResult.setEcgAbnormalitiesDB(sb.substring(0, sb.length() - 2)); + } + + } + } + + labCompResult.setBeneficiaryRegID(wrapperLabResults.getBeneficiaryRegID()); + labCompResult.setBenVisitID(wrapperLabResults.getVisitID()); + labCompResult.setVisitCode(wrapperLabResults.getVisitCode()); + labCompResult.setProviderServiceMapID(wrapperLabResults.getProviderServiceMapID()); + labCompResult.setCreatedBy(wrapperLabResults.getCreatedBy()); + + labCompResult.setVanID(wrapperLabResults.getVanID()); + labCompResult.setParkingPlaceID(wrapperLabResults.getParkingPlaceID()); + + labResultsListNew.add(labCompResult); + } + + } + } + } + for (LabResultEntry labResultEntry : wrapperLabResults.getRadiologyTestResults()) { + labResultEntry.setBeneficiaryRegID(wrapperLabResults.getBeneficiaryRegID()); + labResultEntry.setBenVisitID(wrapperLabResults.getVisitID()); + labResultEntry.setVisitCode(wrapperLabResults.getVisitCode()); + labResultEntry.setProviderServiceMapID(wrapperLabResults.getProviderServiceMapID()); + labResultEntry.setCreatedBy(wrapperLabResults.getCreatedBy()); + + labResultEntry.setVanID(wrapperLabResults.getVanID()); + labResultEntry.setParkingPlaceID(wrapperLabResults.getParkingPlaceID()); + + // add file/doc id + String[] docIdArr = labResultEntry.getFileIDs(); + StringBuilder sb = new StringBuilder(); + if (docIdArr != null && docIdArr.length > 0) { + for (String i : docIdArr) { + sb.append(i + ","); + } + } + labResultEntry.setTestReportFilePath(sb.toString()); + + labResultsListNew.add(labResultEntry); + + } + if (null != labResultsListNew && labResultsListNew.size() > 0) { + List labResultEntryRes = (List) labResultEntryRepo.saveAll(labResultsListNew); + + if (labResultEntryRes != null && labResultsListNew.size() == labResultEntryRes.size()) { + for (LabResultEntry result : labResultEntryRes) { + if (result.getID() != null) { + labResultEntryRepo.updateVanSerialNo(result.getID()); + } + } + labResultSaveFlag = 1; + } + } else { + labResultSaveFlag = 1; + } } + return labResultSaveFlag; + } - labFlag = (short) 1; - } else { - labFlag = (short) 1; - } - returnOBJ = commonBenStatusFlowServiceImpl.updateFlowAfterLabResultEntry(benFlowID, benRegID, benVisitID, - nurseFlag, doctorFlag, labFlag); - } - - return returnOBJ; - } - - public Integer saveLabTestResult(WrapperLabResultEntry wrapperLabResults) { - Integer labResultSaveFlag = null; - Integer radiologyResultSaveFlag = null; - - List labResultsList = wrapperLabResults.getLabTestResults(); - - if ((null != labResultsList && labResultsList.size() > 0) - || (null != wrapperLabResults.getRadiologyTestResults() - && wrapperLabResults.getRadiologyTestResults().size() > 0)) { - List labResultsListNew = new ArrayList(); - for (LabResultEntry labResult : labResultsList) { - List> compResult = labResult.getCompList(); - if (null != compResult && compResult.size() > 0) { - for (Map comp : compResult) { - LabResultEntry labCompResult = new LabResultEntry(); - labCompResult.setPrescriptionID(labResult.getPrescriptionID()); - labCompResult.setProcedureID(labResult.getProcedureID()); - labCompResult.setStripsNotAvailable(labResult.getStripsNotAvailable()); - - if (null != comp.get("testComponentID") - && !String.valueOf(comp.get("testComponentID")).isEmpty() - && ((null != comp.get("testResultValue") - && !comp.get("testResultValue").toString().isEmpty()) - || (null != comp.get("stripsNotAvailable") && comp.get("stripsNotAvailable") - .toString().equalsIgnoreCase("true")))) { - labCompResult.setTestComponentID( - (int) Double.parseDouble(comp.get("testComponentID").toString())); - - if (comp.containsKey("testResultValue") && comp.get("testResultValue") != null - && !String.valueOf(comp.get("testResultValue")).isEmpty()) - labCompResult.setTestResultValue(comp.get("testResultValue").toString()); - - if (comp.containsKey("testResultUnit") && comp.get("testResultUnit") != null - && !String.valueOf(comp.get("testResultUnit")).isEmpty()) - labCompResult.setTestResultUnit(String.valueOf(comp.get("testResultUnit"))); - - if (comp.containsKey("remarks") && comp.get("remarks") != null - && !String.valueOf(comp.get("remarks")).isEmpty()) - labCompResult.setRemarks(String.valueOf(comp.get("remarks"))); - - if (comp.containsKey("stripsNotAvailable") && comp.get("stripsNotAvailable") != null - && comp.get("stripsNotAvailable").toString().equalsIgnoreCase("true")) - labCompResult.setStripsNotAvailable( - Boolean.valueOf(String.valueOf(comp.get("stripsNotAvailable")))); - - if (comp.containsKey("ecgAbnormalities") && comp.get("ecgAbnormalities") != null) { - List ecgAbnormalitiesList = (List) comp.get("ecgAbnormalities"); - // String[] ecgAbnormalities = (String[]) comp.get("ecgAbnormalities"); - - if (ecgAbnormalitiesList != null && ecgAbnormalitiesList.size() > 0) { - StringBuilder sb = new StringBuilder(); - for (String abnormility : ecgAbnormalitiesList) { - sb.append(abnormility).append("||"); - - } - if (sb.length() > 2) - labCompResult.setEcgAbnormalitiesDB(sb.substring(0, sb.length() - 2)); - - } - } - - labCompResult.setBeneficiaryRegID(wrapperLabResults.getBeneficiaryRegID()); - labCompResult.setBenVisitID(wrapperLabResults.getVisitID()); - labCompResult.setVisitCode(wrapperLabResults.getVisitCode()); - labCompResult.setProviderServiceMapID(wrapperLabResults.getProviderServiceMapID()); - labCompResult.setCreatedBy(wrapperLabResults.getCreatedBy()); - - labCompResult.setVanID(wrapperLabResults.getVanID()); - labCompResult.setParkingPlaceID(wrapperLabResults.getParkingPlaceID()); - - labResultsListNew.add(labCompResult); - } - - } - } - } - for (LabResultEntry labResultEntry : wrapperLabResults.getRadiologyTestResults()) { - labResultEntry.setBeneficiaryRegID(wrapperLabResults.getBeneficiaryRegID()); - labResultEntry.setBenVisitID(wrapperLabResults.getVisitID()); - labResultEntry.setVisitCode(wrapperLabResults.getVisitCode()); - labResultEntry.setProviderServiceMapID(wrapperLabResults.getProviderServiceMapID()); - labResultEntry.setCreatedBy(wrapperLabResults.getCreatedBy()); - - labResultEntry.setVanID(wrapperLabResults.getVanID()); - labResultEntry.setParkingPlaceID(wrapperLabResults.getParkingPlaceID()); - - // add file/doc id - String[] docIdArr = labResultEntry.getFileIDs(); - StringBuilder sb = new StringBuilder(); - if (docIdArr != null && docIdArr.length > 0) { - for (String i : docIdArr) { - sb.append(i + ","); - } - } - labResultEntry.setTestReportFilePath(sb.toString()); + - labResultsListNew.add(labResultEntry); + public String getLast_3_ArchivedTestVisitList(Long benRegID, Long visitCode) { + ArrayList visitCodeList = labResultEntryRepo.getLast_3_visitForLabTestDone(benRegID, visitCode); - } - if (null != labResultsListNew && labResultsListNew.size() > 0) { - List labResultEntryRes = (List) labResultEntryRepo - .saveAll(labResultsListNew); - if (null != labResultEntryRes && labResultsListNew.size() == labResultEntryRes.size()) { - labResultSaveFlag = 1; - } - } else { - labResultSaveFlag = 1; - } - } else { - labResultSaveFlag = 1; - } - - return labResultSaveFlag; - } - - public String getLast_3_ArchivedTestVisitList(Long benRegID, Long visitCode) { - ArrayList visitCodeList = labResultEntryRepo.getLast_3_visitForLabTestDone(benRegID, visitCode); - - return new Gson().toJson(LabResultEntry.getVisitCodeAndDate(visitCodeList)); - } - - public String getLabResultForVisitcode(Long benRegID, Long visitCode) throws Exception { - ArrayList labResultList = getLabResultDataForBen(benRegID, visitCode); - return new Gson().toJson(labResultList); - } + return new Gson().toJson(LabResultEntry.getVisitCodeAndDate(visitCodeList)); + } + + public String getLabResultForVisitcode(Long benRegID, Long visitCode) throws Exception { + ArrayList labResultList = getLabResultDataForBen(benRegID, visitCode); + return new Gson().toJson(labResultList); + } }