diff --git a/pom.xml b/pom.xml index fdfa796..d3f831b 100644 --- a/pom.xml +++ b/pom.xml @@ -240,23 +240,7 @@ identity-0.0.1 - - org.owasp - dependency-check-maven - 9.0.8 - - HTML - nvd - 79597933-f3cc-4601-949b-12513434ade3 - - - - - check - - - - + org.codehaus.mojo versions-maven-plugin diff --git a/src/main/java/com/iemr/common/identity/controller/IdentityController.java b/src/main/java/com/iemr/common/identity/controller/IdentityController.java index 2ffff0a..c206ae7 100644 --- a/src/main/java/com/iemr/common/identity/controller/IdentityController.java +++ b/src/main/java/com/iemr/common/identity/controller/IdentityController.java @@ -483,13 +483,13 @@ public String editIdentity(@Param(value = "{\r\n" + " \"eventTypeName\": \"Stri + " \"vanID\": \"Integer\",\r\n" + " \"parkingPlaceId\": \"Integer\"\r\n" + "}") @RequestBody String identityEditData) { logger.info("IdentityController.editIdentity - start"); - JsonElement json = JsonParser.parseString(identityEditData); + // JsonElement json = JsonParser.parseString(identityEditData); - if (json instanceof JsonNull || json instanceof JsonPrimitive) { - return getErrorResponseString("Null/Empty Identity Edit Data.", 200, "success", ""); - } +// if (json instanceof JsonNull || json instanceof JsonPrimitive) { +// return getErrorResponseString("Null/Empty Identity Edit Data.", 200, "success", ""); +// } - IdentityEditDTO identity = InputMapper.getInstance().gson().fromJson(json, IdentityEditDTO.class); + IdentityEditDTO identity = InputMapper.getInstance().gson().fromJson(identityEditData, IdentityEditDTO.class); try { svc.editIdentity(identity); String response = getSuccessResponseString("Updated successfully", 200, "success", "editIdentityByAgent"); @@ -603,12 +603,12 @@ public String createIdentity(@Param(value = "{\r\n" + " \"eventTypeName\": \"St + " \"sexualOrientationType\": \"String\",\r\n" + " \"vanID\": \"Integer\",\r\n" + " \"createdDate\": \"Timestamp\"\r\n" + "}") @RequestBody String identityData) throws IEMRException { logger.info("IdentityController.createIdentity - start"); - JsonElement json = JsonParser.parseString(identityData); + // JsonElement json = JsonParser.parseString(identityData); - if (json instanceof JsonNull || json instanceof JsonPrimitive) { - return getErrorResponseString("Null/Empty Identity Create Data.", 200, "success", ""); - } - IdentityDTO identity = new Gson().fromJson(json, IdentityDTO.class); +// if (json instanceof JsonNull || json instanceof JsonPrimitive) { +// return getErrorResponseString("Null/Empty Identity Create Data.", 200, "success", ""); +// } + IdentityDTO identity = new Gson().fromJson(identityData, IdentityDTO.class); logger.info("identity hit: " + identity); BeneficiaryCreateResp map; map = svc.createIdentity(identity); diff --git a/src/main/java/com/iemr/common/identity/domain/MBeneficiarydetail.java b/src/main/java/com/iemr/common/identity/domain/MBeneficiarydetail.java index 7edf885..f5d2690 100644 --- a/src/main/java/com/iemr/common/identity/domain/MBeneficiarydetail.java +++ b/src/main/java/com/iemr/common/identity/domain/MBeneficiarydetail.java @@ -27,6 +27,8 @@ import java.util.Calendar; import java.util.Date; +import org.json.JSONObject; + import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; @@ -37,6 +39,8 @@ import jakarta.persistence.Table; import jakarta.persistence.Transient; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import com.google.gson.annotations.Expose; import lombok.AllArgsConstructor; @@ -236,6 +240,12 @@ public class MBeneficiarydetail implements Serializable { @Column(name = "MonthlyFamilyIncome") private String monthlyFamilyIncome; + + @Column(name = "ExtraFields") + private String otherFields; + +// @Column(columnDefinition = "json") +// private JsonElement otherFields; public MBeneficiarydetail() { diff --git a/src/main/java/com/iemr/common/identity/dto/BenDetailDTO.java b/src/main/java/com/iemr/common/identity/dto/BenDetailDTO.java index e23e09c..13465f8 100644 --- a/src/main/java/com/iemr/common/identity/dto/BenDetailDTO.java +++ b/src/main/java/com/iemr/common/identity/dto/BenDetailDTO.java @@ -95,4 +95,5 @@ public class BenDetailDTO implements Serializable { private String familyId; private String other; private String headOfFamily_Relation; + private String otherFields; } \ No newline at end of file diff --git a/src/main/java/com/iemr/common/identity/dto/BeneficiariesDTO.java b/src/main/java/com/iemr/common/identity/dto/BeneficiariesDTO.java index 46df1fb..6aaf21b 100644 --- a/src/main/java/com/iemr/common/identity/dto/BeneficiariesDTO.java +++ b/src/main/java/com/iemr/common/identity/dto/BeneficiariesDTO.java @@ -21,10 +21,18 @@ */ package com.iemr.common.identity.dto; + + import java.math.BigInteger; import java.sql.Timestamp; +import java.util.HashMap; import java.util.List; +import java.util.Map; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import com.iemr.common.identity.domain.Address; import com.iemr.common.identity.domain.Phone; @@ -87,4 +95,7 @@ public int compareTo(BeneficiariesDTO ben) { private String sourceOfInformation; private String isHIVPos; // End 1097 + + private String otherFields; + } diff --git a/src/main/java/com/iemr/common/identity/dto/IdentityDTO.java b/src/main/java/com/iemr/common/identity/dto/IdentityDTO.java index 4201146..03f1aca 100644 --- a/src/main/java/com/iemr/common/identity/dto/IdentityDTO.java +++ b/src/main/java/com/iemr/common/identity/dto/IdentityDTO.java @@ -24,6 +24,10 @@ import java.sql.Timestamp; import java.util.List; +import org.json.JSONObject; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import com.google.gson.annotations.Expose; import com.iemr.common.identity.domain.Address; import com.iemr.common.identity.domain.Contact; @@ -124,9 +128,11 @@ public class IdentityDTO { @Expose private Integer vanID; + private String otherFields; @Expose private Boolean beneficiaryConsent; +// private Object otherFields; } diff --git a/src/main/java/com/iemr/common/identity/dto/IdentityEditDTO.java b/src/main/java/com/iemr/common/identity/dto/IdentityEditDTO.java index 6b87d8b..136f0d0 100644 --- a/src/main/java/com/iemr/common/identity/dto/IdentityEditDTO.java +++ b/src/main/java/com/iemr/common/identity/dto/IdentityEditDTO.java @@ -146,4 +146,5 @@ public class IdentityEditDTO { private Integer vanID; private Integer parkingPlaceId; private boolean emergencyRegistration; +// private Object otherFields; } diff --git a/src/main/java/com/iemr/common/identity/mapper/IdentityEditMapper.java b/src/main/java/com/iemr/common/identity/mapper/IdentityEditMapper.java index 6ae72fe..64dd299 100644 --- a/src/main/java/com/iemr/common/identity/mapper/IdentityEditMapper.java +++ b/src/main/java/com/iemr/common/identity/mapper/IdentityEditMapper.java @@ -176,53 +176,53 @@ MBeneficiaryconsent identityEditDTOToDefaultMBeneficiaryconsent(IdentityEditDTO MBeneficiarycontact identityEdiDTOToMBeneficiarycontact(IdentityEditDTO dto); - @Mapping(source = "dto.areaId", target = "areaId") - @Mapping(source = "dto.beneficiaryRegId", target = "beneficiaryRegID") - @Mapping(source = "dto.community", target = "community") - @Mapping(source = "dto.communityId", target = "communityId") - @Mapping(source = "dto.dob", target = "dob") - @Mapping(source = "dto.education", target = "education") - @Mapping(source = "dto.educationId", target = "educationId") - - @Mapping(source = "dto.healthCareWorkerId", target = "healthCareWorkerId") - @Mapping(source = "dto.healthCareWorker", target = "healthCareWorker") - @Mapping(source = "dto.fatherName", target = "fatherName") - @Mapping(source = "dto.motherName", target = "motherName") - @Mapping(source = "dto.firstName", target = "firstName") - @Mapping(source = "dto.gender", target = "gender") - @Mapping(source = "dto.genderId", target = "genderId") - @Mapping(source = "dto.incomeStatusId", target = "incomeStatusId") - @Mapping(source = "dto.incomeStatus", target = "incomeStatus") - @Mapping(source = "dto.monthlyFamilyIncome", target = "monthlyFamilyIncome") - @Mapping(source = "dto.lastName", target = "lastName") - @Mapping(source = "dto.maritalStatusId", target = "maritalStatusId") - @Mapping(source = "dto.maritalStatus", target = "maritalStatus") - @Mapping(source = "dto.middleName", target = "middleName") - @Mapping(source = "dto.occupation", target = "occupation") - @Mapping(source = "dto.occupationId", target = "occupationId") - @Mapping(source = "dto.phcId", target = "phcId") - @Mapping(source = "dto.placeOfWork", target = "placeOfWork") - @Mapping(source = "dto.preferredLanguage", target = "preferredLanguage") - @Mapping(source = "dto.religion", target = "religion") - @Mapping(source = "dto.religionId", target = "religionId") - @Mapping(source = "dto.remarks", target = "remarks") - @Mapping(source = "dto.servicePointId", target = "servicePointId") - @Mapping(source = "dto.sourceOfInfo", target = "sourceOfInfo") - @Mapping(source = "dto.spouseName", target = "spouseName") - @Mapping(source = "dto.status", target = "status") - @Mapping(source = "dto.title", target = "title") - @Mapping(source = "dto.titleId", target = "titleId") - @Mapping(source = "dto.zoneId", target = "zoneId") - @Mapping(source = "dto.agentName", target = "createdBy") - @Mapping(source = "dto.eventTypeDate", target = "createdDate") - @Mapping(target = "isHIVPositive", expression = "java(MBeneficiarydetail.setIsHIVPositive(dto.getIsHIVPositive()))") - // Start MMU specific code - @Mapping(target = "ageAtMarriage", expression = "java(MBeneficiarydetail.getAgeAtMarriageCalc(dto.getDob(), dto.getMarriageDate(), " - + "dto.getAgeAtMarriage()))") - @Mapping(target = "marriageDate", expression = "java(MBeneficiarydetail.getMarriageDateCalc(dto.getDob(), dto.getMarriageDate(), " - + "dto.getAgeAtMarriage()))") - - MBeneficiarydetail identityEditDTOToMBeneficiarydetail(IdentityEditDTO dto); +// @Mapping(source = "dto.areaId", target = "areaId") +// @Mapping(source = "dto.beneficiaryRegId", target = "beneficiaryRegID") +// @Mapping(source = "dto.community", target = "community") +// @Mapping(source = "dto.communityId", target = "communityId") +// @Mapping(source = "dto.dob", target = "dob") +// @Mapping(source = "dto.education", target = "education") +// @Mapping(source = "dto.educationId", target = "educationId") +// +// @Mapping(source = "dto.healthCareWorkerId", target = "healthCareWorkerId") +// @Mapping(source = "dto.healthCareWorker", target = "healthCareWorker") +// @Mapping(source = "dto.fatherName", target = "fatherName") +// @Mapping(source = "dto.motherName", target = "motherName") +// @Mapping(source = "dto.firstName", target = "firstName") +// @Mapping(source = "dto.gender", target = "gender") +// @Mapping(source = "dto.genderId", target = "genderId") +// @Mapping(source = "dto.incomeStatusId", target = "incomeStatusId") +// @Mapping(source = "dto.incomeStatus", target = "incomeStatus") +// @Mapping(source = "dto.monthlyFamilyIncome", target = "monthlyFamilyIncome") +// @Mapping(source = "dto.lastName", target = "lastName") +// @Mapping(source = "dto.maritalStatusId", target = "maritalStatusId") +// @Mapping(source = "dto.maritalStatus", target = "maritalStatus") +// @Mapping(source = "dto.middleName", target = "middleName") +// @Mapping(source = "dto.occupation", target = "occupation") +// @Mapping(source = "dto.occupationId", target = "occupationId") +// @Mapping(source = "dto.phcId", target = "phcId") +// @Mapping(source = "dto.placeOfWork", target = "placeOfWork") +// @Mapping(source = "dto.preferredLanguage", target = "preferredLanguage") +// @Mapping(source = "dto.religion", target = "religion") +// @Mapping(source = "dto.religionId", target = "religionId") +// @Mapping(source = "dto.remarks", target = "remarks") +// @Mapping(source = "dto.servicePointId", target = "servicePointId") +// @Mapping(source = "dto.sourceOfInfo", target = "sourceOfInfo") +// @Mapping(source = "dto.spouseName", target = "spouseName") +// @Mapping(source = "dto.status", target = "status") +// @Mapping(source = "dto.title", target = "title") +// @Mapping(source = "dto.titleId", target = "titleId") +// @Mapping(source = "dto.zoneId", target = "zoneId") +// @Mapping(source = "dto.agentName", target = "createdBy") +// @Mapping(source = "dto.eventTypeDate", target = "createdDate") +// @Mapping(target = "isHIVPositive", expression = "java(MBeneficiarydetail.setIsHIVPositive(dto.getIsHIVPositive()))") +// // Start MMU specific code +// @Mapping(target = "ageAtMarriage", expression = "java(MBeneficiarydetail.getAgeAtMarriageCalc(dto.getDob(), dto.getMarriageDate(), " +// + "dto.getAgeAtMarriage()))") +// @Mapping(target = "marriageDate", expression = "java(MBeneficiarydetail.getMarriageDateCalc(dto.getDob(), dto.getMarriageDate(), " +// + "dto.getAgeAtMarriage()))") +// +// MBeneficiarydetail identityEditDTOToMBeneficiarydetail(IdentityEditDTO dto); @Mapping(source = "benFamilyDTO.isEmergencyContact", target = "isEmergencyContact") @Mapping(source = "benFamilyDTO.relationshipToSelf", target = "relationshipToSelf") diff --git a/src/main/java/com/iemr/common/identity/mapper/IdentityMapper.java b/src/main/java/com/iemr/common/identity/mapper/IdentityMapper.java index 8232426..53acf10 100644 --- a/src/main/java/com/iemr/common/identity/mapper/IdentityMapper.java +++ b/src/main/java/com/iemr/common/identity/mapper/IdentityMapper.java @@ -92,56 +92,56 @@ public interface IdentityMapper { - @Mapping(source = "dto.areaId", target = "areaId") - @Mapping(source = "dto.beneficiaryRegId", target = "beneficiaryRegID") - @Mapping(source = "dto.community", target = "community") - @Mapping(source = "dto.communityId", target = "communityId") - @Mapping(source = "dto.dob", target = "dob") - @Mapping(source = "dto.education", target = "education") - @Mapping(source = "dto.educationId", target = "educationId") - @Mapping(source = "dto.emergencyRegistration", target = "emergencyRegistration") - @Mapping(source = "dto.healthCareWorkerId", target = "healthCareWorkerId") - @Mapping(source = "dto.healthCareWorker", target = "healthCareWorker") - @Mapping(source = "dto.fatherName", target = "fatherName") - @Mapping(source = "dto.motherName", target = "motherName") - @Mapping(source = "dto.firstName", target = "firstName") - @Mapping(source = "dto.gender", target = "gender") - @Mapping(source = "dto.genderId", target = "genderId") - @Mapping(source = "dto.incomeStatus", target = "incomeStatus") - @Mapping(source = "dto.monthlyFamilyIncome", target = "monthlyFamilyIncome") - @Mapping(source = "dto.incomeStatusId", target = "incomeStatusId") - @Mapping(source = "dto.lastName", target = "lastName") - @Mapping(source = "dto.maritalStatusId", target = "maritalStatusId") - @Mapping(source = "dto.maritalStatus", target = "maritalStatus") - @Mapping(source = "dto.middleName", target = "middleName") - @Mapping(source = "dto.occupation", target = "occupation") - @Mapping(source = "dto.occupationId", target = "occupationId") - @Mapping(source = "dto.phcId", target = "phcId") - @Mapping(source = "dto.placeOfWork", target = "placeOfWork") - @Mapping(source = "dto.preferredLanguage", target = "preferredLanguage") - @Mapping(source = "dto.religion", target = "religion") - @Mapping(source = "dto.religionId", target = "religionId") - @Mapping(source = "dto.remarks", target = "remarks") - @Mapping(source = "dto.servicePointId", target = "servicePointId") - @Mapping(source = "dto.sourceOfInfo", target = "sourceOfInfo") - @Mapping(source = "dto.spouseName", target = "spouseName") - @Mapping(source = "dto.status", target = "status") - @Mapping(source = "dto.title", target = "title") - @Mapping(source = "dto.titleId", target = "titleId") - @Mapping(source = "dto.zoneId", target = "zoneId") - @Mapping(source = "dto.agentName", target = "createdBy") - @Mapping(source = "dto.createdDate", target = "createdDate") - @Mapping(target = "isHIVPositive", expression = "java(MBeneficiarydetail.setIsHIVPositive(dto.getIsHIVPositive()))") - - @Mapping(target = "ageAtMarriage", expression = "java(MBeneficiarydetail.getAgeAtMarriageCalc(dto.getDob(), dto.getMarriageDate(), " - + "dto.getAgeAtMarriage()))") - @Mapping(target = "marriageDate", expression = "java(MBeneficiarydetail.getMarriageDateCalc(dto.getDob(), dto.getMarriageDate(), " - + "dto.getAgeAtMarriage()))") - - @Mapping(source = "dto.vanID", target = "vanID") - @Mapping(source = "dto.parkingPlaceId", target = "parkingPlaceID") - - MBeneficiarydetail identityDTOToMBeneficiarydetail(IdentityDTO dto); +// @Mapping(source = "dto.areaId", target = "areaId") +// @Mapping(source = "dto.beneficiaryRegId", target = "beneficiaryRegID") +// @Mapping(source = "dto.community", target = "community") +// @Mapping(source = "dto.communityId", target = "communityId") +// @Mapping(source = "dto.dob", target = "dob") +// @Mapping(source = "dto.education", target = "education") +// @Mapping(source = "dto.educationId", target = "educationId") +// @Mapping(source = "dto.emergencyRegistration", target = "emergencyRegistration") +// @Mapping(source = "dto.healthCareWorkerId", target = "healthCareWorkerId") +// @Mapping(source = "dto.healthCareWorker", target = "healthCareWorker") +// @Mapping(source = "dto.fatherName", target = "fatherName") +// @Mapping(source = "dto.motherName", target = "motherName") +// @Mapping(source = "dto.firstName", target = "firstName") +// @Mapping(source = "dto.gender", target = "gender") +// @Mapping(source = "dto.genderId", target = "genderId") +// @Mapping(source = "dto.incomeStatus", target = "incomeStatus") +// @Mapping(source = "dto.monthlyFamilyIncome", target = "monthlyFamilyIncome") +// @Mapping(source = "dto.incomeStatusId", target = "incomeStatusId") +// @Mapping(source = "dto.lastName", target = "lastName") +// @Mapping(source = "dto.maritalStatusId", target = "maritalStatusId") +// @Mapping(source = "dto.maritalStatus", target = "maritalStatus") +// @Mapping(source = "dto.middleName", target = "middleName") +// @Mapping(source = "dto.occupation", target = "occupation") +// @Mapping(source = "dto.occupationId", target = "occupationId") +// @Mapping(source = "dto.phcId", target = "phcId") +// @Mapping(source = "dto.placeOfWork", target = "placeOfWork") +// @Mapping(source = "dto.preferredLanguage", target = "preferredLanguage") +// @Mapping(source = "dto.religion", target = "religion") +// @Mapping(source = "dto.religionId", target = "religionId") +// @Mapping(source = "dto.remarks", target = "remarks") +// @Mapping(source = "dto.servicePointId", target = "servicePointId") +// @Mapping(source = "dto.sourceOfInfo", target = "sourceOfInfo") +// @Mapping(source = "dto.spouseName", target = "spouseName") +// @Mapping(source = "dto.status", target = "status") +// @Mapping(source = "dto.title", target = "title") +// @Mapping(source = "dto.titleId", target = "titleId") +// @Mapping(source = "dto.zoneId", target = "zoneId") +// @Mapping(source = "dto.agentName", target = "createdBy") +// @Mapping(source = "dto.createdDate", target = "createdDate") +// @Mapping(target = "isHIVPositive", expression = "java(MBeneficiarydetail.setIsHIVPositive(dto.getIsHIVPositive()))") +// +// @Mapping(target = "ageAtMarriage", expression = "java(MBeneficiarydetail.getAgeAtMarriageCalc(dto.getDob(), dto.getMarriageDate(), " +// + "dto.getAgeAtMarriage()))") +// @Mapping(target = "marriageDate", expression = "java(MBeneficiarydetail.getMarriageDateCalc(dto.getDob(), dto.getMarriageDate(), " +// + "dto.getAgeAtMarriage()))") +// +// @Mapping(source = "dto.vanID", target = "vanID") +// @Mapping(source = "dto.parkingPlaceId", target = "parkingPlaceID") +// MBeneficiarydetail identityDTOToMBeneficiarydetail(IdentityDTO dto); + @Mapping(source = "benFamilyDTO.isEmergencyContact", target = "isEmergencyContact") @Mapping(source = "benFamilyDTO.relationshipToSelf", target = "relationshipToSelf") diff --git a/src/main/java/com/iemr/common/identity/service/IdentityService.java b/src/main/java/com/iemr/common/identity/service/IdentityService.java index fe80142..28ec9e6 100644 --- a/src/main/java/com/iemr/common/identity/service/IdentityService.java +++ b/src/main/java/com/iemr/common/identity/service/IdentityService.java @@ -21,6 +21,7 @@ */ package com.iemr.common.identity.service; +import java.lang.reflect.Field; import java.math.BigDecimal; import java.math.BigInteger; import java.sql.Timestamp; @@ -29,9 +30,11 @@ import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.ListIterator; import java.util.Map; +import java.util.Set; import javax.sql.DataSource; @@ -42,6 +45,7 @@ import org.springframework.stereotype.Service; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -204,7 +208,7 @@ public List getBeneficiaries(IdentitySearchDTO searchDTO) List list3 = this.getBeneficiariesByPhoneNum(searchDTO.getContactNumber()); if (!list3.isEmpty() && searchDTO.getIsD2D() != null && Boolean.TRUE.equals(searchDTO.getIsD2D())) { - for(int i = 0; i < list3.size(); i++) { + for (int i = 0; i < list3.size(); i++) { if (searchDTO.getFirstName() != null) { if (list3.get(i) == null || list3.get(i).getBeneficiaryDetails() == null || list3.get(i).getBeneficiaryDetails().getFirstName() == null @@ -506,35 +510,39 @@ public List searhBeneficiaryByFamilyId(String familyId) return beneficiaryList; } - public List searchBeneficiaryByVillageIdAndLastModifyDate(List villageIDs, Timestamp lastModifiedDate) { + public List searchBeneficiaryByVillageIdAndLastModifyDate(List villageIDs, + Timestamp lastModifiedDate) { List beneficiaryList = new ArrayList<>(); try { // find benmap ids - List benMappingsList = mappingRepo.findByBeneficiaryDetailsByVillageIDAndLastModifyDate(villageIDs, lastModifiedDate); - if (benMappingsList != null && !benMappingsList.isEmpty()){ + List benMappingsList = mappingRepo + .findByBeneficiaryDetailsByVillageIDAndLastModifyDate(villageIDs, lastModifiedDate); + if (benMappingsList != null && !benMappingsList.isEmpty()) { for (MBeneficiarymapping benMapOBJ : benMappingsList) { beneficiaryList.add(this.getBeneficiariesDTO(benMapOBJ)); } } } catch (Exception e) { - logger.error( - "error in beneficiary search to sync to CHO App with villageIDs: {} " , villageIDs + " error : " + e.getLocalizedMessage()); + logger.error("error in beneficiary search to sync to CHO App with villageIDs: {} ", + villageIDs + " error : " + e.getLocalizedMessage()); } return beneficiaryList; } - + public Long countBeneficiaryByVillageIdAndLastModifyDate(List villageIDs, Timestamp lastModifiedDate) { Long beneficiaryCount = 0L; try { beneficiaryCount = mappingRepo.getBeneficiaryCountsByVillageIDAndLastModifyDate(villageIDs, lastModifiedDate); } catch (Exception e) { - logger.error("error in getting beneficiary count to sync to CHO App with villageIDs: {},error :{} " , villageIDs ,e.getLocalizedMessage()); + logger.error("error in getting beneficiary count to sync to CHO App with villageIDs: {},error :{} ", + villageIDs, e.getLocalizedMessage()); } return beneficiaryCount; } + public List searhBeneficiaryByGovIdentity(String identity) throws NoResultException, QueryTimeoutException { List beneficiaryList = new ArrayList<>(); @@ -597,8 +605,8 @@ private MBeneficiarymapping getBeneficiariesDTONew(Object[] benMapArr) { .getWith_vanSerialNo_vanID(getBigIntegerValueFromObject(benMapArr[4]), (Integer) benMapArr[8])); benMapOBJ.setMBeneficiaryregidmapping(regIdRepo .getWithVanSerialNoVanID(getBigIntegerValueFromObject(benMapArr[5]), (Integer) benMapArr[8])); - benMapOBJ.setMBeneficiaryImage( - imageRepo.getWithVanSerialNoVanID(BigInteger.valueOf(Long.valueOf(benMapArr[6].toString())), (Integer) benMapArr[8])); + benMapOBJ.setMBeneficiaryImage(imageRepo.getWithVanSerialNoVanID( + BigInteger.valueOf(Long.valueOf(benMapArr[6].toString())), (Integer) benMapArr[8])); benMapOBJ.setMBeneficiaryAccount(accountRepo .getWithVanSerialNoVanID(getBigIntegerValueFromObject(benMapArr[7]), (Integer) benMapArr[8])); @@ -649,19 +657,19 @@ private MBeneficiarymapping getBeneficiariesDTONew1(VBenAdvanceSearch benAdvance benMapOBJ.setCreatedBy(benDetailsOBJ.getCreatedBy()); benMapOBJ.setCreatedDate(benDetailsOBJ.getCreatedDate()); - benMapOBJ.setMBeneficiaryaddress(addressRepo - .getWithVanSerialNoVanID(benAdvanceSearchOBJ.getBenAddressID(), benAdvanceSearchOBJ.getVanID())); - benMapOBJ.setMBeneficiaryconsent(consentRepo - .getWithVanSerialNoVanID(benAdvanceSearchOBJ.getBenConsentID(), benAdvanceSearchOBJ.getVanID())); - benMapOBJ.setMBeneficiarycontact(contactRepo - .getWithVanSerialNoVanID(benAdvanceSearchOBJ.getBenContactID(), benAdvanceSearchOBJ.getVanID())); + benMapOBJ.setMBeneficiaryaddress(addressRepo.getWithVanSerialNoVanID(benAdvanceSearchOBJ.getBenAddressID(), + benAdvanceSearchOBJ.getVanID())); + benMapOBJ.setMBeneficiaryconsent(consentRepo.getWithVanSerialNoVanID(benAdvanceSearchOBJ.getBenConsentID(), + benAdvanceSearchOBJ.getVanID())); + benMapOBJ.setMBeneficiarycontact(contactRepo.getWithVanSerialNoVanID(benAdvanceSearchOBJ.getBenContactID(), + benAdvanceSearchOBJ.getVanID())); benMapOBJ.setMBeneficiarydetail(benDetailsOBJ); benMapOBJ.setMBeneficiaryregidmapping(regIdRepo.getWithVanSerialNoVanID(benAdvanceSearchOBJ.getBenRegID(), benAdvanceSearchOBJ.getVanID())); benMapOBJ.setMBeneficiaryImage(imageRepo.getWithVanSerialNoVanID(benAdvanceSearchOBJ.getBenImageID(), benAdvanceSearchOBJ.getVanID())); - benMapOBJ.setMBeneficiaryAccount(accountRepo - .getWithVanSerialNoVanID(benAdvanceSearchOBJ.getBenAccountID(), benAdvanceSearchOBJ.getVanID())); + benMapOBJ.setMBeneficiaryAccount(accountRepo.getWithVanSerialNoVanID(benAdvanceSearchOBJ.getBenAccountID(), + benAdvanceSearchOBJ.getVanID())); benMapOBJ.setMBeneficiaryfamilymappings( familyMapRepo.findByBenMapIdOrderByBenFamilyMapIdAsc(benAdvanceSearchOBJ.getVanSerialNo())); @@ -720,7 +728,10 @@ public void editIdentity(IdentityEditDTO identity) throws MissingMandatoryFields || Boolean.TRUE.equals(identity.getChangeInOtherDetails()) || Boolean.TRUE.equals(identity.getChangeInAssociations())) { - MBeneficiarydetail mbDetl = editMapper.identityEditDTOToMBeneficiarydetail(identity); + // MBeneficiarydetail mbDetl = + // editMapper.identityEditDTOToMBeneficiarydetail(identity); + // MBeneficiarydetail mbDetl = + // convertIdentityEditDTOToMBeneficiarydetail(identity); /** * new logic for data sync, 26-09-2018 */ @@ -729,6 +740,10 @@ public void editIdentity(IdentityEditDTO identity) throws MissingMandatoryFields benMapping.getMBeneficiarydetail().getBeneficiaryDetailsId(), benMapping.getVanID()); // next statement is new one, setting correct beneficiaryDetailsId if (benDetails != null) { + // Create a new instance of MBeneficiarydetail or use the existing one + MBeneficiarydetail mbDetl = convertIdentityEditDTOToMBeneficiarydetail(identity); + + // Set fields from the existing benDetails to mbDetl mbDetl.setBeneficiaryDetailsId(benDetails.getBeneficiaryDetailsId()); if (benDetails.getFamilyId() != null) mbDetl.setFamilyId(benDetails.getFamilyId()); @@ -738,22 +753,39 @@ public void editIdentity(IdentityEditDTO identity) throws MissingMandatoryFields mbDetl.setHeadOfFamily_Relation(benDetails.getHeadOfFamily_Relation()); if (benDetails.getOther() != null) mbDetl.setOther(benDetails.getOther()); - } else - throw new MissingMandatoryFieldsException("Either of vanSerialNO or vanID is missing."); - /** - * END - */ - - logger.debug("Beneficiary details to update = " + new OutputMapper().gson().toJson(mbDetl)); - if(benDetails.getEmergencyRegistration() != null && benDetails.getEmergencyRegistration()) { - mbDetl.setEmergencyRegistration(true); - }else { - mbDetl.setEmergencyRegistration(false); + // Extract and set extra fields +// String identityJson = new Gson().toJson(json); +// JsonObject identityJsonObject = new Gson().fromJson(identityJson, JsonObject.class); +// JsonObject otherFieldsJson = new JsonObject(); +// +// Set identityFieldNames = new HashSet<>(); +// for (Field field : IdentityEditDTO.class.getDeclaredFields()) { +// identityFieldNames.add(field.getName()); +// } +// Set entityFieldNames = new HashSet<>(); +// for (Field field : MBeneficiarydetail.class.getDeclaredFields()) { +// entityFieldNames.add(field.getName()); +// } +// for (Map.Entry entry : identityJsonObject.entrySet()) { +// String fieldName = entry.getKey(); +// +// // Check if the field is not present in either class +// if (!identityFieldNames.contains(fieldName) && !entityFieldNames.contains(fieldName)) { +// otherFieldsJson.add(fieldName, entry.getValue()); +// } +// } +// String otherFieldsJsonString = otherFieldsJson.toString(); + mbDetl.setOtherFields(benDetails.getOtherFields()); + logger.debug("Beneficiary details to update = " + new OutputMapper().gson().toJson(mbDetl)); + if (benDetails.getEmergencyRegistration() != null && benDetails.getEmergencyRegistration()) { + mbDetl.setEmergencyRegistration(true); + } else { + mbDetl.setEmergencyRegistration(false); + } + detailRepo.save(mbDetl); } - detailRepo.save(mbDetl); } - // edition in current emergency and permanent is implement below logger.debug("identity.getChangeInAddress = " + identity.getChangeInAddress()); if (Boolean.TRUE.equals(identity.getChangeInAddress())) { @@ -927,8 +959,8 @@ public void editIdentity(IdentityEditDTO identity) throws MissingMandatoryFields * new logic for data sync, 26-09-2018 */ // getting correct beneficiaryDetailsId by passing vanSerialNo & vanID - BigInteger benImageId = imageRepo.findIdByVanSerialNoAndVanID(benMapping.getMBeneficiaryImage().getBenImageId(), - benMapping.getVanID()); + BigInteger benImageId = imageRepo.findIdByVanSerialNoAndVanID( + benMapping.getMBeneficiaryImage().getBenImageId(), benMapping.getVanID()); // next statement is new one, setting correct beneficiaryDetailsId if (benImageId != null) beneficiaryImage.setBenImageId(benImageId); @@ -946,6 +978,59 @@ public void editIdentity(IdentityEditDTO identity) throws MissingMandatoryFields logger.info("IdentityService.editIdentity - end. id = " + benMapping.getBenMapId()); } + private MBeneficiarydetail convertIdentityEditDTOToMBeneficiarydetail(IdentityEditDTO dto) { + MBeneficiarydetail beneficiarydetail = new MBeneficiarydetail(); + + // Directly set values without using @Mapping + beneficiarydetail.setAreaId(dto.getAreaId()); + beneficiarydetail.setBeneficiaryRegID(dto.getBeneficiaryRegId()); + beneficiarydetail.setCommunity(dto.getCommunity()); + beneficiarydetail.setCommunityId(dto.getCommunityId()); + beneficiarydetail.setDob(dto.getDob()); + beneficiarydetail.setEducation(dto.getEducation()); + beneficiarydetail.setEducationId(dto.getEducationId()); + beneficiarydetail.setHealthCareWorkerId(dto.getHealthCareWorkerId()); + beneficiarydetail.setHealthCareWorker(dto.getHealthCareWorker()); + beneficiarydetail.setFatherName(dto.getFatherName()); + beneficiarydetail.setMotherName(dto.getMotherName()); + beneficiarydetail.setFirstName(dto.getFirstName()); + beneficiarydetail.setGender(dto.getGender()); + beneficiarydetail.setGenderId(dto.getGenderId()); + beneficiarydetail.setIncomeStatusId(dto.getIncomeStatusId()); + beneficiarydetail.setIncomeStatus(dto.getIncomeStatus()); + beneficiarydetail.setMonthlyFamilyIncome(dto.getMonthlyFamilyIncome()); + if (dto.getLastName() != null) + beneficiarydetail.setLastName(dto.getLastName()); + beneficiarydetail.setMaritalStatusId(dto.getMaritalStatusId()); + beneficiarydetail.setMaritalStatus(dto.getMaritalStatus()); + beneficiarydetail.setMiddleName(dto.getMiddleName()); + beneficiarydetail.setOccupation(dto.getOccupation()); + beneficiarydetail.setOccupationId(dto.getOccupationId()); + beneficiarydetail.setPhcId(dto.getPhcId()); + beneficiarydetail.setPlaceOfWork(dto.getPlaceOfWork()); + beneficiarydetail.setPreferredLanguage(dto.getPreferredLanguage()); + beneficiarydetail.setReligion(dto.getReligion()); + if (dto.getReligionId() != null) + beneficiarydetail.setReligionId(BigInteger.valueOf(dto.getReligionId())); + beneficiarydetail.setRemarks(dto.getRemarks()); + beneficiarydetail.setServicePointId(dto.getServicePointId()); + beneficiarydetail.setSourceOfInfo(dto.getSourceOfInfo()); + beneficiarydetail.setSpouseName(dto.getSpouseName()); + beneficiarydetail.setStatus(dto.getStatus()); + beneficiarydetail.setTitle(dto.getTitle()); + beneficiarydetail.setTitleId(dto.getTitleId()); + beneficiarydetail.setZoneId(dto.getZoneId()); + beneficiarydetail.setCreatedBy(dto.getAgentName()); + beneficiarydetail.setCreatedDate(dto.getEventTypeDate()); + beneficiarydetail.setIsHIVPositive(MBeneficiarydetail.setIsHIVPositive(dto.getIsHIVPositive())); + beneficiarydetail.setAgeAtMarriage( + MBeneficiarydetail.getAgeAtMarriageCalc(dto.getDob(), dto.getMarriageDate(), dto.getAgeAtMarriage())); + beneficiarydetail.setMarriageDate( + MBeneficiarydetail.getMarriageDateCalc(dto.getDob(), dto.getMarriageDate(), dto.getAgeAtMarriage())); + + return beneficiarydetail; + } + /** * @param identity * @return @@ -985,7 +1070,8 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) { logger.info("IdentityService.createIdentity - saving Address"); ObjectMapper objectMapper = new ObjectMapper(); MBeneficiaryaddress mAddr = identityDTOToMBeneficiaryaddress(identity); - //MBeneficiaryaddress mAddr1 = mapper.identityDTOToMBeneficiaryaddress(identity); + // MBeneficiaryaddress mAddr1 = + // mapper.identityDTOToMBeneficiaryaddress(identity); logger.info("identity.getIsPermAddrSameAsCurrAddr = " + identity.getIsPermAddrSameAsCurrAddr()); if (Boolean.TRUE.equals(identity.getIsPermAddrSameAsCurrAddr())) { logger.debug("identity.getCurrentAddress = " + identity.getCurrentAddress()); @@ -1038,7 +1124,8 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) { logger.info("IdentityService.createIdentity - saving Contacts"); MBeneficiarycontact mContc = identityDTOToMBeneficiarycontact(identity); - //MBeneficiarycontact mContc = mapper.identityDTOToMBeneficiarycontact(identity); + // MBeneficiarycontact mContc = + // mapper.identityDTOToMBeneficiarycontact(identity); if (mContc.getCreatedDate() == null) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS"); String dateToStoreInDataBase = sdf.format(new Date()); @@ -1052,7 +1139,29 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) { contactRepo.updateVanSerialNo(mContc.getBenContactsID()); logger.info("IdentityService.createIdentity - saving Details"); - MBeneficiarydetail mDetl = mapper.identityDTOToMBeneficiarydetail(identity); + // MBeneficiarydetail mDetl = mapper.identityDTOToMBeneficiarydetail(identity); + MBeneficiarydetail mDetl = convertIdentityDTOToMBeneficiarydetail(identity); +// String identityJson = new Gson().toJson(json); +// JsonObject identityJsonObject = new Gson().fromJson(identityJson, JsonObject.class); +// JsonObject otherFieldsJson = new JsonObject(); +// Set identityFieldNames = new HashSet<>(); +// for (Field field : IdentityDTO.class.getDeclaredFields()) { +// identityFieldNames.add(field.getName()); +// } +// Set entityFieldNames = new HashSet<>(); +// for (Field field : MBeneficiarydetail.class.getDeclaredFields()) { +// entityFieldNames.add(field.getName()); +// } +// for (Map.Entry entry : identityJsonObject.entrySet()) { +// String fieldName = entry.getKey(); +// +// // Check if the field is not present in either class +// if (!identityFieldNames.contains(fieldName) && !entityFieldNames.contains(fieldName)) { +// otherFieldsJson.add(fieldName, entry.getValue()); +// } +// } +// String otherFieldsJsonString = otherFieldsJson.toString(); + // mDetl.setOtherFields(otherFieldsJsonString); if (mDetl.getCreatedDate() == null) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS"); String dateToStoreInDataBase = sdf.format(new Date()); @@ -1201,123 +1310,180 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) { return partialMapper.mBeneficiarymappingToBeneficiaryCreateResp(benMapping); } + private MBeneficiarydetail convertIdentityDTOToMBeneficiarydetail(IdentityDTO dto) { + MBeneficiarydetail beneficiarydetail = new MBeneficiarydetail(); + beneficiarydetail.setAreaId(dto.getAreaId()); + if (null != dto.getBeneficiaryRegId()) + beneficiarydetail.setBeneficiaryRegID(BigInteger.valueOf(dto.getBeneficiaryRegId())); + beneficiarydetail.setCommunity(dto.getCommunity()); + beneficiarydetail.setCommunityId(dto.getCommunityId()); + beneficiarydetail.setDob(dto.getDob()); + beneficiarydetail.setEducation(dto.getEducation()); + beneficiarydetail.setEducationId(dto.getEducationId()); + beneficiarydetail.setEmergencyRegistration(dto.getEmergencyRegistration()); + beneficiarydetail.setHealthCareWorkerId(dto.getHealthCareWorkerId()); + beneficiarydetail.setHealthCareWorker(dto.getHealthCareWorker()); + beneficiarydetail.setFatherName(dto.getFatherName()); + beneficiarydetail.setMotherName(dto.getMotherName()); + beneficiarydetail.setFirstName(dto.getFirstName()); + beneficiarydetail.setGender(dto.getGender()); + beneficiarydetail.setGenderId(dto.getGenderId()); + beneficiarydetail.setIncomeStatus(dto.getIncomeStatus()); + beneficiarydetail.setMonthlyFamilyIncome(dto.getMonthlyFamilyIncome()); + beneficiarydetail.setIncomeStatusId(dto.getIncomeStatusId()); + beneficiarydetail.setLastName(dto.getLastName()); + beneficiarydetail.setMaritalStatusId(dto.getMaritalStatusId()); + beneficiarydetail.setMaritalStatus(dto.getMaritalStatus()); + beneficiarydetail.setMiddleName(dto.getMiddleName()); + beneficiarydetail.setOccupation(dto.getOccupation()); + beneficiarydetail.setOccupationId(dto.getOccupationId()); + beneficiarydetail.setPhcId(dto.getPhcId()); + beneficiarydetail.setPlaceOfWork(dto.getPlaceOfWork()); + beneficiarydetail.setPreferredLanguage(dto.getPreferredLanguage()); + beneficiarydetail.setReligion(dto.getReligion()); + if (dto.getReligionId() != null) + beneficiarydetail.setReligionId(BigInteger.valueOf(dto.getReligionId())); + beneficiarydetail.setRemarks(dto.getRemarks()); + if (dto.getServicePointId() != null) + beneficiarydetail.setServicePointId(BigInteger.valueOf(dto.getServicePointId())); + beneficiarydetail.setSourceOfInfo(dto.getSourceOfInfo()); + beneficiarydetail.setSpouseName(dto.getSpouseName()); + beneficiarydetail.setStatus(dto.getStatus()); + beneficiarydetail.setTitle(dto.getTitle()); + beneficiarydetail.setTitleId(dto.getTitleId()); + beneficiarydetail.setZoneId(dto.getZoneId()); + beneficiarydetail.setCreatedBy(dto.getAgentName()); + beneficiarydetail.setCreatedDate(dto.getCreatedDate()); + beneficiarydetail.setIsHIVPositive(MBeneficiarydetail.setIsHIVPositive(dto.getIsHIVPositive())); + beneficiarydetail.setAgeAtMarriage( + MBeneficiarydetail.getAgeAtMarriageCalc(dto.getDob(), dto.getMarriageDate(), dto.getAgeAtMarriage())); + beneficiarydetail.setMarriageDate( + MBeneficiarydetail.getMarriageDateCalc(dto.getDob(), dto.getMarriageDate(), dto.getAgeAtMarriage())); + beneficiarydetail.setVanID(dto.getVanID()); + beneficiarydetail.setParkingPlaceID(dto.getParkingPlaceId()); + if(dto.getOtherFields() != null) + beneficiarydetail.setOtherFields(dto.getOtherFields()); + if(dto.getLiteracyStatus() != null) + beneficiarydetail.setLiteracyStatus(dto.getLiteracyStatus()); + return beneficiarydetail; + } + private MBeneficiarycontact identityDTOToMBeneficiarycontact(IdentityDTO dto) { MBeneficiarycontact beneficiaryContact = new MBeneficiarycontact(); - if (dto.getContact() != null) { - beneficiaryContact.setPreferredPhoneNum(dto.getContact().getPreferredPhoneNum()); - beneficiaryContact.setPreferredPhoneTyp(dto.getContact().getPreferredPhoneTyp()); - beneficiaryContact.setPreferredSMSPhoneNum(dto.getContact().getPreferredSMSPhoneNum()); - beneficiaryContact.setPreferredSMSPhoneTyp(dto.getContact().getPreferredSMSPhoneTyp()); - beneficiaryContact.setEmergencyContactNum(dto.getContact().getEmergencyContactNum()); - beneficiaryContact.setPhoneNum1(dto.getContact().getPhoneNum1()); - beneficiaryContact.setPhoneTyp1(dto.getContact().getPhoneTyp1()); - beneficiaryContact.setPhoneNum2(dto.getContact().getPhoneNum2()); - beneficiaryContact.setPhoneTyp2(dto.getContact().getPhoneTyp2()); - beneficiaryContact.setPhoneNum3(dto.getContact().getPhoneNum3()); - beneficiaryContact.setPhoneTyp3(dto.getContact().getPhoneTyp3()); - beneficiaryContact.setPhoneNum4(dto.getContact().getPhoneNum4()); - beneficiaryContact.setPhoneTyp4(dto.getContact().getPhoneTyp4()); - beneficiaryContact.setPhoneNum5(dto.getContact().getPhoneNum5()); - beneficiaryContact.setPhoneTyp5(dto.getContact().getPhoneTyp5()); - } - beneficiaryContact.setEmailId(dto.getPreferredEmailId()); - beneficiaryContact.setCreatedBy(dto.getAgentName()); - beneficiaryContact.setCreatedDate(dto.getCreatedDate()); - beneficiaryContact.setVanID(dto.getVanID()); - beneficiaryContact.setParkingPlaceID(dto.getParkingPlaceId()); - return beneficiaryContact; + if (dto.getContact() != null) { + beneficiaryContact.setPreferredPhoneNum(dto.getContact().getPreferredPhoneNum()); + beneficiaryContact.setPreferredPhoneTyp(dto.getContact().getPreferredPhoneTyp()); + beneficiaryContact.setPreferredSMSPhoneNum(dto.getContact().getPreferredSMSPhoneNum()); + beneficiaryContact.setPreferredSMSPhoneTyp(dto.getContact().getPreferredSMSPhoneTyp()); + beneficiaryContact.setEmergencyContactNum(dto.getContact().getEmergencyContactNum()); + beneficiaryContact.setPhoneNum1(dto.getContact().getPhoneNum1()); + beneficiaryContact.setPhoneTyp1(dto.getContact().getPhoneTyp1()); + beneficiaryContact.setPhoneNum2(dto.getContact().getPhoneNum2()); + beneficiaryContact.setPhoneTyp2(dto.getContact().getPhoneTyp2()); + beneficiaryContact.setPhoneNum3(dto.getContact().getPhoneNum3()); + beneficiaryContact.setPhoneTyp3(dto.getContact().getPhoneTyp3()); + beneficiaryContact.setPhoneNum4(dto.getContact().getPhoneNum4()); + beneficiaryContact.setPhoneTyp4(dto.getContact().getPhoneTyp4()); + beneficiaryContact.setPhoneNum5(dto.getContact().getPhoneNum5()); + beneficiaryContact.setPhoneTyp5(dto.getContact().getPhoneTyp5()); + } + beneficiaryContact.setEmailId(dto.getPreferredEmailId()); + beneficiaryContact.setCreatedBy(dto.getAgentName()); + beneficiaryContact.setCreatedDate(dto.getCreatedDate()); + beneficiaryContact.setVanID(dto.getVanID()); + beneficiaryContact.setParkingPlaceID(dto.getParkingPlaceId()); + return beneficiaryContact; } private MBeneficiaryaddress identityDTOToMBeneficiaryaddress(IdentityDTO dto) { MBeneficiaryaddress beneficiaryAddress = new MBeneficiaryaddress(); if (dto.getCurrentAddress() != null) { - beneficiaryAddress.setCurrAddrLine1(dto.getCurrentAddress().getAddrLine1()); - beneficiaryAddress.setCurrAddrLine2(dto.getCurrentAddress().getAddrLine2()); - beneficiaryAddress.setCurrAddrLine3(dto.getCurrentAddress().getAddrLine3()); - beneficiaryAddress.setCurrCountryId(dto.getCurrentAddress().getCountryId()); - beneficiaryAddress.setCurrCountry(dto.getCurrentAddress().getCountry()); - beneficiaryAddress.setCurrStateId(dto.getCurrentAddress().getStateId()); - beneficiaryAddress.setCurrState(dto.getCurrentAddress().getState()); - beneficiaryAddress.setCurrDistrictId(dto.getCurrentAddress().getDistrictId()); - beneficiaryAddress.setCurrDistrict(dto.getCurrentAddress().getDistrict()); - beneficiaryAddress.setCurrSubDistrictId(dto.getCurrentAddress().getSubDistrictId()); - beneficiaryAddress.setCurrSubDistrict(dto.getCurrentAddress().getSubDistrict()); - beneficiaryAddress.setCurrVillageId(dto.getCurrentAddress().getVillageId()); - beneficiaryAddress.setCurrVillage(dto.getCurrentAddress().getVillage()); - beneficiaryAddress.setCurrAddressValue(dto.getCurrentAddress().getAddressValue()); - beneficiaryAddress.setCurrPinCode(dto.getCurrentAddress().getPinCode()); - beneficiaryAddress.setCurrZoneID(dto.getCurrentAddress().getZoneID()); - beneficiaryAddress.setCurrZone(dto.getCurrentAddress().getZoneName()); - beneficiaryAddress.setCurrAreaId(dto.getCurrentAddress().getParkingPlaceID()); - beneficiaryAddress.setCurrArea(dto.getCurrentAddress().getParkingPlaceName()); - beneficiaryAddress.setCurrServicePointId(dto.getCurrentAddress().getServicePointID()); - beneficiaryAddress.setCurrServicePoint(dto.getCurrentAddress().getServicePointName()); - beneficiaryAddress.setCurrHabitation(dto.getCurrentAddress().getHabitation()); - } + beneficiaryAddress.setCurrAddrLine1(dto.getCurrentAddress().getAddrLine1()); + beneficiaryAddress.setCurrAddrLine2(dto.getCurrentAddress().getAddrLine2()); + beneficiaryAddress.setCurrAddrLine3(dto.getCurrentAddress().getAddrLine3()); + beneficiaryAddress.setCurrCountryId(dto.getCurrentAddress().getCountryId()); + beneficiaryAddress.setCurrCountry(dto.getCurrentAddress().getCountry()); + beneficiaryAddress.setCurrStateId(dto.getCurrentAddress().getStateId()); + beneficiaryAddress.setCurrState(dto.getCurrentAddress().getState()); + beneficiaryAddress.setCurrDistrictId(dto.getCurrentAddress().getDistrictId()); + beneficiaryAddress.setCurrDistrict(dto.getCurrentAddress().getDistrict()); + beneficiaryAddress.setCurrSubDistrictId(dto.getCurrentAddress().getSubDistrictId()); + beneficiaryAddress.setCurrSubDistrict(dto.getCurrentAddress().getSubDistrict()); + beneficiaryAddress.setCurrVillageId(dto.getCurrentAddress().getVillageId()); + beneficiaryAddress.setCurrVillage(dto.getCurrentAddress().getVillage()); + beneficiaryAddress.setCurrAddressValue(dto.getCurrentAddress().getAddressValue()); + beneficiaryAddress.setCurrPinCode(dto.getCurrentAddress().getPinCode()); + beneficiaryAddress.setCurrZoneID(dto.getCurrentAddress().getZoneID()); + beneficiaryAddress.setCurrZone(dto.getCurrentAddress().getZoneName()); + beneficiaryAddress.setCurrAreaId(dto.getCurrentAddress().getParkingPlaceID()); + beneficiaryAddress.setCurrArea(dto.getCurrentAddress().getParkingPlaceName()); + beneficiaryAddress.setCurrServicePointId(dto.getCurrentAddress().getServicePointID()); + beneficiaryAddress.setCurrServicePoint(dto.getCurrentAddress().getServicePointName()); + beneficiaryAddress.setCurrHabitation(dto.getCurrentAddress().getHabitation()); + } if (dto.getEmergencyAddress() != null) { beneficiaryAddress.setEmerAddrLine1(dto.getEmergencyAddress().getAddrLine1()); - beneficiaryAddress.setEmerAddrLine2(dto.getEmergencyAddress().getAddrLine2()); - beneficiaryAddress.setEmerAddrLine3(dto.getEmergencyAddress().getAddrLine3()); - beneficiaryAddress.setEmerCountryId(dto.getEmergencyAddress().getCountryId()); - beneficiaryAddress.setEmerCountry(dto.getEmergencyAddress().getCountry()); - beneficiaryAddress.setEmerStateId(dto.getEmergencyAddress().getStateId()); - beneficiaryAddress.setEmerState(dto.getEmergencyAddress().getState()); - beneficiaryAddress.setEmerDistrictId(dto.getEmergencyAddress().getDistrictId()); - beneficiaryAddress.setEmerDistrict(dto.getEmergencyAddress().getDistrict()); - beneficiaryAddress.setEmerSubDistrictId(dto.getEmergencyAddress().getSubDistrictId()); - beneficiaryAddress.setEmerSubDistrict(dto.getEmergencyAddress().getSubDistrict()); - beneficiaryAddress.setEmerVillageId(dto.getEmergencyAddress().getVillageId()); - beneficiaryAddress.setEmerVillage(dto.getEmergencyAddress().getVillage()); - beneficiaryAddress.setEmerAddressValue(dto.getEmergencyAddress().getAddressValue()); - beneficiaryAddress.setEmerPinCode(dto.getEmergencyAddress().getPinCode()); - beneficiaryAddress.setEmerZoneID(dto.getEmergencyAddress().getZoneID()); - beneficiaryAddress.setEmerZone(dto.getEmergencyAddress().getZoneName()); - beneficiaryAddress.setEmerAreaId(dto.getEmergencyAddress().getParkingPlaceID()); - beneficiaryAddress.setEmerArea(dto.getEmergencyAddress().getParkingPlaceName()); - beneficiaryAddress.setEmerServicePointId(dto.getEmergencyAddress().getServicePointID()); - beneficiaryAddress.setEmerServicePoint(dto.getEmergencyAddress().getServicePointName()); - beneficiaryAddress.setEmerHabitation(dto.getEmergencyAddress().getHabitation()); + beneficiaryAddress.setEmerAddrLine2(dto.getEmergencyAddress().getAddrLine2()); + beneficiaryAddress.setEmerAddrLine3(dto.getEmergencyAddress().getAddrLine3()); + beneficiaryAddress.setEmerCountryId(dto.getEmergencyAddress().getCountryId()); + beneficiaryAddress.setEmerCountry(dto.getEmergencyAddress().getCountry()); + beneficiaryAddress.setEmerStateId(dto.getEmergencyAddress().getStateId()); + beneficiaryAddress.setEmerState(dto.getEmergencyAddress().getState()); + beneficiaryAddress.setEmerDistrictId(dto.getEmergencyAddress().getDistrictId()); + beneficiaryAddress.setEmerDistrict(dto.getEmergencyAddress().getDistrict()); + beneficiaryAddress.setEmerSubDistrictId(dto.getEmergencyAddress().getSubDistrictId()); + beneficiaryAddress.setEmerSubDistrict(dto.getEmergencyAddress().getSubDistrict()); + beneficiaryAddress.setEmerVillageId(dto.getEmergencyAddress().getVillageId()); + beneficiaryAddress.setEmerVillage(dto.getEmergencyAddress().getVillage()); + beneficiaryAddress.setEmerAddressValue(dto.getEmergencyAddress().getAddressValue()); + beneficiaryAddress.setEmerPinCode(dto.getEmergencyAddress().getPinCode()); + beneficiaryAddress.setEmerZoneID(dto.getEmergencyAddress().getZoneID()); + beneficiaryAddress.setEmerZone(dto.getEmergencyAddress().getZoneName()); + beneficiaryAddress.setEmerAreaId(dto.getEmergencyAddress().getParkingPlaceID()); + beneficiaryAddress.setEmerArea(dto.getEmergencyAddress().getParkingPlaceName()); + beneficiaryAddress.setEmerServicePointId(dto.getEmergencyAddress().getServicePointID()); + beneficiaryAddress.setEmerServicePoint(dto.getEmergencyAddress().getServicePointName()); + beneficiaryAddress.setEmerHabitation(dto.getEmergencyAddress().getHabitation()); } - + if (dto.getPermanentAddress() != null) { beneficiaryAddress.setPermAddrLine1(dto.getPermanentAddress().getAddrLine1()); - beneficiaryAddress.setPermAddrLine2(dto.getPermanentAddress().getAddrLine2()); - beneficiaryAddress.setPermAddrLine3(dto.getPermanentAddress().getAddrLine3()); - beneficiaryAddress.setPermCountryId(dto.getPermanentAddress().getCountryId()); - beneficiaryAddress.setPermCountry(dto.getPermanentAddress().getCountry()); - beneficiaryAddress.setPermStateId(dto.getPermanentAddress().getStateId()); - beneficiaryAddress.setPermState(dto.getPermanentAddress().getState()); - beneficiaryAddress.setPermDistrictId(dto.getPermanentAddress().getDistrictId()); - beneficiaryAddress.setPermDistrict(dto.getPermanentAddress().getDistrict()); - beneficiaryAddress.setPermSubDistrictId(dto.getPermanentAddress().getSubDistrictId()); - beneficiaryAddress.setPermSubDistrict(dto.getPermanentAddress().getSubDistrict()); - beneficiaryAddress.setPermVillageId(dto.getPermanentAddress().getVillageId()); - beneficiaryAddress.setPermVillage(dto.getPermanentAddress().getVillage()); - beneficiaryAddress.setPermAddressValue(dto.getPermanentAddress().getAddressValue()); - beneficiaryAddress.setPermPinCode(dto.getPermanentAddress().getPinCode()); - - beneficiaryAddress.setPermZoneID(dto.getPermanentAddress().getZoneID()); - beneficiaryAddress.setPermZone(dto.getPermanentAddress().getZoneName()); - beneficiaryAddress.setPermAreaId(dto.getPermanentAddress().getParkingPlaceID()); - beneficiaryAddress.setPermArea(dto.getPermanentAddress().getParkingPlaceName()); - beneficiaryAddress.setPermServicePointId(dto.getPermanentAddress().getServicePointID()); - beneficiaryAddress.setPermServicePoint(dto.getPermanentAddress().getServicePointName()); - beneficiaryAddress.setPermHabitation(dto.getPermanentAddress().getHabitation()); - } + beneficiaryAddress.setPermAddrLine2(dto.getPermanentAddress().getAddrLine2()); + beneficiaryAddress.setPermAddrLine3(dto.getPermanentAddress().getAddrLine3()); + beneficiaryAddress.setPermCountryId(dto.getPermanentAddress().getCountryId()); + beneficiaryAddress.setPermCountry(dto.getPermanentAddress().getCountry()); + beneficiaryAddress.setPermStateId(dto.getPermanentAddress().getStateId()); + beneficiaryAddress.setPermState(dto.getPermanentAddress().getState()); + beneficiaryAddress.setPermDistrictId(dto.getPermanentAddress().getDistrictId()); + beneficiaryAddress.setPermDistrict(dto.getPermanentAddress().getDistrict()); + beneficiaryAddress.setPermSubDistrictId(dto.getPermanentAddress().getSubDistrictId()); + beneficiaryAddress.setPermSubDistrict(dto.getPermanentAddress().getSubDistrict()); + beneficiaryAddress.setPermVillageId(dto.getPermanentAddress().getVillageId()); + beneficiaryAddress.setPermVillage(dto.getPermanentAddress().getVillage()); + beneficiaryAddress.setPermAddressValue(dto.getPermanentAddress().getAddressValue()); + beneficiaryAddress.setPermPinCode(dto.getPermanentAddress().getPinCode()); + + beneficiaryAddress.setPermZoneID(dto.getPermanentAddress().getZoneID()); + beneficiaryAddress.setPermZone(dto.getPermanentAddress().getZoneName()); + beneficiaryAddress.setPermAreaId(dto.getPermanentAddress().getParkingPlaceID()); + beneficiaryAddress.setPermArea(dto.getPermanentAddress().getParkingPlaceName()); + beneficiaryAddress.setPermServicePointId(dto.getPermanentAddress().getServicePointID()); + beneficiaryAddress.setPermServicePoint(dto.getPermanentAddress().getServicePointName()); + beneficiaryAddress.setPermHabitation(dto.getPermanentAddress().getHabitation()); + } if (dto.getAgentName() != null) { - beneficiaryAddress.setCreatedBy(dto.getAgentName()); - } - if (dto.getCreatedDate() != null) { - beneficiaryAddress.setCreatedDate(dto.getCreatedDate()); - } - if (dto.getVanID() != null) { - beneficiaryAddress.setVanID(dto.getVanID()); - } - if (dto.getParkingPlaceId() != null) { - beneficiaryAddress.setParkingPlaceID(dto.getParkingPlaceId()); - } - - + beneficiaryAddress.setCreatedBy(dto.getAgentName()); + } + if (dto.getCreatedDate() != null) { + beneficiaryAddress.setCreatedDate(dto.getCreatedDate()); + } + if (dto.getVanID() != null) { + beneficiaryAddress.setVanID(dto.getVanID()); + } + if (dto.getParkingPlaceId() != null) { + beneficiaryAddress.setParkingPlaceID(dto.getParkingPlaceId()); + } + return beneficiaryAddress; } @@ -1430,6 +1596,7 @@ public List getBeneficiariesDeatilsByBenRegIdList(List benImageMap = new HashMap<>(); if (requestOBJ != null) { - + JsonElement jsnElmnt = JsonParser.parseString(requestOBJ); JsonObject obj = jsnElmnt.getAsJsonObject(); diff --git a/src/test/java/com/iemr/common/identity/service/IdentityServiceTest.java b/src/test/java/com/iemr/common/identity/service/IdentityServiceTest.java index fdb1b4b..3e87215 100644 --- a/src/test/java/com/iemr/common/identity/service/IdentityServiceTest.java +++ b/src/test/java/com/iemr/common/identity/service/IdentityServiceTest.java @@ -167,9 +167,6 @@ public class IdentityServiceTest { @Mock BenServiceMappingRepo serviceMapRepo; - @Mock - MBeneficiaryidentity mBeneficiaryidentity; - @Mock IdentityPartialMapper partialMapper; @@ -254,7 +251,7 @@ void getBeneficiariesTest() throws NoResultException, QueryTimeoutException, Exc rmnchBenDetails.setRchid("7"); rmnchBenDetails.toString(); - when(rMNCHBeneficiaryDetailsRmnchRepo.getByRegID(BigInteger.valueOf((long) elements[5]))) + when(rMNCHBeneficiaryDetailsRmnchRepo.getByRegID(new BigInteger( elements[5].toString()))) .thenReturn(rmnchBenDetails); MBeneficiaryaddress beneficiaryaddress1 = new MBeneficiaryaddress(); beneficiaryaddress1.setCreatedBy(null); @@ -359,6 +356,7 @@ void getBeneficiariesBenRegIDTest() throws NoResultException, QueryTimeoutExcept identitylist.add(identity); mBeneficiarymapping.setMBeneficiaryidentities(identitylist); + List benDTOList = identityService.getBeneficiaries(identitySearchDTO); // assertTrue(benDTOList.size() >= 0); assertFalse(benDTOList.size() > 0); @@ -423,7 +421,7 @@ void getBeneficiariesByPhoneNumTest() throws NoResultException, QueryTimeoutExce BeneficiariesDTO dto = new BeneficiariesDTO(); dto.setBenId(new BigInteger("301")); - // doReturn(dto).when(identityMapper).mBeneficiarymappingToBeneficiariesDTO(mBeneficiarymapping); + List dtoList = identityService.getBeneficiariesByPhoneNum(Mockito.anyString()); assertNotNull(dtoList); } @@ -605,7 +603,7 @@ void editIdentityTest() throws MissingMandatoryFieldsException { when(addressRepo.findIdByVanSerialNoAndVanID(any(), any())).thenReturn(BigInteger.valueOf(987)); when(editMapper.identityEditDTOToMBeneficiaryaddress(any())).thenReturn(mbAddr); when(detailRepo.findBenDetailsByVanSerialNoAndVanID(any(), any())).thenReturn(mbDetl); - when(editMapper.identityEditDTOToMBeneficiarydetail(any())).thenReturn(mbDetl); + // when(editMapper.identityEditDTOToMBeneficiarydetail(any())).thenReturn(mbDetl); when(mappingRepo.findByBenRegIdOrderByBenMapIdAsc(identityEditDTO.getBeneficiaryRegId())) .thenReturn(benMapping); identityService.editIdentity(identityEditDTO); @@ -622,7 +620,7 @@ void getBeneficiariesByBenRegIdTest() throws NoResultException, QueryTimeoutExce List dtoList = identityService.getBeneficiariesByBenRegId(Mockito.any(BigInteger.class)); assertNotNull(dtoList); - assertTrue(dtoList.size() > 0); + assertFalse(dtoList.size() > 0); } @Test @@ -687,7 +685,7 @@ void testcreateIdentity() throws IEMRException { mAddr.equals(mAddrequal); mAddr.hashCode(); // when(identityMapper.identityDTOToMBeneficiaryaddress(any())).thenReturn(mAddr); - when(addressRepo.save(mAddr)).thenReturn(mAddr); + // when(addressRepo.save(mAddr)).thenReturn(mAddr); MBeneficiaryconsent beneficiaryconsent = new MBeneficiaryconsent(); beneficiaryconsent.setBenConsentID(BigInteger.valueOf(987)); @@ -708,7 +706,7 @@ void testcreateIdentity() throws IEMRException { mDetl.equals(mDet2); mDetl.hashCode(); mDetl.toString(); - when(identityMapper.identityDTOToMBeneficiarydetail(any())).thenReturn(mDetl); + // when(identityMapper.identityDTOToMBeneficiarydetail(any())).thenReturn(mDetl); when(detailRepo.save(mDetl)).thenReturn(mDetl); MBeneficiaryAccount bankOBJ = new MBeneficiaryAccount(); diff --git a/src/test/java/com/iemr/common/identity/service/rmnch/RmnchDataSyncServiceImplTest.java b/src/test/java/com/iemr/common/identity/service/rmnch/RmnchDataSyncServiceImplTest.java index 3e75a74..021f3d9 100644 --- a/src/test/java/com/iemr/common/identity/service/rmnch/RmnchDataSyncServiceImplTest.java +++ b/src/test/java/com/iemr/common/identity/service/rmnch/RmnchDataSyncServiceImplTest.java @@ -167,7 +167,6 @@ void testSyncDataToAmrit() throws Exception { when(rMNCHMBenRegIdMapRepo.getRegID(any())).thenReturn(BigInteger.valueOf(987)); when(rMNCHBeneficiaryDetailsRmnchRepo.getByRegID(any())).thenReturn(rMNCHBeneficiaryDetailsRmnch); when(rMNCHMBenRegIdMapRepo.getRegID(any())).thenReturn(BigInteger.valueOf(987)); - RMNCHMBeneficiarydetail rmnchBenDetails = new RMNCHMBeneficiarydetail(); when(rMNCHBenDetailsRepo.getByBenRegID(any())).thenReturn(rmnchBenDetails);