diff --git a/.github/workflows/publishAllPackages.yml b/.github/workflows/publishAllPackages.yml index ba0a9b700a8..cfd4512151f 100644 --- a/.github/workflows/publishAllPackages.yml +++ b/.github/workflows/publishAllPackages.yml @@ -2,7 +2,7 @@ name: Node.js Publish UI Packages on: push: - branches: ["develop"] + branches: ["sandbox"] paths: - "frontend/micro-ui/web/micro-ui-internals/**" diff --git a/birth-death-services/pom.xml b/birth-death-services/pom.xml index 1bf92989c68..473cc870205 100644 --- a/birth-death-services/pom.xml +++ b/birth-death-services/pom.xml @@ -48,12 +48,15 @@ 2.9.0-SNAPSHOT - - org.projectlombok - lombok - true - - + + org.projectlombok + lombok + 1.18.30 + provided + + + + org.postgresql postgresql 42.7.1 @@ -78,6 +81,26 @@ + + javax.validation + validation-api + 2.0.1.Final + + + org.hibernate.validator + hibernate-validator + 7.0.5.Final + + + org.glassfish + jakarta.el + 4.0.2 + + + net.minidev + json-smart + 2.5.0 + diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/BirthDeathApplication.java b/birth-death-services/src/main/java/org/bel/birthdeath/BirthDeathApplication.java index 9b580a77e22..44f86a6696d 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/BirthDeathApplication.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/BirthDeathApplication.java @@ -13,6 +13,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.Primary; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import com.fasterxml.jackson.databind.DeserializationFeature; @@ -33,6 +34,7 @@ public static void main(String[] args) { } @Bean + @Primary public ObjectMapper objectMapperBnd(){ return new ObjectMapper() .configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true) diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/birth/certmodel/BirthCertAppln.java b/birth-death-services/src/main/java/org/bel/birthdeath/birth/certmodel/BirthCertAppln.java index eb690d61c6e..4ab9333ebe8 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/birth/certmodel/BirthCertAppln.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/birth/certmodel/BirthCertAppln.java @@ -31,4 +31,10 @@ public class BirthCertAppln { private String tenantId; private String fileStoreId; + + private String motherName; + + private String fatherName; + + private String dateOfBirth; } diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/birth/certmodel/BirthCertificate.java b/birth-death-services/src/main/java/org/bel/birthdeath/birth/certmodel/BirthCertificate.java index 4e4e00201a2..65f5fd4bf8c 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/birth/certmodel/BirthCertificate.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/birth/certmodel/BirthCertificate.java @@ -6,8 +6,7 @@ import org.bel.birthdeath.birth.calculation.Calculation; import org.bel.birthdeath.common.model.Amount; import org.bel.birthdeath.common.model.AuditDetails; -import org.egov.common.contract.request.User; - +import org.bel.birthdeath.common.model.user.User; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/birth/model/EgBirthDtl.java b/birth-death-services/src/main/java/org/bel/birthdeath/birth/model/EgBirthDtl.java index 87231e2b00c..4ec7aa37235 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/birth/model/EgBirthDtl.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/birth/model/EgBirthDtl.java @@ -2,12 +2,16 @@ import java.sql.Timestamp; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; +import org.bel.birthdeath.common.contract.ParentInfo; +import org.bel.birthdeath.common.contract.ParentInfoProvider; +import org.bel.birthdeath.common.model.user.User; @Getter @Setter @@ -15,7 +19,8 @@ @AllArgsConstructor @NoArgsConstructor @Builder -public class EgBirthDtl{ +@JsonIgnoreProperties(ignoreUnknown = true) +public class EgBirthDtl implements ParentInfoProvider { private String id; @@ -70,7 +75,9 @@ public class EgBirthDtl{ private String hospitalid; private EgBirthFatherInfo birthFatherInfo; - + + private User user; + private EgBirthMotherInfo birthMotherInfo; private EgBirthPermaddr birthPermaddr; @@ -84,4 +91,14 @@ public class EgBirthDtl{ private String fullName; private Boolean isLegacyRecord = false; + + @Override + public String getTenantid() { + return this.tenantid; + } + + @Override + public ParentInfo getFatherInfo() { + return this.birthFatherInfo; + } } \ No newline at end of file diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/birth/model/EgBirthFatherInfo.java b/birth-death-services/src/main/java/org/bel/birthdeath/birth/model/EgBirthFatherInfo.java index 563d1ba959e..67185565a2d 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/birth/model/EgBirthFatherInfo.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/birth/model/EgBirthFatherInfo.java @@ -6,6 +6,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; +import org.bel.birthdeath.common.contract.ParentInfo; @Getter @Setter @@ -13,38 +14,33 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class EgBirthFatherInfo { +public class EgBirthFatherInfo implements ParentInfo { private String id; - private String aadharno; - private String createdby; - private Long createdtime; - private String education; - private String emailid; - private String firstname; - private String lastname; - private String middlename; - private String mobileno; - private String nationality; - private String proffession; - private String religion; - private String lastmodifiedby; - private Long lastmodifiedtime; - private String fullName; -} \ No newline at end of file + // Step 3: Implement interface methods explicitly + @Override + public String getFirstname() { + return this.firstname; + } + + @Override + public String getMobileno() { + return this.mobileno; + } +} diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/birth/repository/BirthRepository.java b/birth-death-services/src/main/java/org/bel/birthdeath/birth/repository/BirthRepository.java index db2b01f9c3c..d538240ca35 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/birth/repository/BirthRepository.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/birth/repository/BirthRepository.java @@ -205,7 +205,8 @@ public EgovPdfResp saveBirthCertPdf(BirthPdfApplicationRequest pdfApplicationReq try { SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy"); pdfApplicationRequest.getBirthCertificate().forEach(cert-> { - String uiHost = config.getUiAppHost(); + String stateLevelTenantId = centralInstanceUtil.getStateLevelTenant(cert.getTenantid()); + String uiHost = config.getUiAppHostMap().get(stateLevelTenantId); String birthCertPath = config.getBirthCertLink(); birthCertPath = birthCertPath.replace("$id",cert.getId()); birthCertPath = birthCertPath.replace("$tenantId",cert.getTenantid()); @@ -260,7 +261,7 @@ public List getBirthDtlsAll(SearchCriteria criteria ,RequestInfo req birthDtls.forEach(birthDtl -> { birthDtl.setBirthFatherInfo(encryptionDecryptionUtil.decryptObject(birthDtl.getBirthFatherInfo(), BirthDeathConstants.BND_DESCRYPT_KEY, EgBirthFatherInfo.class, requestInfo)); birthDtl.setBirthMotherInfo(encryptionDecryptionUtil.decryptObject(birthDtl.getBirthMotherInfo(), BirthDeathConstants.BND_DESCRYPT_KEY, EgBirthMotherInfo.class, requestInfo)); - commonUtils.maskAndShowLast4Chars(birthDtl); +// commonUtils.maskAndShowLast4Chars(birthDtl); }); } return birthDtls; diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/birth/repository/builder/BirthDtlAllQueryBuilder.java b/birth-death-services/src/main/java/org/bel/birthdeath/birth/repository/builder/BirthDtlAllQueryBuilder.java index 5f3b7786cc4..3c8880d6efe 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/birth/repository/builder/BirthDtlAllQueryBuilder.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/birth/repository/builder/BirthDtlAllQueryBuilder.java @@ -23,10 +23,10 @@ public class BirthDtlAllQueryBuilder { private static String QUERY_MASTER_FULL_ALL = "SELECT bdtl.id birthdtlid,bfat.id bfatid,bmot.id bmotid,bpmad.id bpmadid,bpsad.id bpsadid," + "bdtl.tenantid tenantid, registrationno, dateofbirth, counter, gender , " + - "CASE WHEN gender = '1' THEN 'Male' WHEN gender = '2' THEN 'Female' WHEN gender = '3' THEN 'Others' END AS genderstr ," + + "CASE WHEN gender = '1' THEN 'Male' WHEN gender = '2' THEN 'Female' WHEN gender = '3' THEN 'Transgender' WHEN gender = '4' THEN 'Others' END AS genderstr ," + "(select bh.hospitalname from {schema}.eg_birth_death_hospitals bh where bh.id=hospitalid) AS hospitalname, placeofbirth, dateofreport, remarks," + "hospitalid , informantsname , informantsaddress , islegacyrecord, " + - "bfat.firstname bfatfn ,bmot.firstname bmotfn , bdtl.firstname bdtlfn ," + + "bfat.firstname bfatfn , bfat.mobileno bfatfmobileno, bmot.firstname bmotfn , bdtl.firstname bdtlfn ," + "bfat.middlename bfatmn ,bmot.middlename bmotmn , bdtl.middlename bdtlmn ," + "bfat.lastname bfatln ,bmot.lastname bmotln , bdtl.lastname bdtlln ," + "bfat.aadharno bfataadharno ,bmot.aadharno bmotaadharno ," + @@ -47,9 +47,9 @@ public class BirthDtlAllQueryBuilder { "left join {schema}.eg_birth_presentaddr bpsad on bpsad.birthdtlid = bdtl.id"; private static String QUERY_MASTER_ALL = "SELECT bdtl.id birthdtlid, bdtl.tenantid tenantid, registrationno, dateofbirth, counter, gender , " - + "CASE WHEN gender = '1' THEN 'Male' WHEN gender = '2' THEN 'Female' WHEN gender = '3' THEN 'Others' END AS genderstr ," + +"CASE WHEN gender = '1' THEN 'Male' WHEN gender = '2' THEN 'Female' WHEN gender = '3' THEN 'Transgender' WHEN gender = '4' THEN 'Others' END AS genderstr ," + " (select bh.hospitalname from {schema}.eg_birth_death_hospitals bh where bh.id=hospitalid) AS hospitalname, placeofbirth, dateofreport, remarks, " - + "bfat.firstname bfatfn ,bmot.firstname bmotfn , bdtl.firstname bdtlfn ," + + "bfat.firstname bfatfn ,bfat.mobileno bfatfmobileno, bmot.firstname bmotfn , bdtl.firstname bdtlfn ," + "bfat.middlename bfatmn ,bmot.middlename bmotmn , bdtl.middlename bdtlmn ," + "bfat.lastname bfatln ,bmot.lastname bmotln , bdtl.lastname bdtlln ," + "bpmad.houseno pmhouseno,bpmad.buildingno pmbuildingno,bpmad.streetname pmstreetname,bpmad.locality pmlocality,bpmad.tehsil pmtehsil," @@ -64,20 +64,26 @@ public class BirthDtlAllQueryBuilder { "left join {schema}.eg_birth_presentaddr bpsad on bpsad.birthdtlid = bdtl.id "; private static final String QUERY_MASTER = "SELECT bdtl.id birthdtlid, tenantid, registrationno, dateofbirth, counter, gender ,hospitalname, "+ - "CASE WHEN gender = '1' THEN 'Male' WHEN gender = '2' THEN 'Female' WHEN gender = '3' THEN 'Others' END AS genderstr ," + + "CASE WHEN gender = '1' THEN 'Male' WHEN gender = '2' THEN 'Female' WHEN gender = '3' THEN 'Transgender' WHEN gender = '4' THEN 'Others' END AS genderstr ," + " (select bh.hospitalname from {schema}.eg_birth_death_hospitals bh where bh.id=hospitalid) AS hospitalname ,"+ - "bfat.firstname bfatfn ,bmot.firstname bmotfn , bdtl.firstname bdtlfn ,"+ + "bfat.firstname bfatfn ,bfat.mobileno bfatfmobileno, bmot.firstname bmotfn , bdtl.firstname bdtlfn ,"+ "bfat.middlename bfatmn ,bmot.middlename bmotmn , bdtl.middlename bdtlmn ,"+ "bfat.lastname bfatln ,bmot.lastname bmotln , bdtl.lastname bdtlln "+ "FROM {schema}.eg_birth_dtls bdtl " + "left join {schema}.eg_birth_father_info bfat on bfat.birthdtlid = bdtl.id " + "left join {schema}.eg_birth_mother_info bmot on bmot.birthdtlid = bdtl.id " ; - private static String APPLSQUERY ="select breq.birthCertificateNo, breq.createdtime, breq.status, bdtl.registrationno, bdtl.tenantid, " + private static String APPLSQUERY ="select breq.birthCertificateNo, breq.createdtime, breq.status, bdtl.registrationno, bdtl.tenantid, " + "concat(COALESCE(bdtl.firstname,'') , ' ', COALESCE(bdtl.middlename,'') ,' ', COALESCE(bdtl.lastname,'')) as name, " - + "CASE WHEN breq.lastmodifiedtime/1000 < (extract(epoch from NOW())-?*24*60*60) THEN 'EXPIRED' ELSE breq.filestoreid END as filestoreid " - + "from {schema}.eg_birth_cert_request breq left join {schema}.eg_birth_dtls bdtl on bdtl.id=breq.birthDtlId where " - + "breq.createdby=? order by breq.createdtime DESC "; + + "CASE WHEN breq.lastmodifiedtime/1000 < (extract(epoch from NOW())-?*24*60*60) THEN 'EXPIRED' ELSE breq.filestoreid END as filestoreid, " + + "concat(COALESCE(bmot.firstname,'') , ' ', COALESCE(bmot.middlename,'') ,' ', COALESCE(bmot.lastname,'')) as mothername, " + + "concat(COALESCE(bfat.firstname,'') , ' ', COALESCE(bfat.middlename,'') ,' ', COALESCE(bfat.lastname,'')) as fathername, " + + "bdtl.dateofbirth as dateofbirth " + + "from {schema}.eg_birth_cert_request breq " + + "left join {schema}.eg_birth_dtls bdtl on bdtl.id=breq.birthDtlId " + + "left join {schema}.eg_birth_mother_info bmot on bmot.birthdtlid = bdtl.id " + + "left join {schema}.eg_birth_father_info bfat on bfat.birthdtlid = bdtl.id " + + "where breq.createdby=? order by breq.createdtime DESC "; private static final String PAGINATIONWRAPPER = "SELECT * FROM " + "(SELECT *, DENSE_RANK() OVER (ORDER BY dateofbirth DESC , birthdtlid) offset_ FROM " + diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/birth/repository/rowmapper/BirthCertApplnRowMapper.java b/birth-death-services/src/main/java/org/bel/birthdeath/birth/repository/rowmapper/BirthCertApplnRowMapper.java index 89660469fc3..42bac1c1579 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/birth/repository/rowmapper/BirthCertApplnRowMapper.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/birth/repository/rowmapper/BirthCertApplnRowMapper.java @@ -2,7 +2,10 @@ import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Timestamp; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -19,15 +22,47 @@ public class BirthCertApplnRowMapper implements ResultSetExtractor extractData(ResultSet rs) throws SQLException, DataAccessException { Map birthDtlMap = new LinkedHashMap<>(); + SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy"); try { while (rs.next()) { String applNo = rs.getString("birthCertificateNo"); BirthCertAppln certReq = birthDtlMap.get(applNo); if (certReq == null) { - certReq = BirthCertAppln.builder().applicationNumber(rs.getString("birthCertificateNo")).applicationDate(rs.getString("createdtime")) - .status(rs.getString("status")).regNo(rs.getString("registrationno")).tenantId(rs.getString("tenantid")).name(rs.getString("name")) - .applicationCategory("Birth").applicationType("CERT_DOWNLOAD").fileStoreId(rs.getString("filestoreid")) + // Format application date + String applicationDate = rs.getString("createdtime"); + + // Get date of birth in epoch format + String dateOfBirth = "NA"; + Timestamp dobTimestamp = rs.getTimestamp("dateofbirth"); + if (dobTimestamp != null) { + dateOfBirth = String.valueOf(dobTimestamp.getTime()); + } + + // Get parent names + String motherName = rs.getString("mothername"); + if (motherName == null || motherName.trim().isEmpty()) { + motherName = "NA"; + } + + String fatherName = rs.getString("fathername"); + if (fatherName == null || fatherName.trim().isEmpty()) { + fatherName = "NA"; + } + + certReq = BirthCertAppln.builder() + .applicationCategory("Birth") + .applicationType("CERT_DOWNLOAD") + .applicationNumber(applNo) + .applicationDate(applicationDate) + .regNo(rs.getString("registrationno")) + .name(rs.getString("name")) + .status(rs.getString("status")) + .tenantId(rs.getString("tenantid")) + .fileStoreId(rs.getString("filestoreid")) + .motherName(motherName) + .fatherName(fatherName) + .dateOfBirth(dateOfBirth) .build(); birthDtlMap.put(applNo, certReq); } @@ -40,4 +75,4 @@ public List extractData(ResultSet rs) throws SQLException, DataA return new ArrayList<> (birthDtlMap.values()); } -} +} \ No newline at end of file diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/birth/repository/rowmapper/BirthDtlsAllRowMapper.java b/birth-death-services/src/main/java/org/bel/birthdeath/birth/repository/rowmapper/BirthDtlsAllRowMapper.java index 73dad08cf30..7d8e3aca3fa 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/birth/repository/rowmapper/BirthDtlsAllRowMapper.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/birth/repository/rowmapper/BirthDtlsAllRowMapper.java @@ -35,7 +35,7 @@ public List extractData(ResultSet rs) throws SQLException, DataAcces .aadharno(rs.getString("bmotaadharno")).build(); motherInfo.setFullName(utils.addfullName(motherInfo.getFirstname(),motherInfo.getMiddlename(),motherInfo.getLastname())); - EgBirthFatherInfo fatherInfo = EgBirthFatherInfo.builder().firstname(rs.getString("bfatfn")).middlename(rs.getString("bfatmn")).lastname(rs.getString("bfatln")) + EgBirthFatherInfo fatherInfo = EgBirthFatherInfo.builder().firstname(rs.getString("bfatfn")).middlename(rs.getString("bfatmn")).lastname(rs.getString("bfatln")).mobileno(rs.getString("bfatfmobileno")) .aadharno(rs.getString("bfataadharno")).build(); fatherInfo.setFullName(utils.addfullName(fatherInfo.getFirstname(),fatherInfo.getMiddlename(),fatherInfo.getLastname())); @@ -52,7 +52,7 @@ public List extractData(ResultSet rs) throws SQLException, DataAcces presentaddr.getDistrict(),presentaddr.getCity(),presentaddr.getState(),presentaddr.getPinno(),presentaddr.getCountry())); birthDtl = EgBirthDtl.builder().id(birthdtlid).registrationno(rs.getString("registrationno")).hospitalname(rs.getString("hospitalname")).dateofreport(rs.getTimestamp("dateofreport")).gender(rs.getInt("gender")) - .dateofbirth(rs.getTimestamp("dateofbirth")).counter(rs.getInt("counter")).genderStr(rs.getString("genderstr")).tenantid(rs.getString("tenantid")).dateofissue(System.currentTimeMillis()) + .dateofbirth(rs.getTimestamp("dateofbirth")).counter(rs.getInt("counter")).genderStr(rs.getString("genderstr")).tenantid(rs.getString("tenantid")).dateofissue(rs.getTimestamp("dateofreport") != null ? rs.getTimestamp("dateofreport").getTime() : System.currentTimeMillis()) .firstname(rs.getString("bdtlfn")).middlename(rs.getString("bdtlmn")).lastname(rs.getString("bdtlln")).birthMotherInfo(motherInfo).birthFatherInfo(fatherInfo) .birthPermaddr(permaddr).birthPresentaddr(presentaddr).placeofbirth(rs.getString("placeofbirth")).remarks(rs.getString("remarks")) .build(); diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/birth/service/BirthService.java b/birth-death-services/src/main/java/org/bel/birthdeath/birth/service/BirthService.java index fc80620d711..e051f6dcca2 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/birth/service/BirthService.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/birth/service/BirthService.java @@ -1,10 +1,9 @@ package org.bel.birthdeath.birth.service; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.bel.birthdeath.birth.certmodel.BirthCertAppln; @@ -12,6 +11,8 @@ import org.bel.birthdeath.birth.certmodel.BirthCertificate; import org.bel.birthdeath.birth.certmodel.BirthCertificate.StatusEnum; import org.bel.birthdeath.birth.model.EgBirthDtl; +import org.bel.birthdeath.birth.model.EgBirthFatherInfo; +import org.bel.birthdeath.birth.model.EgBirthMotherInfo; import org.bel.birthdeath.birth.model.SearchCriteria; import org.bel.birthdeath.birth.repository.BirthRepository; import org.bel.birthdeath.birth.validator.BirthValidator; @@ -20,12 +21,15 @@ import org.bel.birthdeath.common.calculation.collections.models.PaymentResponse; import org.bel.birthdeath.common.calculation.collections.models.PaymentSearchCriteria; import org.bel.birthdeath.common.consumer.ReceiptConsumer; -import org.bel.birthdeath.common.contract.BirthPdfApplicationRequest; -import org.bel.birthdeath.common.contract.EgovPdfResp; -import org.bel.birthdeath.common.contract.RequestInfoWrapper; +import org.bel.birthdeath.common.contract.*; import org.bel.birthdeath.common.model.AuditDetails; +import org.bel.birthdeath.common.model.user.User; +import org.bel.birthdeath.common.model.user.UserDetailResponse; import org.bel.birthdeath.common.repository.ServiceRequestRepository; +import org.bel.birthdeath.common.services.UserService; import org.bel.birthdeath.config.BirthDeathConfiguration; +import org.bel.birthdeath.death.model.EgDeathDtl; +import org.bel.birthdeath.utils.BirthDeathConstants; import org.bel.birthdeath.utils.CommonUtils; import org.egov.common.contract.request.RequestInfo; import org.egov.tracer.model.CustomException; @@ -51,6 +55,9 @@ public class BirthService { @Autowired BirthValidator validator; + + @Autowired + private EncryptionDecryptionUtil encryptionDecryptionUtil; @Autowired EnrichmentService enrichmentService; @@ -66,6 +73,9 @@ public class BirthService { @Autowired ReceiptConsumer consumer; + + @Autowired + UserService userService; public List search(SearchCriteria criteria, RequestInfo requestInfo) { List birthDtls = new ArrayList<>() ; @@ -79,6 +89,44 @@ public List search(SearchCriteria criteria, RequestInfo requestInfo) birthDtls = repository.getBirthDtls(criteria); } } + + // ✅ Decrypt full list + if (!birthDtls.isEmpty()) { + // Decrypt top-level fields like aadharno, icdcode + birthDtls = encryptionDecryptionUtil.decryptObject(birthDtls, "BndDetail", EgBirthDtl.class, requestInfo); + + // Explicitly decrypt nested parent info + for (EgBirthDtl btl : birthDtls) { + if (btl.getBirthFatherInfo() != null) { + btl.setBirthFatherInfo(encryptionDecryptionUtil.decryptObject(btl.getBirthFatherInfo(), + BirthDeathConstants.BND_DESCRYPT_KEY, EgBirthFatherInfo.class, requestInfo)); + } + + if (btl.getBirthMotherInfo() != null) { + btl.setBirthMotherInfo(encryptionDecryptionUtil.decryptObject(btl.getBirthMotherInfo(), + BirthDeathConstants.BND_DESCRYPT_KEY, EgBirthMotherInfo.class, requestInfo)); + } + } + } + + + if (!birthDtls.isEmpty()) { + UserDetailResponse userDetailResponse = userService.getOwners(birthDtls, requestInfo); + + if (userDetailResponse != null && userDetailResponse.getUser() != null) { + Map mobileToUserMap = userDetailResponse.getUser().stream() + .filter(user -> user.getMobileNumber() != null) + .collect(Collectors.toMap(User::getMobileNumber, Function.identity(), (u1, u2) -> u1)); // avoid duplicates + + for (EgBirthDtl btl : birthDtls) { + ParentInfo fatherInfo = btl.getFatherInfo(); + if (fatherInfo != null && fatherInfo.getMobileno() != null) { + User user = mobileToUserMap.get(fatherInfo.getMobileno()); + if (user != null) btl.setUser(user); + } + } + } + } return birthDtls; } @@ -94,6 +142,8 @@ public BirthCertificate download(SearchCriteria criteria, RequestInfo requestInf birthCertificate.setTenantId(criteria.getTenantId()); BirthCertRequest birthCertRequest = BirthCertRequest.builder().birthCertificate(birthCertificate).requestInfo(requestInfo).build(); List birtDtls = repository.getBirthDtlsAll(criteria,requestInfo); + UserDetailResponse userDetailResponse = userService.getOwners(birtDtls, requestInfo); + birtDtls.get(0).setUser(userDetailResponse.getUser().get(0)); birthCertificate.setBirthPlace(birtDtls.get(0).getPlaceofbirth()); birthCertificate.setGender(birtDtls.get(0).getGenderStr()); birthCertificate.setWard(birtDtls.get(0).getBirthPermaddr().getTehsil()); @@ -110,7 +160,7 @@ public BirthCertificate download(SearchCriteria criteria, RequestInfo requestInf enrichmentService.enrichCreateRequest(birthCertRequest); enrichmentService.setIdgenIds(birthCertRequest); if(birtDtls.get(0).getCounter()>0){ - enrichmentService.setDemandParams(birthCertRequest); + enrichmentService.setDemandParams(birthCertRequest,birtDtls); enrichmentService.setGLCode(birthCertRequest); calculationService.addCalculation(birthCertRequest); birthCertificate.setApplicationStatus(StatusEnum.ACTIVE); diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/birth/service/DemandService.java b/birth-death-services/src/main/java/org/bel/birthdeath/birth/service/DemandService.java index d2cd7076b6e..9ddcda94729 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/birth/service/DemandService.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/birth/service/DemandService.java @@ -10,11 +10,11 @@ import org.bel.birthdeath.common.calculation.demand.models.DemandDetail; import org.bel.birthdeath.common.repository.DemandRepository; import org.egov.common.contract.request.RequestInfo; -import org.egov.common.contract.request.User; import org.egov.tracer.model.CustomException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import org.bel.birthdeath.common.model.user.User; diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/birth/service/EnrichmentService.java b/birth-death-services/src/main/java/org/bel/birthdeath/birth/service/EnrichmentService.java index 990f81d1433..cbc8a487ea0 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/birth/service/EnrichmentService.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/birth/service/EnrichmentService.java @@ -1,5 +1,6 @@ package org.bel.birthdeath.birth.service; +import static org.bel.birthdeath.common.util.UserUtil.convertToCustomUser; import static org.bel.birthdeath.utils.BirthDeathConstants.*; import java.math.BigDecimal; @@ -12,12 +13,14 @@ import org.bel.birthdeath.birth.certmodel.BirthCertRequest; import org.bel.birthdeath.birth.certmodel.BirthCertificate; +import org.bel.birthdeath.birth.model.EgBirthDtl; import org.bel.birthdeath.common.Idgen.IdResponse; import org.bel.birthdeath.common.model.Amount; import org.bel.birthdeath.common.model.AuditDetails; import org.bel.birthdeath.common.repository.IdGenRepository; import org.bel.birthdeath.common.repository.ServiceRequestRepository; import org.bel.birthdeath.config.BirthDeathConfiguration; +import org.bel.birthdeath.death.model.EgDeathDtl; import org.bel.birthdeath.utils.CommonUtils; import org.egov.common.contract.request.RequestInfo; import org.egov.mdms.model.MasterDetail; @@ -104,7 +107,7 @@ private ModuleDetail getGLCodeRequest() { .moduleName(BILLING_SERVICE).build(); } - public void setDemandParams(BirthCertRequest birthCertRequest) { + public void setDemandParams(BirthCertRequest birthCertRequest ,List birtDtls) { BirthCertificate birthCert = birthCertRequest.getBirthCertificate(); birthCert.setBusinessService(BIRTH_CERT); ArrayList amounts = new ArrayList<>(); @@ -113,7 +116,11 @@ public void setDemandParams(BirthCertRequest birthCertRequest) { amount.setAmount(new BigDecimal(50)); amounts.add(amount); birthCert.setAmount(amounts); - birthCert.setCitizen(birthCertRequest.getRequestInfo().getUserInfo()); + if (birthCertRequest.getRequestInfo().getUserInfo().getType().equalsIgnoreCase("CITIZEN")) + birthCert.setCitizen(convertToCustomUser(birthCertRequest.getRequestInfo().getUserInfo())); + else + birthCert.setCitizen(birtDtls.get(0).getUser()); + birthCert.setTaxPeriodFrom(System.currentTimeMillis()); birthCert.setTaxPeriodTo(System.currentTimeMillis()+86400000); } diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/birth/validator/BirthValidator.java b/birth-death-services/src/main/java/org/bel/birthdeath/birth/validator/BirthValidator.java index ffe7a9b0b07..15b9afcd133 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/birth/validator/BirthValidator.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/birth/validator/BirthValidator.java @@ -201,7 +201,7 @@ public boolean validateImportFields(EgBirthDtl birthDtl,ImportBirthWrapper impor importBirthWrapper.setServiceError(BirthDeathConstants.PERMENANT_PINCODE_EMPTY); return false; } - if(birthDtl.getGender().intValue()!=1 && birthDtl.getGender().intValue()!=2 && birthDtl.getGender().intValue()!=3 ) { + if(birthDtl.getGender().intValue()!=1 && birthDtl.getGender().intValue()!=2 && birthDtl.getGender().intValue()!=3 && birthDtl.getGender().intValue()!=4 ) { setRejectionReason(BirthDeathConstants.GENDER_INVALID,birthDtl,importBirthWrapper); importBirthWrapper.setServiceError(BirthDeathConstants.GENDER_INVALID); return false; diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/common/calculation/demand/models/Demand.java b/birth-death-services/src/main/java/org/bel/birthdeath/common/calculation/demand/models/Demand.java index 52bed5f5f06..e65362a9b09 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/common/calculation/demand/models/Demand.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/common/calculation/demand/models/Demand.java @@ -7,7 +7,6 @@ import jakarta.validation.Valid; import org.bel.birthdeath.common.model.AuditDetails; -import org.egov.common.contract.request.User; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -17,6 +16,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.bel.birthdeath.common.model.user.User; /** * A Object which holds the basic info about the revenue assessment for which the org.bel.birthdeath.common.calculation.demand.models is generated like module name, consumercode, owner, etc. diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/common/config/CommonConfiguration.java b/birth-death-services/src/main/java/org/bel/birthdeath/common/config/CommonConfiguration.java new file mode 100644 index 00000000000..2be595fd45c --- /dev/null +++ b/birth-death-services/src/main/java/org/bel/birthdeath/common/config/CommonConfiguration.java @@ -0,0 +1,39 @@ +package org.bel.birthdeath.common.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Component +public class CommonConfiguration { + + // User Configuration + @Value("${egov.user.host}") + private String userHost; + + @Value("${egov.user.context.path}") + private String userContextPath; + + @Value("${egov.user.create.path}") + private String userCreateEndpoint; + + @Value("${egov.user.search.path}") + private String userSearchEndpoint; + + @Value("${egov.user.update.path}") + private String userUpdateEndpoint; + + @Value("${egov.user.username.prefix}") + private String usernamePrefix; + +} diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/common/consumer/ReceiptConsumer.java b/birth-death-services/src/main/java/org/bel/birthdeath/common/consumer/ReceiptConsumer.java index e7f26a638df..d481694b5f3 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/common/consumer/ReceiptConsumer.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/common/consumer/ReceiptConsumer.java @@ -130,6 +130,7 @@ public DeathCertificate updateDeathPDFGEN(RequestInfo requestInfo, DeathCertific if(deathCertificate.getApplicationStatus().equals(org.bel.birthdeath.death.certmodel.DeathCertificate.StatusEnum.PAID)) { org.bel.birthdeath.death.model.SearchCriteria criteria=new org.bel.birthdeath.death.model.SearchCriteria(); criteria.setId(deathCertificate.getDeathDtlId()); + criteria.setTenantId(deathCertificate.getTenantId()); List deathDtls = repositoryDeath.getDeathDtlsAll(criteria,requestInfo); if(deathDtls.size()>1) throw new CustomException("Invalid_Input","Error in processing data"); @@ -179,6 +180,7 @@ public BirthCertificate updateBirthPDFGEN(RequestInfo requestInfo, BirthCertifi if(birthCertificate.getApplicationStatus().equals(StatusEnum.PAID)) { SearchCriteria criteria=new SearchCriteria(); criteria.setId(birthCertificate.getBirthDtlId()); + criteria.setTenantId(birthCertificate.getTenantId()); List birtDtls = repository.getBirthDtlsAll(criteria,requestInfo); if(birtDtls.size()>1) throw new CustomException("Invalid_Input","Error in processing data"); diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/common/contract/DeathResponse.java b/birth-death-services/src/main/java/org/bel/birthdeath/common/contract/DeathResponse.java index 10296c0fa00..4acbfc08c06 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/common/contract/DeathResponse.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/common/contract/DeathResponse.java @@ -16,22 +16,21 @@ import lombok.NoArgsConstructor; import lombok.Setter; - @Getter @Setter @AllArgsConstructor @NoArgsConstructor @Builder -public class DeathResponse { - - @JsonProperty("RequestInfo") - private RequestInfo requestInfo; - @JsonProperty("ResponseInfo") - private ResponseInfo responseInfo = null; - - @JsonProperty("deathCerts") - @Valid - private List deathCerts = null; - -} +public class DeathResponse { + + @JsonProperty("RequestInfo") + private RequestInfo requestInfo; + @JsonProperty("ResponseInfo") + private ResponseInfo responseInfo = null; + + @JsonProperty("deathCerts") + @Valid + private List deathCerts = null; + +} diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/common/contract/ParentInfo.java b/birth-death-services/src/main/java/org/bel/birthdeath/common/contract/ParentInfo.java new file mode 100644 index 00000000000..8c3ca98a0d6 --- /dev/null +++ b/birth-death-services/src/main/java/org/bel/birthdeath/common/contract/ParentInfo.java @@ -0,0 +1,6 @@ +package org.bel.birthdeath.common.contract; + +public interface ParentInfo { + String getFirstname(); + String getMobileno(); +} diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/common/contract/ParentInfoProvider.java b/birth-death-services/src/main/java/org/bel/birthdeath/common/contract/ParentInfoProvider.java new file mode 100644 index 00000000000..fbf762dab25 --- /dev/null +++ b/birth-death-services/src/main/java/org/bel/birthdeath/common/contract/ParentInfoProvider.java @@ -0,0 +1,7 @@ +package org.bel.birthdeath.common.contract; + +public interface ParentInfoProvider { + String getTenantid(); + ParentInfo getFatherInfo(); +} + diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/common/model/user/User.java b/birth-death-services/src/main/java/org/bel/birthdeath/common/model/user/User.java new file mode 100644 index 00000000000..70b0ccdae1e --- /dev/null +++ b/birth-death-services/src/main/java/org/bel/birthdeath/common/model/user/User.java @@ -0,0 +1,178 @@ +package org.bel.birthdeath.common.model.user; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import javax.validation.Valid; +import javax.validation.constraints.Pattern; +import javax.validation.constraints.Size; + +import org.egov.common.contract.request.Role; +import org.springframework.validation.annotation.Validated; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Validated +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class User { + + @JsonProperty("id") + private Long id; + + @Size(max=64) + @JsonProperty("uuid") + private String uuid; + + @Size(max=64) + @JsonProperty("userName") + private String userName; + + + @Size(min=1,max=64) + @Pattern(regexp = "^[a-zA-Z \\-'`\\.]*$", message = "Invalid name. Only alphabets and special characters -, ',`, .") + @JsonProperty("name") + private String name; + + @Size(max=64) + @JsonProperty("password") + private String password; + + @Size(max=64) + @JsonProperty("mobileNumber") + private String mobileNumber; + + @Size(max=64) + @JsonProperty("tenantId") + private String tenantId; + + @JsonProperty("salutation") + private String salutation; + + @Size(max=128) + @JsonProperty("emailId") + private String emailId; + + @Size(max=50) + @JsonProperty("altContactNumber") + private String altContactNumber; + + @Size(max=10) + @JsonProperty("pan") + private String pan; + + @Pattern(regexp = "^[0-9]{12}$", message = "AdharNumber should be 12 digit number") + @JsonProperty("aadhaarNumber") + private String aadhaarNumber; + + @Size(max=300) + @JsonProperty("permanentAddress") + private String permanentAddress; + + @Size(max=300) + @JsonProperty("permanentCity") + private String permanentCity; + + @Size(max=10) + @JsonProperty("permanentPinCode") + private String permanentPincode; + + @Size(max=300) + @JsonProperty("correspondenceCity") + private String correspondenceCity; + + @Size(max=10) + @JsonProperty("correspondencePinCode") + private String correspondencePincode; + + @JsonProperty("active") + private Boolean active; + + @JsonProperty("dob") + private Long dob; + + @JsonProperty("pwdExpiryDate") + private Long pwdExpiryDate; + + @Size(max=16) + @JsonProperty("locale") + private String locale; + + @Size(max=50) + @JsonProperty("type") + private String type; + + @JsonProperty("signature") + private String signature; + + @JsonProperty("accountLocked") + private Boolean accountLocked; + + @JsonProperty("roles") + @Valid + private List roles; + + @Size(max=32) + @JsonProperty("bloodGroup") + private String bloodGroup; + + @JsonProperty("identificationMark") + private String identificationMark; + + @JsonProperty("photo") + private String photo; + + @Size(max=64) + @JsonProperty("createdBy") + private String createdBy; + + @JsonProperty("createdDate") + private Long createdDate; + + @Size(max=64) + @JsonProperty("lastModifiedBy") + private String lastModifiedBy; + + @JsonProperty("lastModifiedDate") + private Long lastModifiedDate; + + @JsonProperty("otpReference") + private String otpReference; + + @JsonProperty("gender") + private String gender; + + public User addRolesItem(Role rolesItem) { + if (this.roles == null) { + this.roles = new ArrayList<>(); + } + this.roles.add(rolesItem); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + User user = (User) o; + return Objects.equals(emailId, user.emailId); +// Objects.equals(dob, user.dob) && //Epoch format not converting properly from UI + + } + + @Override + public int hashCode() { + + return Objects.hash(uuid); + } +} diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/common/model/user/UserDetailResponse.java b/birth-death-services/src/main/java/org/bel/birthdeath/common/model/user/UserDetailResponse.java new file mode 100644 index 00000000000..65098e4d68b --- /dev/null +++ b/birth-death-services/src/main/java/org/bel/birthdeath/common/model/user/UserDetailResponse.java @@ -0,0 +1,22 @@ +package org.bel.birthdeath.common.model.user; + +import java.util.List; + +import lombok.*; +import org.egov.common.contract.response.ResponseInfo; + +import com.fasterxml.jackson.annotation.JsonProperty; + +@AllArgsConstructor +@NoArgsConstructor +@Getter +@Setter +@Builder +public class UserDetailResponse { + + @JsonProperty("responseInfo") + ResponseInfo responseInfo; + + @JsonProperty("user") + List user; +} diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/common/model/user/UserRequest.java b/birth-death-services/src/main/java/org/bel/birthdeath/common/model/user/UserRequest.java new file mode 100644 index 00000000000..b78d7750b77 --- /dev/null +++ b/birth-death-services/src/main/java/org/bel/birthdeath/common/model/user/UserRequest.java @@ -0,0 +1,25 @@ +package org.bel.birthdeath.common.model.user; + +import org.egov.common.contract.request.RequestInfo; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@AllArgsConstructor +@Getter +@Setter +@NoArgsConstructor +@Builder +public class UserRequest { + + @JsonProperty("requestInfo") + private RequestInfo requestInfo; + + @JsonProperty("user") + private User user; + +} diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/common/model/user/UserSearchRequest.java b/birth-death-services/src/main/java/org/bel/birthdeath/common/model/user/UserSearchRequest.java new file mode 100644 index 00000000000..ed7e716c961 --- /dev/null +++ b/birth-death-services/src/main/java/org/bel/birthdeath/common/model/user/UserSearchRequest.java @@ -0,0 +1,79 @@ +package org.bel.birthdeath.common.model.user; + +import java.util.Collections; +import java.util.List; + +import org.egov.common.contract.request.RequestInfo; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@AllArgsConstructor +@EqualsAndHashCode +@Getter +@NoArgsConstructor +@Setter +@ToString +@Builder +public class UserSearchRequest { + + @JsonProperty("RequestInfo") + private RequestInfo requestInfo; + + @JsonProperty("uuid") + private List uuid; + + @JsonProperty("id") + private List id; + + @JsonProperty("userName") + private String userName; + + @JsonProperty("name") + private String name; + + @JsonProperty("mobileNumber") + private String mobileNumber; + + @JsonProperty("aadhaarNumber") + private String aadhaarNumber; + + @JsonProperty("pan") + private String pan; + + @JsonProperty("emailId") + private String emailId; + + @JsonProperty("fuzzyLogic") + private boolean fuzzyLogic; + + @JsonProperty("active") + @Setter + private Boolean active; + + @JsonProperty("tenantId") + private String tenantId; + + @JsonProperty("pageSize") + private int pageSize; + + @JsonProperty("pageNumber") + private int pageNumber = 0; + + @JsonProperty("sort") + private List sort = Collections.singletonList("name"); + + @JsonProperty("userType") + private String userType; + + @JsonProperty("roleCodes") + private List roleCodes; + +} diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/common/repository/CommonRepository.java b/birth-death-services/src/main/java/org/bel/birthdeath/common/repository/CommonRepository.java index 938f4679b9c..6bc9083155b 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/common/repository/CommonRepository.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/common/repository/CommonRepository.java @@ -1,6 +1,5 @@ package org.bel.birthdeath.common.repository; - import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -22,9 +21,11 @@ import org.bel.birthdeath.common.contract.EncryptionDecryptionUtil; import org.bel.birthdeath.common.model.AuditDetails; import org.bel.birthdeath.common.model.EgHospitalDtl; +import org.bel.birthdeath.common.model.user.User; import org.bel.birthdeath.common.repository.builder.CommonQueryBuilder; import org.bel.birthdeath.common.repository.rowmapper.CommonRowMapper; import org.bel.birthdeath.common.services.CommonService; +import org.bel.birthdeath.common.services.UserService; import org.bel.birthdeath.death.model.EgDeathDtl; import org.bel.birthdeath.death.model.EgDeathFatherInfo; import org.bel.birthdeath.death.model.EgDeathMotherInfo; @@ -45,995 +46,1101 @@ import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.stereotype.Repository; +import org.bel.birthdeath.config.BirthDeathConfiguration; +import org.bel.birthdeath.common.Idgen.IdGenerationResponse; import lombok.extern.slf4j.Slf4j; @Slf4j @Repository public class CommonRepository { - - @Autowired + + @Autowired private JdbcTemplate jdbcTemplate; - - @Autowired - private CommonQueryBuilder queryBuilder; - - @Autowired - private CommonRowMapper rowMapper; - - @Autowired - private NamedParameterJdbcTemplate namedParameterJdbcTemplate; - - @Autowired - private CommonUtils commUtils; - - @Autowired - BirthValidator birthValidator; - - @Autowired - DeathValidator deathValidator; - - private CommonService commonService; - - @Autowired - EncryptionDecryptionUtil encryptionDecryptionUtil; - - @Autowired - private MultiStateInstanceUtil centralInstanceUtil; - - @Autowired - @Lazy - public CommonRepository(CommonService commonService) { - this.commonService = commonService; - } - - private static final String BIRTHDTLDELETEQRY="Delete from {schema}.eg_birth_dtls where tenantid = :tenantid and registrationno = :registrationno; "; - - private static final String DEATHDTLDELETEQRY="Delete from {schema}.eg_death_dtls where tenantid = :tenantid and registrationno = :registrationno; "; - - private static final String BIRTHDTLSAVEQRY="INSERT INTO {schema}.eg_birth_dtls(id, registrationno, hospitalname, dateofreport, " - + "dateofbirth, firstname, middlename, lastname, placeofbirth, informantsname, informantsaddress, " - + "createdtime, createdby, lastmodifiedtime, lastmodifiedby, counter, tenantid, gender, remarks, hospitalid, islegacyrecord) " - + "VALUES (:id, :registrationno, :hospitalname, :dateofreport, :dateofbirth, :firstname, :middlename, :lastname, " - + ":placeofbirth, :informantsname, :informantsaddress, :createdtime, :createdby, :lastmodifiedtime, " - + ":lastmodifiedby, :counter, :tenantid, :gender, :remarks, :hospitalid, :islegacyrecord); "; - - private static final String BIRTHFATHERINFOSAVEQRY="INSERT INTO {schema}.eg_birth_father_info( id, firstname, middlename, lastname, aadharno, " - + "emailid, mobileno, education, proffession, nationality, religion, createdtime, createdby, lastmodifiedtime, lastmodifiedby, birthdtlid) " - + "VALUES (:id, :firstname, :middlename, :lastname, :aadharno, :emailid, :mobileno, :education, :proffession, :nationality," - + " :religion, :createdtime, :createdby, :lastmodifiedtime, :lastmodifiedby, :birthdtlid);"; - - private static final String BIRTHMOTHERINFOSAVEQRY="INSERT INTO {schema}.eg_birth_mother_info(id, firstname, middlename, lastname, aadharno, " - + "emailid, mobileno, education, proffession, nationality, religion, createdtime, createdby, lastmodifiedtime, lastmodifiedby, birthdtlid) " - + "VALUES (:id, :firstname, :middlename, :lastname, :aadharno, :emailid, :mobileno, :education, :proffession, :nationality," - + " :religion, :createdtime, :createdby, :lastmodifiedtime, :lastmodifiedby, :birthdtlid);"; - - private static final String BIRTHPERMADDRSAVEQRY="INSERT INTO {schema}.eg_birth_permaddr(id, buildingno, houseno, streetname, locality, tehsil, " - + "district, city, state, pinno, country, createdby, createdtime, lastmodifiedby, lastmodifiedtime, birthdtlid) " - + "VALUES (:id, :buildingno, :houseno, :streetname, :locality, :tehsil, :district, :city, :state, :pinno, :country," - + " :createdby, :createdtime, :lastmodifiedby, :lastmodifiedtime, :birthdtlid);"; - - private static final String BIRTHPRESENTADDRSAVEQRY="INSERT INTO {schema}.eg_birth_presentaddr(id, buildingno, houseno, streetname, locality, tehsil, " - + "district, city, state, pinno, country, createdby, createdtime, lastmodifiedby, lastmodifiedtime, birthdtlid) " - + "VALUES (:id, :buildingno, :houseno, :streetname, :locality, :tehsil, :district, :city, :state, :pinno, :country, " - + ":createdby, :createdtime, :lastmodifiedby, :lastmodifiedtime, :birthdtlid);"; - - private static final String DEATHDTLSAVEQRY="INSERT INTO {schema}.eg_death_dtls(id, registrationno, hospitalname, dateofreport, " - + "dateofdeath, firstname, middlename, lastname, placeofdeath, informantsname, informantsaddress, " - + "createdtime, createdby, lastmodifiedtime, lastmodifiedby, counter, tenantid, gender, remarks, hospitalid, age, eidno, aadharno, nationality, religion, icdcode, islegacyrecord) " - + "VALUES (:id, :registrationno, :hospitalname, :dateofreport, :dateofdeath, :firstname, :middlename, :lastname, " - + ":placeofdeath, :informantsname, :informantsaddress, :createdtime, :createdby, :lastmodifiedtime, " - + ":lastmodifiedby, :counter, :tenantid, :gender, :remarks, :hospitalid, :age, :eidno, :aadharno, :nationality, :religion, :icdcode, :islegacyrecord); "; - - private static final String DEATHFATHERINFOSAVEQRY="INSERT INTO {schema}.eg_death_father_info( id, firstname, middlename, lastname, aadharno, " - + "emailid, mobileno, createdtime, createdby, lastmodifiedtime, lastmodifiedby, deathdtlid) " - + "VALUES (:id, :firstname, :middlename, :lastname, :aadharno, :emailid, :mobileno, :createdtime, :createdby, :lastmodifiedtime, :lastmodifiedby, :deathdtlid);"; - - private static final String DEATHMOTHERINFOSAVEQRY="INSERT INTO {schema}.eg_death_mother_info(id, firstname, middlename, lastname, aadharno, " - + "emailid, mobileno, createdtime, createdby, lastmodifiedtime, lastmodifiedby, deathdtlid) " - + "VALUES (:id, :firstname, :middlename, :lastname, :aadharno, :emailid, :mobileno, :createdtime, :createdby, :lastmodifiedtime, :lastmodifiedby, :deathdtlid);"; - - private static final String DEATHSPOUSEINFOSAVEQRY="INSERT INTO {schema}.eg_death_spouse_info(id, firstname, middlename, lastname, aadharno, " - + "emailid, mobileno, createdtime, createdby, lastmodifiedtime, lastmodifiedby, deathdtlid) " - + "VALUES (:id, :firstname, :middlename, :lastname, :aadharno, :emailid, :mobileno, :createdtime, :createdby, :lastmodifiedtime, :lastmodifiedby, :deathdtlid);"; - - private static final String DEATHPERMADDRSAVEQRY="INSERT INTO {schema}.eg_death_permaddr(id, buildingno, houseno, streetname, locality, tehsil, " - + "district, city, state, pinno, country, createdby, createdtime, lastmodifiedby, lastmodifiedtime, deathdtlid) " - + "VALUES (:id, :buildingno, :houseno, :streetname, :locality, :tehsil, :district, :city, :state, :pinno, :country," - + " :createdby, :createdtime, :lastmodifiedby, :lastmodifiedtime, :deathdtlid);"; - - private static final String DEATHPRESENTADDRSAVEQRY="INSERT INTO {schema}.eg_death_presentaddr(id, buildingno, houseno, streetname, locality, tehsil, " - + "district, city, state, pinno, country, createdby, createdtime, lastmodifiedby, lastmodifiedtime, deathdtlid) " - + "VALUES (:id, :buildingno, :houseno, :streetname, :locality, :tehsil, :district, :city, :state, :pinno, :country, " - + ":createdby, :createdtime, :lastmodifiedby, :lastmodifiedtime, :deathdtlid);"; - - private static final String HOSPITALINSERTSQL="INSERT INTO {schema}.eg_birth_death_hospitals(id, hospitalname, tenantid) VALUES " - + " (?, ?, ?) ;"; - - private static final String BIRTHDTLUPDATEQRY="UPDATE {schema}.eg_birth_dtls SET registrationno = :registrationno, hospitalname = :hospitalname, dateofreport = :dateofreport, " - + "dateofbirth = :dateofbirth , firstname= :firstname, middlename = :middlename, lastname = :lastname, placeofbirth= :placeofbirth, informantsname = :informantsname, " - + "informantsaddress = :informantsaddress, lastmodifiedtime = :lastmodifiedtime, lastmodifiedby= :lastmodifiedby, gender = :gender, remarks = :remarks, " - + "hospitalid = :hospitalid, islegacyrecord =:islegacyrecord WHERE id = :id;"; - - private static final String BIRTHFATHERINFOUPDATEQRY="UPDATE {schema}.eg_birth_father_info SET firstname = :firstname, middlename = :middlename, lastname = :lastname, " - + "aadharno = :aadharno, emailid = :emailid, mobileno = :mobileno, education = :education, proffession = :proffession, nationality = :nationality, " - + "religion = :religion, lastmodifiedtime = :lastmodifiedtime, lastmodifiedby = :lastmodifiedby WHERE birthdtlid = :birthdtlid;"; - - private static final String BIRTHMOTHERINFOUPDATEQRY="UPDATE {schema}.eg_birth_mother_info SET firstname = :firstname, middlename = :middlename, lastname = :lastname, " - + "aadharno = :aadharno, emailid = :emailid, mobileno = :mobileno, education = :education, proffession = :proffession, nationality = :nationality, " - + "religion = :religion, lastmodifiedtime = :lastmodifiedtime, lastmodifiedby = :lastmodifiedby WHERE birthdtlid = :birthdtlid;"; - - private static final String BIRTHPERMADDRUPDATEQRY = "UPDATE {schema}.eg_birth_permaddr SET buildingno = :buildingno, houseno = :houseno, streetname = :streetname, " - + "locality = :locality, tehsil = :tehsil, district = :district, city = :city, state = :state, pinno = :pinno, country = :country, " - + "lastmodifiedby = :lastmodifiedby, lastmodifiedtime = :lastmodifiedtime WHERE birthdtlid = :birthdtlid;"; - - private static final String BIRTHPRESENTADDRUPDATEQRY="UPDATE {schema}.eg_birth_presentaddr SET buildingno = :buildingno, houseno = :houseno, streetname = :streetname, " - + "locality = :locality, tehsil = :tehsil, district = :district, city = :city, state = :state, pinno = :pinno, country = :country, " - + "lastmodifiedby = :lastmodifiedby, lastmodifiedtime = :lastmodifiedtime WHERE birthdtlid = :birthdtlid;"; - - - private static final String DEATHDTLUPDATEQRY="UPDATE {schema}.eg_death_dtls SET registrationno = :registrationno, hospitalname = :hospitalname, dateofreport = :dateofreport, " - + "dateofdeath = :dateofdeath , firstname= :firstname, middlename = :middlename, lastname = :lastname, placeofdeath= :placeofdeath, informantsname = :informantsname, " - + "informantsaddress = :informantsaddress, lastmodifiedtime = :lastmodifiedtime, lastmodifiedby= :lastmodifiedby, gender = :gender, remarks = :remarks, " - + "hospitalid = :hospitalid , age = :age, eidno = :eidno, aadharno = :aadharno, nationality = :nationality, religion = :religion, icdcode = :icdcode, islegacyrecord =:islegacyrecord WHERE id = :id;"; - - private static final String DEATHFATHERINFOUPDATEQRY="UPDATE {schema}.eg_death_father_info SET firstname = :firstname, middlename = :middlename, lastname = :lastname, " - + "aadharno = :aadharno, emailid = :emailid, mobileno = :mobileno, lastmodifiedtime = :lastmodifiedtime, lastmodifiedby = :lastmodifiedby WHERE deathdtlid = :deathdtlid;"; - - private static final String DEATHMOTHERINFOUPDATEQRY="UPDATE {schema}.eg_death_mother_info SET firstname = :firstname, middlename = :middlename, lastname = :lastname, " - + "aadharno = :aadharno, emailid = :emailid, mobileno = :mobileno, lastmodifiedtime = :lastmodifiedtime, lastmodifiedby = :lastmodifiedby WHERE deathdtlid = :deathdtlid;"; - - private static final String DEATHSPOUSEINFOUPDATEQRY="UPDATE {schema}.eg_death_spouse_info SET firstname = :firstname, middlename = :middlename, lastname = :lastname, " - + "aadharno = :aadharno, emailid = :emailid, mobileno = :mobileno, lastmodifiedtime = :lastmodifiedtime, lastmodifiedby = :lastmodifiedby WHERE deathdtlid = :deathdtlid;"; - - private static final String DEATHPERMADDRUPDATEQRY = "UPDATE {schema}.eg_death_permaddr SET buildingno = :buildingno, houseno = :houseno, streetname = :streetname, " - + "locality = :locality, tehsil = :tehsil, district = :district, city = :city, state = :state, pinno = :pinno, country = :country, " - + "lastmodifiedby = :lastmodifiedby, lastmodifiedtime = :lastmodifiedtime WHERE deathdtlid = :deathdtlid;"; - - private static final String DEATHPRESENTADDRUPDATEQRY="UPDATE {schema}.eg_death_presentaddr SET buildingno = :buildingno, houseno = :houseno, streetname = :streetname, " - + "locality = :locality, tehsil = :tehsil, district = :district, city = :city, state = :state, pinno = :pinno, country = :country, " - + "lastmodifiedby = :lastmodifiedby, lastmodifiedtime = :lastmodifiedtime WHERE deathdtlid = :deathdtlid;"; - - - public List getHospitalDtls(String tenantId) { - List preparedStmtList = new ArrayList<>(); + + @Autowired + private CommonQueryBuilder queryBuilder; + + @Autowired + private CommonRowMapper rowMapper; + + @Autowired + private NamedParameterJdbcTemplate namedParameterJdbcTemplate; + + @Autowired + private CommonUtils commUtils; + + @Autowired + BirthValidator birthValidator; + + @Autowired + DeathValidator deathValidator; + + private CommonService commonService; + + @Autowired + EncryptionDecryptionUtil encryptionDecryptionUtil; + + @Autowired + private MultiStateInstanceUtil centralInstanceUtil; + + @Autowired + private UserService userService; + + @Autowired + private BirthDeathConfiguration config; + + @Autowired + private IdGenRepository idGenRepository; + + @Autowired + @Lazy + public CommonRepository(CommonService commonService) { + this.commonService = commonService; + } + + private static final String BIRTHDTLDELETEQRY = "Delete from {schema}.eg_birth_dtls where tenantid = :tenantid and registrationno = :registrationno; "; + + private static final String DEATHDTLDELETEQRY = "Delete from {schema}.eg_death_dtls where tenantid = :tenantid and registrationno = :registrationno; "; + + private static final String BIRTHDTLSAVEQRY = "INSERT INTO {schema}.eg_birth_dtls(id, registrationno, hospitalname, dateofreport, " + + "dateofbirth, firstname, middlename, lastname, placeofbirth, informantsname, informantsaddress, " + + "createdtime, createdby, lastmodifiedtime, lastmodifiedby, counter, tenantid, gender, remarks, hospitalid, islegacyrecord) " + + "VALUES (:id, :registrationno, :hospitalname, :dateofreport, :dateofbirth, :firstname, :middlename, :lastname, " + + ":placeofbirth, :informantsname, :informantsaddress, :createdtime, :createdby, :lastmodifiedtime, " + + ":lastmodifiedby, :counter, :tenantid, :gender, :remarks, :hospitalid, :islegacyrecord); "; + + private static final String BIRTHFATHERINFOSAVEQRY = "INSERT INTO {schema}.eg_birth_father_info( id, firstname, middlename, lastname, aadharno, " + + "emailid, mobileno, education, proffession, nationality, religion, createdtime, createdby, lastmodifiedtime, lastmodifiedby, birthdtlid) " + + "VALUES (:id, :firstname, :middlename, :lastname, :aadharno, :emailid, :mobileno, :education, :proffession, :nationality," + + " :religion, :createdtime, :createdby, :lastmodifiedtime, :lastmodifiedby, :birthdtlid);"; + + private static final String BIRTHMOTHERINFOSAVEQRY = "INSERT INTO {schema}.eg_birth_mother_info(id, firstname, middlename, lastname, aadharno, " + + "emailid, mobileno, education, proffession, nationality, religion, createdtime, createdby, lastmodifiedtime, lastmodifiedby, birthdtlid) " + + "VALUES (:id, :firstname, :middlename, :lastname, :aadharno, :emailid, :mobileno, :education, :proffession, :nationality," + + " :religion, :createdtime, :createdby, :lastmodifiedtime, :lastmodifiedby, :birthdtlid);"; + + private static final String BIRTHPERMADDRSAVEQRY = "INSERT INTO {schema}.eg_birth_permaddr(id, buildingno, houseno, streetname, locality, tehsil, " + + "district, city, state, pinno, country, createdby, createdtime, lastmodifiedby, lastmodifiedtime, birthdtlid) " + + "VALUES (:id, :buildingno, :houseno, :streetname, :locality, :tehsil, :district, :city, :state, :pinno, :country," + + " :createdby, :createdtime, :lastmodifiedby, :lastmodifiedtime, :birthdtlid);"; + + private static final String BIRTHPRESENTADDRSAVEQRY = "INSERT INTO {schema}.eg_birth_presentaddr(id, buildingno, houseno, streetname, locality, tehsil, " + + "district, city, state, pinno, country, createdby, createdtime, lastmodifiedby, lastmodifiedtime, birthdtlid) " + + "VALUES (:id, :buildingno, :houseno, :streetname, :locality, :tehsil, :district, :city, :state, :pinno, :country, " + + ":createdby, :createdtime, :lastmodifiedby, :lastmodifiedtime, :birthdtlid);"; + + private static final String DEATHDTLSAVEQRY = "INSERT INTO {schema}.eg_death_dtls(id, registrationno, hospitalname, dateofreport, " + + "dateofdeath, firstname, middlename, lastname, placeofdeath, informantsname, informantsaddress, " + + "createdtime, createdby, lastmodifiedtime, lastmodifiedby, counter, tenantid, gender, remarks, hospitalid, age, eidno, aadharno, nationality, religion, icdcode, islegacyrecord) " + + "VALUES (:id, :registrationno, :hospitalname, :dateofreport, :dateofdeath, :firstname, :middlename, :lastname, " + + ":placeofdeath, :informantsname, :informantsaddress, :createdtime, :createdby, :lastmodifiedtime, " + + ":lastmodifiedby, :counter, :tenantid, :gender, :remarks, :hospitalid, :age, :eidno, :aadharno, :nationality, :religion, :icdcode, :islegacyrecord); "; + + private static final String DEATHFATHERINFOSAVEQRY = "INSERT INTO {schema}.eg_death_father_info( id, firstname, middlename, lastname, aadharno, " + + "emailid, mobileno, createdtime, createdby, lastmodifiedtime, lastmodifiedby, deathdtlid) " + + "VALUES (:id, :firstname, :middlename, :lastname, :aadharno, :emailid, :mobileno, :createdtime, :createdby, :lastmodifiedtime, :lastmodifiedby, :deathdtlid);"; + + private static final String DEATHMOTHERINFOSAVEQRY = "INSERT INTO {schema}.eg_death_mother_info(id, firstname, middlename, lastname, aadharno, " + + "emailid, mobileno, createdtime, createdby, lastmodifiedtime, lastmodifiedby, deathdtlid) " + + "VALUES (:id, :firstname, :middlename, :lastname, :aadharno, :emailid, :mobileno, :createdtime, :createdby, :lastmodifiedtime, :lastmodifiedby, :deathdtlid);"; + + private static final String DEATHSPOUSEINFOSAVEQRY = "INSERT INTO {schema}.eg_death_spouse_info(id, firstname, middlename, lastname, aadharno, " + + "emailid, mobileno, createdtime, createdby, lastmodifiedtime, lastmodifiedby, deathdtlid) " + + "VALUES (:id, :firstname, :middlename, :lastname, :aadharno, :emailid, :mobileno, :createdtime, :createdby, :lastmodifiedtime, :lastmodifiedby, :deathdtlid);"; + + private static final String DEATHPERMADDRSAVEQRY = "INSERT INTO {schema}.eg_death_permaddr(id, buildingno, houseno, streetname, locality, tehsil, " + + "district, city, state, pinno, country, createdby, createdtime, lastmodifiedby, lastmodifiedtime, deathdtlid) " + + "VALUES (:id, :buildingno, :houseno, :streetname, :locality, :tehsil, :district, :city, :state, :pinno, :country," + + " :createdby, :createdtime, :lastmodifiedby, :lastmodifiedtime, :deathdtlid);"; + + private static final String DEATHPRESENTADDRSAVEQRY = "INSERT INTO {schema}.eg_death_presentaddr(id, buildingno, houseno, streetname, locality, tehsil, " + + "district, city, state, pinno, country, createdby, createdtime, lastmodifiedby, lastmodifiedtime, deathdtlid) " + + "VALUES (:id, :buildingno, :houseno, :streetname, :locality, :tehsil, :district, :city, :state, :pinno, :country, " + + ":createdby, :createdtime, :lastmodifiedby, :lastmodifiedtime, :deathdtlid);"; + + private static final String HOSPITALINSERTSQL = "INSERT INTO {schema}.eg_birth_death_hospitals(id, hospitalname, tenantid) VALUES " + + " (?, ?, ?) ;"; + + private static final String BIRTHDTLUPDATEQRY = "UPDATE {schema}.eg_birth_dtls SET registrationno = :registrationno, hospitalname = :hospitalname, dateofreport = :dateofreport, " + + "dateofbirth = :dateofbirth , firstname= :firstname, middlename = :middlename, lastname = :lastname, placeofbirth= :placeofbirth, informantsname = :informantsname, " + + "informantsaddress = :informantsaddress, lastmodifiedtime = :lastmodifiedtime, lastmodifiedby= :lastmodifiedby, gender = :gender, remarks = :remarks, " + + "hospitalid = :hospitalid, islegacyrecord =:islegacyrecord WHERE id = :id;"; + + private static final String BIRTHFATHERINFOUPDATEQRY = "UPDATE {schema}.eg_birth_father_info SET firstname = :firstname, middlename = :middlename, lastname = :lastname, " + + "aadharno = :aadharno, emailid = :emailid, mobileno = :mobileno, education = :education, proffession = :proffession, nationality = :nationality, " + + "religion = :religion, lastmodifiedtime = :lastmodifiedtime, lastmodifiedby = :lastmodifiedby WHERE birthdtlid = :birthdtlid;"; + + private static final String BIRTHMOTHERINFOUPDATEQRY = "UPDATE {schema}.eg_birth_mother_info SET firstname = :firstname, middlename = :middlename, lastname = :lastname, " + + "aadharno = :aadharno, emailid = :emailid, mobileno = :mobileno, education = :education, proffession = :proffession, nationality = :nationality, " + + "religion = :religion, lastmodifiedtime = :lastmodifiedtime, lastmodifiedby = :lastmodifiedby WHERE birthdtlid = :birthdtlid;"; + + private static final String BIRTHPERMADDRUPDATEQRY = "UPDATE {schema}.eg_birth_permaddr SET buildingno = :buildingno, houseno = :houseno, streetname = :streetname, " + + "locality = :locality, tehsil = :tehsil, district = :district, city = :city, state = :state, pinno = :pinno, country = :country, " + + "lastmodifiedby = :lastmodifiedby, lastmodifiedtime = :lastmodifiedtime WHERE birthdtlid = :birthdtlid;"; + + private static final String BIRTHPRESENTADDRUPDATEQRY = "UPDATE {schema}.eg_birth_presentaddr SET buildingno = :buildingno, houseno = :houseno, streetname = :streetname, " + + "locality = :locality, tehsil = :tehsil, district = :district, city = :city, state = :state, pinno = :pinno, country = :country, " + + "lastmodifiedby = :lastmodifiedby, lastmodifiedtime = :lastmodifiedtime WHERE birthdtlid = :birthdtlid;"; + + private static final String DEATHDTLUPDATEQRY = "UPDATE {schema}.eg_death_dtls SET registrationno = :registrationno, hospitalname = :hospitalname, dateofreport = :dateofreport, " + + "dateofdeath = :dateofdeath , firstname= :firstname, middlename = :middlename, lastname = :lastname, placeofdeath= :placeofdeath, informantsname = :informantsname, " + + "informantsaddress = :informantsaddress, lastmodifiedtime = :lastmodifiedtime, lastmodifiedby= :lastmodifiedby, gender = :gender, remarks = :remarks, " + + "hospitalid = :hospitalid , age = :age, eidno = :eidno, aadharno = :aadharno, nationality = :nationality, religion = :religion, icdcode = :icdcode, islegacyrecord =:islegacyrecord WHERE id = :id;"; + + private static final String DEATHFATHERINFOUPDATEQRY = "UPDATE {schema}.eg_death_father_info SET firstname = :firstname, middlename = :middlename, lastname = :lastname, " + + "aadharno = :aadharno, emailid = :emailid, mobileno = :mobileno, lastmodifiedtime = :lastmodifiedtime, lastmodifiedby = :lastmodifiedby WHERE deathdtlid = :deathdtlid;"; + + private static final String DEATHMOTHERINFOUPDATEQRY = "UPDATE {schema}.eg_death_mother_info SET firstname = :firstname, middlename = :middlename, lastname = :lastname, " + + "aadharno = :aadharno, emailid = :emailid, mobileno = :mobileno, lastmodifiedtime = :lastmodifiedtime, lastmodifiedby = :lastmodifiedby WHERE deathdtlid = :deathdtlid;"; + + private static final String DEATHSPOUSEINFOUPDATEQRY = "UPDATE {schema}.eg_death_spouse_info SET firstname = :firstname, middlename = :middlename, lastname = :lastname, " + + "aadharno = :aadharno, emailid = :emailid, mobileno = :mobileno, lastmodifiedtime = :lastmodifiedtime, lastmodifiedby = :lastmodifiedby WHERE deathdtlid = :deathdtlid;"; + + private static final String DEATHPERMADDRUPDATEQRY = "UPDATE {schema}.eg_death_permaddr SET buildingno = :buildingno, houseno = :houseno, streetname = :streetname, " + + "locality = :locality, tehsil = :tehsil, district = :district, city = :city, state = :state, pinno = :pinno, country = :country, " + + "lastmodifiedby = :lastmodifiedby, lastmodifiedtime = :lastmodifiedtime WHERE deathdtlid = :deathdtlid;"; + + private static final String DEATHPRESENTADDRUPDATEQRY = "UPDATE {schema}.eg_death_presentaddr SET buildingno = :buildingno, houseno = :houseno, streetname = :streetname, " + + "locality = :locality, tehsil = :tehsil, district = :district, city = :city, state = :state, pinno = :pinno, country = :country, " + + "lastmodifiedby = :lastmodifiedby, lastmodifiedtime = :lastmodifiedtime WHERE deathdtlid = :deathdtlid;"; + + public List getHospitalDtls(String tenantId) { + List preparedStmtList = new ArrayList<>(); String query = queryBuilder.getHospitalDtls(tenantId, preparedStmtList); - try { - query = centralInstanceUtil.replaceSchemaPlaceholder(query, tenantId); - } catch (InvalidTenantIdException e) { - throw new CustomException("WS_AS_TENANTID_ERROR", - "TenantId length is not sufficient to replace query schema in a multi state instance"); - } - List hospitalDtls = jdbcTemplate.query(query, preparedStmtList.toArray(), rowMapper); + try { + query = centralInstanceUtil.replaceSchemaPlaceholder(query, tenantId); + } catch (InvalidTenantIdException e) { + throw new CustomException("WS_AS_TENANTID_ERROR", + "TenantId length is not sufficient to replace query schema in a multi state instance"); + } + List hospitalDtls = jdbcTemplate.query(query, preparedStmtList.toArray(), rowMapper); return hospitalDtls; - } - - public ImportBirthWrapper saveBirthImport(BirthResponse response, RequestInfo requestInfo) { - ImportBirthWrapper importBirthWrapper = new ImportBirthWrapper(); - try { - Map uniqueList = new HashMap(); - Map> uniqueHospList = new HashMap>(); - Set duplicates = new HashSet(); - response.getBirthCerts().forEach(bdtl -> { - if(null != bdtl.getRejectReason()) - { - importBirthWrapper.updateMaps(BirthDeathConstants.EXCEL_DATA_ERROR, bdtl); - } - else - { - if (bdtl.getRegistrationno() != null) { - if (uniqueList.get(bdtl.getRegistrationno()) == null) - { - birthValidator.removeSpaceChars(bdtl); - uniqueList.put(bdtl.getRegistrationno(), bdtl); - if (null != bdtl.getHospitalname() && !bdtl.getHospitalname().trim().isEmpty() ) - { - if(bdtl.getHospitalname().length() >500) { - importBirthWrapper.updateMaps(BirthDeathConstants.HOSPNAME_LARGE, bdtl); - importBirthWrapper.setServiceError(BirthDeathConstants.HOSPNAME_LARGE); - uniqueList.remove(bdtl.getRegistrationno()); - } - else { - bdtl.setHospitalname(bdtl.getHospitalname().trim()); - if(!uniqueHospList.containsKey(bdtl.getHospitalname())) - { - uniqueHospList.put(bdtl.getHospitalname(),new ArrayList()); - } - uniqueHospList.get(bdtl.getHospitalname()).add(bdtl); - } - } - } - else { - importBirthWrapper.updateMaps(BirthDeathConstants.DUPLICATE_REG_EXCEL, bdtl); - importBirthWrapper.setServiceError(BirthDeathConstants.DUPLICATE_REG_EXCEL); - duplicates.add(bdtl.getRegistrationno()); - } - } - else - { - importBirthWrapper.updateMaps(BirthDeathConstants.REG_EMPTY, bdtl); - importBirthWrapper.setServiceError(BirthDeathConstants.REG_EMPTY); - } - } - }); - for (String regno : duplicates) { - importBirthWrapper.updateMaps(BirthDeathConstants.DUPLICATE_REG_EXCEL, uniqueList.get(regno)); - importBirthWrapper.setServiceError(BirthDeathConstants.DUPLICATE_REG_EXCEL); - uniqueList.remove(regno); - } - modifyHospIdBirth(uniqueHospList , response.getBirthCerts().get(0).getTenantid()); - int finalCount=0; - AuditDetails auditDetails; - for (Entry entry : uniqueList.entrySet()) { - EgBirthDtl birthDtl = entry.getValue(); - birthDtl.setGenderStr(birthDtl.getGenderStr()==null?"":birthDtl.getGenderStr().trim().toLowerCase()); - if(birthDtl.getIsLegacyRecord() != null && birthDtl.getIsLegacyRecord()) { - auditDetails = commUtils.getAuditDetails("import-user", true); - } else { - auditDetails = commUtils.getAuditDetails(requestInfo.getUserInfo().getUuid(), true); - } - switch (birthDtl.getGenderStr()) { - case "male": - birthDtl.setGender(1); - break; - case "female": - birthDtl.setGender(2); - break; - case "others": - birthDtl.setGender(3); - break; - default: - birthDtl.setGender(0); - break; - } - if(birthValidator.validateUniqueRegNo(birthDtl,importBirthWrapper) && birthValidator.validateImportFields(birthDtl,importBirthWrapper)){ - try { - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(BIRTHDTLSAVEQRY, birthDtl.getTenantid()), getParametersForBirthDtl(birthDtl, auditDetails, true)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(BIRTHFATHERINFOSAVEQRY, birthDtl.getTenantid()), getParametersForFatherInfo(birthDtl, auditDetails, true)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(BIRTHMOTHERINFOSAVEQRY, birthDtl.getTenantid()), getParametersForMotherInfo(birthDtl, auditDetails, true)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(BIRTHPERMADDRSAVEQRY, birthDtl.getTenantid()), getParametersForPermAddr(birthDtl, auditDetails, true)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(BIRTHPRESENTADDRSAVEQRY, birthDtl.getTenantid()), getParametersForPresentAddr(birthDtl, auditDetails, true)); - finalCount++; - } - catch (Exception e) { - birthDtl.setRejectReason(BirthDeathConstants.DATA_ERROR); - importBirthWrapper.updateMaps(BirthDeathConstants.DATA_ERROR, birthDtl); - Map params = new HashMap<>(); - params.put("tenantid", birthDtl.getTenantid()); - params.put("registrationno", birthDtl.getRegistrationno()); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(BIRTHDTLDELETEQRY,birthDtl.getTenantid()), params); - e.printStackTrace(); - } - } - } - - log.info("completed " + finalCount); - importBirthWrapper.finaliseStats(response.getBirthCerts().size(),finalCount); - List hospitaldtls = getHospitalDtls(response.getBirthCerts().get(0).getTenantid()); - List hospitals = new ArrayList(); - for(EgHospitalDtl hospitalDtl: hospitaldtls) { - hospitals.add(hospitalDtl.getName()); - } - importBirthWrapper.setHospitals(hospitals); - } - catch (Exception e) { - importBirthWrapper.setServiceError("Service Error in importing"); - e.printStackTrace(); - } - return importBirthWrapper; - } - - private void modifyHospIdBirth(Map> uniqueHospList , String tenantid) { - Map dbHospNameIdMap = new HashMap(); - List hospitals = commonService.search(tenantid); - for (EgHospitalDtl egHospitalDtl : hospitals) { - dbHospNameIdMap.put(egHospitalDtl.getName(), egHospitalDtl.getId()); - } - if(!uniqueHospList.keySet().isEmpty()) { - - for (String hospName : uniqueHospList.keySet()) { - if(!dbHospNameIdMap.containsKey(hospName)) - { - String id = tenantid.split("\\.")[1] + "_" + (dbHospNameIdMap.keySet().size() + 1); - jdbcTemplate.update(callToReplaceSchemaPlaceHolder(HOSPITALINSERTSQL, tenantid), id,hospName,tenantid); - dbHospNameIdMap.put(hospName,id); - } - for (EgBirthDtl bdtl : uniqueHospList.get(hospName)) { - bdtl.setHospitalid(dbHospNameIdMap.get(hospName)); - } - } - } - } - - private void modifyHospIdDeath(Map> uniqueHospList , String tenantid) { - Map dbHospNameIdMap = new HashMap(); - List hospitals = commonService.search(tenantid); - for (EgHospitalDtl egHospitalDtl : hospitals) { - dbHospNameIdMap.put(egHospitalDtl.getName(), egHospitalDtl.getId()); - } - if(!uniqueHospList.keySet().isEmpty()) { - - for (String hospName : uniqueHospList.keySet()) { - if(!dbHospNameIdMap.containsKey(hospName)) - { - String id = tenantid.split("\\.")[1] + "_" + (dbHospNameIdMap.keySet().size() + 1); - jdbcTemplate.update(callToReplaceSchemaPlaceHolder(HOSPITALINSERTSQL,tenantid), id,hospName,tenantid); - dbHospNameIdMap.put(hospName,id); - } - for (EgDeathDtl bdtl : uniqueHospList.get(hospName)) { - bdtl.setHospitalid(dbHospNameIdMap.get(hospName)); - } - } - } - } - - private MapSqlParameterSource getParametersForPresentAddr(EgBirthDtl birthDtl, AuditDetails auditDetails, boolean isInsert) { - MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); - EgBirthPresentaddr presentaddr = birthDtl.getBirthPresentaddr(); - sqlParameterSource.addValue("id", UUID.randomUUID().toString()); - sqlParameterSource.addValue("buildingno", presentaddr.getBuildingno()); - sqlParameterSource.addValue("houseno", presentaddr.getHouseno()); - sqlParameterSource.addValue("streetname", presentaddr.getStreetname()); - sqlParameterSource.addValue("locality", presentaddr.getLocality()); - sqlParameterSource.addValue("tehsil", presentaddr.getTehsil()); - sqlParameterSource.addValue("district", presentaddr.getDistrict()); - sqlParameterSource.addValue("city", presentaddr.getCity()); - sqlParameterSource.addValue("state", presentaddr.getState()); - sqlParameterSource.addValue("pinno", presentaddr.getPinno()); - sqlParameterSource.addValue("country", presentaddr.getCountry()); - sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); - sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); - if(isInsert) { - sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); - sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); - sqlParameterSource.addValue("lastmodifiedtime", null); - sqlParameterSource.addValue("lastmodifiedby", null); - } - else{ - sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); - sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); - } - sqlParameterSource.addValue("birthdtlid", birthDtl.getId()); - return sqlParameterSource; - } - - private MapSqlParameterSource getParametersForPermAddr(EgBirthDtl birthDtl, AuditDetails auditDetails, boolean isInsert) { - MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); - EgBirthPermaddr permaddr = birthDtl.getBirthPermaddr(); - sqlParameterSource.addValue("id", UUID.randomUUID().toString()); - sqlParameterSource.addValue("buildingno", permaddr.getBuildingno()); - sqlParameterSource.addValue("houseno", permaddr.getHouseno()); - sqlParameterSource.addValue("streetname", permaddr.getStreetname()); - sqlParameterSource.addValue("locality", permaddr.getLocality()); - sqlParameterSource.addValue("tehsil", permaddr.getTehsil()); - sqlParameterSource.addValue("district", permaddr.getDistrict()); - sqlParameterSource.addValue("city", permaddr.getCity()); - sqlParameterSource.addValue("state", permaddr.getState()); - sqlParameterSource.addValue("pinno", permaddr.getPinno()); - sqlParameterSource.addValue("country", permaddr.getCountry()); - sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); - sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); - if(isInsert) { - sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); - sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); - sqlParameterSource.addValue("lastmodifiedtime", null); - sqlParameterSource.addValue("lastmodifiedby", null); - } - else{ - sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); - sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); - } - sqlParameterSource.addValue("birthdtlid", birthDtl.getId()); - return sqlParameterSource; - } - - private MapSqlParameterSource getParametersForMotherInfo(EgBirthDtl birthDtl, AuditDetails auditDetails, boolean isInsert) { - EgBirthMotherInfo birthMotherInfo = encryptionDecryptionUtil.encryptObject(birthDtl.getBirthMotherInfo(), "BndDetail", EgBirthMotherInfo.class); - MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); - sqlParameterSource.addValue("id", UUID.randomUUID().toString()); - sqlParameterSource.addValue("firstname", birthMotherInfo.getFirstname()); - sqlParameterSource.addValue("middlename", birthMotherInfo.getMiddlename()); - sqlParameterSource.addValue("lastname", birthMotherInfo.getLastname()); - sqlParameterSource.addValue("aadharno", birthMotherInfo.getAadharno()); - sqlParameterSource.addValue("emailid", birthMotherInfo.getEmailid()); - sqlParameterSource.addValue("mobileno", birthMotherInfo.getMobileno()); - sqlParameterSource.addValue("education", birthMotherInfo.getEducation()); - sqlParameterSource.addValue("proffession", birthMotherInfo.getProffession()); - sqlParameterSource.addValue("nationality", birthMotherInfo.getNationality()); - sqlParameterSource.addValue("religion", birthMotherInfo.getReligion()); - if(isInsert) { - sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); - sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); - sqlParameterSource.addValue("lastmodifiedtime", null); - sqlParameterSource.addValue("lastmodifiedby", null); - } - else{ - sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); - sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); - } - sqlParameterSource.addValue("birthdtlid", birthDtl.getId()); - return sqlParameterSource; - } - - private MapSqlParameterSource getParametersForFatherInfo(EgBirthDtl birthDtl, AuditDetails auditDetails, boolean isInsert) { - EgBirthFatherInfo birthFatherInfo = encryptionDecryptionUtil.encryptObject(birthDtl.getBirthFatherInfo(), "BndDetail", EgBirthFatherInfo.class); - MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); - sqlParameterSource.addValue("id", UUID.randomUUID().toString()); - sqlParameterSource.addValue("firstname", birthFatherInfo.getFirstname()); - sqlParameterSource.addValue("middlename", birthFatherInfo.getMiddlename()); - sqlParameterSource.addValue("lastname", birthFatherInfo.getLastname()); - sqlParameterSource.addValue("aadharno", birthFatherInfo.getAadharno()); - sqlParameterSource.addValue("emailid", birthFatherInfo.getEmailid()); - sqlParameterSource.addValue("mobileno", birthFatherInfo.getMobileno()); - sqlParameterSource.addValue("education", birthFatherInfo.getEducation()); - sqlParameterSource.addValue("proffession", birthFatherInfo.getProffession()); - sqlParameterSource.addValue("nationality", birthFatherInfo.getNationality()); - sqlParameterSource.addValue("religion", birthFatherInfo.getReligion()); - if(isInsert) { - sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); - sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); - sqlParameterSource.addValue("lastmodifiedtime", null); - sqlParameterSource.addValue("lastmodifiedby", null); - } - else{ - sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); - sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); - } - sqlParameterSource.addValue("birthdtlid", birthDtl.getId()); - - return sqlParameterSource; - } - - private MapSqlParameterSource getParametersForBirthDtl(EgBirthDtl birthDtl, AuditDetails auditDetails, boolean isInsert) { - MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); - String id= ""; - if(isInsert) - id= UUID.randomUUID().toString(); - else - id=birthDtl.getId(); - sqlParameterSource.addValue("id", id); - sqlParameterSource.addValue("registrationno", birthDtl.getRegistrationno()); - sqlParameterSource.addValue("hospitalname", birthDtl.getHospitalname()); - sqlParameterSource.addValue("dateofreport", birthDtl.getDateofreport()); - sqlParameterSource.addValue("dateofbirth", birthDtl.getDateofbirth()); - sqlParameterSource.addValue("firstname", birthDtl.getFirstname()); - sqlParameterSource.addValue("middlename", birthDtl.getMiddlename()); - sqlParameterSource.addValue("lastname", birthDtl.getLastname()); - sqlParameterSource.addValue("placeofbirth", birthDtl.getPlaceofbirth()); - sqlParameterSource.addValue("informantsname", birthDtl.getInformantsname()); - sqlParameterSource.addValue("informantsaddress", birthDtl.getInformantsaddress()); - if(isInsert) { - sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); - sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); - sqlParameterSource.addValue("lastmodifiedtime", null); - sqlParameterSource.addValue("lastmodifiedby", null); - } - else{ - sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); - sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); - } - sqlParameterSource.addValue("counter", birthDtl.getCounter()); - sqlParameterSource.addValue("tenantid", birthDtl.getTenantid()); - sqlParameterSource.addValue("gender", birthDtl.getGender()); - sqlParameterSource.addValue("remarks", birthDtl.getRemarks()); - sqlParameterSource.addValue("hospitalid", birthDtl.getHospitalid()); - sqlParameterSource.addValue("islegacyrecord", birthDtl.getIsLegacyRecord()); - birthDtl.setId(id); - return sqlParameterSource; - - } - - - public ImportDeathWrapper saveDeathImport(DeathResponse response, RequestInfo requestInfo) { - ImportDeathWrapper importDeathWrapper = new ImportDeathWrapper(); - try { - Map uniqueList = new HashMap(); - Map> uniqueHospList = new HashMap>(); - Set duplicates = new HashSet(); - response.getDeathCerts().forEach(deathtl -> { - if (null != deathtl.getRejectReason()) { - importDeathWrapper.updateMaps(BirthDeathConstants.EXCEL_DATA_ERROR, deathtl); - importDeathWrapper.setServiceError(BirthDeathConstants.EXCEL_DATA_ERROR); - } else { - if (deathtl.getRegistrationno() != null) { - if (uniqueList.get(deathtl.getRegistrationno()) == null) { - deathValidator.removeSpaceChars(deathtl); - uniqueList.put(deathtl.getRegistrationno(), deathtl); - if (null != deathtl.getHospitalname() && !deathtl.getHospitalname().trim().isEmpty()) { - if (deathtl.getHospitalname().length() > 500) { - importDeathWrapper.updateMaps(BirthDeathConstants.HOSPNAME_LARGE, deathtl); - importDeathWrapper.setServiceError(BirthDeathConstants.HOSPNAME_LARGE); - uniqueList.remove(deathtl.getRegistrationno()); - } else { - deathtl.setHospitalname(deathtl.getHospitalname().trim()); - if (!uniqueHospList.containsKey(deathtl.getHospitalname())) { - uniqueHospList.put(deathtl.getHospitalname(), new ArrayList()); - } - uniqueHospList.get(deathtl.getHospitalname()).add(deathtl); - } - } - - } else { - importDeathWrapper.updateMaps(BirthDeathConstants.DUPLICATE_REG_EXCEL, deathtl); - importDeathWrapper.setServiceError(BirthDeathConstants.DUPLICATE_REG_EXCEL); - duplicates.add(deathtl.getRegistrationno()); - } - } else { - importDeathWrapper.updateMaps(BirthDeathConstants.REG_EMPTY, deathtl); - importDeathWrapper.setServiceError(BirthDeathConstants.REG_EMPTY); - } - } - }); - for (String regno : duplicates) { - importDeathWrapper.updateMaps(BirthDeathConstants.DUPLICATE_REG_EXCEL, uniqueList.get(regno)); - importDeathWrapper.setServiceError(BirthDeathConstants.DUPLICATE_REG_EXCEL); - uniqueList.remove(regno); - } - modifyHospIdDeath(uniqueHospList , response.getDeathCerts().get(0).getTenantid()); - int finalCount=0; - AuditDetails auditDetails; - for (Entry entry : uniqueList.entrySet()) { - EgDeathDtl deathDtl = entry.getValue(); - if(deathDtl.getIsLegacyRecord() != null && deathDtl.getIsLegacyRecord()) { - auditDetails = commUtils.getAuditDetails("import-user", true); - } else { - auditDetails = commUtils.getAuditDetails(requestInfo.getUserInfo().getUuid(), true); - } - deathDtl.setGenderStr(deathDtl.getGenderStr()==null?"":deathDtl.getGenderStr().trim().toLowerCase()); - switch (deathDtl.getGenderStr()) { - case "male": - deathDtl.setGender(1); - break; - case "female": - deathDtl.setGender(2); - break; - case "transgender": - deathDtl.setGender(3); - break; - default: - deathDtl.setGender(0); - break; - } - if(deathValidator.validateUniqueRegNo(deathDtl,importDeathWrapper) && deathValidator.validateImportFields(deathDtl,importDeathWrapper)){ - try { - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(DEATHDTLSAVEQRY, deathDtl.getTenantid()), getParametersForDeathDtl(deathDtl, auditDetails, true)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(DEATHFATHERINFOSAVEQRY, deathDtl.getTenantid()), getParametersForFatherInfo(deathDtl, auditDetails, true)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(DEATHMOTHERINFOSAVEQRY, deathDtl.getTenantid()), getParametersForMotherInfo(deathDtl, auditDetails, true)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(DEATHSPOUSEINFOSAVEQRY, deathDtl.getTenantid()), getParametersForSpouseInfo(deathDtl, auditDetails, true)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(DEATHPERMADDRSAVEQRY, deathDtl.getTenantid()), getParametersForPermAddr(deathDtl, auditDetails, true)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(DEATHPRESENTADDRSAVEQRY,deathDtl.getTenantid()), getParametersForPresentAddr(deathDtl, auditDetails, true)); - finalCount++; - } - catch (Exception e) { - deathDtl.setRejectReason(BirthDeathConstants.DATA_ERROR); - importDeathWrapper.updateMaps(BirthDeathConstants.DATA_ERROR, deathDtl); - Map params = new HashMap<>(); - params.put("tenantid", deathDtl.getTenantid()); - params.put("registrationno", deathDtl.getRegistrationno()); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(DEATHDTLDELETEQRY, deathDtl.getTenantid()), params); - e.printStackTrace(); - } - } - } - - log.info("completed " + finalCount); - importDeathWrapper.finaliseStats(response.getDeathCerts().size(),finalCount); - List hospitaldtls = getHospitalDtls(response.getDeathCerts().get(0).getTenantid()); - List hospitals = new ArrayList(); - for(EgHospitalDtl hospitalDtl: hospitaldtls) { - hospitals.add(hospitalDtl.getName()); - } - importDeathWrapper.setHospitals(hospitals); - } - catch (Exception e) { - importDeathWrapper.setServiceError("Service Error in importing"); - e.printStackTrace(); - } - return importDeathWrapper; - } - - private MapSqlParameterSource getParametersForPresentAddr(EgDeathDtl deathDtl, AuditDetails auditDetails, boolean isInsert) { - MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); - EgDeathPresentaddr presentaddr = deathDtl.getDeathPresentaddr(); - sqlParameterSource.addValue("id", UUID.randomUUID().toString()); - sqlParameterSource.addValue("buildingno", presentaddr.getBuildingno()); - sqlParameterSource.addValue("houseno", presentaddr.getHouseno()); - sqlParameterSource.addValue("streetname", presentaddr.getStreetname()); - sqlParameterSource.addValue("locality", presentaddr.getLocality()); - sqlParameterSource.addValue("tehsil", presentaddr.getTehsil()); - sqlParameterSource.addValue("district", presentaddr.getDistrict()); - sqlParameterSource.addValue("city", presentaddr.getCity()); - sqlParameterSource.addValue("state", presentaddr.getState()); - sqlParameterSource.addValue("pinno", presentaddr.getPinno()); - sqlParameterSource.addValue("country", presentaddr.getCountry()); - if(isInsert) { - sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); - sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); - sqlParameterSource.addValue("lastmodifiedtime", null); - sqlParameterSource.addValue("lastmodifiedby", null); - } - else{ - sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); - sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); - } - sqlParameterSource.addValue("deathdtlid", deathDtl.getId()); - return sqlParameterSource; - } - - private MapSqlParameterSource getParametersForPermAddr(EgDeathDtl deathDtl, AuditDetails auditDetails, boolean isInsert) { - MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); - EgDeathPermaddr permaddr = deathDtl.getDeathPermaddr(); - sqlParameterSource.addValue("id", UUID.randomUUID().toString()); - sqlParameterSource.addValue("buildingno", permaddr.getBuildingno()); - sqlParameterSource.addValue("houseno", permaddr.getHouseno()); - sqlParameterSource.addValue("streetname", permaddr.getStreetname()); - sqlParameterSource.addValue("locality", permaddr.getLocality()); - sqlParameterSource.addValue("tehsil", permaddr.getTehsil()); - sqlParameterSource.addValue("district", permaddr.getDistrict()); - sqlParameterSource.addValue("city", permaddr.getCity()); - sqlParameterSource.addValue("state", permaddr.getState()); - sqlParameterSource.addValue("pinno", permaddr.getPinno()); - sqlParameterSource.addValue("country", permaddr.getCountry()); - if(isInsert) { - sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); - sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); - sqlParameterSource.addValue("lastmodifiedtime", null); - sqlParameterSource.addValue("lastmodifiedby", null); - } - else{ - sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); - sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); - } - sqlParameterSource.addValue("deathdtlid", deathDtl.getId()); - return sqlParameterSource; - } - - private MapSqlParameterSource getParametersForMotherInfo(EgDeathDtl deathDtl, AuditDetails auditDetails, boolean isInsert) { - EgDeathMotherInfo deathMotherInfo = encryptionDecryptionUtil.encryptObject(deathDtl.getDeathMotherInfo(), "BndDetail", EgDeathMotherInfo.class); - MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); - sqlParameterSource.addValue("id", UUID.randomUUID().toString()); - sqlParameterSource.addValue("firstname", deathMotherInfo.getFirstname()); - sqlParameterSource.addValue("middlename", deathMotherInfo.getMiddlename()); - sqlParameterSource.addValue("lastname", deathMotherInfo.getLastname()); - sqlParameterSource.addValue("aadharno", deathMotherInfo.getAadharno()); - sqlParameterSource.addValue("emailid", deathMotherInfo.getEmailid()); - sqlParameterSource.addValue("mobileno", deathMotherInfo.getMobileno()); - if(isInsert) { - sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); - sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); - sqlParameterSource.addValue("lastmodifiedtime", null); - sqlParameterSource.addValue("lastmodifiedby", null); - } - else{ - sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); - sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); - } - sqlParameterSource.addValue("deathdtlid", deathDtl.getId()); - return sqlParameterSource; - } - - private MapSqlParameterSource getParametersForSpouseInfo(EgDeathDtl deathDtl, AuditDetails auditDetails, boolean isInsert) { - EgDeathSpouseInfo deathSpouseInfo = encryptionDecryptionUtil.encryptObject(deathDtl.getDeathSpouseInfo(), "BndDetail", EgDeathSpouseInfo.class); - MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); - sqlParameterSource.addValue("id", UUID.randomUUID().toString()); - sqlParameterSource.addValue("firstname", deathSpouseInfo.getFirstname()); - sqlParameterSource.addValue("middlename", deathSpouseInfo.getMiddlename()); - sqlParameterSource.addValue("lastname", deathSpouseInfo.getLastname()); - sqlParameterSource.addValue("aadharno", deathSpouseInfo.getAadharno()); - sqlParameterSource.addValue("emailid", deathSpouseInfo.getEmailid()); - sqlParameterSource.addValue("mobileno", deathSpouseInfo.getMobileno()); - if(isInsert) { - sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); - sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); - sqlParameterSource.addValue("lastmodifiedtime", null); - sqlParameterSource.addValue("lastmodifiedby", null); - } - else{ - sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); - sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); - } - sqlParameterSource.addValue("deathdtlid", deathDtl.getId()); - return sqlParameterSource; - } - - private MapSqlParameterSource getParametersForFatherInfo(EgDeathDtl deathDtl, - AuditDetails auditDetails, boolean isInsert) { - EgDeathFatherInfo deathFatherInfo = encryptionDecryptionUtil.encryptObject(deathDtl.getDeathFatherInfo(), "BndDetail", EgDeathFatherInfo.class); - MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); - sqlParameterSource.addValue("id", UUID.randomUUID().toString()); - sqlParameterSource.addValue("firstname", deathFatherInfo.getFirstname()); - sqlParameterSource.addValue("middlename", deathFatherInfo.getMiddlename()); - sqlParameterSource.addValue("lastname", deathFatherInfo.getLastname()); - sqlParameterSource.addValue("aadharno", deathFatherInfo.getAadharno()); - sqlParameterSource.addValue("emailid", deathFatherInfo.getEmailid()); - sqlParameterSource.addValue("mobileno", deathFatherInfo.getMobileno()); - if(isInsert) { - sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); - sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); - sqlParameterSource.addValue("lastmodifiedtime", null); - sqlParameterSource.addValue("lastmodifiedby", null); - } - else{ - sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); - sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); - } - sqlParameterSource.addValue("deathdtlid", deathDtl.getId()); - return sqlParameterSource; - } - - private MapSqlParameterSource getParametersForDeathDtl(EgDeathDtl deathDtl, AuditDetails auditDetails, boolean isInsert) { - MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); - EgDeathDtl deathDtlEnc = encryptionDecryptionUtil.encryptObject(deathDtl, "BndDetail", EgDeathDtl.class); - String id=""; - if(isInsert) - id= UUID.randomUUID().toString(); - else - id=deathDtl.getId(); - sqlParameterSource.addValue("id", id); - sqlParameterSource.addValue("registrationno", deathDtl.getRegistrationno()); - sqlParameterSource.addValue("hospitalname", deathDtl.getHospitalname()); - sqlParameterSource.addValue("dateofreport", deathDtl.getDateofreport()); - sqlParameterSource.addValue("dateofdeath", deathDtl.getDateofdeath()); - sqlParameterSource.addValue("firstname", deathDtl.getFirstname()); - sqlParameterSource.addValue("middlename", deathDtl.getMiddlename()); - sqlParameterSource.addValue("lastname", deathDtl.getLastname()); - sqlParameterSource.addValue("placeofdeath", deathDtl.getPlaceofdeath()); - sqlParameterSource.addValue("informantsname", deathDtl.getInformantsname()); - sqlParameterSource.addValue("informantsaddress", deathDtl.getInformantsaddress()); - if(isInsert) { - sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); - sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); - sqlParameterSource.addValue("lastmodifiedtime", null); - sqlParameterSource.addValue("lastmodifiedby", null); - } - else{ - sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); - sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); - } - sqlParameterSource.addValue("counter", deathDtl.getCounter()); - sqlParameterSource.addValue("tenantid", deathDtl.getTenantid()); - sqlParameterSource.addValue("gender", deathDtl.getGender()); - sqlParameterSource.addValue("remarks", deathDtl.getRemarks()); - sqlParameterSource.addValue("hospitalid", deathDtl.getHospitalid()); - sqlParameterSource.addValue("age", deathDtl.getAge() ); - sqlParameterSource.addValue("eidno", deathDtl.getEidno() ); - sqlParameterSource.addValue("aadharno", deathDtlEnc.getAadharno() ); - sqlParameterSource.addValue("nationality", deathDtl.getNationality() ); - sqlParameterSource.addValue("religion", deathDtl.getReligion() ); - sqlParameterSource.addValue("icdcode", deathDtlEnc.getIcdcode() ); - sqlParameterSource.addValue("islegacyrecord", deathDtl.getIsLegacyRecord()); - deathDtl.setId(id); - return sqlParameterSource; - - } - - public ImportBirthWrapper updateBirthImport(BirthResponse response, RequestInfo requestInfo) { - ImportBirthWrapper importBirthWrapper = new ImportBirthWrapper(); - try { - Map uniqueList = new HashMap(); - Map> uniqueHospList = new HashMap>(); - Set duplicates = new HashSet(); - response.getBirthCerts().forEach(bdtl -> { - if (null != bdtl.getRejectReason()) { - importBirthWrapper.updateMaps(BirthDeathConstants.EXCEL_DATA_ERROR, bdtl); - importBirthWrapper.setServiceError(BirthDeathConstants.EXCEL_DATA_ERROR); - } else { - if (bdtl.getId() != null) { - if (bdtl.getRegistrationno() != null) { - if (uniqueList.get(bdtl.getRegistrationno()) == null) { - birthValidator.removeSpaceChars(bdtl); - uniqueList.put(bdtl.getRegistrationno(), bdtl); - if (null != bdtl.getHospitalname() && !bdtl.getHospitalname().trim().isEmpty()) { - if (bdtl.getHospitalname().length() > 500) { - importBirthWrapper.updateMaps(BirthDeathConstants.HOSPNAME_LARGE, bdtl); - importBirthWrapper.setServiceError(BirthDeathConstants.EXCEL_DATA_ERROR); - uniqueList.remove(bdtl.getRegistrationno()); - } else { - bdtl.setHospitalname(bdtl.getHospitalname().trim()); - if (!uniqueHospList.containsKey(bdtl.getHospitalname())) { - uniqueHospList.put(bdtl.getHospitalname(), new ArrayList()); - } - uniqueHospList.get(bdtl.getHospitalname()).add(bdtl); - } - } - } else { - importBirthWrapper.updateMaps(BirthDeathConstants.DUPLICATE_REG_EXCEL, bdtl); - importBirthWrapper.setServiceError(BirthDeathConstants.EXCEL_DATA_ERROR); - duplicates.add(bdtl.getRegistrationno()); - } - } else { - importBirthWrapper.updateMaps(BirthDeathConstants.REG_EMPTY, bdtl); - importBirthWrapper.setServiceError(BirthDeathConstants.EXCEL_DATA_ERROR); - } - } else { - importBirthWrapper.updateMaps(BirthDeathConstants.UPDATE_ERROR, bdtl); - importBirthWrapper.setServiceError(BirthDeathConstants.EXCEL_DATA_ERROR); - } - } - - }); - for (String regno : duplicates) { - importBirthWrapper.updateMaps(BirthDeathConstants.DUPLICATE_REG_EXCEL, uniqueList.get(regno)); - uniqueList.remove(regno); - } - modifyHospIdBirth(uniqueHospList , response.getBirthCerts().get(0).getTenantid()); - AuditDetails auditDetails; - int finalCount=0; - for (Entry entry : uniqueList.entrySet()) { - EgBirthDtl birthDtl = entry.getValue(); - if(birthDtl.getIsLegacyRecord() != null && birthDtl.getIsLegacyRecord()) { - auditDetails = commUtils.getAuditDetails("import-user", true); - } else { - auditDetails = commUtils.getAuditDetails(requestInfo.getUserInfo().getUuid(), true); - } - birthDtl.setGenderStr(birthDtl.getGenderStr()==null?"":birthDtl.getGenderStr().trim().toLowerCase()); - switch (birthDtl.getGenderStr()) { - case "male": - birthDtl.setGender(1); - break; - case "female": - birthDtl.setGender(2); - break; - case "others": - birthDtl.setGender(3); - break; - default: - birthDtl.setGender(0); - break; - } - if(birthValidator.validateImportFields(birthDtl,importBirthWrapper)){ - try { - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(BIRTHDTLUPDATEQRY, birthDtl.getTenantid()), getParametersForBirthDtl(birthDtl, auditDetails, false)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(BIRTHFATHERINFOUPDATEQRY, birthDtl.getTenantid()),getParametersForFatherInfo(birthDtl, auditDetails, false)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(BIRTHMOTHERINFOUPDATEQRY, birthDtl.getTenantid()),getParametersForMotherInfo(birthDtl, auditDetails, false)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(BIRTHPERMADDRUPDATEQRY, birthDtl.getTenantid()),getParametersForPermAddr(birthDtl, auditDetails, false)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(BIRTHPRESENTADDRUPDATEQRY,birthDtl.getTenantid()), getParametersForPresentAddr(birthDtl, auditDetails, false)); - finalCount++; - } - catch (Exception e) { - birthDtl.setRejectReason(BirthDeathConstants.DATA_ERROR); - importBirthWrapper.updateMaps(BirthDeathConstants.DATA_ERROR, birthDtl); - importBirthWrapper.setServiceError(BirthDeathConstants.DATA_ERROR); - e.printStackTrace(); - } - } - } - - log.info("completed " + finalCount); - importBirthWrapper.finaliseStats(response.getBirthCerts().size(),finalCount); - List hospitaldtls = getHospitalDtls(response.getBirthCerts().get(0).getTenantid()); - List hospitals = new ArrayList(); - for(EgHospitalDtl hospitalDtl: hospitaldtls) { - hospitals.add(hospitalDtl.getName()); - } - importBirthWrapper.setHospitals(hospitals); - } - catch (Exception e) { - importBirthWrapper.setServiceError("Service Error in Updating"); - e.printStackTrace(); - } - return importBirthWrapper; - } - - public ImportDeathWrapper updateDeathImport(DeathResponse response, RequestInfo requestInfo) { - ImportDeathWrapper importDeathWrapper = new ImportDeathWrapper(); - try { - //DeathResponse response= mapper.convertValue(importJSon, DeathResponse.class); - Map uniqueList = new HashMap(); - Map> uniqueHospList = new HashMap>(); - Set duplicates = new HashSet(); - response.getDeathCerts().forEach(deathtl -> { - if (null != deathtl.getRejectReason()) { - importDeathWrapper.updateMaps(BirthDeathConstants.EXCEL_DATA_ERROR, deathtl); - } else { - if (deathtl.getId() != null) { - if (deathtl.getRegistrationno() != null) { - if (uniqueList.get(deathtl.getRegistrationno()) == null) { - deathValidator.removeSpaceChars(deathtl); - uniqueList.put(deathtl.getRegistrationno(), deathtl); - if (null != deathtl.getHospitalname() && !deathtl.getHospitalname().trim().isEmpty()) { - if (deathtl.getHospitalname().length() > 500) { - importDeathWrapper.updateMaps(BirthDeathConstants.HOSPNAME_LARGE, deathtl); - importDeathWrapper.setServiceError(BirthDeathConstants.HOSPNAME_LARGE); - uniqueList.remove(deathtl.getRegistrationno()); - } else { - deathtl.setHospitalname(deathtl.getHospitalname().trim()); - if (!uniqueHospList.containsKey(deathtl.getHospitalname())) { - uniqueHospList.put(deathtl.getHospitalname(), new ArrayList()); - } - uniqueHospList.get(deathtl.getHospitalname()).add(deathtl); - } - } - - } else { - importDeathWrapper.updateMaps(BirthDeathConstants.DUPLICATE_REG_EXCEL, deathtl); - importDeathWrapper.setServiceError(BirthDeathConstants.DUPLICATE_REG_EXCEL); - duplicates.add(deathtl.getRegistrationno()); - } - } else { - importDeathWrapper.updateMaps(BirthDeathConstants.REG_EMPTY, deathtl); - importDeathWrapper.setServiceError(BirthDeathConstants.REG_EMPTY); - } - } else { - importDeathWrapper.updateMaps(BirthDeathConstants.UPDATE_ERROR, deathtl); - importDeathWrapper.setServiceError(BirthDeathConstants.UPDATE_ERROR); - } - } - }); - for (String regno : duplicates) { - importDeathWrapper.updateMaps(BirthDeathConstants.DUPLICATE_REG_EXCEL, uniqueList.get(regno)); - importDeathWrapper.setServiceError(BirthDeathConstants.DUPLICATE_REG_EXCEL); - uniqueList.remove(regno); - } - modifyHospIdDeath(uniqueHospList , response.getDeathCerts().get(0).getTenantid()); - AuditDetails auditDetails; - int finalCount=0; - for (Entry entry : uniqueList.entrySet()) { - EgDeathDtl deathDtl = entry.getValue(); - if(deathDtl.getIsLegacyRecord() != null && deathDtl.getIsLegacyRecord()) { - auditDetails = commUtils.getAuditDetails("import-user", true); - } else { - auditDetails = commUtils.getAuditDetails(requestInfo.getUserInfo().getUuid(), true); - } - deathDtl.setGenderStr(deathDtl.getGenderStr()==null?"":deathDtl.getGenderStr().trim().toLowerCase()); - switch (deathDtl.getGenderStr()) { - case "male": - deathDtl.setGender(1); - break; - case "female": - deathDtl.setGender(2); - break; - case "transgender": - deathDtl.setGender(3); - break; - default: - deathDtl.setGender(0); - break; - } - if(deathValidator.validateImportFields(deathDtl,importDeathWrapper)){ - try { - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(DEATHDTLUPDATEQRY, deathDtl.getTenantid()), getParametersForDeathDtl(deathDtl, auditDetails, false)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(DEATHFATHERINFOUPDATEQRY, deathDtl.getTenantid()), getParametersForFatherInfo(deathDtl, auditDetails, false)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(DEATHMOTHERINFOUPDATEQRY, deathDtl.getTenantid()), getParametersForMotherInfo(deathDtl, auditDetails, false)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(DEATHSPOUSEINFOUPDATEQRY, deathDtl.getTenantid()), getParametersForSpouseInfo(deathDtl, auditDetails, false)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(DEATHPERMADDRUPDATEQRY, deathDtl.getTenantid()), getParametersForPermAddr(deathDtl, auditDetails, false)); - namedParameterJdbcTemplate.update(callToReplaceSchemaPlaceHolder(DEATHPRESENTADDRUPDATEQRY, deathDtl.getTenantid()), getParametersForPresentAddr(deathDtl, auditDetails, false)); - finalCount++; - } - catch (Exception e) { - deathDtl.setRejectReason(BirthDeathConstants.DATA_ERROR); - importDeathWrapper.updateMaps(BirthDeathConstants.DATA_ERROR, deathDtl); - importDeathWrapper.setServiceError(BirthDeathConstants.DATA_ERROR); - e.printStackTrace(); - } - } - } - - log.info("completed " + finalCount); - importDeathWrapper.finaliseStats(response.getDeathCerts().size(),finalCount); - List hospitaldtls = getHospitalDtls(response.getDeathCerts().get(0).getTenantid()); - List hospitals = new ArrayList(); - for(EgHospitalDtl hospitalDtl: hospitaldtls) { - hospitals.add(hospitalDtl.getName()); - } - importDeathWrapper.setHospitals(hospitals); - } - catch (Exception e) { - importDeathWrapper.setServiceError("Service Error in Updating"); - e.printStackTrace(); - } - return importDeathWrapper; - } - - public String callToReplaceSchemaPlaceHolder(String query, String tenantId){ - try { - //TODO: Need to check with kavi if we need to do this or if its correct - query = centralInstanceUtil.replaceSchemaPlaceholder(query, tenantId); - } catch (InvalidTenantIdException e) { - throw new CustomException("WS_AS_TENANTID_ERROR", - "TenantId length is not sufficient to replace query schema in a multi state instance"); - } - return query; - } + } + + public ImportBirthWrapper saveBirthImport(BirthResponse response, RequestInfo requestInfo) { + ImportBirthWrapper importBirthWrapper = new ImportBirthWrapper(); + try { + Map uniqueList = new HashMap(); + Map> uniqueHospList = new HashMap>(); + Set duplicates = new HashSet(); + response.getBirthCerts().forEach(bdtl -> { + if (null != bdtl.getRejectReason()) { + importBirthWrapper.updateMaps(BirthDeathConstants.EXCEL_DATA_ERROR, bdtl); + } else { + boolean isLegacy = bdtl.getIsLegacyRecord() != null && bdtl.getIsLegacyRecord(); + // Always set id as random UUID + bdtl.setId(UUID.randomUUID().toString()); + if (!isLegacy && (bdtl.getRegistrationno() == null || bdtl.getRegistrationno().isEmpty())) { + // Generate registrationno from IdGen + IdGenerationResponse idGenResp = idGenRepository.getId(requestInfo, bdtl.getTenantid(), + config.getBirthApplNumberIdgenName(), config.getBirthApplNumberIdgenFormat(), 1); + if (idGenResp != null && idGenResp.getIdResponses() != null + && !idGenResp.getIdResponses().isEmpty()) { + bdtl.setRegistrationno(idGenResp.getIdResponses().get(0).getId()); + } else { + importBirthWrapper.updateMaps(BirthDeathConstants.REG_EMPTY, bdtl); + importBirthWrapper.setServiceError(BirthDeathConstants.REG_EMPTY); + return; + } + } + if (bdtl.getRegistrationno() != null) { + if (uniqueList.get(bdtl.getRegistrationno()) == null) { + birthValidator.removeSpaceChars(bdtl); + uniqueList.put(bdtl.getRegistrationno(), bdtl); + if (null != bdtl.getHospitalname() && !bdtl.getHospitalname().trim().isEmpty()) { + if (bdtl.getHospitalname().length() > 500) { + importBirthWrapper.updateMaps(BirthDeathConstants.HOSPNAME_LARGE, bdtl); + importBirthWrapper.setServiceError(BirthDeathConstants.HOSPNAME_LARGE); + uniqueList.remove(bdtl.getRegistrationno()); + } else { + bdtl.setHospitalname(bdtl.getHospitalname().trim()); + if (!uniqueHospList.containsKey(bdtl.getHospitalname())) { + uniqueHospList.put(bdtl.getHospitalname(), new ArrayList()); + } + uniqueHospList.get(bdtl.getHospitalname()).add(bdtl); + } + } + } else { + importBirthWrapper.updateMaps(BirthDeathConstants.DUPLICATE_REG_EXCEL, bdtl); + importBirthWrapper.setServiceError(BirthDeathConstants.DUPLICATE_REG_EXCEL); + duplicates.add(bdtl.getRegistrationno()); + } + } else { + importBirthWrapper.updateMaps(BirthDeathConstants.REG_EMPTY, bdtl); + importBirthWrapper.setServiceError(BirthDeathConstants.REG_EMPTY); + } + } + }); + for (String regno : duplicates) { + importBirthWrapper.updateMaps(BirthDeathConstants.DUPLICATE_REG_EXCEL, uniqueList.get(regno)); + importBirthWrapper.setServiceError(BirthDeathConstants.DUPLICATE_REG_EXCEL); + uniqueList.remove(regno); + } + modifyHospIdBirth(uniqueHospList, response.getBirthCerts().get(0).getTenantid()); + int finalCount = 0; + AuditDetails auditDetails; + for (Entry entry : uniqueList.entrySet()) { + EgBirthDtl birthDtl = entry.getValue(); + birthDtl.setGenderStr( + birthDtl.getGenderStr() == null ? "" : birthDtl.getGenderStr().trim().toLowerCase()); + if (birthDtl.getIsLegacyRecord() != null && birthDtl.getIsLegacyRecord()) { + auditDetails = commUtils.getAuditDetails("import-user", true); + } else { + auditDetails = commUtils.getAuditDetails(requestInfo.getUserInfo().getUuid(), true); + } + log.info("Gender String: {}", birthDtl.getGenderStr()); + switch (birthDtl.getGenderStr()) { + case "male": + birthDtl.setGender(1); + break; + case "female": + birthDtl.setGender(2); + break; + case "transgender": + birthDtl.setGender(3); + break; + case "other": + birthDtl.setGender(4); + break; + default: + birthDtl.setGender(0); + break; + } + if (birthValidator.validateUniqueRegNo(birthDtl, importBirthWrapper) + && birthValidator.validateImportFields(birthDtl, importBirthWrapper)) { + try { + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(BIRTHDTLSAVEQRY, birthDtl.getTenantid()), + getParametersForBirthDtl(birthDtl, auditDetails, true)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(BIRTHFATHERINFOSAVEQRY, birthDtl.getTenantid()), + getParametersForFatherInfo(birthDtl, auditDetails, true)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(BIRTHMOTHERINFOSAVEQRY, birthDtl.getTenantid()), + getParametersForMotherInfo(birthDtl, auditDetails, true)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(BIRTHPERMADDRSAVEQRY, birthDtl.getTenantid()), + getParametersForPermAddr(birthDtl, auditDetails, true)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(BIRTHPRESENTADDRSAVEQRY, birthDtl.getTenantid()), + getParametersForPresentAddr(birthDtl, auditDetails, true)); + finalCount++; + } catch (Exception e) { + birthDtl.setRejectReason(BirthDeathConstants.DATA_ERROR); + importBirthWrapper.updateMaps(BirthDeathConstants.DATA_ERROR, birthDtl); + Map params = new HashMap<>(); + params.put("tenantid", birthDtl.getTenantid()); + params.put("registrationno", birthDtl.getRegistrationno()); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(BIRTHDTLDELETEQRY, birthDtl.getTenantid()), params); + e.printStackTrace(); + } + } + } + + log.info("completed " + finalCount); + EgBirthDtl bdtl = response.getBirthCerts().get(0); + User owner = userService.manageOwner(bdtl.getTenantid(), bdtl.getBirthFatherInfo(), response.getRequestInfo(), false); + bdtl.setUser(owner); + importBirthWrapper.finaliseStats(response.getBirthCerts().size(), finalCount); + List hospitaldtls = getHospitalDtls(response.getBirthCerts().get(0).getTenantid()); + List hospitals = new ArrayList(); + for (EgHospitalDtl hospitalDtl : hospitaldtls) { + hospitals.add(hospitalDtl.getName()); + } + importBirthWrapper.setHospitals(hospitals); + } catch (Exception e) { + importBirthWrapper.setServiceError("Service Error in importing"); + e.printStackTrace(); + } + return importBirthWrapper; + } + + private void modifyHospIdBirth(Map> uniqueHospList, String tenantid) { + Map dbHospNameIdMap = new HashMap(); + List hospitals = commonService.search(tenantid); + for (EgHospitalDtl egHospitalDtl : hospitals) { + dbHospNameIdMap.put(egHospitalDtl.getName(), egHospitalDtl.getId()); + } + if (!uniqueHospList.keySet().isEmpty()) { + + for (String hospName : uniqueHospList.keySet()) { + if (!dbHospNameIdMap.containsKey(hospName)) { + String id = tenantid.split("\\.")[1] + "_" + (dbHospNameIdMap.keySet().size() + 1); + jdbcTemplate.update(callToReplaceSchemaPlaceHolder(HOSPITALINSERTSQL, tenantid), id, hospName, + tenantid); + dbHospNameIdMap.put(hospName, id); + } + for (EgBirthDtl bdtl : uniqueHospList.get(hospName)) { + bdtl.setHospitalid(dbHospNameIdMap.get(hospName)); + } + } + } + } + + private void modifyHospIdDeath(Map> uniqueHospList, String tenantid) { + Map dbHospNameIdMap = new HashMap(); + List hospitals = commonService.search(tenantid); + for (EgHospitalDtl egHospitalDtl : hospitals) { + dbHospNameIdMap.put(egHospitalDtl.getName(), egHospitalDtl.getId()); + } + if (!uniqueHospList.keySet().isEmpty()) { + + for (String hospName : uniqueHospList.keySet()) { + if (!dbHospNameIdMap.containsKey(hospName)) { + String id = tenantid.split("\\.")[1] + "_" + (dbHospNameIdMap.keySet().size() + 1); + jdbcTemplate.update(callToReplaceSchemaPlaceHolder(HOSPITALINSERTSQL, tenantid), id, hospName, + tenantid); + dbHospNameIdMap.put(hospName, id); + } + for (EgDeathDtl bdtl : uniqueHospList.get(hospName)) { + bdtl.setHospitalid(dbHospNameIdMap.get(hospName)); + } + } + } + } + + private MapSqlParameterSource getParametersForPresentAddr(EgBirthDtl birthDtl, AuditDetails auditDetails, + boolean isInsert) { + MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); + EgBirthPresentaddr presentaddr = birthDtl.getBirthPresentaddr(); + sqlParameterSource.addValue("id", UUID.randomUUID().toString()); + sqlParameterSource.addValue("buildingno", presentaddr.getBuildingno()); + sqlParameterSource.addValue("houseno", presentaddr.getHouseno()); + sqlParameterSource.addValue("streetname", presentaddr.getStreetname()); + sqlParameterSource.addValue("locality", presentaddr.getLocality()); + sqlParameterSource.addValue("tehsil", presentaddr.getTehsil()); + sqlParameterSource.addValue("district", presentaddr.getDistrict()); + sqlParameterSource.addValue("city", presentaddr.getCity()); + sqlParameterSource.addValue("state", presentaddr.getState()); + sqlParameterSource.addValue("pinno", presentaddr.getPinno()); + sqlParameterSource.addValue("country", presentaddr.getCountry()); + sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); + sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); + if (isInsert) { + sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); + sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); + sqlParameterSource.addValue("lastmodifiedtime", null); + sqlParameterSource.addValue("lastmodifiedby", null); + } else { + sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); + sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); + } + sqlParameterSource.addValue("birthdtlid", birthDtl.getId()); + return sqlParameterSource; + } + + private MapSqlParameterSource getParametersForPermAddr(EgBirthDtl birthDtl, AuditDetails auditDetails, + boolean isInsert) { + MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); + EgBirthPermaddr permaddr = birthDtl.getBirthPermaddr(); + sqlParameterSource.addValue("id", UUID.randomUUID().toString()); + sqlParameterSource.addValue("buildingno", permaddr.getBuildingno()); + sqlParameterSource.addValue("houseno", permaddr.getHouseno()); + sqlParameterSource.addValue("streetname", permaddr.getStreetname()); + sqlParameterSource.addValue("locality", permaddr.getLocality()); + sqlParameterSource.addValue("tehsil", permaddr.getTehsil()); + sqlParameterSource.addValue("district", permaddr.getDistrict()); + sqlParameterSource.addValue("city", permaddr.getCity()); + sqlParameterSource.addValue("state", permaddr.getState()); + sqlParameterSource.addValue("pinno", permaddr.getPinno()); + sqlParameterSource.addValue("country", permaddr.getCountry()); + sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); + sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); + if (isInsert) { + sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); + sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); + sqlParameterSource.addValue("lastmodifiedtime", null); + sqlParameterSource.addValue("lastmodifiedby", null); + } else { + sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); + sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); + } + sqlParameterSource.addValue("birthdtlid", birthDtl.getId()); + return sqlParameterSource; + } + + private MapSqlParameterSource getParametersForMotherInfo(EgBirthDtl birthDtl, AuditDetails auditDetails, + boolean isInsert) { + EgBirthMotherInfo birthMotherInfo = encryptionDecryptionUtil.encryptObject(birthDtl.getBirthMotherInfo(), + "BndDetail", EgBirthMotherInfo.class); + MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); + sqlParameterSource.addValue("id", UUID.randomUUID().toString()); + sqlParameterSource.addValue("firstname", birthMotherInfo.getFirstname()); + sqlParameterSource.addValue("middlename", birthMotherInfo.getMiddlename()); + sqlParameterSource.addValue("lastname", birthMotherInfo.getLastname()); + sqlParameterSource.addValue("aadharno", birthMotherInfo.getAadharno()); + sqlParameterSource.addValue("emailid", birthMotherInfo.getEmailid()); + sqlParameterSource.addValue("mobileno", birthMotherInfo.getMobileno()); + sqlParameterSource.addValue("education", birthMotherInfo.getEducation()); + sqlParameterSource.addValue("proffession", birthMotherInfo.getProffession()); + sqlParameterSource.addValue("nationality", birthMotherInfo.getNationality()); + sqlParameterSource.addValue("religion", birthMotherInfo.getReligion()); + if (isInsert) { + sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); + sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); + sqlParameterSource.addValue("lastmodifiedtime", null); + sqlParameterSource.addValue("lastmodifiedby", null); + } else { + sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); + sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); + } + sqlParameterSource.addValue("birthdtlid", birthDtl.getId()); + return sqlParameterSource; + } + + private MapSqlParameterSource getParametersForFatherInfo(EgBirthDtl birthDtl, AuditDetails auditDetails, + boolean isInsert) { + EgBirthFatherInfo birthFatherInfo = encryptionDecryptionUtil.encryptObject(birthDtl.getBirthFatherInfo(), + "BndDetail", EgBirthFatherInfo.class); + MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); + sqlParameterSource.addValue("id", UUID.randomUUID().toString()); + sqlParameterSource.addValue("firstname", birthFatherInfo.getFirstname()); + sqlParameterSource.addValue("middlename", birthFatherInfo.getMiddlename()); + sqlParameterSource.addValue("lastname", birthFatherInfo.getLastname()); + sqlParameterSource.addValue("aadharno", birthFatherInfo.getAadharno()); + sqlParameterSource.addValue("emailid", birthFatherInfo.getEmailid()); + sqlParameterSource.addValue("mobileno", birthFatherInfo.getMobileno()); + sqlParameterSource.addValue("education", birthFatherInfo.getEducation()); + sqlParameterSource.addValue("proffession", birthFatherInfo.getProffession()); + sqlParameterSource.addValue("nationality", birthFatherInfo.getNationality()); + sqlParameterSource.addValue("religion", birthFatherInfo.getReligion()); + if (isInsert) { + sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); + sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); + sqlParameterSource.addValue("lastmodifiedtime", null); + sqlParameterSource.addValue("lastmodifiedby", null); + } else { + sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); + sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); + } + sqlParameterSource.addValue("birthdtlid", birthDtl.getId()); + + return sqlParameterSource; + } + + private MapSqlParameterSource getParametersForBirthDtl(EgBirthDtl birthDtl, AuditDetails auditDetails, + boolean isInsert) { + MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); + String id = ""; + if (isInsert) + id = UUID.randomUUID().toString(); + else + id = birthDtl.getId(); + sqlParameterSource.addValue("id", id); + sqlParameterSource.addValue("registrationno", birthDtl.getRegistrationno()); + sqlParameterSource.addValue("hospitalname", birthDtl.getHospitalname()); + sqlParameterSource.addValue("dateofreport", birthDtl.getDateofreport()); + sqlParameterSource.addValue("dateofbirth", birthDtl.getDateofbirth()); + sqlParameterSource.addValue("firstname", birthDtl.getFirstname()); + sqlParameterSource.addValue("middlename", birthDtl.getMiddlename()); + sqlParameterSource.addValue("lastname", birthDtl.getLastname()); + sqlParameterSource.addValue("placeofbirth", birthDtl.getPlaceofbirth()); + sqlParameterSource.addValue("informantsname", birthDtl.getInformantsname()); + sqlParameterSource.addValue("informantsaddress", birthDtl.getInformantsaddress()); + if (isInsert) { + sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); + sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); + sqlParameterSource.addValue("lastmodifiedtime", null); + sqlParameterSource.addValue("lastmodifiedby", null); + } else { + sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); + sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); + } + sqlParameterSource.addValue("counter", birthDtl.getCounter()); + sqlParameterSource.addValue("tenantid", birthDtl.getTenantid()); + sqlParameterSource.addValue("gender", birthDtl.getGender()); + sqlParameterSource.addValue("remarks", birthDtl.getRemarks()); + sqlParameterSource.addValue("hospitalid", birthDtl.getHospitalid()); + sqlParameterSource.addValue("islegacyrecord", birthDtl.getIsLegacyRecord()); + birthDtl.setId(id); + return sqlParameterSource; + + } + + public ImportDeathWrapper saveDeathImport(DeathResponse response, RequestInfo requestInfo) { + ImportDeathWrapper importDeathWrapper = new ImportDeathWrapper(); + try { + Map uniqueList = new HashMap(); + Map> uniqueHospList = new HashMap>(); + Set duplicates = new HashSet(); + response.getDeathCerts().forEach(deathtl -> { + if (null != deathtl.getRejectReason()) { + importDeathWrapper.updateMaps(BirthDeathConstants.EXCEL_DATA_ERROR, deathtl); + importDeathWrapper.setServiceError(BirthDeathConstants.EXCEL_DATA_ERROR); + } else { + boolean isLegacy = deathtl.getIsLegacyRecord() != null && deathtl.getIsLegacyRecord(); + // Always set id as random UUID + deathtl.setId(UUID.randomUUID().toString()); + if (!isLegacy && (deathtl.getRegistrationno() == null || deathtl.getRegistrationno().isEmpty())) { + // Generate registrationno from IdGen + IdGenerationResponse idGenResp = idGenRepository.getId(requestInfo, deathtl.getTenantid(), + config.getDeathApplNumberIdgenName(), config.getDeathApplNumberIdgenFormat(), 1); + if (idGenResp != null && idGenResp.getIdResponses() != null + && !idGenResp.getIdResponses().isEmpty()) { + deathtl.setRegistrationno(idGenResp.getIdResponses().get(0).getId()); + } else { + importDeathWrapper.updateMaps(BirthDeathConstants.REG_EMPTY, deathtl); + importDeathWrapper.setServiceError(BirthDeathConstants.REG_EMPTY); + return; + } + } + if (deathtl.getRegistrationno() != null) { + if (uniqueList.get(deathtl.getRegistrationno()) == null) { + deathValidator.removeSpaceChars(deathtl); + uniqueList.put(deathtl.getRegistrationno(), deathtl); + if (null != deathtl.getHospitalname() && !deathtl.getHospitalname().trim().isEmpty()) { + if (deathtl.getHospitalname().length() > 500) { + importDeathWrapper.updateMaps(BirthDeathConstants.HOSPNAME_LARGE, deathtl); + importDeathWrapper.setServiceError(BirthDeathConstants.HOSPNAME_LARGE); + uniqueList.remove(deathtl.getRegistrationno()); + } else { + deathtl.setHospitalname(deathtl.getHospitalname().trim()); + if (!uniqueHospList.containsKey(deathtl.getHospitalname())) { + uniqueHospList.put(deathtl.getHospitalname(), new ArrayList()); + } + uniqueHospList.get(deathtl.getHospitalname()).add(deathtl); + } + } + } else { + importDeathWrapper.updateMaps(BirthDeathConstants.DUPLICATE_REG_EXCEL, deathtl); + importDeathWrapper.setServiceError(BirthDeathConstants.DUPLICATE_REG_EXCEL); + duplicates.add(deathtl.getRegistrationno()); + } + } else { + importDeathWrapper.updateMaps(BirthDeathConstants.REG_EMPTY, deathtl); + importDeathWrapper.setServiceError(BirthDeathConstants.REG_EMPTY); + } + } + }); + for (String regno : duplicates) { + importDeathWrapper.updateMaps(BirthDeathConstants.DUPLICATE_REG_EXCEL, uniqueList.get(regno)); + importDeathWrapper.setServiceError(BirthDeathConstants.DUPLICATE_REG_EXCEL); + uniqueList.remove(regno); + } + modifyHospIdDeath(uniqueHospList, response.getDeathCerts().get(0).getTenantid()); + int finalCount = 0; + AuditDetails auditDetails; + for (Entry entry : uniqueList.entrySet()) { + EgDeathDtl deathDtl = entry.getValue(); + if (deathDtl.getIsLegacyRecord() != null && deathDtl.getIsLegacyRecord()) { + auditDetails = commUtils.getAuditDetails("import-user", true); + } else { + auditDetails = commUtils.getAuditDetails(requestInfo.getUserInfo().getUuid(), true); + } + deathDtl.setGenderStr( + deathDtl.getGenderStr() == null ? "" : deathDtl.getGenderStr().trim().toLowerCase()); + switch (deathDtl.getGenderStr()) { + case "male": + deathDtl.setGender(1); + break; + case "female": + deathDtl.setGender(2); + break; + case "transgender": + deathDtl.setGender(3); + break; + case "other": + deathDtl.setGender(4); + break; + default: + deathDtl.setGender(0); + break; + } + if (deathValidator.validateUniqueRegNo(deathDtl, importDeathWrapper) + && deathValidator.validateImportFields(deathDtl, importDeathWrapper)) { + try { + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(DEATHDTLSAVEQRY, deathDtl.getTenantid()), + getParametersForDeathDtl(deathDtl, auditDetails, true)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(DEATHFATHERINFOSAVEQRY, deathDtl.getTenantid()), + getParametersForFatherInfo(deathDtl, auditDetails, true)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(DEATHMOTHERINFOSAVEQRY, deathDtl.getTenantid()), + getParametersForMotherInfo(deathDtl, auditDetails, true)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(DEATHSPOUSEINFOSAVEQRY, deathDtl.getTenantid()), + getParametersForSpouseInfo(deathDtl, auditDetails, true)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(DEATHPERMADDRSAVEQRY, deathDtl.getTenantid()), + getParametersForPermAddr(deathDtl, auditDetails, true)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(DEATHPRESENTADDRSAVEQRY, deathDtl.getTenantid()), + getParametersForPresentAddr(deathDtl, auditDetails, true)); + finalCount++; + } catch (Exception e) { + deathDtl.setRejectReason(BirthDeathConstants.DATA_ERROR); + importDeathWrapper.updateMaps(BirthDeathConstants.DATA_ERROR, deathDtl); + Map params = new HashMap<>(); + params.put("tenantid", deathDtl.getTenantid()); + params.put("registrationno", deathDtl.getRegistrationno()); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(DEATHDTLDELETEQRY, deathDtl.getTenantid()), params); + e.printStackTrace(); + } + } + } + + log.info("completed " + finalCount); + + EgDeathDtl dtl = response.getDeathCerts().get(0); + User owner = userService.manageOwner(dtl.getTenantid(), dtl.getDeathFatherInfo(), response.getRequestInfo(), false); + dtl.setUser(owner); + + importDeathWrapper.finaliseStats(response.getDeathCerts().size(), finalCount); + List hospitaldtls = getHospitalDtls(response.getDeathCerts().get(0).getTenantid()); + List hospitals = new ArrayList(); + for (EgHospitalDtl hospitalDtl : hospitaldtls) { + hospitals.add(hospitalDtl.getName()); + } + importDeathWrapper.setHospitals(hospitals); + } catch (Exception e) { + importDeathWrapper.setServiceError("Service Error in importing"); + e.printStackTrace(); + } + return importDeathWrapper; + } + + private MapSqlParameterSource getParametersForPresentAddr(EgDeathDtl deathDtl, AuditDetails auditDetails, + boolean isInsert) { + MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); + EgDeathPresentaddr presentaddr = deathDtl.getDeathPresentaddr(); + sqlParameterSource.addValue("id", UUID.randomUUID().toString()); + sqlParameterSource.addValue("buildingno", presentaddr.getBuildingno()); + sqlParameterSource.addValue("houseno", presentaddr.getHouseno()); + sqlParameterSource.addValue("streetname", presentaddr.getStreetname()); + sqlParameterSource.addValue("locality", presentaddr.getLocality()); + sqlParameterSource.addValue("tehsil", presentaddr.getTehsil()); + sqlParameterSource.addValue("district", presentaddr.getDistrict()); + sqlParameterSource.addValue("city", presentaddr.getCity()); + sqlParameterSource.addValue("state", presentaddr.getState()); + sqlParameterSource.addValue("pinno", presentaddr.getPinno()); + sqlParameterSource.addValue("country", presentaddr.getCountry()); + if (isInsert) { + sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); + sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); + sqlParameterSource.addValue("lastmodifiedtime", null); + sqlParameterSource.addValue("lastmodifiedby", null); + } else { + sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); + sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); + } + sqlParameterSource.addValue("deathdtlid", deathDtl.getId()); + return sqlParameterSource; + } + + private MapSqlParameterSource getParametersForPermAddr(EgDeathDtl deathDtl, AuditDetails auditDetails, + boolean isInsert) { + MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); + EgDeathPermaddr permaddr = deathDtl.getDeathPermaddr(); + sqlParameterSource.addValue("id", UUID.randomUUID().toString()); + sqlParameterSource.addValue("buildingno", permaddr.getBuildingno()); + sqlParameterSource.addValue("houseno", permaddr.getHouseno()); + sqlParameterSource.addValue("streetname", permaddr.getStreetname()); + sqlParameterSource.addValue("locality", permaddr.getLocality()); + sqlParameterSource.addValue("tehsil", permaddr.getTehsil()); + sqlParameterSource.addValue("district", permaddr.getDistrict()); + sqlParameterSource.addValue("city", permaddr.getCity()); + sqlParameterSource.addValue("state", permaddr.getState()); + sqlParameterSource.addValue("pinno", permaddr.getPinno()); + sqlParameterSource.addValue("country", permaddr.getCountry()); + if (isInsert) { + sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); + sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); + sqlParameterSource.addValue("lastmodifiedtime", null); + sqlParameterSource.addValue("lastmodifiedby", null); + } else { + sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); + sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); + } + sqlParameterSource.addValue("deathdtlid", deathDtl.getId()); + return sqlParameterSource; + } + + private MapSqlParameterSource getParametersForMotherInfo(EgDeathDtl deathDtl, AuditDetails auditDetails, + boolean isInsert) { + EgDeathMotherInfo deathMotherInfo = encryptionDecryptionUtil.encryptObject(deathDtl.getDeathMotherInfo(), + "BndDetail", EgDeathMotherInfo.class); + MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); + sqlParameterSource.addValue("id", UUID.randomUUID().toString()); + sqlParameterSource.addValue("firstname", deathMotherInfo.getFirstname()); + sqlParameterSource.addValue("middlename", deathMotherInfo.getMiddlename()); + sqlParameterSource.addValue("lastname", deathMotherInfo.getLastname()); + sqlParameterSource.addValue("aadharno", deathMotherInfo.getAadharno()); + sqlParameterSource.addValue("emailid", deathMotherInfo.getEmailid()); + sqlParameterSource.addValue("mobileno", deathMotherInfo.getMobileno()); + if (isInsert) { + sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); + sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); + sqlParameterSource.addValue("lastmodifiedtime", null); + sqlParameterSource.addValue("lastmodifiedby", null); + } else { + sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); + sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); + } + sqlParameterSource.addValue("deathdtlid", deathDtl.getId()); + return sqlParameterSource; + } + + private MapSqlParameterSource getParametersForSpouseInfo(EgDeathDtl deathDtl, AuditDetails auditDetails, + boolean isInsert) { + EgDeathSpouseInfo deathSpouseInfo = encryptionDecryptionUtil.encryptObject(deathDtl.getDeathSpouseInfo(), + "BndDetail", EgDeathSpouseInfo.class); + MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); + sqlParameterSource.addValue("id", UUID.randomUUID().toString()); + sqlParameterSource.addValue("firstname", deathSpouseInfo.getFirstname()); + sqlParameterSource.addValue("middlename", deathSpouseInfo.getMiddlename()); + sqlParameterSource.addValue("lastname", deathSpouseInfo.getLastname()); + sqlParameterSource.addValue("aadharno", deathSpouseInfo.getAadharno()); + sqlParameterSource.addValue("emailid", deathSpouseInfo.getEmailid()); + sqlParameterSource.addValue("mobileno", deathSpouseInfo.getMobileno()); + if (isInsert) { + sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); + sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); + sqlParameterSource.addValue("lastmodifiedtime", null); + sqlParameterSource.addValue("lastmodifiedby", null); + } else { + sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); + sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); + } + sqlParameterSource.addValue("deathdtlid", deathDtl.getId()); + return sqlParameterSource; + } + + private MapSqlParameterSource getParametersForFatherInfo(EgDeathDtl deathDtl, + AuditDetails auditDetails, boolean isInsert) { + EgDeathFatherInfo deathFatherInfo = encryptionDecryptionUtil.encryptObject(deathDtl.getDeathFatherInfo(), + "BndDetail", EgDeathFatherInfo.class); + MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); + sqlParameterSource.addValue("id", UUID.randomUUID().toString()); + sqlParameterSource.addValue("firstname", deathFatherInfo.getFirstname()); + sqlParameterSource.addValue("middlename", deathFatherInfo.getMiddlename()); + sqlParameterSource.addValue("lastname", deathFatherInfo.getLastname()); + sqlParameterSource.addValue("aadharno", deathFatherInfo.getAadharno()); + sqlParameterSource.addValue("emailid", deathFatherInfo.getEmailid()); + sqlParameterSource.addValue("mobileno", deathFatherInfo.getMobileno()); + if (isInsert) { + sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); + sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); + sqlParameterSource.addValue("lastmodifiedtime", null); + sqlParameterSource.addValue("lastmodifiedby", null); + } else { + sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); + sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); + } + sqlParameterSource.addValue("deathdtlid", deathDtl.getId()); + return sqlParameterSource; + } + + private MapSqlParameterSource getParametersForDeathDtl(EgDeathDtl deathDtl, AuditDetails auditDetails, + boolean isInsert) { + MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource(); + EgDeathDtl deathDtlEnc = encryptionDecryptionUtil.encryptObject(deathDtl, "BndDetail", EgDeathDtl.class); + String id = ""; + if (isInsert) + id = UUID.randomUUID().toString(); + else + id = deathDtl.getId(); + sqlParameterSource.addValue("id", id); + sqlParameterSource.addValue("registrationno", deathDtl.getRegistrationno()); + sqlParameterSource.addValue("hospitalname", deathDtl.getHospitalname()); + sqlParameterSource.addValue("dateofreport", deathDtl.getDateofreport()); + sqlParameterSource.addValue("dateofdeath", deathDtl.getDateofdeath()); + sqlParameterSource.addValue("firstname", deathDtl.getFirstname()); + sqlParameterSource.addValue("middlename", deathDtl.getMiddlename()); + sqlParameterSource.addValue("lastname", deathDtl.getLastname()); + sqlParameterSource.addValue("placeofdeath", deathDtl.getPlaceofdeath()); + sqlParameterSource.addValue("informantsname", deathDtl.getInformantsname()); + sqlParameterSource.addValue("informantsaddress", deathDtl.getInformantsaddress()); + if (isInsert) { + sqlParameterSource.addValue("createdtime", auditDetails.getCreatedTime()); + sqlParameterSource.addValue("createdby", auditDetails.getCreatedBy()); + sqlParameterSource.addValue("lastmodifiedtime", null); + sqlParameterSource.addValue("lastmodifiedby", null); + } else { + sqlParameterSource.addValue("lastmodifiedtime", auditDetails.getLastModifiedTime()); + sqlParameterSource.addValue("lastmodifiedby", auditDetails.getLastModifiedBy()); + } + sqlParameterSource.addValue("counter", deathDtl.getCounter()); + sqlParameterSource.addValue("tenantid", deathDtl.getTenantid()); + sqlParameterSource.addValue("gender", deathDtl.getGender()); + sqlParameterSource.addValue("remarks", deathDtl.getRemarks()); + sqlParameterSource.addValue("hospitalid", deathDtl.getHospitalid()); + sqlParameterSource.addValue("age", deathDtl.getAge()); + sqlParameterSource.addValue("eidno", deathDtl.getEidno()); + sqlParameterSource.addValue("aadharno", deathDtlEnc.getAadharno()); + // sqlParameterSource.addValue("aadharno", "567346251423" ); + sqlParameterSource.addValue("nationality", deathDtl.getNationality()); + sqlParameterSource.addValue("religion", deathDtl.getReligion()); + sqlParameterSource.addValue("icdcode", deathDtlEnc.getIcdcode()); + // sqlParameterSource.addValue("icdcode", "2345"); + sqlParameterSource.addValue("islegacyrecord", deathDtl.getIsLegacyRecord()); + deathDtl.setId(id); + return sqlParameterSource; + + } + + public ImportBirthWrapper updateBirthImport(BirthResponse response, RequestInfo requestInfo) { + ImportBirthWrapper importBirthWrapper = new ImportBirthWrapper(); + try { + Map uniqueList = new HashMap(); + Map> uniqueHospList = new HashMap>(); + Set duplicates = new HashSet(); + response.getBirthCerts().forEach(bdtl -> { + if (null != bdtl.getRejectReason()) { + importBirthWrapper.updateMaps(BirthDeathConstants.EXCEL_DATA_ERROR, bdtl); + importBirthWrapper.setServiceError(BirthDeathConstants.EXCEL_DATA_ERROR); + } else { + if (bdtl.getId() != null) { + if (bdtl.getRegistrationno() != null) { + if (uniqueList.get(bdtl.getRegistrationno()) == null) { + birthValidator.removeSpaceChars(bdtl); + uniqueList.put(bdtl.getRegistrationno(), bdtl); + if (null != bdtl.getHospitalname() && !bdtl.getHospitalname().trim().isEmpty()) { + if (bdtl.getHospitalname().length() > 500) { + importBirthWrapper.updateMaps(BirthDeathConstants.HOSPNAME_LARGE, bdtl); + importBirthWrapper.setServiceError(BirthDeathConstants.EXCEL_DATA_ERROR); + uniqueList.remove(bdtl.getRegistrationno()); + } else { + bdtl.setHospitalname(bdtl.getHospitalname().trim()); + if (!uniqueHospList.containsKey(bdtl.getHospitalname())) { + uniqueHospList.put(bdtl.getHospitalname(), new ArrayList()); + } + uniqueHospList.get(bdtl.getHospitalname()).add(bdtl); + } + } + } else { + importBirthWrapper.updateMaps(BirthDeathConstants.DUPLICATE_REG_EXCEL, bdtl); + importBirthWrapper.setServiceError(BirthDeathConstants.EXCEL_DATA_ERROR); + duplicates.add(bdtl.getRegistrationno()); + } + } else { + importBirthWrapper.updateMaps(BirthDeathConstants.REG_EMPTY, bdtl); + importBirthWrapper.setServiceError(BirthDeathConstants.EXCEL_DATA_ERROR); + } + } else { + importBirthWrapper.updateMaps(BirthDeathConstants.UPDATE_ERROR, bdtl); + importBirthWrapper.setServiceError(BirthDeathConstants.EXCEL_DATA_ERROR); + } + } + + }); + for (String regno : duplicates) { + importBirthWrapper.updateMaps(BirthDeathConstants.DUPLICATE_REG_EXCEL, uniqueList.get(regno)); + uniqueList.remove(regno); + } + modifyHospIdBirth(uniqueHospList, response.getBirthCerts().get(0).getTenantid()); + AuditDetails auditDetails; + int finalCount = 0; + for (Entry entry : uniqueList.entrySet()) { + EgBirthDtl birthDtl = entry.getValue(); + if (birthDtl.getIsLegacyRecord() != null && birthDtl.getIsLegacyRecord()) { + auditDetails = commUtils.getAuditDetails("import-user", true); + } else { + auditDetails = commUtils.getAuditDetails(requestInfo.getUserInfo().getUuid(), true); + } + birthDtl.setGenderStr( + birthDtl.getGenderStr() == null ? "" : birthDtl.getGenderStr().trim().toLowerCase()); + switch (birthDtl.getGenderStr()) { + case "male": + birthDtl.setGender(1); + break; + case "female": + birthDtl.setGender(2); + break; + case "transgender": + birthDtl.setGender(3); + break; + case "other": + birthDtl.setGender(4); + break; + default: + birthDtl.setGender(0); + break; + } + if (birthValidator.validateImportFields(birthDtl, importBirthWrapper)) { + try { + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(BIRTHDTLUPDATEQRY, birthDtl.getTenantid()), + getParametersForBirthDtl(birthDtl, auditDetails, false)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(BIRTHFATHERINFOUPDATEQRY, birthDtl.getTenantid()), + getParametersForFatherInfo(birthDtl, auditDetails, false)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(BIRTHMOTHERINFOUPDATEQRY, birthDtl.getTenantid()), + getParametersForMotherInfo(birthDtl, auditDetails, false)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(BIRTHPERMADDRUPDATEQRY, birthDtl.getTenantid()), + getParametersForPermAddr(birthDtl, auditDetails, false)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(BIRTHPRESENTADDRUPDATEQRY, birthDtl.getTenantid()), + getParametersForPresentAddr(birthDtl, auditDetails, false)); + finalCount++; + } catch (Exception e) { + birthDtl.setRejectReason(BirthDeathConstants.DATA_ERROR); + importBirthWrapper.updateMaps(BirthDeathConstants.DATA_ERROR, birthDtl); + importBirthWrapper.setServiceError(BirthDeathConstants.DATA_ERROR); + e.printStackTrace(); + } + } + } + + log.info("completed " + finalCount); + EgBirthDtl bdtl = response.getBirthCerts().get(0); + User owner = userService.manageOwner(bdtl.getTenantid(), bdtl.getBirthFatherInfo(), response.getRequestInfo(), false); + bdtl.setUser(owner); + importBirthWrapper.finaliseStats(response.getBirthCerts().size(), finalCount); + List hospitaldtls = getHospitalDtls(response.getBirthCerts().get(0).getTenantid()); + List hospitals = new ArrayList(); + for (EgHospitalDtl hospitalDtl : hospitaldtls) { + hospitals.add(hospitalDtl.getName()); + } + importBirthWrapper.setHospitals(hospitals); + } catch (Exception e) { + importBirthWrapper.setServiceError("Service Error in Updating"); + e.printStackTrace(); + } + return importBirthWrapper; + } + + public ImportDeathWrapper updateDeathImport(DeathResponse response, RequestInfo requestInfo) { + ImportDeathWrapper importDeathWrapper = new ImportDeathWrapper(); + try { + // DeathResponse response= mapper.convertValue(importJSon, DeathResponse.class); + Map uniqueList = new HashMap(); + Map> uniqueHospList = new HashMap>(); + Set duplicates = new HashSet(); + response.getDeathCerts().forEach(deathtl -> { + if (null != deathtl.getRejectReason()) { + importDeathWrapper.updateMaps(BirthDeathConstants.EXCEL_DATA_ERROR, deathtl); + } else { + if (deathtl.getId() != null) { + if (deathtl.getRegistrationno() != null) { + if (uniqueList.get(deathtl.getRegistrationno()) == null) { + deathValidator.removeSpaceChars(deathtl); + uniqueList.put(deathtl.getRegistrationno(), deathtl); + if (null != deathtl.getHospitalname() && !deathtl.getHospitalname().trim().isEmpty()) { + if (deathtl.getHospitalname().length() > 500) { + importDeathWrapper.updateMaps(BirthDeathConstants.HOSPNAME_LARGE, deathtl); + importDeathWrapper.setServiceError(BirthDeathConstants.HOSPNAME_LARGE); + uniqueList.remove(deathtl.getRegistrationno()); + } else { + deathtl.setHospitalname(deathtl.getHospitalname().trim()); + if (!uniqueHospList.containsKey(deathtl.getHospitalname())) { + uniqueHospList.put(deathtl.getHospitalname(), new ArrayList()); + } + uniqueHospList.get(deathtl.getHospitalname()).add(deathtl); + } + } + + } else { + importDeathWrapper.updateMaps(BirthDeathConstants.DUPLICATE_REG_EXCEL, deathtl); + importDeathWrapper.setServiceError(BirthDeathConstants.DUPLICATE_REG_EXCEL); + duplicates.add(deathtl.getRegistrationno()); + } + } else { + importDeathWrapper.updateMaps(BirthDeathConstants.REG_EMPTY, deathtl); + importDeathWrapper.setServiceError(BirthDeathConstants.REG_EMPTY); + } + } else { + importDeathWrapper.updateMaps(BirthDeathConstants.UPDATE_ERROR, deathtl); + importDeathWrapper.setServiceError(BirthDeathConstants.UPDATE_ERROR); + } + } + }); + for (String regno : duplicates) { + importDeathWrapper.updateMaps(BirthDeathConstants.DUPLICATE_REG_EXCEL, uniqueList.get(regno)); + importDeathWrapper.setServiceError(BirthDeathConstants.DUPLICATE_REG_EXCEL); + uniqueList.remove(regno); + } + modifyHospIdDeath(uniqueHospList, response.getDeathCerts().get(0).getTenantid()); + AuditDetails auditDetails; + int finalCount = 0; + for (Entry entry : uniqueList.entrySet()) { + EgDeathDtl deathDtl = entry.getValue(); + if (deathDtl.getIsLegacyRecord() != null && deathDtl.getIsLegacyRecord()) { + auditDetails = commUtils.getAuditDetails("import-user", true); + } else { + auditDetails = commUtils.getAuditDetails(requestInfo.getUserInfo().getUuid(), true); + } + deathDtl.setGenderStr( + deathDtl.getGenderStr() == null ? "" : deathDtl.getGenderStr().trim().toLowerCase()); + switch (deathDtl.getGenderStr()) { + case "male": + deathDtl.setGender(1); + break; + case "female": + deathDtl.setGender(2); + break; + case "transgender": + deathDtl.setGender(3); + break; + case "other": + deathDtl.setGender(4); + break; + default: + deathDtl.setGender(0); + break; + } + if (deathValidator.validateImportFields(deathDtl, importDeathWrapper)) { + try { + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(DEATHDTLUPDATEQRY, deathDtl.getTenantid()), + getParametersForDeathDtl(deathDtl, auditDetails, false)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(DEATHFATHERINFOUPDATEQRY, deathDtl.getTenantid()), + getParametersForFatherInfo(deathDtl, auditDetails, false)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(DEATHMOTHERINFOUPDATEQRY, deathDtl.getTenantid()), + getParametersForMotherInfo(deathDtl, auditDetails, false)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(DEATHSPOUSEINFOUPDATEQRY, deathDtl.getTenantid()), + getParametersForSpouseInfo(deathDtl, auditDetails, false)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(DEATHPERMADDRUPDATEQRY, deathDtl.getTenantid()), + getParametersForPermAddr(deathDtl, auditDetails, false)); + namedParameterJdbcTemplate.update( + callToReplaceSchemaPlaceHolder(DEATHPRESENTADDRUPDATEQRY, deathDtl.getTenantid()), + getParametersForPresentAddr(deathDtl, auditDetails, false)); + finalCount++; + } catch (Exception e) { + deathDtl.setRejectReason(BirthDeathConstants.DATA_ERROR); + importDeathWrapper.updateMaps(BirthDeathConstants.DATA_ERROR, deathDtl); + importDeathWrapper.setServiceError(BirthDeathConstants.DATA_ERROR); + e.printStackTrace(); + } + } + } + + log.info("completed " + finalCount); + EgDeathDtl dtl = response.getDeathCerts().get(0); + User owner = userService.manageOwner(dtl.getTenantid(), dtl.getDeathFatherInfo(), response.getRequestInfo(), false); + dtl.setUser(owner); + importDeathWrapper.finaliseStats(response.getDeathCerts().size(), finalCount); + List hospitaldtls = getHospitalDtls(response.getDeathCerts().get(0).getTenantid()); + List hospitals = new ArrayList(); + for (EgHospitalDtl hospitalDtl : hospitaldtls) { + hospitals.add(hospitalDtl.getName()); + } + importDeathWrapper.setHospitals(hospitals); + } catch (Exception e) { + importDeathWrapper.setServiceError("Service Error in Updating"); + e.printStackTrace(); + } + return importDeathWrapper; + } + + public String callToReplaceSchemaPlaceHolder(String query, String tenantId) { + try { + // TODO: Need to check with kavi if we need to do this or if its correct + query = centralInstanceUtil.replaceSchemaPlaceholder(query, tenantId); + } catch (InvalidTenantIdException e) { + throw new CustomException("WS_AS_TENANTID_ERROR", + "TenantId length is not sufficient to replace query schema in a multi state instance"); + } + return query; + } } \ No newline at end of file diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/common/services/UserService.java b/birth-death-services/src/main/java/org/bel/birthdeath/common/services/UserService.java new file mode 100644 index 00000000000..bbe78defe14 --- /dev/null +++ b/birth-death-services/src/main/java/org/bel/birthdeath/common/services/UserService.java @@ -0,0 +1,372 @@ +package org.bel.birthdeath.common.services; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +import org.bel.birthdeath.common.config.CommonConfiguration; +import org.bel.birthdeath.common.contract.DeathResponse; +import org.bel.birthdeath.common.contract.ParentInfo; +import org.bel.birthdeath.common.contract.ParentInfoProvider; +import org.bel.birthdeath.common.model.user.User; +import org.bel.birthdeath.common.model.user.UserDetailResponse; +import org.bel.birthdeath.common.model.user.UserRequest; +import org.bel.birthdeath.common.model.user.UserSearchRequest; +import org.bel.birthdeath.common.repository.ServiceRequestRepository; +import org.bel.birthdeath.common.util.CommonErrorConstants; +import org.bel.birthdeath.common.util.Constants; +import org.bel.birthdeath.death.model.EgDeathDtl; +import org.bel.birthdeath.death.model.SearchCriteria; +import org.egov.common.contract.request.RequestInfo; +import org.egov.common.contract.request.Role; +import org.egov.tracer.model.CustomException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import lombok.extern.slf4j.Slf4j; + +@Service +@Slf4j +public class UserService { + + @Autowired + CommonConfiguration config; + + @Autowired + private ServiceRequestRepository serviceRequestRepository; + + @Autowired + private ObjectMapper mapper; + + /** + * + */ + @SuppressWarnings("null") + public User manageOwner(String tenantId, ParentInfo fatherInfo, RequestInfo requestInfo, boolean isUpdate) { + + if (fatherInfo == null) { + throw new CustomException("FATHER_INFO_MISSING", "Father information is missing"); + } + + User owner = new User(); + owner.setTenantId(tenantId); + owner.setGender(Constants.MALE); + owner.setName(fatherInfo.getFirstname()); + owner.setMobileNumber(fatherInfo.getMobileno()); + + if (owner.getMobileNumber() == null) { + throw new CustomException(CommonErrorConstants.INVALID_OWNER_ERROR, + "MobileNo is mandatory for ownerInfo"); + } + + UserDetailResponse userDetailResponse = userExists(owner); + + if (userDetailResponse != null && !CollectionUtils.isEmpty(userDetailResponse.getUser()) && !isUpdate) { + boolean notFoundUser = true; + + for (User user : userDetailResponse.getUser()) { + if ((user.getUserName().equalsIgnoreCase(user.getMobileNumber()) + && user.getName().equalsIgnoreCase(owner.getName())) + || user.getName().equalsIgnoreCase(owner.getName())) { + owner = user; + notFoundUser = false; + break; + } + } + + if (notFoundUser) { + owner = createFatherInfo(owner, requestInfo); + } + + } else { + if (!isUpdate) { + owner = createFatherInfo(owner, requestInfo); + } else { + HashMap errorMap = new HashMap<>(); + owner = updateUserDetails(owner, requestInfo, errorMap); + } + } + + return owner; + } + + /** + * Update Vehicle Details + * + * @param userInfo + * @param requestInfo + * @param errorMap + * @return + */ + private User updateUserDetails(User userInfo, RequestInfo requestInfo, HashMap errorMap) { + User userUpdated = new User(); + UserRequest userRequest = UserRequest.builder().user(userInfo).requestInfo(requestInfo).build(); + StringBuilder uri = new StringBuilder(); + uri.append(config.getUserHost()).append(config.getUserContextPath()).append(config.getUserUpdateEndpoint()); + UserDetailResponse userResponse = ownerCall(userRequest, uri); + if (userResponse != null && !userResponse.getUser().isEmpty()) { + userUpdated = userResponse.getUser().get(0); + } else { + errorMap.put(CommonErrorConstants.INVALID_OWNER, + "Unable to Update UserDetails to the existing birth/death certificate !"); + } + return userUpdated; + + } + + /** + * create Father info in User + * + * @param owner + * @param requestInfo + * @return + */ + private User createFatherInfo(User owner, RequestInfo requestInfo) { + +// if (!isUserValid(owner)) { +// throw new CustomException(CommonErrorConstants.INVALID_OWNER_ERROR, +// "Dob, relationShip, relation ship name and gender are mandaotry !"); +// } + Role role = getCitizenRole(); + addUserDefaultFields(owner.getTenantId(), role, owner); + StringBuilder uri = new StringBuilder(config.getUserHost()).append(config.getUserContextPath()) + .append(config.getUserCreateEndpoint()); + + setUserName(owner); + + owner.setType(Constants.CITIZEN); + UserDetailResponse userDetailResponse = userCall(new UserRequest(requestInfo, owner), uri); + log.debug("owner created --> " + userDetailResponse.getUser().get(0).getUuid()); + return userDetailResponse.getUser().get(0); + } + + /** + * Creates citizen role + * + * @return Role object for citizen + */ + private Role getCitizenRole() { + Role role = new Role(); + role.setCode(Constants.CITIZEN); + role.setName("Citizen"); + return role; + } + + /** + * Sets the role,type,active and tenantId for a Citizen + * + * @param tenantId TenantId of the property + * @param role + * @param role The role of the user set in this case to CITIZEN + * @param applicant The user whose fields are to be set + */ + private void addUserDefaultFields(String tenantId, Role role, User applicant) { + applicant.setActive(true); + applicant.setTenantId(tenantId.split("\\.")[0]); + applicant.setRoles(Collections.singletonList(role)); + applicant.setType(Constants.CITIZEN); + } + + /** + * Sets the username as uuid + * + * @param owner The owner to whom the username is to assigned + */ + private void setUserName(User owner) { + String uuid = UUID.randomUUID().toString(); + owner.setUserName(uuid); + owner.setUuid(uuid); + + } + + /** + * Returns UserDetailResponse by calling user service with given uri and object + * + * @param userRequest Request object for user service + * @param uri The address of the end point + * @return Response from user service as parsed as userDetailResponse + */ + @SuppressWarnings("rawtypes") + UserDetailResponse userCall(Object userRequest, StringBuilder uri) { + String dobFormat = null; + if (uri.toString().contains(config.getUserSearchEndpoint()) + || uri.toString().contains(config.getUserUpdateEndpoint())) + dobFormat = "yyyy-MM-dd"; + else if (uri.toString().contains(config.getUserCreateEndpoint())) + dobFormat = "dd/MM/yyyy"; + try { + + LinkedHashMap responseMap = (LinkedHashMap) serviceRequestRepository.fetchResult(uri, userRequest); + parseResponse(responseMap, dobFormat); + return mapper.convertValue(responseMap, UserDetailResponse.class); + } catch (IllegalArgumentException e) { + throw new CustomException(Constants.ILLEGAL_ARGUMENT_EXCEPTION, + "ObjectMapper not able to convertValue in userCall"); + } + } + + /** + * @return + */ + private Role getRolObj(String roleCode, String roleName) { + Role role = new Role(); + role.setCode(roleCode); + role.setName(roleName); + return role; + } + + public UserDetailResponse userExists(User owner) { + + UserSearchRequest ownerSearchRequest = new UserSearchRequest(); + ownerSearchRequest.setTenantId(owner.getTenantId().split("\\.")[0]); + + if (!StringUtils.isEmpty(owner.getMobileNumber())) { + ownerSearchRequest.setMobileNumber(owner.getMobileNumber()); + } + + StringBuilder uri = new StringBuilder(config.getUserHost()).append(config.getUserSearchEndpoint()); + return ownerCall(ownerSearchRequest, uri); + + } + + public Boolean isRoleAvailale(User user, String role, String tenantId) { + Boolean flag = false; + Map> tenantIdToOwnerRoles = getTenantIdToOwnerRolesMap(user); + flag = isRoleAvailable(tenantIdToOwnerRoles.get(tenantId), role); + return flag; + } + + public Map> getTenantIdToOwnerRolesMap(User user) { + Map> tenantIdToOwnerRoles = new HashMap<>(); + user.getRoles().forEach(role -> { + if (tenantIdToOwnerRoles.containsKey(role.getTenantId())) { + tenantIdToOwnerRoles.get(role.getTenantId()).add(role.getCode()); + } else { + List roleCodes = new LinkedList<>(); + roleCodes.add(role.getCode()); + tenantIdToOwnerRoles.put(role.getTenantId(), roleCodes); + } + + }); + return tenantIdToOwnerRoles; + } + + private Boolean isRoleAvailable(List ownerRoles, String role) { + if (CollectionUtils.isEmpty(ownerRoles)) { + return false; + } + return ownerRoles.contains(role); + + } + + /** + * @param ownerRequest + * @param uri + * @return + */ + @SuppressWarnings("rawtypes") + UserDetailResponse ownerCall(Object ownerRequest, StringBuilder uri) { + String dobFormat = null; + if (uri.toString().contains(config.getUserSearchEndpoint()) + || uri.toString().contains(config.getUserUpdateEndpoint())) + dobFormat = "yyyy-MM-dd"; + else if (uri.toString().contains(config.getUserCreateEndpoint())) + dobFormat = "dd/MM/yyyy"; + try { + LinkedHashMap responseMap = (LinkedHashMap) serviceRequestRepository.fetchResult(uri, ownerRequest); + parseResponse(responseMap, dobFormat); + return mapper.convertValue(responseMap, UserDetailResponse.class); + } catch (IllegalArgumentException e) { + throw new CustomException(Constants.ILLEGAL_ARGUMENT_EXCEPTION, + "ObjectMapper not able to convertValue in ownerCall"); + } + + } + + @SuppressWarnings({"unchecked", "rawtypes"}) + private void parseResponse(LinkedHashMap responeMap, String dobFormat) { + List owners = (List) responeMap.get("user"); + String format1 = "dd-MM-yyyy HH:mm:ss"; + if (owners != null) { + owners.forEach(map -> { + map.put("createdDate", dateTolong((String) map.get("createdDate"), format1)); + if ((String) map.get("lastModifiedDate") != null) + map.put("lastModifiedDate", dateTolong((String) map.get("lastModifiedDate"), format1)); + if ((String) map.get("dob") != null) + map.put("dob", dateTolong((String) map.get("dob"), dobFormat)); + if ((String) map.get("pwdExpiryDate") != null) + map.put("pwdExpiryDate", dateTolong((String) map.get("pwdExpiryDate"), format1)); + }); + } + } + + private Long dateTolong(String date, String format) { + SimpleDateFormat f = new SimpleDateFormat(format); + Date d = null; + try { + d = f.parse(date); + } catch (ParseException e) { + throw new CustomException("PARSING_ERROR", "Failed to parse dateTolong" + e); + } + return d != null ? d.getTime() : 0; + } + +// public UserDetailResponse getOwner(UserOwnerSearchCriteria criteria, RequestInfo requestInfo) { +// UserSearchRequest ownerSearchRequest = getOwnerSearchRequest(criteria, requestInfo); +// StringBuilder uri = new StringBuilder(config.getUserHost()).append(config.getUserSearchEndpoint()); +// return ownerCall(ownerSearchRequest, uri); +// } +public UserDetailResponse getOwners(List dtls, RequestInfo requestInfo) { + Set mobileNumbers = new HashSet<>(); + String tenantId = null; + + for (T dtl : dtls) { + ParentInfo fatherInfo = dtl.getFatherInfo(); + if (fatherInfo != null && fatherInfo.getMobileno() != null) { + mobileNumbers.add(fatherInfo.getMobileno()); + if (tenantId == null) tenantId = dtl.getTenantid(); + } + } + + if (mobileNumbers.isEmpty()) return new UserDetailResponse(); + + List allUsers = new ArrayList<>(); + for (String mobile : mobileNumbers) { + UserSearchRequest searchRequest = new UserSearchRequest(); + searchRequest.setRequestInfo(requestInfo); + searchRequest.setTenantId(tenantId.split("\\.")[0]); + searchRequest.setMobileNumber(mobile); + + StringBuilder uri = new StringBuilder(config.getUserHost()).append(config.getUserSearchEndpoint()); + UserDetailResponse response = ownerCall(searchRequest, uri); + + if (response != null && response.getUser() != null) { + allUsers.addAll(response.getUser()); + } + } + + return UserDetailResponse.builder().user(allUsers).build(); +} + + +// private UserSearchRequest getOwnerSearchRequest(UserOwnerSearchCriteria criteria, RequestInfo requestInfo) { +// UserSearchRequest searchRequest = new UserSearchRequest(); +// searchRequest.setRequestInfo(requestInfo); +// +// searchRequest.setTenantId(criteria.getTenantid().split("\\.")[0]); +// +// ParentInfo fatherInfo = criteria.getFatherInfo(); +// if (fatherInfo != null) { +// searchRequest.setName(fatherInfo.getFirstname()); +// searchRequest.setMobileNumber(fatherInfo.getMobileno()); +// } +// +// return searchRequest; +// } + +} \ No newline at end of file diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/common/util/CommonErrorConstants.java b/birth-death-services/src/main/java/org/bel/birthdeath/common/util/CommonErrorConstants.java new file mode 100644 index 00000000000..19f031fac9b --- /dev/null +++ b/birth-death-services/src/main/java/org/bel/birthdeath/common/util/CommonErrorConstants.java @@ -0,0 +1,9 @@ +package org.bel.birthdeath.common.util; + +public class CommonErrorConstants { + + public static final String INVALID_OWNER_ERROR = "INVALID_OWNER_ERROR"; + public static final String INVALID_OWNER = "INVALID_VEHICLE_OWNER"; + + +} diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/common/util/Constants.java b/birth-death-services/src/main/java/org/bel/birthdeath/common/util/Constants.java new file mode 100644 index 00000000000..3e00d9ae3cf --- /dev/null +++ b/birth-death-services/src/main/java/org/bel/birthdeath/common/util/Constants.java @@ -0,0 +1,13 @@ +package org.bel.birthdeath.common.util; + +import org.springframework.stereotype.Component; + +@Component +public class Constants { + + public static final String CITIZEN = "CITIZEN"; + public static final String MALE = "MALE"; + public static final String ACTIVE = "ACTIVE"; + public static final String ILLEGAL_ARGUMENT_EXCEPTION = "IllegalArgumentException"; + +} diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/common/util/UserUtil.java b/birth-death-services/src/main/java/org/bel/birthdeath/common/util/UserUtil.java new file mode 100644 index 00000000000..f56e0fd47d6 --- /dev/null +++ b/birth-death-services/src/main/java/org/bel/birthdeath/common/util/UserUtil.java @@ -0,0 +1,23 @@ +package org.bel.birthdeath.common.util; + +import org.bel.birthdeath.common.model.user.User; +import org.egov.common.contract.request.RequestInfo; + +public class UserUtil { + + public static User convertToCustomUser(org.egov.common.contract.request.User reqUser) { + if (reqUser == null) return null; + + User user = new User(); + user.setUuid(reqUser.getUuid()); + user.setUserName(reqUser.getUserName()); + user.setName(reqUser.getName()); + user.setType(reqUser.getType()); + user.setMobileNumber(reqUser.getMobileNumber()); + user.setEmailId(reqUser.getEmailId()); + user.setTenantId(reqUser.getTenantId()); + user.setRoles(reqUser.getRoles()); // direct copy since same structure + + return user; + } +} diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/config/BirthDeathConfiguration.java b/birth-death-services/src/main/java/org/bel/birthdeath/config/BirthDeathConfiguration.java index dffab6f81d8..8b0b9928b6f 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/config/BirthDeathConfiguration.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/config/BirthDeathConfiguration.java @@ -1,5 +1,7 @@ package org.bel.birthdeath.config; +import java.util.Map; + import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -91,8 +93,8 @@ public class BirthDeathConfiguration { @Value("${egov.url.shortner.endpoint}") private String urlShortnerEndpoint; - @Value("${egov.ui.app.host}") - private String uiAppHost; + @Value("#{${egov.ui.app.host}}") + private Map uiAppHostMap; @Value("${egov.bnd.default.limit}") private Integer defaultBndLimit; @@ -121,4 +123,5 @@ public class BirthDeathConfiguration { @Value("${egov.pdf.deathcert.createEndPoint}") private String egovPdfDeathEndPoint; + } diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/death/certmodel/DeathCertRequest.java b/birth-death-services/src/main/java/org/bel/birthdeath/death/certmodel/DeathCertRequest.java index c0b79fdabd7..942e35a59d3 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/death/certmodel/DeathCertRequest.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/death/certmodel/DeathCertRequest.java @@ -1,8 +1,6 @@ package org.bel.birthdeath.death.certmodel; -import org.egov.common.contract.request.RequestInfo; - import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; @@ -11,6 +9,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; +import org.egov.common.contract.request.RequestInfo; @Getter diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/death/certmodel/DeathCertificate.java b/birth-death-services/src/main/java/org/bel/birthdeath/death/certmodel/DeathCertificate.java index 51495c12b9a..52ea1915e0d 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/death/certmodel/DeathCertificate.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/death/certmodel/DeathCertificate.java @@ -5,9 +5,8 @@ import org.bel.birthdeath.common.model.Amount; import org.bel.birthdeath.common.model.AuditDetails; +import org.bel.birthdeath.common.model.user.User; import org.bel.birthdeath.death.calculation.Calculation; -import org.egov.common.contract.request.User; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonValue; diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/death/model/EgDeathDtl.java b/birth-death-services/src/main/java/org/bel/birthdeath/death/model/EgDeathDtl.java index a91b16001a4..a34a06cd3a1 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/death/model/EgDeathDtl.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/death/model/EgDeathDtl.java @@ -2,12 +2,16 @@ import java.sql.Timestamp; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; +import org.bel.birthdeath.common.contract.ParentInfo; +import org.bel.birthdeath.common.contract.ParentInfoProvider; +import org.bel.birthdeath.common.model.user.User; @Getter @Setter @@ -15,7 +19,8 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class EgDeathDtl{ +@JsonIgnoreProperties(ignoreUnknown = true) +public class EgDeathDtl implements ParentInfoProvider { private String id; @@ -68,6 +73,8 @@ public class EgDeathDtl{ private String hospitalid; private EgDeathFatherInfo deathFatherInfo; + + private User user; private EgDeathMotherInfo deathMotherInfo; @@ -98,4 +105,14 @@ public class EgDeathDtl{ private String fullName; private Boolean isLegacyRecord = false; + + @Override + public String getTenantid() { + return this.tenantid; + } + + @Override + public ParentInfo getFatherInfo() { + return this.deathFatherInfo; + } } \ No newline at end of file diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/death/model/EgDeathFatherInfo.java b/birth-death-services/src/main/java/org/bel/birthdeath/death/model/EgDeathFatherInfo.java index f288fac0ce6..62fe70037d5 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/death/model/EgDeathFatherInfo.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/death/model/EgDeathFatherInfo.java @@ -6,6 +6,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; +import org.bel.birthdeath.common.contract.ParentInfo; @Getter @Setter @@ -13,7 +14,7 @@ @Builder @AllArgsConstructor @NoArgsConstructor -public class EgDeathFatherInfo { +public class EgDeathFatherInfo implements ParentInfo { private String id; @@ -23,6 +24,8 @@ public class EgDeathFatherInfo { private Long createdtime; + private String tenantid; + private String emailid; private String firstname; @@ -38,4 +41,14 @@ public class EgDeathFatherInfo { private Long lastmodifiedtime; private String fullName; + + @Override + public String getFirstname() { + return firstname; + } + + @Override + public String getMobileno() { + return mobileno; + } } \ No newline at end of file diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/death/model/UserSearchRequest.java b/birth-death-services/src/main/java/org/bel/birthdeath/death/model/UserSearchRequest.java new file mode 100644 index 00000000000..681f3adab5c --- /dev/null +++ b/birth-death-services/src/main/java/org/bel/birthdeath/death/model/UserSearchRequest.java @@ -0,0 +1,80 @@ +package org.bel.birthdeath.death.model; + +import java.util.Collections; +import java.util.List; +import java.util.Set; + +import org.egov.common.contract.request.RequestInfo; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Builder.Default; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class UserSearchRequest { + + @JsonProperty("RequestInfo") + private RequestInfo requestInfo; + + @JsonProperty("uuid") + private Set uuid; + + @JsonProperty("id") + private List id; + + @JsonProperty("userName") + private String userName; + + @JsonProperty("name") + private String name; + + @JsonProperty("mobileNumber") + private String mobileNumber; + + @JsonProperty("aadhaarNumber") + private String aadhaarNumber; + + @JsonProperty("pan") + private String pan; + + @JsonProperty("emailId") + private String emailId; + + @JsonProperty("fuzzyLogic") + private boolean fuzzyLogic; + + @JsonProperty("active") + @Setter + private Boolean active; + + @JsonProperty("tenantId") + private String tenantId; + + @JsonProperty("pageSize") + private int pageSize; + + @JsonProperty("pageNumber") + @Default + private int pageNumber = 0; + + @JsonProperty("sort") + @Default + private List sort = Collections.singletonList("name"); + + @JsonProperty("userType") + private String userType; + + @JsonProperty("roleCodes") + private List roleCodes; + + +} diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/death/repository/DeathRepository.java b/birth-death-services/src/main/java/org/bel/birthdeath/death/repository/DeathRepository.java index ceef8350800..0614883c55c 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/death/repository/DeathRepository.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/death/repository/DeathRepository.java @@ -208,7 +208,8 @@ public EgovPdfResp saveDeathCertPdf(DeathPdfApplicationRequest pdfApplicationReq try { SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy"); pdfApplicationRequest.getDeathCertificate().forEach(cert-> { - String uiHost = config.getUiAppHost(); + String stateLevelTenantId = centralInstanceUtil.getStateLevelTenant(cert.getTenantid()); + String uiHost = config.getUiAppHostMap().get(stateLevelTenantId); String deathCertPath = config.getDeathCertLink(); deathCertPath = deathCertPath.replace("$id",cert.getId()); deathCertPath = deathCertPath.replace("$tenantId",cert.getTenantid()); @@ -268,7 +269,7 @@ public List getDeathDtlsAll(SearchCriteria criteria ,RequestInfo req EgDeathDtl dec = encryptionDecryptionUtil.decryptObject(deathDtl, "BndDetail", EgDeathDtl.class, requestInfo); deathDtl.setAadharno(dec.getAadharno()); deathDtl.setIcdcode(dec.getIcdcode()); - commonUtils.maskAndShowLast4Chars(deathDtl); +// commonUtils.maskAndShowLast4Chars(deathDtl); }); } return deathDtls; diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/death/repository/builder/DeathDtlAllQueryBuilder.java b/birth-death-services/src/main/java/org/bel/birthdeath/death/repository/builder/DeathDtlAllQueryBuilder.java index 927efefff29..2a8e7f07471 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/death/repository/builder/DeathDtlAllQueryBuilder.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/death/repository/builder/DeathDtlAllQueryBuilder.java @@ -23,7 +23,7 @@ public class DeathDtlAllQueryBuilder { private static String QUERY_MASTER_FULL_ALL = "SELECT bdtl.id deathdtlid,bfat.id bfatid,bmot.id bmotid,bpmad.id bpmadid,bpsad.id bpsadid, bsps.id bspsid," + "bdtl.tenantid tenantid, registrationno, dateofdeath, counter, gender , " + - "CASE WHEN gender = '1' THEN 'Male' WHEN gender = '2' THEN 'Female' WHEN gender = '3' THEN 'Transgender' END AS genderstr , " + + "CASE WHEN gender = '1' THEN 'Male' WHEN gender = '2' THEN 'Female' WHEN gender = '3' THEN 'Transgender' WHEN gender = '4' THEN 'Others' END AS genderstr ," + "(select bh.hospitalname from eg_birth_death_hospitals bh where bh.id=hospitalid) AS hospitalname, placeofdeath, dateofreport, remarks, " + "hospitalid , informantsname , informantsaddress , age, eidno , icdcode, islegacyrecord, bdtl.nationality bdtlnationality, bdtl.religion bdtlreligion ," + "bfat.firstname bfatfn ,bmot.firstname bmotfn , bdtl.firstname bdtlfn , bsps.firstname bspsfn ," + @@ -44,9 +44,9 @@ public class DeathDtlAllQueryBuilder { "left join {schema}.eg_death_presentaddr bpsad on bpsad.deathdtlid = bdtl.id"; private static String QUERY_MASTER_ALL = "SELECT bdtl.id deathdtlid, bdtl.tenantid tenantid, registrationno, dateofdeath, counter, gender , age , " - + "CASE WHEN gender = '1' THEN 'Male' WHEN gender = '2' THEN 'Female' WHEN gender = '3' THEN 'Transgender' END AS genderstr ," + + "CASE WHEN gender = '1' THEN 'Male' WHEN gender = '2' THEN 'Female' WHEN gender = '3' THEN 'Transgender' WHEN gender = '4' THEN 'Others' END AS genderstr ," + " (select bh.hospitalname from eg_birth_death_hospitals bh where bh.id=hospitalid) AS hospitalname, placeofdeath, dateofreport, remarks, " - + "bfat.firstname bfatfn ,bmot.firstname bmotfn , bdtl.firstname bdtlfn ,bsps.firstname bspsfn , " + + "bfat.firstname bfatfn ,bfat.mobileno bfatmobileno ,bmot.firstname bmotfn , bdtl.firstname bdtlfn ,bsps.firstname bspsfn , " + "bfat.middlename bfatmn ,bmot.middlename bmotmn , bdtl.middlename bdtlmn ,bsps.middlename bspsmn , " + "bfat.lastname bfatln ,bmot.lastname bmotln , bdtl.lastname bdtlln ,bsps.lastname bspsln , " + "bpmad.houseno pmhouseno,bpmad.buildingno pmbuildingno,bpmad.streetname pmstreetname,bpmad.locality pmlocality,bpmad.tehsil pmtehsil," @@ -62,9 +62,9 @@ public class DeathDtlAllQueryBuilder { "left join {schema}.eg_death_spouse_info bsps on bsps.deathdtlid = bdtl.id " ; private static final String QUERY_MASTER = "SELECT bdtl.id deathdtlid, tenantid, registrationno, dateofdeath, counter, gender, hospitalname, "+ - "CASE WHEN gender = '1' THEN 'Male' WHEN gender = '2' THEN 'Female' WHEN gender = '3' THEN 'Transgender' END AS genderstr ," + + "CASE WHEN gender = '1' THEN 'Male' WHEN gender = '2' THEN 'Female' WHEN gender = '3' THEN 'Transgender' WHEN gender = '4' THEN 'Others' END AS genderstr ," + "(select bh.hospitalname from eg_birth_death_hospitals bh where bh.id=hospitalid) AS hospitalname ,"+ - "bfat.firstname bfatfn ,bmot.firstname bmotfn , bdtl.firstname bdtlfn ,bsps.firstname bspsfn , "+ + "bfat.firstname bfatfn ,bfat.mobileno bfatmobileno ,bmot.firstname bmotfn , bdtl.firstname bdtlfn ,bsps.firstname bspsfn , "+ "bfat.middlename bfatmn ,bmot.middlename bmotmn , bdtl.middlename bdtlmn ,bsps.middlename bspsmn , "+ "bfat.lastname bfatln ,bmot.lastname bmotln , bdtl.lastname bdtlln ,bsps.lastname bspsln "+ "FROM {schema}.eg_death_dtls bdtl " + diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/death/repository/rowmapper/DeathDtlsAllRowMapper.java b/birth-death-services/src/main/java/org/bel/birthdeath/death/repository/rowmapper/DeathDtlsAllRowMapper.java index 654467bd49b..10beb82d1d4 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/death/repository/rowmapper/DeathDtlsAllRowMapper.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/death/repository/rowmapper/DeathDtlsAllRowMapper.java @@ -39,7 +39,7 @@ public List extractData(ResultSet rs) throws SQLException, DataAcces .aadharno(rs.getString("bmotaadharno")).build(); motherInfo.setFullName(utils.addfullName(motherInfo.getFirstname(),motherInfo.getMiddlename(),motherInfo.getLastname())); - EgDeathFatherInfo fatherInfo = EgDeathFatherInfo.builder().firstname(rs.getString("bfatfn")).middlename(rs.getString("bfatmn")).lastname(rs.getString("bfatln")) + EgDeathFatherInfo fatherInfo = EgDeathFatherInfo.builder().firstname(rs.getString("bfatfn")).middlename(rs.getString("bfatmn")).lastname(rs.getString("bfatln")).mobileno(rs.getString("bfatmobileno")) .aadharno(rs.getString("bfataadharno")).build(); fatherInfo.setFullName(utils.addfullName(fatherInfo.getFirstname(),fatherInfo.getMiddlename(),fatherInfo.getLastname())); @@ -60,7 +60,7 @@ public List extractData(ResultSet rs) throws SQLException, DataAcces presentaddr.getDistrict(),presentaddr.getCity(),presentaddr.getState(),presentaddr.getPinno(),presentaddr.getCountry())); deathDtl = EgDeathDtl.builder().id(deathdtlid).registrationno(rs.getString("registrationno")).hospitalname(rs.getString("hospitalname")).dateofreport(rs.getTimestamp("dateofreport")).gender(rs.getInt("gender")) - .dateofdeath(rs.getTimestamp("dateofdeath")).counter(rs.getInt("counter")).genderStr(rs.getString("genderstr")).tenantid(rs.getString("tenantid")).dateofissue(System.currentTimeMillis()) + .dateofdeath(rs.getTimestamp("dateofdeath")).counter(rs.getInt("counter")).genderStr(rs.getString("genderstr")).tenantid(rs.getString("tenantid")).dateofissue(rs.getTimestamp("dateofreport") != null ? rs.getTimestamp("dateofreport").getTime() : System.currentTimeMillis()) .firstname(rs.getString("bdtlfn")).middlename(rs.getString("bdtlmn")).lastname(rs.getString("bdtlln")).deathMotherInfo(motherInfo).deathFatherInfo(fatherInfo).deathSpouseInfo(spouseInfo) .deathPermaddr(permaddr).deathPresentaddr(presentaddr).placeofdeath(rs.getString("placeofdeath")).remarks(rs.getString("remarks")).age(rs.getLong("age")) .aadharno(rs.getString("bdtlaadharno")).build(); diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/death/repository/rowmapper/DeathDtlsRowMapper.java b/birth-death-services/src/main/java/org/bel/birthdeath/death/repository/rowmapper/DeathDtlsRowMapper.java index ba6531c9379..e9adfd78484 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/death/repository/rowmapper/DeathDtlsRowMapper.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/death/repository/rowmapper/DeathDtlsRowMapper.java @@ -37,7 +37,7 @@ public List extractData(ResultSet rs) throws SQLException, DataAcces .build(); motherInfo.setFullName(utils.addfullName(motherInfo.getFirstname(),motherInfo.getMiddlename(),motherInfo.getLastname())); - EgDeathFatherInfo fatherInfo = EgDeathFatherInfo.builder().firstname(rs.getString("bfatfn")).middlename(rs.getString("bfatmn")).lastname(rs.getString("bfatln")) + EgDeathFatherInfo fatherInfo = EgDeathFatherInfo.builder().firstname(rs.getString("bfatfn")).middlename(rs.getString("bfatmn")).lastname(rs.getString("bfatln")).mobileno(rs.getString("bfatmobileno")) .build(); fatherInfo.setFullName(utils.addfullName(fatherInfo.getFirstname(),fatherInfo.getMiddlename(),fatherInfo.getLastname())); diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/death/service/DeathService.java b/birth-death-services/src/main/java/org/bel/birthdeath/death/service/DeathService.java index 804dad16ff0..87d81e29e83 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/death/service/DeathService.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/death/service/DeathService.java @@ -4,6 +4,9 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.bel.birthdeath.common.calculation.collections.models.Payment; @@ -11,22 +14,24 @@ import org.bel.birthdeath.common.calculation.collections.models.PaymentResponse; import org.bel.birthdeath.common.calculation.collections.models.PaymentSearchCriteria; import org.bel.birthdeath.common.consumer.ReceiptConsumer; -import org.bel.birthdeath.common.contract.DeathPdfApplicationRequest; -import org.bel.birthdeath.common.contract.EgovPdfResp; -import org.bel.birthdeath.common.contract.RequestInfoWrapper; +import org.bel.birthdeath.common.contract.*; import org.bel.birthdeath.common.model.AuditDetails; +import org.bel.birthdeath.common.model.user.UserDetailResponse; import org.bel.birthdeath.common.repository.ServiceRequestRepository; +import org.bel.birthdeath.common.services.UserService; import org.bel.birthdeath.config.BirthDeathConfiguration; import org.bel.birthdeath.death.certmodel.DeathCertAppln; import org.bel.birthdeath.death.certmodel.DeathCertRequest; import org.bel.birthdeath.death.certmodel.DeathCertificate; import org.bel.birthdeath.death.certmodel.DeathCertificate.StatusEnum; -import org.bel.birthdeath.death.model.EgDeathDtl; -import org.bel.birthdeath.death.model.SearchCriteria; +import org.bel.birthdeath.death.model.*; import org.bel.birthdeath.death.repository.DeathRepository; import org.bel.birthdeath.death.validator.DeathValidator; +import org.bel.birthdeath.utils.BirthDeathConstants; import org.bel.birthdeath.utils.CommonUtils; import org.egov.common.contract.request.RequestInfo; +import org.egov.encryption.EncryptionService; +import org.bel.birthdeath.common.model.user.User; import org.egov.tracer.model.CustomException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -47,7 +52,10 @@ public class DeathService { @Autowired @Qualifier("objectMapperBnd") ObjectMapper objectMapper; - + + @Autowired + EncryptionDecryptionUtil encryptionDecryptionUtil; + @Autowired DeathValidator validator; @@ -65,6 +73,9 @@ public class DeathService { @Autowired ReceiptConsumer consumer; + + @Autowired + UserService userService; public List search(SearchCriteria criteria,RequestInfo requestInfo) { List deathDtls = new ArrayList<>() ; @@ -78,6 +89,54 @@ public List search(SearchCriteria criteria,RequestInfo requestInfo) deathDtls = repository.getDeathDtls(criteria); } } + // ✅ Decrypt full list + if (!deathDtls.isEmpty()) { + // Decrypt top-level fields like aadharno, icdcode + deathDtls = encryptionDecryptionUtil.decryptObject(deathDtls, "BndDetail", EgDeathDtl.class, requestInfo); + + // Explicitly decrypt nested parent info + for (EgDeathDtl dtl : deathDtls) { + if (dtl.getDeathFatherInfo() != null) { + dtl.setDeathFatherInfo(encryptionDecryptionUtil.decryptObject(dtl.getDeathFatherInfo(), + BirthDeathConstants.BND_DESCRYPT_KEY, EgDeathFatherInfo.class, requestInfo)); + } + + if (dtl.getDeathMotherInfo() != null) { + dtl.setDeathMotherInfo(encryptionDecryptionUtil.decryptObject(dtl.getDeathMotherInfo(), + BirthDeathConstants.BND_DESCRYPT_KEY, EgDeathMotherInfo.class, requestInfo)); + } + + if (dtl.getDeathSpouseInfo() != null) { + dtl.setDeathSpouseInfo(encryptionDecryptionUtil.decryptObject(dtl.getDeathSpouseInfo(), + BirthDeathConstants.BND_DESCRYPT_KEY, EgDeathSpouseInfo.class, requestInfo)); + } + } + } + + +// // Set owner/user info if records are found +// if (!deathDtls.isEmpty()) { +// UserDetailResponse userDetailResponse = userService.getOwner(deathDtls.get(0), requestInfo); +// deathDtls.get(0).setUser(userDetailResponse.getUser().get(0)); +// } + + if (!deathDtls.isEmpty()) { + UserDetailResponse userDetailResponse = userService.getOwners(deathDtls, requestInfo); + + if (userDetailResponse != null && userDetailResponse.getUser() != null) { + Map mobileToUserMap = userDetailResponse.getUser().stream() + .filter(user -> user.getMobileNumber() != null) + .collect(Collectors.toMap(User::getMobileNumber, Function.identity(), (u1, u2) -> u1)); // avoid duplicates + + for (EgDeathDtl dtl : deathDtls) { + ParentInfo fatherInfo = dtl.getDeathFatherInfo(); + if (fatherInfo != null && fatherInfo.getMobileno() != null) { + User user = mobileToUserMap.get(fatherInfo.getMobileno()); + if (user != null) dtl.setUser(user); + } + } + } + } return deathDtls; } @@ -93,6 +152,8 @@ public DeathCertificate download(SearchCriteria criteria, RequestInfo requestInf deathCertificate.setTenantId(criteria.getTenantId()); DeathCertRequest deathCertRequest = DeathCertRequest.builder().deathCertificate(deathCertificate).requestInfo(requestInfo).build(); List deathDtls = repository.getDeathDtlsAll(criteria,requestInfo); + UserDetailResponse userDetailResponse = userService.getOwners(deathDtls, requestInfo); + deathDtls.get(0).setUser(userDetailResponse.getUser().get(0)); deathCertificate.setGender(deathDtls.get(0).getGenderStr()); deathCertificate.setAge(deathDtls.get(0).getAge()); deathCertificate.setWard(deathDtls.get(0).getDeathPermaddr().getTehsil()); @@ -110,7 +171,7 @@ public DeathCertificate download(SearchCriteria criteria, RequestInfo requestInf enrichmentServiceDeath.enrichCreateRequest(deathCertRequest); enrichmentServiceDeath.setIdgenIds(deathCertRequest); if(deathDtls.get(0).getCounter()>0){ - enrichmentServiceDeath.setDemandParams(deathCertRequest); + enrichmentServiceDeath.setDemandParams(deathCertRequest,deathDtls); enrichmentServiceDeath.setGLCode(deathCertRequest); calculationServiceDeath.addCalculation(deathCertRequest); deathCertificate.setApplicationStatus(StatusEnum.ACTIVE); diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/death/service/DemandServiceDeath.java b/birth-death-services/src/main/java/org/bel/birthdeath/death/service/DemandServiceDeath.java index 88215251b4f..6e27807bdc8 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/death/service/DemandServiceDeath.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/death/service/DemandServiceDeath.java @@ -6,11 +6,11 @@ import org.bel.birthdeath.common.calculation.demand.models.Demand; import org.bel.birthdeath.common.calculation.demand.models.DemandDetail; +import org.bel.birthdeath.common.model.user.User; import org.bel.birthdeath.common.repository.DemandRepository; import org.bel.birthdeath.death.calculation.Calculation; import org.bel.birthdeath.death.certmodel.DeathCertificate; import org.egov.common.contract.request.RequestInfo; -import org.egov.common.contract.request.User; import org.egov.tracer.model.CustomException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/death/service/EnrichmentServiceDeath.java b/birth-death-services/src/main/java/org/bel/birthdeath/death/service/EnrichmentServiceDeath.java index 0936a1ca820..985d0b93df2 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/death/service/EnrichmentServiceDeath.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/death/service/EnrichmentServiceDeath.java @@ -1,5 +1,6 @@ package org.bel.birthdeath.death.service; +import static org.bel.birthdeath.common.util.UserUtil.convertToCustomUser; import static org.bel.birthdeath.utils.BirthDeathConstants.*; import java.math.BigDecimal; @@ -10,14 +11,18 @@ import java.util.UUID; import java.util.stream.Collectors; +import com.fasterxml.jackson.databind.ObjectMapper; import org.bel.birthdeath.common.Idgen.IdResponse; import org.bel.birthdeath.common.model.Amount; import org.bel.birthdeath.common.model.AuditDetails; +import org.bel.birthdeath.common.model.user.UserDetailResponse; import org.bel.birthdeath.common.repository.IdGenRepository; import org.bel.birthdeath.common.repository.ServiceRequestRepository; import org.bel.birthdeath.config.BirthDeathConfiguration; import org.bel.birthdeath.death.certmodel.DeathCertRequest; import org.bel.birthdeath.death.certmodel.DeathCertificate; +import org.bel.birthdeath.death.model.EgDeathDtl; +import org.bel.birthdeath.death.model.UserSearchRequest; import org.bel.birthdeath.utils.CommonUtils; import org.egov.common.contract.request.RequestInfo; import org.egov.mdms.model.MasterDetail; @@ -26,6 +31,7 @@ import org.egov.mdms.model.ModuleDetail; import org.egov.tracer.model.CustomException; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -45,6 +51,12 @@ public class EnrichmentServiceDeath { @Autowired ServiceRequestRepository serviceRequestRepository; + + @Value("${egov.user.host}") + private String userHost; + + @Value("${egov.user.search.path}") + private String userSearchEndpoint; public void enrichCreateRequest(DeathCertRequest deathCertRequest) { RequestInfo requestInfo = deathCertRequest.getRequestInfo(); @@ -104,7 +116,7 @@ private ModuleDetail getGLCodeRequest() { .moduleName(BILLING_SERVICE).build(); } - public void setDemandParams(DeathCertRequest deathCertRequest) { + public void setDemandParams(DeathCertRequest deathCertRequest,List deathDtls) { DeathCertificate deathCert = deathCertRequest.getDeathCertificate(); deathCert.setBusinessService(DEATH_CERT); ArrayList amounts = new ArrayList<>(); @@ -113,9 +125,38 @@ public void setDemandParams(DeathCertRequest deathCertRequest) { amount.setAmount(new BigDecimal(50)); amounts.add(amount); deathCert.setAmount(amounts); - deathCert.setCitizen(deathCertRequest.getRequestInfo().getUserInfo()); + if(deathCertRequest.getRequestInfo().getUserInfo().getType().equalsIgnoreCase("CITIZEN")) + deathCert.setCitizen(convertToCustomUser(deathCertRequest.getRequestInfo().getUserInfo())); + else if (deathDtls != null && !deathDtls.isEmpty() && deathDtls.get(0).getUser() != null) { + deathCert.setCitizen(deathDtls.get(0).getUser()); + } else{ + // fetch user using the id sent in deathcertRequest and then pass that user + UserSearchRequest userSearchRequest = getBaseUserSearchRequest(deathCertRequest.getRequestInfo().getUserInfo().getTenantId(), deathCertRequest.getRequestInfo()); + UserDetailResponse userDetailResponse = getUser(userSearchRequest); + deathCert.setCitizen(userDetailResponse.getUser().get(0)); + } + deathCert.setTaxPeriodFrom(System.currentTimeMillis()); deathCert.setTaxPeriodTo(System.currentTimeMillis()+86400000); } + public UserDetailResponse getUser(UserSearchRequest userSearchRequest) { + + StringBuilder uri = new StringBuilder(userHost).append(userSearchEndpoint); + Object response = serviceRequestRepository.fetchResult(uri, userSearchRequest); + ObjectMapper mapper = new ObjectMapper(); + UserDetailResponse userDetailResponse = mapper.convertValue(response, UserDetailResponse.class); + return userDetailResponse; + } + + public UserSearchRequest getBaseUserSearchRequest(String tenantId, RequestInfo requestInfo) { + + return UserSearchRequest.builder() + .requestInfo(requestInfo) + .userType("EMPLOYEE") + .tenantId(tenantId) + .active(true) + .build(); + } + } diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/death/validator/DeathValidator.java b/birth-death-services/src/main/java/org/bel/birthdeath/death/validator/DeathValidator.java index 8cbd5c9f63c..1cef8d5a276 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/death/validator/DeathValidator.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/death/validator/DeathValidator.java @@ -198,7 +198,7 @@ public boolean validateImportFields(EgDeathDtl deathDtl,ImportDeathWrapper impor importDeathWrapper.setServiceError(BirthDeathConstants.PERMENANT_PINCODE_EMPTY); return false; } - if(deathDtl.getGender().intValue()!=1 && deathDtl.getGender().intValue()!=2 && deathDtl.getGender().intValue()!=3 ) { + if(deathDtl.getGender().intValue()!=1 && deathDtl.getGender().intValue()!=2 && deathDtl.getGender().intValue()!=3 && deathDtl.getGender().intValue()!=4 ) { setRejectionReason(BirthDeathConstants.GENDER_INVALID,deathDtl,importDeathWrapper); importDeathWrapper.setServiceError(BirthDeathConstants.GENDER_INVALID); return false; diff --git a/birth-death-services/src/main/java/org/bel/birthdeath/utils/BirthDeathConstants.java b/birth-death-services/src/main/java/org/bel/birthdeath/utils/BirthDeathConstants.java index 299911fde74..178a42ee57e 100644 --- a/birth-death-services/src/main/java/org/bel/birthdeath/utils/BirthDeathConstants.java +++ b/birth-death-services/src/main/java/org/bel/birthdeath/utils/BirthDeathConstants.java @@ -12,9 +12,9 @@ public class BirthDeathConstants { public static final String BILLING_SERVICE = "BillingService"; - public static final String BIRTH_CERT = "BIRTH_CERT.BIRTH_CERT"; + public static final String BIRTH_CERT = "BIRTH_CERT"; - public static final String BIRTH_CERT_FEE = "BIRTH_CERT.BIRTH_CERT_CHARGES"; + public static final String BIRTH_CERT_FEE = "BIRTH_CERT_CHARGES"; public static final String DEATH_CERT = "DEATH_CERT"; diff --git a/birth-death-services/src/main/resources/application.properties b/birth-death-services/src/main/resources/application.properties index d8a09f2ecf7..5497c1e76b5 100644 --- a/birth-death-services/src/main/resources/application.properties +++ b/birth-death-services/src/main/resources/application.properties @@ -1,23 +1,23 @@ server.context-path=/birth-death-services server.servlet.context-path=/birth-death-services -server.port=0 +server.port=8080 app.timezone=UTC ##----------------------------- SPRING DS CONFIGURATIONS ------------------------------# spring.datasource.driver-class-name=org.postgresql.Driver -spring.datasource.url=jdbc:postgresql://localhost:5432/bel_cb_dev +spring.datasource.url=jdbc:postgresql://localhost:5432/postgres spring.datasource.username=postgres spring.datasource.password=postgres ##----------------------------- FLYWAY CONFIGURATIONS ------------------------------# -spring.flyway.url=jdbc:postgresql://localhost:5432/bel_cb_dev +spring.flyway.url=jdbc:postgresql://localhost:5432/postgres spring.flyway.user=postgres spring.flyway.password=postgres spring.flyway.table=public spring.flyway.baseline-on-migrate=true spring.flyway.outOfOrder=true spring.flyway.locations=classpath:/db/migration/main -spring.flyway.enabled=false +spring.flyway.enabled=true # KAFKA SERVER CONFIGURATIONS @@ -65,11 +65,11 @@ egov.idgen.deathapplnum.name=death_cert.receipt.id egov.idgen.deathapplnum.format=DT/CB/[cb.name]/[fy:yyyy]/[SEQ_EGOV_COMMON] #mdms configurations -egov.mdms.host=http://localhost:8081 +egov.mdms.host=http://localhost:8084 egov.mdms.search.endpoint=/egov-mdms-service/v1/_search #billing-service -egov.billingservice.host=http://localhost:8081 +egov.billingservice.host=http://localhost:8082 egov.demand.create.endpoint=/billing-service/demand/_create egov.bill.gen.endpoint=/billing-service/bill/v2/_fetchbill @@ -79,12 +79,13 @@ egov.pdf.birthcert.postendpoint=egov-pdf/download/BIRTHDEATH/birth-certificate?t egov.pdf.deathcert.postendpoint=egov-pdf/download/BIRTHDEATH/death-certificate?tenantId=$tenantId #pdf service path config -egov.pdfservice.host=https://dev.digit.org/ +egov.pdfservice.host=http://localhost:8081/ egov.pdf.birthcert.createEndPoint=pdf-service/v1/_create?key=birth-certificate&tenantId=$tenantId egov.pdf.deathcert.createEndPoint=pdf-service/v1/_create?key=death-certificate&tenantId=$tenantId #view certificate path config egov.ui.app.host=https://13.71.65.215.nip.io/ + egov.bnd.birthcert.link=citizen/withoutAuth/bnd/viewcertificate?id=$id&tenantId=$tenantId&module=birth®No=$regNo&dateofbirth=$dateofbirth&gender=$gender&birthcertificateno=$birthcertificateno egov.bnd.deathcert.link=citizen/withoutAuth/bnd/viewcertificate?id=$id&tenantId=$tenantId&module=death®No=$regNo&dateofdeath=$dateofdeath&gender=$gender&deathcertificateno=$deathcertificateno @@ -93,7 +94,7 @@ egov.url.shortner.host=http://localhost:8093 egov.url.shortner.endpoint=/egov-url-shortening/shortener #state level tenant -egov.state.level.tenant.id=pb +egov.state.level.tenant.id=pg #decryption enable decryption.abac.enabled=false @@ -104,8 +105,8 @@ egov.enc.encrypt.endpoint=/egov-enc-service/crypto/v1/_encrypt egov.enc.decrypt.endpoint=/egov-enc-service/crypto/v1/_decrypt #testing tenants -egov.bnd.freedownload.tenants=pb.testing -egov.bnd.live.citizen.tenants=pb.testing +egov.bnd.freedownload.tenants=pg.testing +egov.bnd.live.citizen.tenants=pg.testing #download limit egov.bnd.download.bufferdays=3 @@ -117,4 +118,14 @@ egov.bnd.max.limit=100 egov.collection.service.host=http://localhost:8091 egov.payment.search.endpoint=/collection-services/payments/_search -spring.main.allow-circular-references=true \ No newline at end of file +spring.main.allow-circular-references=true + +egov.user.host=http://localhost:8085 +egov.user.search.path=/user/_search + +#User config +## changed to egov.user.host +egov.user.context.path=/user/users +egov.user.create.path=/_createnovalidate +egov.user.update.path=/_updatenovalidate +egov.user.username.prefix=FSM- \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/example/package.json b/frontend/micro-ui/web/micro-ui-internals/example/package.json index 8d78e218bdf..c0f41e74263 100644 --- a/frontend/micro-ui/web/micro-ui-internals/example/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/example/package.json @@ -9,24 +9,28 @@ "start": "react-scripts start" }, "devDependencies": { - "@egovernments/digit-ui-libraries": "1.7.10", - "@egovernments/digit-ui-module-common": "1.7.10", - "@egovernments/digit-ui-module-engagement": "1.7.10", - "@egovernments/digit-ui-module-fsm": "1.7.10", - "@egovernments/digit-ui-module-mcollect": "1.7.10", - "@egovernments/digit-ui-module-noc": "1.7.10", - "@egovernments/digit-ui-module-obps": "1.7.10", - "@egovernments/digit-ui-module-pgr": "1.7.10", - "@egovernments/digit-ui-module-pt": "1.7.10", - "@egovernments/digit-ui-module-receipts": "1.7.10", - "@egovernments/digit-ui-module-tl": "1.7.10", - "@egovernments/digit-ui-module-ws": "1.7.10", - "@egovernments/digit-ui-module-bills": "1.7.10", - "@egovernments/digit-ui-module-commonpt": "1.7.10", - "@egovernments/digit-ui-module-hrms":"1.7.10", - "@egovernments/digit-ui-module-core":"1.7.10", - "@egovernments/digit-ui-module-dss":"1.7.10", - "@egovernments/digit-ui-react-components":"1.7.10", + "@egovernments/digit-ui-libraries": "0.0.1-sandbox", + "@egovernments/digit-ui-module-common": "1.7.35", + "@egovernments/digit-ui-module-engagement": "1.7.36", + "@egovernments/digit-ui-module-fsm": "1.7.35", + "@egovernments/digit-ui-module-mcollect": "0.0.1-sandbox", + "@egovernments/digit-ui-module-noc": "1.7.35", + "@egovernments/digit-ui-module-obps": "0.0.2-sandbox", + "@egovernments/digit-ui-module-pgr": "1.7.38", + "@egovernments/digit-ui-module-pt": "0.0.1-sandbox", + "@egovernments/digit-ui-module-receipts": "1.7.0-beta.2", + "@egovernments/digit-ui-module-tl": "0.0.3-sandbox", + "@egovernments/digit-ui-module-ws": "0.0.1-sandbox", + "@egovernments/digit-ui-module-bills": "1.7.35", + "@egovernments/digit-ui-module-commonpt": "1.7.35", + "@egovernments/digit-ui-module-hrms": "1.7.35", + "@egovernments/digit-ui-module-core": "0.0.1-sandbox", + "@egovernments/digit-ui-module-dss": "0.0.2-sandbox", + "@egovernments/digit-ui-react-components": "1.7.35", + "@egovernments/digit-ui-module-firenoc": "0.0.1-sandbox", + "@egovernments/digit-ui-module-birth": "0.0.1-sandbox", + "@egovernments/digit-ui-module-death": "0.0.1-sandbox", + "@egovernments/digit-ui-module-finance": "0.0.1-sandbox", "http-proxy-middleware": "1.0.5", "react": "17.0.2", "react-dom": "17.0.2", @@ -35,12 +39,12 @@ "react-scripts": "^4.0.1" }, "resolutions": { - "**/@babel/traverse":"7.25.9", + "**/@babel/traverse": "7.25.9", "**/styled-components": "5.0.0" }, "browserslist": [ ">0.2%", - "not dead", - "not op_mini all" - ] -} + "not dead", + "not op_mini all" + ] +} \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/example/public/index.html b/frontend/micro-ui/web/micro-ui-internals/example/public/index.html index 4c3b6e089b1..b259a0f3db9 100644 --- a/frontend/micro-ui/web/micro-ui-internals/example/public/index.html +++ b/frontend/micro-ui/web/micro-ui-internals/example/public/index.html @@ -1,28 +1,63 @@ - - - - - - - Digit - - - - - - - - - - -
+ } + + + + +
- + \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/example/src/index.js b/frontend/micro-ui/web/micro-ui-internals/example/src/index.js index 119623ac76e..94fe7e7b339 100644 --- a/frontend/micro-ui/web/micro-ui-internals/example/src/index.js +++ b/frontend/micro-ui/web/micro-ui-internals/example/src/index.js @@ -35,6 +35,10 @@ import { initBillsComponents, BillsModule } from "@egovernments/digit-ui-module- // import { subFormRegistry } from "@egovernments/digit-ui-libraries"; import { pgrCustomizations, pgrComponents } from "./pgr"; +import { initFirenocComponents } from "@egovernments/digit-ui-module-firenoc"; +import { initBirthComponents } from "@egovernments/digit-ui-module-birth"; +import { initDeathComponents } from "@egovernments/digit-ui-module-death"; +import { initFinanceComponents, FinanceModule } from "@egovernments/digit-ui-module-finance"; var Digit = window.Digit || {}; @@ -59,12 +63,16 @@ const enabledModules = [ "Bills", "SW", "BillAmendment", + "Firenoc", + "Birth", + "Death", + "Finance" ]; const initTokens = (stateCode) => { const userType = window.sessionStorage.getItem("userType") || process.env.REACT_APP_USER_TYPE || "CITIZEN"; - const token = window.localStorage.getItem("token") || process.env[`REACT_APP_${userType}_TOKEN`]; + const token = userType == "CITIZEN" ? window.localStorage.getItem("Citizen.token") : window.localStorage.getItem("Employee.token") || process.env[`REACT_APP_${userType}_TOKEN`]; const citizenInfo = window.localStorage.getItem("Citizen.user-info"); @@ -89,6 +97,7 @@ const initTokens = (stateCode) => { }; const initDigitUI = () => { + window.contextPath = window?.globalConfigs?.getConfig("CONTEXT_PATH") || "digit-ui"; window?.Digit.ComponentRegistryService.setupRegistry({ ...pgrComponents, PaymentModule, @@ -102,11 +111,17 @@ const initDigitUI = () => { HRMSModule, ReceiptsModule, BillsModule, + FinanceModule + // FireNocCard // TLModule, // TLLinks, }); + + initBirthComponents(); + initDeathComponents(); + initFinanceComponents(); initFSMComponents(); initPGRComponents(); initDSSComponents(); @@ -121,6 +136,7 @@ const initDigitUI = () => { initWSComponents(); initCommonPTComponents(); initBillsComponents(); + initFirenocComponents(); // initCustomisationComponents(); diff --git a/frontend/micro-ui/web/micro-ui-internals/package.json b/frontend/micro-ui/web/micro-ui-internals/package.json index de039b5dd6c..33afc6f745d 100644 --- a/frontend/micro-ui/web/micro-ui-internals/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/package.json @@ -2,11 +2,25 @@ "name": "egovernments", "version": "1.5.4", "main": "index.js", - "workspaces": [ + "workspaces": [ "packages/libraries", "example", "packages/react-components", - "packages/modules/*" + "packages/modules/tl", + "packages/modules/mCollect", + "packages/modules/dss", + "packages/modules/ws", + "packages/modules/birth", + "packages/modules/core", + "packages/modules/death", + "packages/modules/firenoc", + "packages/modules/obps", + "packages/modules/pt", + "packages/modules/bills", + "packages/modules/engagement", + "packages/modules/commonPt", + "packages/modules/finance", + "packages/modules/common" ], "author": "Abhinav Kushwaha ", "license": "MIT", @@ -41,34 +55,40 @@ "dev:bills": "cd packages/modules/bills && yarn start", "dev:reports": "cd packages/modules/reports && yarn start", "dev:example": "cd example && yarn start", + "dev:firenoc": "cd packages/modules/firenoc && yarn start", + "dev:birth": "cd packages/modules/birth && yarn start", + "dev:death": "cd packages/modules/death && yarn start", + "dev:finance": "cd packages/modules/finance && yarn start", "build": "run-p build:**", "build:libraries": "cd packages/libraries && yarn build", "build:components": "cd packages/react-components && yarn build", + "build:firenoc": "cd packages/modules/firenoc && yarn build", + "build:birth": "cd packages/modules/birth && yarn build", + "build:death": "cd packages/modules/death && yarn build", "build:common": "cd packages/modules/common && yarn build", "build:pt": "cd packages/modules/pt && yarn build", - "buildD:commonPt": "cd packages/modules/commonPt && yarn build", + "build:commonPt": "cd packages/modules/commonPt && yarn build", "build:core": "cd packages/modules/core && yarn build", "build:pgr": "cd packages/modules/pgr && yarn build", "build:fsm": "cd packages/modules/fsm && yarn build", "build:dss": "cd packages/modules/dss && yarn build", - "buildD:mcollect": "cd packages/modules/mCollect && yarn build", + "build:mcollect": "cd packages/modules/mCollect && yarn build", "buildD:receipts": "cd packages/modules/receipts && yarn build", "build:tl": "cd packages/modules/tl && yarn build", "buildD:hrms": "cd packages/modules/hrms && yarn build", - "buildD:obps": "cd packages/modules/obps && yarn build", + "build:obps": "cd packages/modules/obps && yarn build", "build:engagement": "cd packages/modules/engagement && yarn build", "buildD:noc": "cd packages/modules/noc && yarn build", "build:ws": "cd packages/modules/ws && yarn build", - "buildD:bills": "cd packages/modules/bills && yarn build", + "build:bills": "cd packages/modules/bills && yarn build", "buildR:reports": "cd packages/modules/reports && yarn build", + "build:finance": "cd packages/modules/finance && yarn build", "deploy:jenkins": "./scripts/jenkins.sh" }, "devDependencies": { "husky": "7.0.4", "lint-staged": "12.3.7", - "npm-run-all": "4.1.5", - "prettier": "2.1.2", - "@babel/plugin-transform-optional-chaining": "7.25.9" + "npm-run-all": "4.1.5" }, "husky": {}, "lint-staged": { @@ -77,11 +97,13 @@ "dependencies": { "lodash": "4.17.21", "microbundle-crl": "0.13.11" - } , + }, "resolutions": { "**/babel-loader": "8.2.2", "**/@babel/core": "7.14.0", "**/@babel/preset-env": "7.14.0", - "**/@babel/plugin-transform-modules-commonjs": "7.14.0" + "**/@babel/plugin-transform-modules-commonjs": "7.14.0", + "minimatch": "^3.0.4", + "glob": "^7.1.2" } } diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/css/package.json b/frontend/micro-ui/web/micro-ui-internals/packages/css/package.json index 0628c3e5486..9dbc6e9443d 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/css/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/packages/css/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-css", - "version": "1.6.6", + "version": "1.7.35", "license": "MIT", "main": "dist/index.css", "engines": { diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/README.md b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/README.md index d54ecfde277..bdb8d01e795 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/README.md +++ b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/README.md @@ -35,10 +35,10 @@ export default App; ## Changelog -### Summary for Version [1.7.10] - 2025-02-13 +### Summary for Version [1.7.35] - 2025-03-20 Added tenantId in Multiple api calls of obps, bills, tl, pt etc ## License -MIT © [](https://github.com/) +MIT © [](https://github.com/) \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/package.json b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/package.json index be388bc73f0..510927cd8d7 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-libraries", - "version": "1.7.10", + "version": "0.0.1-sandbox", "main": "dist/index.js", "module": "dist/index.modern.js", "source": "src/index.js", @@ -46,4 +46,4 @@ "**/@babel/preset-env": "7.16.0", "**/@babel/plugin-transform-modules-commonjs": "7.16.0" } -} +} \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/payment.js b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/payment.js index 255ac45ff95..9aa12d00681 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/payment.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/payment.js @@ -55,7 +55,7 @@ export const useFetchPayment = ({ tenantId, consumerCode, businessService }, con const fetchBill = async () => { /* Currently enabled the logic to get bill no and expiry date for PT Module */ - if (businessService?.includes("PT") || businessService?.includes("SW") || businessService?.includes("WS")) { + if (businessService?.includes("PT") || businessService?.includes("SW") || businessService?.includes("WS") || businessService?.includes("1001.PEF")) { const fetchedBill = await Digit.PaymentService.fetchBill(tenantId, { consumerCode, businessService }); const billdetail = fetchedBill?.Bill?.[0]?.billDetails?.sort((a, b) => b.fromPeriod - a.fromPeriod)?.[0] || {}; fetchedBill.Bill[0].billDetails = fetchedBill?.Bill[0]?.billDetails?.map((ele) => ({ diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/tl/useInbox.js b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/tl/useInbox.js index 9cee97dc5dc..4d2743bfd7c 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/tl/useInbox.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/tl/useInbox.js @@ -38,7 +38,7 @@ const useTLInbox = ({ tenantId, filters, config }) => { ?.toUpperCase() ?.split(".") ?.join("_")}_REVENUE_${application.businessObject?.tradeLicenseDetail?.address?.locality?.code?.toUpperCase()}`, - status: application.businessObject.status, + status: application.ProcessInstance?.state?.applicationStatus, owner: application.ProcessInstance?.assigner?.name, sla: application?.businessObject?.status?.match(/^(EXPIRED|APPROVED|CANCELLED)$/) ? "CS_NA" diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/useModuleTenants.js b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/useModuleTenants.js index 25e51a94e97..73b7e5373eb 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/useModuleTenants.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/hooks/useModuleTenants.js @@ -5,35 +5,65 @@ import { useTranslation } from "react-i18next"; const useModuleTenants = (module, config = {}) => { const { t } = useTranslation(); - return useQuery(["ULB_TENANTS", module], () => Digit.SessionStorage.get("initData"), { - select: (data) => ({ - ddr: data.modules - .find((e) => e.module === module) - .tenants.map((tenant) => ({ - ...tenant, - ulbKey: t(`TENANT_TENANTS_${tenant?.code?.toUpperCase?.()?.replace(".", "_")}`), - ddrKey: t( - `DDR_${data.tenants - .filter((t) => t.code === tenant.code)?.[0] - .city?.districtTenantCode?.toUpperCase?.() - .replace(".", "_")}` - ), - })) - .filter((item, i, arr) => i === arr.findIndex((t) => t.ddrKey === item.ddrKey)), - ulb: data.modules - .find((e) => e.module === module) - .tenants.map((tenant) => ({ - ...tenant, - ulbKey: t(`TENANT_TENANTS_${tenant?.code?.toUpperCase?.()?.replace(".", "_")}`), - ddrKey: t( - `DDR_${data.tenants - .filter((t) => t.code === tenant.code)?.[0] - .city?.districtTenantCode?.toUpperCase?.() - .replace(".", "_")}` - ), - })), - }), - ...config, - }); + return useQuery( + ["ULB_TENANTS", module], + () => { + const initData = Digit.SessionStorage.get("initData"); + + if (!initData) { + throw new Error("Missing initData from SessionStorage"); + } + + return initData; + }, + { + select: (data) => { + try { + + const moduleData = data.modules.find((e) => e.module === module); + + if (!moduleData) { + return { ddr: [], ulb: [] }; + } + + const transformedTenants = moduleData.tenants.map((tenant) => { + const tenantCodeKey = `TENANT_TENANTS_${tenant?.code?.toUpperCase?.()?.replace(".", "_")}`; + const tenantObj = data.tenants.find((t) => t.code === tenant.code); + const districtCode = tenantObj?.city?.districtTenantCode; + + if (!districtCode) { + } + + const ddrKey = `DDR_${districtCode?.toUpperCase?.()?.replace(".", "_")}`; + const ulbKey = t(tenantCodeKey); + const ddrTranslatedKey = t(ddrKey); + + + + return { + ...tenant, + ulbKey, + ddrKey: ddrTranslatedKey, + }; + }); + + const ddr = transformedTenants.filter( + (item, index, arr) => index === arr.findIndex((t) => t.ddrKey === item.ddrKey) + ); + + + + return { + ddr, + ulb: transformedTenants, + }; + } catch (error) { + return { ddr: [], ulb: [] }; + } + }, + ...config, + } + ); }; + export default useModuleTenants; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/atoms/UploadServices.js b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/atoms/UploadServices.js index 2400839e2b4..4bcd55472c3 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/atoms/UploadServices.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/atoms/UploadServices.js @@ -5,7 +5,7 @@ export const UploadServices = { const formData = new FormData(); formData.append("file", filedata, filedata.name); - formData.append("tenantId", tenantId); + // formData.append("tenantId", tenantId); formData.append("module", module); let tenantInfo=window?.globalConfigs?.getConfig("ENABLE_SINGLEINSTANCE")?`?tenantId=${tenantId}`:""; var config = { @@ -22,7 +22,7 @@ export const UploadServices = { const formData = new FormData(); const filesArray = Array.from(filesData) filesArray?.forEach((fileData, index) => fileData ? formData.append("file", fileData, fileData.name) : null); - formData.append("tenantId", tenantId); + // formData.append("tenantId", tenantId); formData.append("module", module); let tenantInfo=window?.globalConfigs?.getConfig("ENABLE_SINGLEINSTANCE")?`?tenantId=${tenantId}`:""; var config = { diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/atoms/Utils/Date.js b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/atoms/Utils/Date.js index 4b5e6479b0a..e7c2ebab210 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/atoms/Utils/Date.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/atoms/Utils/Date.js @@ -4,6 +4,11 @@ export const ConvertTimestampToDate = (timestamp, dateFormat = "d-MMM-yyyy") => return timestamp ? format(toDate(timestamp), dateFormat) : null; }; +export const convertTimestampToDateFormat = (timestamp, dateFormat = "dd/MM/yyyy") => { + return timestamp ? format(toDate(timestamp), dateFormat) : null; +}; + + export const ConvertEpochToDate = (dateEpoch) => { if (dateEpoch == null || dateEpoch == undefined || dateEpoch == "") { return "NA"; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/MDMS.js b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/MDMS.js index 24a8a858703..3f3d7d6e1c8 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/MDMS.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/MDMS.js @@ -143,9 +143,9 @@ const getBillsGenieKey = (tenantId, moduleCode) => ({ masterDetails: [{ name: "tenants" }, { name: "citymodule" }], }, { - moduleName: "common-masters", - masterDetails: [{name: "uiCommonPay"}] - } + moduleName: "common-masters", + masterDetails: [{ name: "uiCommonPay" }], + }, ], }, }); @@ -639,32 +639,31 @@ const getGenderTypeList = (tenantId, moduleCode, type) => ({ }); const getMeterStatusTypeList = (tenantId) => ({ - moduleDetails: [ - { - moduleName: "ws-services-calculation", - masterDetails: [ - { - name: "MeterStatus", - filter: `$.*.name` - }, - ], - }, - ], - + moduleDetails: [ + { + moduleName: "ws-services-calculation", + masterDetails: [ + { + name: "MeterStatus", + filter: `$.*.name`, + }, + ], + }, + ], }); const getBillingPeriodValidation = (tenantId) => ({ - moduleDetails: [ - { - moduleName: "ws-services-masters", - masterDetails: [ - { - name: "billingPeriod", - filter: "*" - }, - ], - }, - ], + moduleDetails: [ + { + moduleName: "ws-services-masters", + masterDetails: [ + { + name: "billingPeriod", + filter: "*", + }, + ], + }, + ], }); const getDssDashboardCriteria = (tenantId, moduleCode) => ({ @@ -916,53 +915,53 @@ const getWSTaxHeadMasterCritera = (tenantId, moduleCode, type) => ({ }); const getHowItWorksJSON = (tenantId) => ({ - moduleDetails: [ - { - moduleName: "common-masters", - masterDetails: [ - { - name: "howItWorks", - }, - ], - }, - ], + moduleDetails: [ + { + moduleName: "common-masters", + masterDetails: [ + { + name: "howItWorks", + }, + ], + }, + ], }); const getFAQsJSON = (tenantId) => ({ moduleDetails: [ - { - moduleName: "common-masters", - masterDetails: [ - { - name: "faqs", - }, - ], - }, -], + { + moduleName: "common-masters", + masterDetails: [ + { + name: "faqs", + }, + ], + }, + ], }); const getDSSFAQsJSON = (tenantId) => ({ moduleDetails: [ - { - moduleName: "dss-dashboard", - masterDetails: [ - { - name: "FAQs", - }, - ], - }, -], + { + moduleName: "dss-dashboard", + masterDetails: [ + { + name: "FAQs", + }, + ], + }, + ], }); const getDSSAboutJSON = (tenantId) => ({ moduleDetails: [ - { - moduleName: "dss-dashboard", - masterDetails: [ - { - name: "About", - }, - ], - }, -], + { + moduleName: "dss-dashboard", + masterDetails: [ + { + name: "About", + }, + ], + }, + ], }); const getStaticData = () => ({ @@ -1023,12 +1022,11 @@ const GetVehicleType = (MdmsRes) => }); const GetVehicleMakeModel = (MdmsRes) => - MdmsRes["Vehicle"].VehicleMakeModel.filter((vehicle) => vehicle.active) - .map((vehicleDetails) => { - return { - ...vehicleDetails, - i18nKey: `COMMON_MASTER_VEHICLE_${vehicleDetails.code}`, - }; + MdmsRes["Vehicle"].VehicleMakeModel.filter((vehicle) => vehicle.active).map((vehicleDetails) => { + return { + ...vehicleDetails, + i18nKey: `COMMON_MASTER_VEHICLE_${vehicleDetails.code}`, + }; }); const GetSlumLocalityMapping = (MdmsRes, tenantId) => @@ -1721,11 +1719,11 @@ export const MdmsService = { getDSSFAQsJSONData: (tenantId) => { return MdmsService.call(tenantId, getDSSFAQsJSON(tenantId)); }, - + getDSSAboutJSONData: (tenantId) => { return MdmsService.call(tenantId, getDSSAboutJSON(tenantId)); }, getStaticDataJSON: (tenantId) => { return MdmsService.call(tenantId, getStaticData()); - } + }, }; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/WorkFlow.js b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/WorkFlow.js index 689761683b1..c1154596f1c 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/WorkFlow.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/WorkFlow.js @@ -4,19 +4,19 @@ import cloneDeep from "lodash/cloneDeep"; const getThumbnails = async (ids, tenantId, documents = []) => { tenantId = window.location.href.includes("/obps/") || window.location.href.includes("/pt/") ? Digit.ULBService.getStateId() : tenantId; - + if (window.location.href.includes("/obps/")) { if (documents?.length > 0) { let workflowsDocs = []; - documents?.map(doc => { + documents?.map((doc) => { if (doc?.url) { - const thumbs = doc?.url?.split(",")?.[3] || doc?.url?.split(",")?.[0] + const thumbs = doc?.url?.split(",")?.[3] || doc?.url?.split(",")?.[0]; workflowsDocs.push({ thumbs: [thumbs], - images: [Digit.Utils.getFileUrl(doc.url)] - }) + images: [Digit.Utils.getFileUrl(doc.url)], + }); } - }) + }); return workflowsDocs?.[0]; } else { return null; @@ -24,9 +24,10 @@ const getThumbnails = async (ids, tenantId, documents = []) => { } else { const res = await Digit.UploadServices.Filefetch(ids, tenantId); if (res.data.fileStoreIds && res.data.fileStoreIds.length !== 0) { - return { - thumbs: res.data.fileStoreIds.map((o) => o.url.split(",")[3] || o.url.split(",")[0]), - images: res.data.fileStoreIds.map((o) => Digit.Utils.getFileUrl(o.url)) }; + return { + thumbs: res.data.fileStoreIds.map((o) => o.url.split(",")[3] || o.url.split(",")[0]), + images: res.data.fileStoreIds.map((o) => Digit.Utils.getFileUrl(o.url)), + }; } else { return null; } @@ -40,53 +41,62 @@ const makeCommentsSubsidariesOfPreviousActions = async (wf) => { let res = {}; if (window.location.href.includes("/obps/")) { - wf?.map(wfData => { - wfData?.documents?.map(wfDoc => { + wf?.map((wfData) => { + wfData?.documents?.map((wfDoc) => { if (wfDoc?.fileStoreId) fileStoreIdsList.push(wfDoc?.fileStoreId); - }) - }) + }); + }); if (fileStoreIdsList?.length > 0) { res = await Digit.UploadServices.Filefetch(fileStoreIdsList, tenantId); } - wf?.forEach(wfData => { - wfData?.documents?.forEach(wfDoc => { + wf?.forEach((wfData) => { + wfData?.documents?.forEach((wfDoc) => { if (wfDoc?.fileStoreId) wfDoc.url = res.data[wfDoc?.fileStoreId]; - }) + }); }); } for (const eventHappened of wf) { if (eventHappened?.documents) { - eventHappened.thumbnailsToShow = await getThumbnails(eventHappened?.documents?.map(e => e?.fileStoreId), eventHappened?.tenantId, eventHappened?.documents) + eventHappened.thumbnailsToShow = await getThumbnails( + eventHappened?.documents?.map((e) => e?.fileStoreId), + eventHappened?.tenantId, + eventHappened?.documents + ); } if (eventHappened.action === "COMMENT") { - const commentAccumulator = TimelineMap.get("tlCommentStack") || [] - TimelineMap.set("tlCommentStack", [...commentAccumulator, eventHappened]) - } - else { - const eventAccumulator = TimelineMap.get("tlActions") || [] - const commentAccumulator = TimelineMap.get("tlCommentStack") || [] - eventHappened.wfComments = [...commentAccumulator, ...eventHappened.comment ? [eventHappened] : []] - TimelineMap.set("tlActions", [...eventAccumulator, eventHappened]) - TimelineMap.delete("tlCommentStack") + const commentAccumulator = TimelineMap.get("tlCommentStack") || []; + TimelineMap.set("tlCommentStack", [...commentAccumulator, eventHappened]); + } else { + const eventAccumulator = TimelineMap.get("tlActions") || []; + const commentAccumulator = TimelineMap.get("tlCommentStack") || []; + eventHappened.wfComments = [...commentAccumulator, ...(eventHappened.comment ? [eventHappened] : [])]; + TimelineMap.set("tlActions", [...eventAccumulator, eventHappened]); + TimelineMap.delete("tlCommentStack"); } } - const response = TimelineMap.get("tlActions") - return response -} + const response = TimelineMap.get("tlActions"); + return response; +}; const getAssignerDetails = (instance, nextStep, moduleCode) => { - let assigner = instance?.assigner - if (moduleCode === "FSM" || moduleCode === "FSM_POST_PAY_SERVICE" || moduleCode === "FSM_ADVANCE_PAY_SERVICE" || moduleCode === "PAY_LATER_SERVICE" || moduleCode === "FSM_ZERO_PAY_SERVICE") { + let assigner = instance?.assigner; + if ( + moduleCode === "FSM" || + moduleCode === "FSM_POST_PAY_SERVICE" || + moduleCode === "FSM_ADVANCE_PAY_SERVICE" || + moduleCode === "PAY_LATER_SERVICE" || + moduleCode === "FSM_ZERO_PAY_SERVICE" + ) { if (instance.state.applicationStatus === "CREATED") { - assigner = instance?.assigner + assigner = instance?.assigner; } else { - assigner = nextStep?.assigner || instance?.assigner + assigner = nextStep?.assigner || instance?.assigner; } } else { - assigner = instance?.assigner + assigner = instance?.assigner; } - return assigner -} + return assigner; +}; export const WorkflowService = { init: (stateCode, businessServices) => { @@ -126,7 +136,17 @@ export const WorkflowService = { /* To check state is updatable and provide edit option*/ const currentState = businessServiceResponse?.find((state) => state.uuid === processInstances[0]?.state.uuid); if (currentState && currentState?.isStateUpdatable) { - if (moduleCode === "FSM" || moduleCode === "FSM_POST_PAY_SERVICE" || moduleCode === "FSM_ADVANCE_PAY_SERVICE" || moduleCode === "FSM_ZERO_PAY_SERVICE" || moduleCode === "PAY_LATER_SERVICE" || moduleCode === "FSM_VEHICLE_TRIP" || moduleCode === "PGR" || moduleCode === "OBPS") null; + if ( + moduleCode === "FSM" || + moduleCode === "FSM_POST_PAY_SERVICE" || + moduleCode === "FSM_ADVANCE_PAY_SERVICE" || + moduleCode === "FSM_ZERO_PAY_SERVICE" || + moduleCode === "PAY_LATER_SERVICE" || + moduleCode === "FSM_VEHICLE_TRIP" || + moduleCode === "PGR" || + moduleCode === "OBPS" + ) + null; else nextActions.push({ action: "EDIT", state: currentState }); } @@ -146,10 +166,12 @@ export const WorkflowService = { })?.[0]; // HANDLING ACTION for NEW VEHICLE LOG FROM UI SIDE - const action_newVehicle = [{ - "action": "READY_FOR_DISPOSAL", - "roles": "FSM_EMP_FSTPO,FSM_EMP_FSTPO" - }] + const action_newVehicle = [ + { + action: "READY_FOR_DISPOSAL", + roles: "FSM_EMP_FSTPO,FSM_EMP_FSTPO", + }, + ]; // const actionRolePair = nextActions?.map((action) => ({ // action: action?.action, @@ -157,15 +179,15 @@ export const WorkflowService = { // })); if (processInstances.length > 0) { - const TLEnrichedWithWorflowData = await makeCommentsSubsidariesOfPreviousActions(processInstances) + const TLEnrichedWithWorflowData = await makeCommentsSubsidariesOfPreviousActions(processInstances); let timeline = TLEnrichedWithWorflowData.map((instance, ind) => { let checkPoint = { performedAction: instance.action, - status: moduleCode === "WS.AMENDMENT" || moduleCode === "SW.AMENDMENT" ? instance.state.state :instance.state.applicationStatus, + status: moduleCode === "WS.AMENDMENT" || moduleCode === "SW.AMENDMENT" ? instance.state.state : instance.state.applicationStatus, state: instance.state.state, assigner: getAssignerDetails(instance, TLEnrichedWithWorflowData[ind - 1], moduleCode), rating: instance?.rating, - wfComment: instance?.wfComments.map(e => e?.comment), + wfComment: instance?.wfComments.map((e) => e?.comment), wfDocuments: instance?.documents, thumbnailsToShow: { thumbs: instance?.thumbnailsToShow?.thumbs, fullImage: instance?.thumbnailsToShow?.images }, assignes: instance.assignes, @@ -184,97 +206,115 @@ export const WorkflowService = { if (getTripData) { try { const filters = { - businessService: 'FSM_VEHICLE_TRIP', - refernceNos: id + businessService: "FSM_VEHICLE_TRIP", + refernceNos: id, }; - const tripSearchResp = await Digit.FSMService.vehicleSearch(tenantId, filters) + const tripSearchResp = await Digit.FSMService.vehicleSearch(tenantId, filters); if (tripSearchResp && tripSearchResp.vehicleTrip && tripSearchResp.vehicleTrip.length) { - const numberOfTrips = tripSearchResp.vehicleTrip.length - let cretaedTime = 0 - let lastModifiedTime = 0 - let waitingForDisposedCount = 0 - let disposedCount = 0 - let waitingForDisposedAction = [] - let disposedAction = [] + const numberOfTrips = tripSearchResp.vehicleTrip.length; + let cretaedTime = 0; + let lastModifiedTime = 0; + let waitingForDisposedCount = 0; + let disposedCount = 0; + let waitingForDisposedAction = []; + let disposedAction = []; for (const data of tripSearchResp.vehicleTrip) { - const resp = await Digit.WorkflowService.getByBusinessId(tenantId, data.applicationNo) + const resp = await Digit.WorkflowService.getByBusinessId(tenantId, data.applicationNo); resp?.ProcessInstances?.map((instance, ind) => { if (instance.state.applicationStatus === "WAITING_FOR_DISPOSAL") { - waitingForDisposedCount++ - cretaedTime = Digit.DateUtils.ConvertEpochToDate(instance.auditDetails.createdTime) - lastModifiedTime = Digit.DateUtils.ConvertEpochToDate(instance.auditDetails.lastModifiedTime) - waitingForDisposedAction = [{ - performedAction: instance.action, - status: instance.state.applicationStatus, - state: instance.state.state, - assigner: instance?.assigner, - rating: instance?.rating, - thumbnailsToShow: { thumbs: instance?.thumbnailsToShow?.thumbs, fullImage: instance?.thumbnailsToShow?.images }, - assignes: instance.assignes, - caption: instance.assignes ? instance.assignes.map((assignee) => ({ name: assignee.name, mobileNumber: assignee.mobileNumber })) : null, - auditDetails: { - created: cretaedTime, - lastModified: lastModifiedTime, + waitingForDisposedCount++; + cretaedTime = Digit.DateUtils.ConvertEpochToDate(instance.auditDetails.createdTime); + lastModifiedTime = Digit.DateUtils.ConvertEpochToDate(instance.auditDetails.lastModifiedTime); + waitingForDisposedAction = [ + { + performedAction: instance.action, + status: instance.state.applicationStatus, + state: instance.state.state, + assigner: instance?.assigner, + rating: instance?.rating, + thumbnailsToShow: { thumbs: instance?.thumbnailsToShow?.thumbs, fullImage: instance?.thumbnailsToShow?.images }, + assignes: instance.assignes, + caption: instance.assignes + ? instance.assignes.map((assignee) => ({ name: assignee.name, mobileNumber: assignee.mobileNumber })) + : null, + auditDetails: { + created: cretaedTime, + lastModified: lastModifiedTime, + }, + numberOfTrips: numberOfTrips, }, - numberOfTrips: numberOfTrips - }] + ]; } if (instance.state.applicationStatus === "DISPOSED") { - disposedCount++ - cretaedTime = instance.auditDetails.createdTime > cretaedTime ? Digit.DateUtils.ConvertEpochToDate(instance.auditDetails.createdTime) : cretaedTime - lastModifiedTime = instance.auditDetails.lastModifiedTime > lastModifiedTime ? Digit.DateUtils.ConvertEpochToDate(instance.auditDetails.lastModifiedTime) : lastModifiedTime - disposedAction = [{ - performedAction: instance.action, - status: instance.state.applicationStatus, - state: instance.state.state, - assigner: instance?.assigner, - rating: instance?.rating, - thumbnailsToShow: { thumbs: instance?.thumbnailsToShow?.thumbs, fullImage: instance?.thumbnailsToShow?.images }, - assignes: instance.assignes, - caption: instance.assignes ? instance.assignes.map((assignee) => ({ name: assignee.name, mobileNumber: assignee.mobileNumber })) : null, - auditDetails: { - created: cretaedTime, - lastModified: lastModifiedTime, + disposedCount++; + cretaedTime = + instance.auditDetails.createdTime > cretaedTime + ? Digit.DateUtils.ConvertEpochToDate(instance.auditDetails.createdTime) + : cretaedTime; + lastModifiedTime = + instance.auditDetails.lastModifiedTime > lastModifiedTime + ? Digit.DateUtils.ConvertEpochToDate(instance.auditDetails.lastModifiedTime) + : lastModifiedTime; + disposedAction = [ + { + performedAction: instance.action, + status: instance.state.applicationStatus, + state: instance.state.state, + assigner: instance?.assigner, + rating: instance?.rating, + thumbnailsToShow: { thumbs: instance?.thumbnailsToShow?.thumbs, fullImage: instance?.thumbnailsToShow?.images }, + assignes: instance.assignes, + caption: instance.assignes + ? instance.assignes.map((assignee) => ({ name: assignee.name, mobileNumber: assignee.mobileNumber })) + : null, + auditDetails: { + created: cretaedTime, + lastModified: lastModifiedTime, + }, + numberOfTrips: disposedCount, }, - numberOfTrips: disposedCount - }] + ]; } - }) + }); } - let tripTimeline = [] - const disposalInProgressPosition = timeline.findIndex((data) => data.status === "DISPOSAL_IN_PROGRESS") + let tripTimeline = []; + const disposalInProgressPosition = timeline.findIndex((data) => data.status === "DISPOSAL_IN_PROGRESS"); if (disposalInProgressPosition !== -1) { - timeline[disposalInProgressPosition].numberOfTrips = numberOfTrips - timeline.splice(disposalInProgressPosition + 1, 0, ...waitingForDisposedAction) - tripTimeline = disposedAction + timeline[disposalInProgressPosition].numberOfTrips = numberOfTrips; + timeline.splice(disposalInProgressPosition + 1, 0, ...waitingForDisposedAction); + tripTimeline = disposedAction; } else { - tripTimeline = disposedAction.concat(waitingForDisposedAction) + tripTimeline = disposedAction.concat(waitingForDisposedAction); } - const feedbackPosition = timeline.findIndex((data) => data.status === "CITIZEN_FEEDBACK_PENDING") + const feedbackPosition = timeline.findIndex((data) => data.status === "CITIZEN_FEEDBACK_PENDING"); if (feedbackPosition !== -1) { - timeline.splice(feedbackPosition + 1, 0, ...tripTimeline) + timeline.splice(feedbackPosition + 1, 0, ...tripTimeline); } else { - timeline = tripTimeline.concat(timeline) + timeline = tripTimeline.concat(timeline); } } - } catch (err) { } + } catch (err) {} } - //Added the condition so that following filter can happen only for fsm and does not affect other module - let nextStep = []; - if(window.location.href?.includes("fsm")){ - // TAKING OUT CURRENT APPL STATUS - const actionRolePair = nextActions?.map((action) => ({ - action: action?.action, - roles: action.state?.actions?.map((action) => action.roles).join(","), - })); - nextStep = location.pathname.includes("new-vehicle-entry") ? action_newVehicle : location.pathname.includes("dso") ? actionRolePair.filter((i)=> i.action !== "PAY") : actionRolePair; - } + //Added the condition so that following filter can happen only for fsm and does not affect other module + let nextStep = []; + if (window.location.href?.includes("fsm")) { + // TAKING OUT CURRENT APPL STATUS + const actionRolePair = nextActions?.map((action) => ({ + action: action?.action, + roles: action.state?.actions?.map((action) => action.roles).join(","), + })); + nextStep = location.pathname.includes("new-vehicle-entry") + ? action_newVehicle + : location.pathname.includes("dso") + ? actionRolePair.filter((i) => i.action !== "PAY") + : actionRolePair; + } if (role !== "CITIZEN" && moduleCode === "PGR") { - const onlyPendingForAssignmentStatusArray = timeline?.filter(e => e?.status === "PENDINGFORASSIGNMENT") - const duplicateCheckpointOfPendingForAssignment = onlyPendingForAssignmentStatusArray.at(-1) + const onlyPendingForAssignmentStatusArray = timeline?.filter((e) => e?.status === "PENDINGFORASSIGNMENT"); + const duplicateCheckpointOfPendingForAssignment = onlyPendingForAssignmentStatusArray.at(-1); // const duplicateCheckpointOfPendingForAssignment = timeline?.find( e => e?.status === "PENDINGFORASSIGNMENT") timeline.push({ ...duplicateCheckpointOfPendingForAssignment, @@ -282,14 +322,21 @@ export const WorkflowService = { }); } - if (timeline[timeline.length - 1].status !== "CREATED" && (moduleCode === "FSM" || moduleCode === "FSM_POST_PAY_SERVICE" || moduleCode==="FSM_ADVANCE_PAY_SERVICE" || moduleCode==="FSM_ZERO_PAY_SERVICE" || moduleCode==="PAY_LATER_SERVICE" )) + if ( + timeline[timeline.length - 1].status !== "CREATED" && + (moduleCode === "FSM" || + moduleCode === "FSM_POST_PAY_SERVICE" || + moduleCode === "FSM_ADVANCE_PAY_SERVICE" || + moduleCode === "FSM_ZERO_PAY_SERVICE" || + moduleCode === "PAY_LATER_SERVICE") + ) timeline.push({ status: "CREATED", }); const details = { timeline, - nextActions : window.location.href?.includes("fsm") ? nextStep : nextActions, + nextActions: window.location.href?.includes("fsm") ? nextStep : nextActions, actionState, applicationBusinessService: workflow?.ProcessInstances?.[0]?.businessService, processInstances: applicationProcessInstance, diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/molecules/Store/service.js b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/molecules/Store/service.js index c9932b32af3..680023e1edb 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/molecules/Store/service.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/services/molecules/Store/service.js @@ -92,9 +92,13 @@ export const StoreService = { })); // .filter((item) => !!moduleTenants.find((mt) => mt.code === item.code)) // .map((tenant) => ({ i18nKey: `TENANT_TENANTS_${tenant.code.replace(".", "_").toUpperCase()}`, ...tenant })); - + const modules = [ + 'rainmaker-common', + ...(enabledModules.includes('Birth') || enabledModules.includes('Death') ? ['rainmaker-bnd'] : []), + `rainmaker-${stateCode.toLowerCase()}` + ]; await LocalizationService.getLocale({ - modules: [`rainmaker-common`, `rainmaker-${stateCode.toLowerCase()}`], + modules: modules, locale: initData.selectedLanguage, tenantId: stateCode, }); diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/utils/index.js b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/utils/index.js index c78aca0b09a..3dce7d901cf 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/utils/index.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/libraries/src/utils/index.js @@ -152,16 +152,40 @@ const fsmAccess = () => { const NOCAccess = () => { const userInfo = Digit.UserService.getUser(); const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code); - const NOC_ROLES = [ - "FIRE_NOC_APPROVER" + "FIRE_NOC_APPROVER", ] const NOC_ACCESS = userRoles?.filter((role) => NOC_ROLES?.includes(role)); - return NOC_ACCESS?.length > 0; }; +const FirenocAccess = () => { + const userInfo = Digit.UserService.getUser(); + const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code); + const Firenoc_ROLES = [ + "NOC_APPROVER", + "NOC_CEMP", + "NOC_DOC_VERIFIER", + "NOC_FIELD_INSPECTOR", + ] + const Firenoc_ACCESS = userRoles?.filter((role) => Firenoc_ROLES?.includes(role)); + return Firenoc_ACCESS?.length > 0; +}; + +const BnDAccess = () => { + const userInfo = Digit.UserService.getUser(); + const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code); + + const NOC_ROLES = [ + "BND_CEMP" + ] + + const BND_ACCESS = userRoles?.filter((role) => NOC_ROLES?.includes(role)); + + return BND_ACCESS?.length > 0; +}; + const BPAREGAccess = () => { const userInfo = Digit.UserService.getUser(); const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code); @@ -231,6 +255,7 @@ const mCollectAccess = () => { return MCOLLECT_ACCESS?.length > 0; }; + const receiptsAccess = () => { const userInfo = Digit.UserService.getUser(); const userRoles = userInfo?.info?.roles.map((roleData) => roleData?.code); @@ -267,6 +292,75 @@ const swAccess = () => { }; +const mCollectCitizenAccess = () => { + const userInfo = Digit.UserService.getUser(); + const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code); + + const mCollectRoles = ["MC_CITIZEN", "CITIZEN"]; + const MCOLLECT_ACCESS = userRoles?.filter((role) => mCollectRoles?.includes(role)); + + return MCOLLECT_ACCESS?.length > 0; +}; + +const ptCitizenAccess = () => { + const userInfo = Digit.UserService.getUser(); + const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code); + + const ptRoles = ["PT_CITIZEN", "CITIZEN"]; + const PT_ACCESS = userRoles?.filter((role) => ptRoles?.includes(role)); + + return PT_ACCESS?.length > 0; +} + +const tlCitizenAccess = () => { + const userInfo = Digit.UserService.getUser(); + const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code); + + const tlRoles = ["TL_CITIZEN", "CITIZEN"]; + const TL_ACCESS = userRoles?.filter((role) => tlRoles?.includes(role)); + + return TL_ACCESS?.length > 0; +} + +const BPACitizenAccess = () => { + const userInfo = Digit.UserService.getUser(); + const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code); + const bpaRoles = ["BPA_CITIZEN", "CITIZEN"]; + const BPA_ACCESS = userRoles?.filter((role) => bpaRoles?.includes(role)); + + return BPA_ACCESS?.length > 0; +} + +const wsCitizenAccess = () => { + const userInfo = Digit.UserService.getUser(); + const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code); + const waterRoles = ["WS_CITIZEN", "CITIZEN"]; + + const WS_ACCESS = userRoles?.filter((role) => waterRoles?.includes(role)); + + return WS_ACCESS?.length > 0; +}; + +const NOCCitizenAccess = () => { + const userInfo = Digit.UserService.getUser(); + const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code); + const nocRoles = ["FN_CITIZEN", "CITIZEN"]; + + const NOC_ACCESS = userRoles?.filter((role) => nocRoles?.includes(role)); + + return NOC_ACCESS?.length > 0; +}; + +const bdCitizenAccess = () => { + const userInfo = Digit.UserService.getUser(); + const userRoles = userInfo?.info?.roles?.map((roleData) => roleData?.code); + const bdRoles = ["BD_CITIZEN", "CITIZEN"]; + + const BD_ACCESS = userRoles?.filter((role) => bdRoles?.includes(role)); + + return BD_ACCESS?.length > 0; +}; + export default { pdf: PDFUtil, downloadReceipt, @@ -291,6 +385,7 @@ export default { pt, ptAccess, NOCAccess, + FirenocAccess, mCollectAccess, receiptsAccess, didEmployeeHasRole, @@ -301,6 +396,14 @@ export default { tlAccess, wsAccess, swAccess, + BnDAccess, + mCollectCitizenAccess, + tlCitizenAccess, + ptCitizenAccess, + BPACitizenAccess, + wsCitizenAccess, + NOCCitizenAccess, + bdCitizenAccess, ...privacy }; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/bills/README.md b/frontend/micro-ui/web/micro-ui-internals/packages/modules/bills/README.md index b151a101a75..c93044ff341 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/bills/README.md +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/bills/README.md @@ -22,10 +22,10 @@ frontend/micro-ui/web/package.json ## Changelog -### Summary for Version [1.7.10] - 2025-02-13 +### Summary for Version [1.7.35] - 2025-03-20 Added tenantId as param in bill-gen Api ### Contributors -[jagankumar-egov] [hari-egov] [mukund-egov] +[jagankumar-egov] [hari-egov] [mukund-egov] \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/bills/package.json b/frontend/micro-ui/web/micro-ui-internals/packages/modules/bills/package.json index 86cdead531b..05b770ba3be 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/bills/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/bills/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-module-bills", - "version": "1.7.10", + "version": "1.7.35", "description": "BILLS", "license": "MIT", "main": "dist/index.js", diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/bills/src/components/GroupBill/MobileGroupBill.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/bills/src/components/GroupBill/MobileGroupBill.js index 25f50e43d1f..1287335cb4d 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/bills/src/components/GroupBill/MobileGroupBill.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/bills/src/components/GroupBill/MobileGroupBill.js @@ -110,6 +110,17 @@ const MobileGroupBill = ({ Controller, register, control, t, reset, handleSubmit }; + const downloadBills = async () => { + + const keyv1 = keys.filter((key) => key.code === searchParams.businesService); + const bills = await Digit.PaymentService.generatePdf(tenantId, { Bill: data.Bills }, keyv1[0].billKey); + const res = await Digit.UploadServices.Filefetch(bills?.filestoreIds, tenantId); + window.open(res.data[bills.filestoreIds[0]]); + //logic for downloading all bills anyway(if api is giving multiple filestoreids) + const fsObj = res.data.fileStoreIds; + // downloadAll(fsObj) + }; + const [showOptions, setShowOptions] = useState(false) const dowloadOptions = serviceType === "WS" ? [ { diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/birth/package.json b/frontend/micro-ui/web/micro-ui-internals/packages/modules/birth/package.json new file mode 100644 index 00000000000..dd5bd7b874e --- /dev/null +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/birth/package.json @@ -0,0 +1,32 @@ +{ + "name": "@egovernments/digit-ui-module-birth", + "version": "0.0.1-sandbox", + "description": "Birth Module UI", + "main": "dist/index.js", + "module": "dist/index.modern.js", + "source": "src/Module.js", + "files": [ + "dist" + ], + "scripts": { + "start": "microbundle-crl watch --no-compress --format modern,cjs", + "build": "microbundle-crl --compress --no-sourcemap --format cjs", + "prepublish": "yarn build" + }, + "peerDependencies": { + "react": "17.0.2", + "react-router-dom": "5.3.0" + }, + "dependencies": { + "@egovernments/digit-ui-react-components": "1.7.35", + "react": "17.0.2", + "react-date-range": "^1.4.0", + "react-dom": "17.0.2", + "react-hook-form": "6.15.8", + "react-i18next": "11.16.2", + "react-query": "3.6.1", + "react-router-dom": "5.3.0" + }, + "author": "Mukund ", + "license": "MIT" +} \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/birth/src/Module.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/birth/src/Module.js new file mode 100644 index 00000000000..200fda37572 --- /dev/null +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/birth/src/Module.js @@ -0,0 +1,43 @@ +import { Loader} from "@egovernments/digit-ui-react-components"; +import React from "react"; +import BirthCard from "./components/BirthCard"; +import EmployeeApp from "./pages/employee"; +import { useRouteMatch } from "react-router-dom"; + +export const BirthModule = ({ stateCode, userType, tenants }) => { + + + const tenantId = Digit.ULBService.getCurrentTenantId(); + const moduleCode = "birth"; + const language = Digit.StoreData.getCurrentLanguage(); + const { path, url } = useRouteMatch(); + + const { isLoading, data: store } = Digit.Services.useStore({ + stateCode, + moduleCode, + language, + }); + +if (isLoading) { + return ; + } + if (userType === "employee") { + return ; + } else return
Citizen
+ +} + +const componentsToRegister = { + BirthModule, + BirthCard, + EmployeeApp + }; + +export const initBirthComponents = () => { + Object.entries(componentsToRegister).forEach(([key, value]) => { + Digit.ComponentRegistryService.setComponent(key, value); + }); +} + + + diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/birth/src/components/BirthCard.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/birth/src/components/BirthCard.js new file mode 100644 index 00000000000..83617a82355 --- /dev/null +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/birth/src/components/BirthCard.js @@ -0,0 +1,41 @@ +import React, { useEffect, useState } from "react"; +import { Link } from "react-router-dom"; +import { useTranslation } from "react-i18next"; +import { EmployeeModuleCard, PropertyHouse } from "@egovernments/digit-ui-react-components"; +import { CaseIcon } from "@egovernments/digit-ui-react-components"; + +const BirthCard = () => { + if (!Digit.Utils.BnDAccess()) return null; + + const { t } = useTranslation(); + window.localStorage.setItem("Employee.locale", "en_IN"); + window.localStorage.setItem("locale", "en_IN"); + window.localStorage.setItem("Employee.tenant-id", Digit.ULBService.getCurrentTenantId()); + window.localStorage.setItem("tenant-id",Digit.ULBService.getCurrentTenantId()); + + const links = [ + { + label: t("BIRTH_REGISTRATION"), + link: `https://unified-demo.digit.org/employee/birth-employee/newRegistration`, + hyperlink: true + }, + { + label: t("SEARCH_BIRTH_CERTIFICATE"), + link: `https://unified-demo.digit.org/employee/birth-common/getCertificate`, + hyperlink: true + + } + ]; + + const propsForModuleCard = { + Icon:, + moduleName: t("COMMON_BIRTH"), + links: links, + kpis: [ + ], +} + + return ; +}; + +export default BirthCard; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/birth/src/pages/employee/index.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/birth/src/pages/employee/index.js new file mode 100644 index 00000000000..768e6b2abf9 --- /dev/null +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/birth/src/pages/employee/index.js @@ -0,0 +1,25 @@ +import React from "react"; +import { PrivateRoute } from "@egovernments/digit-ui-react-components"; +import { Switch } from "react-router-dom/cjs/react-router-dom.min"; + +const EmployeeApp = ({ path, url, userType }) => { + return ( + + +
+ + ( +
Birth Module
+ )} + /> + +
+
+
+ ); + }; + + export default EmployeeApp; + \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/README.md b/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/README.md index 1a386835ae1..21b05c92f18 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/README.md +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/README.md @@ -22,10 +22,10 @@ frontend/micro-ui/web/package.json ## Changelog -### Summary for Version [1.7.10] - 2025-02-13 +### Summary for Version [1.7.35] - 2025-03-20 No specific change. Version matched as used in URBAN. ### Contributors -[jagankumar-egov] [hari-egov] [mukund-egov] +[jagankumar-egov] [hari-egov] [mukund-egov] \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/package.json b/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/package.json index c78ce45bed2..3205409ab20 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-module-common", - "version": "1.7.10", + "version": "1.7.35", "license": "MIT", "description": "Digit Common Payment Module", "main": "dist/index.js", diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/src/payments/citizen/bills/routes/bill-details/bill-details.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/src/payments/citizen/bills/routes/bill-details/bill-details.js index 0e1adc46559..ef81d7c57d5 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/src/payments/citizen/bills/routes/bill-details/bill-details.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/src/payments/citizen/bills/routes/bill-details/bill-details.js @@ -55,6 +55,7 @@ const BillDetails = ({ paymentRules, businessService }) => { ?.reduce((total, current, index) => (index === 0 ? total : total + current.amount), 0) || 0; const { key, label } = Digit.Hooks.useApplicationsForBusinessServiceSearch({ businessService }, { enabled: false }); + const getBillingPeriod = () => { const { fromPeriod, toPeriod } = billDetails; if (fromPeriod && toPeriod) { @@ -137,18 +138,48 @@ const BillDetails = ({ paymentRules, businessService }) => { } }, [isLoading]); - const onSubmit = () => { + const onSubmit = async() => { let paymentAmount = paymentType === t("CS_PAYMENT_FULL_AMOUNT") ? getTotal() : amount || businessService === "FSM.TRIP_CHARGES" ? application?.pdfData?.advanceAmount : amount; + + let recieptRequest = { + Payment: { + mobileNumber: bill.mobileNumber, + paymentDetails: [ + { + businessService, + billId: bill.id, + totalDue: bill.totalAmount, + totalAmountPaid: bill.totalAmount, + }, + ], + tenantId: bill.tenantId, + totalDue: bill.totalAmount, + totalAmountPaid: bill.totalAmount, + paymentMode: "CASH", + payerName: bill.payerName, + paidBy: "OWNER", + }, + }; + + try { + const resposne = await Digit.PaymentService.createReciept(bill.tenantId, recieptRequest); + sessionStorage.setItem("PaymentResponse", JSON.stringify(resposne)); + history.push(`/digit-ui/citizen/payment/success/${businessService}/${consumerCode}/${tenantId}?workflow=mcollect`); + } catch (error) { + console.log("Error while creating receipt", error); + // setToast({ key: "error", action: error?.response?.data?.Errors?.map((e) => t(e.code)) })?.join(" , "); + // setTimeout(() => setToast(null), 5000); + return; + } + + if (window.location.href.includes("mcollect")) { - history.push(`/digit-ui/citizen/payment/collect/${businessService}/${consumerCode}?workflow=mcollect`, { - paymentAmount, - tenantId: billDetails.tenantId, - }); + history.push(`/digit-ui/citizen/payment/success/${businessService}/${consumerCode}/${tenantId}`) } else if (wrkflow === "WNS") { history.push(`/digit-ui/citizen/payment/billDetails/${businessService}/${consumerCode}/${paymentAmount}?workflow=WNS&ConsumerName=${ConsumerName}`, { paymentAmount, diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/src/payments/citizen/index.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/src/payments/citizen/index.js index 8bbbef59a99..9de5ab0bed4 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/src/payments/citizen/index.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/src/payments/citizen/index.js @@ -5,7 +5,7 @@ import PayersDetails from "./payers-details"; import { MyBills } from "./bills"; import { SelectPaymentType } from "./payment-type/index"; -import { SuccessfulPayment, FailedPayment } from "./response"; +import { SuccessPayment, FailedPayment } from "./response"; const CitizenPayment = ({ stateCode, cityCode, moduleCode }) => { const { path: currentPath } = useRouteMatch(); @@ -25,7 +25,7 @@ const CitizenPayment = ({ stateCode, cityCode, moduleCode }) => { - + diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/src/payments/citizen/response/index.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/src/payments/citizen/response/index.js index 375ff645995..98d158305fb 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/src/payments/citizen/response/index.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/common/src/payments/citizen/response/index.js @@ -427,3 +427,209 @@ export const FailedPayment = (props) => { ); }; + +export const SuccessPayment = (props) => { +// if(localStorage.getItem("BillPaymentEnabled")!=="true"){ +// window.history.forward(); +// return null; +// } + return +} + +const PaymentComponent = (props) => { + const { t } = useTranslation(); + const queryClient = useQueryClient(); + const { eg_pg_txnid: egId, workflow: workflw, propertyId } = Digit.Hooks.useQueryParams(); + const [printing, setPrinting] = useState(false); + const [allowFetchBill, setallowFetchBill] = useState(false); + const { businessService: business_service, consumerCode, tenantId } = useParams(); + const { data: bpaData = {}, isLoading: isBpaSearchLoading, isSuccess: isBpaSuccess, error: bpaerror } = Digit.Hooks.obps.useOBPSSearch( + "", {}, tenantId, { applicationNo: consumerCode }, {}, {enabled:(window.location.href.includes("bpa") || window.location.href.includes("BPA"))} + ); + + // Retrieve stored payment data + const storedPaymentData = JSON.parse(sessionStorage.getItem("PaymentResponse")); + + console.log("storedPaymentData:", storedPaymentData); + + const { isLoading, data, isError } = Digit.Hooks.usePaymentUpdate({ egId }, business_service, { + retry: false, + staleTime: Infinity, + refetchOnWindowFocus: false, + }); + + // const { label } = Digit.Hooks.useApplicationsForBusinessServiceSearch({ businessService: business_service }, { enabled: false }); + + const { data: reciept_data, isLoading: recieptDataLoading } = Digit.Hooks.useRecieptSearch( + { + tenantId, + businessService: business_service, + receiptNumbers: data?.payments?.Payments?.[0]?.paymentDetails[0].receiptNumber, + }, + { + retry: false, + staleTime: Infinity, + refetchOnWindowFocus: false, + select: (dat) => { + return dat.Payments[0]; + }, + enabled: allowFetchBill, + } + ); + + const { data: generatePdfKey } = Digit.Hooks.useCommonMDMS(tenantId, "common-masters", "ReceiptKey", { + select: (data) => + data["common-masters"]?.uiCommonPay?.filter(({ code }) => business_service?.includes(code))[0]?.receiptKey || "consolidatedreceipt", + retry: false, + staleTime: Infinity, + refetchOnWindowFocus: false, + }); +console.log("data",data) + const payments = data?.payments; + + useEffect(() => { + return () => { + localStorage.setItem("BillPaymentEnabled","false") + queryClient.clear(); + }; + }, []); + + useEffect(() => { + if (data && data.txnStatus && data.txnStatus !== "FAILURE") { + setallowFetchBill(true); + } + }, [data]); + + if (isLoading || recieptDataLoading) { + return ; + } + + const applicationNo = data?.applicationNo; + + const isMobile = window.Digit.Utils.browser.isMobile(); + + + if (!storedPaymentData || !storedPaymentData.Payments || storedPaymentData.Payments.length === 0) { + console.log("failure") + return ( + + + {t("CS_PAYMENT_FAILURE_MESSAGE")} + {!(business_service?.includes("PT")) ? ( + + + + ) : ( + + + + + {/* {business_service?.includes("PT") &&
+ +
} */} +
+ {t("CORE_COMMON_GO_TO_HOME")} +
+
+ )} +
+ ); + } + + const paymentData = data?.payments?.Payments[0]; + const amount = reciept_data?.paymentDetails?.[0]?.totalAmountPaid; + const transactionDate = paymentData?.transactionDate; + const printCertificate = async () => { + //const tenantId = Digit.ULBService.getCurrentTenantId(); + const state = tenantId; + const applicationDetails = await Digit.TLService.search({ applicationNumber: consumerCode, tenantId }); + const generatePdfKeyForTL = "tlcertificate"; + + if (applicationDetails) { + let response = await Digit.PaymentService.generatePdf(state, { Licenses: applicationDetails?.Licenses }, generatePdfKeyForTL); + const fileStore = await Digit.PaymentService.printReciept(state, { fileStoreIds: response.filestoreIds[0] }); + window.open(fileStore[response.filestoreIds[0]], "_blank"); + } + }; + + const printReciept = async () => { + if (printing) return; + setPrinting(true); + const tenantId = storedPaymentData.Payments[0]?.tenantId; + const state = Digit.ULBService.getStateId(); + let response = { filestoreIds: [storedPaymentData.Payments[0]?.fileStoreId] }; + if (!paymentData?.fileStoreId) { + response = await Digit.PaymentService.generatePdf(state, { Payments: [storedPaymentData.Payments[0]] }, generatePdfKey); + } + const fileStore = await Digit.PaymentService.printReciept(state, { fileStoreIds: response.filestoreIds[0] }); + if (fileStore && fileStore[response.filestoreIds[0]]) { + window.open(fileStore[response.filestoreIds[0]], "_blank"); + } + setPrinting(false); + }; + + let bannerText; + if (workflw) { + bannerText = `CITIZEN_SUCCESS_UC_PAYMENT_MESSAGE`; + } else { + if (paymentData?.paymentDetails?.[0]?.businessService && paymentData?.paymentDetails?.[0]?.businessService?.includes("BPA")) { + let nameOfAchitect = sessionStorage.getItem("BPA_ARCHITECT_NAME"); + let parsedArchitectName = nameOfAchitect ? JSON.parse(nameOfAchitect) : "ARCHITECT"; + bannerText = `CITIZEN_SUCCESS_${paymentData?.paymentDetails[0]?.businessService.replace(/\./g, "_")}_${parsedArchitectName}_PAYMENT_MESSAGE`; + } else if (business_service?.includes("WS") || business_service?.includes("SW")) { + bannerText = t(`CITIZEN_SUCCESS_${paymentData?.paymentDetails[0].businessService.replace(/\./g, "_")}_WS_PAYMENT_MESSAGE`); + } else { + bannerText = paymentData?.paymentDetails[0]?.businessService ? `CITIZEN_SUCCESS_${paymentData?.paymentDetails[0]?.businessService.replace(/\./g, "_")}_PAYMENT_MESSAGE` : t("CITIZEN_SUCCESS_UC_PAYMENT_MESSAGE"); + } + } + const rowContainerStyle = { + padding: "4px 0px", + justifyContent: "space-between", + }; + + const ommitRupeeSymbol = ["PT"].includes(business_service); + + if ((window.location.href.includes("bpa") || window.location.href.includes("BPA")) && isBpaSearchLoading) return + return ( + + + + + } + message={t("CS_COMMON_PAYMENT_COMPLETE")} + info={t("CS_COMMON_RECIEPT_NO")} + applicationNumber={storedPaymentData?.Payments[0]?.paymentDetails[0]?.receiptNumber} + successful={true} + /> + {t(`${bannerText}_DETAIL`)} + {generatePdfKey ? ( +
+
+ + + + + {t("CS_COMMON_PRINT_RECEIPT")} +
+
+ ) : null} + {business_service && ( +
+ + + +
+ )} +
+ ); +}; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/commonPt/README.md b/frontend/micro-ui/web/micro-ui-internals/packages/modules/commonPt/README.md index 0c7cfabf520..c98e58b0c8c 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/commonPt/README.md +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/commonPt/README.md @@ -22,10 +22,10 @@ frontend/micro-ui/web/package.json ## Changelog -### Summary for Version [1.7.10] - 2025-02-13 +### Summary for Version [1.7.35] - 2025-03-20 No specific change. Version matched as used in URBAN. ### Contributors -[jagankumar-egov] [hari-egov] [mukund-egov] +[jagankumar-egov] [hari-egov] [mukund-egov] \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/commonPt/package.json b/frontend/micro-ui/web/micro-ui-internals/packages/modules/commonPt/package.json index 8cbfa968476..928f4668ddd 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/commonPt/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/commonPt/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-module-commonpt", - "version": "1.7.10", + "version": "1.7.35", "license": "MIT", "description": "Digit PT Light weight Module", "main": "dist/index.js", diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/commonPt/src/pages/components/PropertyOwnerDetails.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/commonPt/src/pages/components/PropertyOwnerDetails.js index 7c8cd80f2ab..fdb03b68a47 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/commonPt/src/pages/components/PropertyOwnerDetails.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/commonPt/src/pages/components/PropertyOwnerDetails.js @@ -280,7 +280,7 @@ const PropertyOwnerDetails = ({ t, config, onSelect, userType, formData, formSta }} render={({ value, onChange, onBlur }) => ( a.name.localeCompare(b.name)) : []} select={(value) => { @@ -474,6 +474,19 @@ const PropertyOwnerDetails = ({ t, config, onSelect, userType, formData, formSta : + {!isMobile && ( +
+ {ismultiple && ( + } + style={{ margin: "0px" }} + onClick={(e) => { + setOwnerDetails([...ownerDetails.filter((own, ind) => ind != index)]); + }} + /> + )} +
+ )} {`${t("PT_FORM3_MOBILE_NUMBER")}*`} @@ -502,19 +515,6 @@ const PropertyOwnerDetails = ({ t, config, onSelect, userType, formData, formSta )} /> - {!isMobile && ( -
- {ismultiple && ( - } - style={{ margin: "0px" }} - onClick={(e) => { - setOwnerDetails([...ownerDetails.filter((own, ind) => ind != index)]); - }} - /> - )} -
- )}
{touched?.["mobileNumber" + index] ? errors?.["mobileNumber" + index]?.message : ""} diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/README.md b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/README.md index 325354b64f9..b67709173cb 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/README.md +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/README.md @@ -22,10 +22,10 @@ frontend/micro-ui/web/package.json ## Changelog -### Summary for Version [1.7.10] - 2025-02-13 +### Summary for Version [1.7.35] - 2025-03-20 Corrected WhatsNewCard to handle when no data is coming from mdms ### Contributors -[jagankumar-egov] [hari-egov] [mukund-egov] +[jagankumar-egov] [hari-egov] [mukund-egov] \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/package.json b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/package.json index c53b895778f..fbe01db302a 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-module-core", - "version": "1.7.10", + "version": "0.0.1-sandbox", "license": "MIT", "description": "Digit App Core Module contains all core components", "main": "dist/index.js", @@ -26,4 +26,4 @@ "redux": "4.1.2", "redux-thunk": "2.4.1" } -} +} \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/AppModules.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/AppModules.js index f12a70eabb7..860044b3667 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/AppModules.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/AppModules.js @@ -13,6 +13,7 @@ const getTenants = (codes, tenants) => { return tenants.filter((tenant) => codes?.map?.((item) => item.code).includes(tenant.code)); }; + export const AppModules = ({ stateCode, userType, modules, appTenants }) => { const ComponentProvider = Digit.Contexts.ComponentProvider; const { path } = useRouteMatch(); diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/SideBar/StaticCitizenSideBar.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/SideBar/StaticCitizenSideBar.js index f900c37b94b..6611f458935 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/SideBar/StaticCitizenSideBar.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/SideBar/StaticCitizenSideBar.js @@ -171,11 +171,16 @@ const StaticCitizenSideBar = ({ linkData, islinkDataLoading }) => { return ; }; let profileItem; + const fromSandbox = Digit.SessionStorage.get("fromSandbox"); if (isFetched && user && user.access_token) { profileItem = ; - menuItems = menuItems.filter((item) => item?.id !== "login-btn" && item?.id !== "help-line"); - menuItems = [ + menuItems = menuItems.filter( + (item) => item?.id !== "login-btn" && item?.id !== "help-line" + ); + + // Always add EDIT_PROFILE + const updatedMenuItems = [ ...menuItems, { text: t("EDIT_PROFILE"), @@ -185,28 +190,37 @@ const StaticCitizenSideBar = ({ linkData, islinkDataLoading }) => { onClick: showProfilePage, }, }, - { + ]; + + // Conditionally add LOGOUT if fromSandbox is false + if (!fromSandbox) { + updatedMenuItems.push({ text: t("CORE_COMMON_LOGOUT"), element: "LOGOUT", icon: "LogoutIcon", populators: { onClick: handleLogout }, - }, - { - text: ( - - {t("CS_COMMON_HELPLINE")} -
- + }); + } + + // Always add HELPLINE + updatedMenuItems.push({ + text: ( + + {t("CS_COMMON_HELPLINE")} +
+ - - ), - element: "Helpline", - icon: "Phone", - }, - ]; +
+
+ ), + element: "Helpline", + icon: "Phone", + }); + + menuItems = updatedMenuItems; } + Object.keys(linkData) ?.sort((x, y) => y.localeCompare(x)) ?.map((key) => { diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/TopBar.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/TopBar.js index a069ad25060..6a106f7f7a0 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/TopBar.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/components/TopBarSideBar/TopBar.js @@ -41,6 +41,7 @@ const TopBar = ({ }, [profilePic !== null, userDetails?.info?.uuid]); const CitizenHomePageTenantId = Digit.ULBService.getCitizenCurrentTenant(true); + const fromSandbox = Digit.SessionStorage.get("fromSandbox"); let history = useHistory(); const { pathname } = useLocation(); @@ -127,7 +128,7 @@ const TopBar = ({ )}
{showLanguageChange && }
- {userDetails?.access_token && ( + {!fromSandbox && userDetails?.access_token && (
{ const handleClickOnWhatsAppBanner = (obj) => { window.open(obj?.navigationUrl); }; + + const userNullCheck = () => { + if (Digit.UserService.getUser() === null) return true; + else if (Digit.UserService.getUser()?.info === null) return true; + else if (Digit.UserService.getUser()?.info?.roles === null) return true; + return false; + }; + + let options = []; + citizenServicesObj?.props?.forEach((element) => { + let serviceIcon = null; + if (options.length >= 4) return; + switch (element?.label) { + case 'ACTION_TEST_MCOLLECT': + if (Digit.Utils.mCollectCitizenAccess() || userNullCheck()) { + serviceIcon = ; + } else return; + break; + case 'MODULE_PT': + if (Digit.Utils.ptCitizenAccess() || userNullCheck()) { + serviceIcon = ; + } else return; + break; + case 'MODULE_TL': + if (Digit.Utils.tlCitizenAccess() || userNullCheck()) { + serviceIcon = ; + } else return; + break; + case 'ACTION_TEST_BPA_STAKEHOLDER_HOME': + if (Digit.Utils.BPACitizenAccess() || userNullCheck()) { + serviceIcon = ; + } else return; + break; + case 'ACTION_TEST_WATER_AND_SEWERAGE': + if (Digit.Utils.wsCitizenAccess() || userNullCheck()) { + serviceIcon = ; + } else return; + break; + case 'ACTION_TEST_FIRE_NOC': + if (Digit.Utils.NOCCitizenAccess() || userNullCheck()) { + serviceIcon = ; + } else return; + break; + case 'ACTION_TEST_BIRTH_CERTIFICATE': + if (Digit.Utils.bdCitizenAccess() || userNullCheck()) { + serviceIcon = ; + } else return; + break; + case 'ACTION_TEST_DEATH_CERTIFICATE': + if (Digit.Utils.bdCitizenAccess() || userNullCheck()) { + serviceIcon = ; + } else return; + break; + default: + return; + } + options.push({ + name: t(element?.label), + Icon: serviceIcon, + onClick: () => history.push(element?.navigationUrl), + }); + }) const allCitizenServicesProps = { header: t(citizenServicesObj?.headerLabel), @@ -66,33 +131,7 @@ const Home = () => { name: t(citizenServicesObj?.sideOption?.name), onClick: () => history.push(citizenServicesObj?.sideOption?.navigationUrl), }, - options: [ - { - name: t(citizenServicesObj?.props?.[0]?.label), - Icon: , - onClick: () => history.push(citizenServicesObj?.props?.[0]?.navigationUrl), - }, - { - name: t(citizenServicesObj?.props?.[1]?.label), - Icon: , - onClick: () => history.push(citizenServicesObj?.props?.[1]?.navigationUrl), - }, - { - name: t(citizenServicesObj?.props?.[2]?.label), - Icon: , - onClick: () => history.push(citizenServicesObj?.props?.[2]?.navigationUrl), - }, - // { - // name: t("ACTION_TEST_WATER_AND_SEWERAGE"), - // Icon: , - // onClick: () => history.push("/digit-ui/citizen") - // }, - { - name: t(citizenServicesObj?.props?.[3]?.label), - Icon: , - onClick: () => history.push(citizenServicesObj?.props?.[3]?.navigationUrl), - }, - ], + options: options, styles: { display: "flex", flexWrap: "wrap", justifyContent: "flex-start", width: "100%" }, }; const allInfoAndUpdatesProps = { diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Login/AutoLogin.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Login/AutoLogin.js new file mode 100644 index 00000000000..906fff24502 --- /dev/null +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Login/AutoLogin.js @@ -0,0 +1,99 @@ +import React, { useEffect, useState } from "react"; +import { Loader } from "@egovernments/digit-ui-react-components"; +import { useHistory, useLocation } from "react-router-dom"; + +const setCitizenDetail = (userObject, token, tenantId) => { + let locale = JSON.parse(sessionStorage.getItem("Digit.locale"))?.value?.selectedLanguage || "en_IN"; + localStorage.setItem("Citizen.tenant-id", tenantId); + localStorage.setItem("tenant-id", tenantId); + localStorage.setItem("citizen.userRequestObject", JSON.stringify(userObject)); + localStorage.setItem("locale", locale); + localStorage.setItem("Citizen.locale", locale); + // localStorage.setItem("token", token); + localStorage.setItem("Citizen.token", token); + // localStorage.setItem("user-info", JSON.stringify(userObject)); + localStorage.setItem("Citizen.user-info", JSON.stringify(userObject)); +}; + +const AutoLogin = () => { + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + const [user, setUser] = useState(null); + const history = useHistory(); + const location = useLocation(); + + + const DEFAULT_REDIRECT_URL = "/digit-ui/citizen"; + + const queryParams = new URLSearchParams(location.search); + const fromSandbox= queryParams.get("fromSandbox") || false + + + const mobileNumber = queryParams.get("mobile"); + const otp = queryParams.get("otp") || "123456"; + const city = queryParams.get("city") || Digit.ULBService.getStateId(); + Digit.SessionStorage.set("CITIZEN.COMMON.HOME.CITY", city); + const redirectUrl = queryParams.get("redirectUrl") || DEFAULT_REDIRECT_URL; + + + useEffect(() => { + if (!user) return; + + Digit.SessionStorage.set("citizen.userRequestObject", user); + Digit.UserService.setUser(user); + setCitizenDetail(user?.info, user?.access_token, city); + Digit.SessionStorage.set("fromSandbox", fromSandbox); + + if (!Digit.ULBService.getCitizenCurrentTenant(true)) { + history.replace("/digit-ui/citizen/select-location", { + redirectBackTo: redirectUrl, + }); + } else { + history.replace(redirectUrl); + } + }, [user]); + + + + const handleAutoLogin = async () => { + try { + const requestData = { + username: mobileNumber, + password: otp, + tenantId: city, + userType: "CITIZEN", + }; + + const { UserRequest: info, ...tokens } = await Digit.UserService.authenticate(requestData); + + // Handle single instance config if applicable + if (window?.globalConfigs?.getConfig("ENABLE_SINGLEINSTANCE")) { + info.tenantId = Digit.ULBService.getStateId(); + } + + setUser({ info, ...tokens }); + } catch (err) { + console.error("Auto-login failed:", err); + setError(err.response?.data?.error_description || "Login failed. Please try again."); + setLoading(false); + } + }; + + useEffect(() => { + handleAutoLogin(); + }, []); + + return ( +
+ {loading ? ( + + ) : error ? ( +
+

Login Failed

+
+ ) : null} +
+ ); +}; + +export default AutoLogin; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Login/index.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Login/index.js index 87c35f2722e..32b760051ee 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Login/index.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Login/index.js @@ -14,15 +14,15 @@ const DEFAULT_REDIRECT_URL = "/digit-ui/citizen"; /* set citizen details to enable backward compatiable */ const setCitizenDetail = (userObject, token, tenantId) => { - let locale = JSON.parse(sessionStorage.getItem("Digit.initData"))?.value?.selectedLanguage; + let locale = JSON.parse(sessionStorage.getItem("Digit.locale"))?.value?.selectedLanguage || "en_IN"; localStorage.setItem("Citizen.tenant-id", tenantId); localStorage.setItem("tenant-id", tenantId); localStorage.setItem("citizen.userRequestObject", JSON.stringify(userObject)); localStorage.setItem("locale", locale); localStorage.setItem("Citizen.locale", locale); - localStorage.setItem("token", token); + // localStorage.setItem("token", token); localStorage.setItem("Citizen.token", token); - localStorage.setItem("user-info", JSON.stringify(userObject)); + // localStorage.setItem("user-info", JSON.stringify(userObject)); localStorage.setItem("Citizen.user-info", JSON.stringify(userObject)); }; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/index.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/index.js index e9bafebbda2..ab2b4ac9d28 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/index.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/index.js @@ -18,6 +18,7 @@ import StaticDynamicCard from "./StaticDynamicComponent/StaticDynamicCard"; import AcknowledgementCF from "../../components/AcknowledgementCF"; import CitizenFeedback from "../../components/CitizenFeedback"; import Search from "./SearchApp"; +import AutoLogin from "./Login/AutoLogin"; const sidebarHiddenFor = [ "digit-ui/citizen/register/name", "/digit-ui/citizen/select-language", @@ -68,6 +69,61 @@ const Home = ({ } ); + const userNullCheck = () => { + if (Digit.UserService.getUser() === null) return true; + else if (Digit.UserService.getUser()?.info === null) return true; + else if (Digit.UserService.getUser()?.info?.roles === null) return true; + return false; + }; + + let roleBasedLinkData = {}; + Object.entries(linkData || {}).forEach(([key , val]) => { + switch (key) { + case "MCollect": + if (Digit.Utils.mCollectCitizenAccess() || userNullCheck()) { + roleBasedLinkData[key] = val; + } + break; + case "TL": + if (Digit.Utils.tlCitizenAccess() || userNullCheck()) { + roleBasedLinkData[key] = val; + } + break; + case "PT": + if (Digit.Utils.ptCitizenAccess() || userNullCheck()) { + roleBasedLinkData[key] = val; + } + break; + case "OBPS": + if (Digit.Utils.BPACitizenAccess() || userNullCheck()) { + roleBasedLinkData[key] = val; + } + break; + case "WS": + if (Digit.Utils.wsCitizenAccess() || userNullCheck()) { + roleBasedLinkData[key] = val; + } + break; + case "FireNoc": + if (Digit.Utils.NOCCitizenAccess() || userNullCheck()) { + roleBasedLinkData[key] = val; + } + break; + case "Birth": + if (Digit.Utils.bdCitizenAccess() || userNullCheck()) { + roleBasedLinkData[key] = val; + } + break; + case "Death": + if (Digit.Utils.bdCitizenAccess() || userNullCheck()) { + roleBasedLinkData[key] = val; + } + break; + default: + return; + } + }) + const classname = Digit.Hooks.fsm.useRouteSubscription(pathname); const { t } = useTranslation(); const { path } = useRouteMatch(); @@ -157,7 +213,7 @@ const Home = ({
{hideSidebar ? null : (
- +
)} @@ -188,7 +244,7 @@ const Home = ({ @@ -198,6 +254,11 @@ const Home = ({ + + + + + diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/Login/AutoLogin.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/Login/AutoLogin.js new file mode 100644 index 00000000000..0e8f352085c --- /dev/null +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/Login/AutoLogin.js @@ -0,0 +1,95 @@ +import React, { useEffect, useState } from "react"; +import { Loader } from "@egovernments/digit-ui-react-components"; +import { useHistory } from "react-router-dom"; + + +const setEmployeeDetail = (userObject, token) => { + let locale = JSON.parse(sessionStorage.getItem("Digit.locale"))?.value || "en_IN"; + localStorage.setItem("Employee[HPM] Error occurred while trying to proxy request /localization/messages/v1/_search?module=rainmaker-privacy-policy&locale=en_IN&_=1743502018537 from localhost:3000 to https://unified-qa.digit.org (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors).tenant-id", userObject?.tenantId); + localStorage.setItem("tenant-id", userObject?.tenantId); + localStorage.setItem("Employee.tenant-id", userObject?.tenantId); + // localStorage.setItem("citizen.userRequestObject", JSON.stringify(userObject)); + localStorage.setItem("locale", locale); + localStorage.setItem("Employee.locale", locale); + // localStorage.setItem("token", token); + localStorage.setItem("Employee.token", token); + // localStorage.setItem("user-info", JSON.stringify(userObject)); + localStorage.setItem("Employee.user-info", JSON.stringify(userObject)); + }; + +const AutoLogin = () => { + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + const history = useHistory(); + const [user, setUser] = useState(null); + + + const queryParams = new URLSearchParams(location.search); + + const defaultCredentials = { + username: queryParams.get("username"), + password: queryParams.get("password"), + city: { + code: queryParams.get("city"), + }, + fromSandbox: queryParams.get("fromSandbox") || false + }; + const redirectUrl = queryParams.get("redirectUrl") || "/digit-ui/employee"; + + console.log(`*** LOG ***`,redirectUrl); + useEffect(() => { + if (!user) { + return; + } + // Digit.SessionStorage.set("citizen.userRequestObject", user); + const filteredRoles = user?.info?.roles?.filter((role) => role.tenantId === Digit.SessionStorage.get("Employee.tenantId")); + if (user?.info?.roles?.length > 0) user.info.roles = filteredRoles; + Digit.UserService.setUser(user); + setEmployeeDetail(user?.info, user?.access_token); + if(queryParams.get("redirectUrl")) + { + window.location.href = redirectUrl; + } + else + history.replace(redirectUrl); + }, [user]); + + const handleAutoLogin = async () => { + try { + const requestData = { + ...defaultCredentials, + userType: "EMPLOYEE", + tenantId: defaultCredentials.city.code, + }; + delete requestData.city; + const { UserRequest: info, ...tokens } = await Digit.UserService.authenticate(requestData); + Digit.SessionStorage.set("Employee.tenantId", info?.tenantId); + Digit.SessionStorage.set("fromSandbox", defaultCredentials.fromSandbox); + setUser({ info, ...tokens }); + + } catch (err) { + console.error("Auto-login failed:", err); + setError(err.response?.data?.error_description || "Invalid login credentials"); + } finally { + setLoading(false); + } + }; + + useEffect(() => { + handleAutoLogin(); + }, []); + + return ( +
+ {loading ? ( + + ) : error ? ( +
+

Login Failed

+
+ ) : null} +
+ ); +}; + +export default AutoLogin; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/Login/login.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/Login/login.js index 557737444ca..bde8a57833d 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/Login/login.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/Login/login.js @@ -10,12 +10,12 @@ const setEmployeeDetail = (userObject, token) => { let locale = JSON.parse(sessionStorage.getItem("Digit.locale"))?.value || "en_IN"; localStorage.setItem("Employee.tenant-id", userObject?.tenantId); localStorage.setItem("tenant-id", userObject?.tenantId); - localStorage.setItem("citizen.userRequestObject", JSON.stringify(userObject)); + // localStorage.setItem("citizen.userRequestObject", JSON.stringify(userObject)); localStorage.setItem("locale", locale); localStorage.setItem("Employee.locale", locale); - localStorage.setItem("token", token); + // localStorage.setItem("token", token); localStorage.setItem("Employee.token", token); - localStorage.setItem("user-info", JSON.stringify(userObject)); + // localStorage.setItem("user-info", JSON.stringify(userObject)); localStorage.setItem("Employee.user-info", JSON.stringify(userObject)); }; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/index.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/index.js index 2449b1a0b25..0b001808393 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/index.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/employee/index.js @@ -10,6 +10,7 @@ import LanguageSelection from "./LanguageSelection"; import EmployeeLogin from "./Login"; import UserProfile from "../citizen/Home/UserProfile"; import ErrorComponent from "../../components/ErrorComponent"; +import AutoLogin from "./Login/AutoLogin"; const userScreensExempted = ["user/profile", "user/error"]; @@ -69,6 +70,9 @@ const EmployeeApp = ({ + + + diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/death/package.json b/frontend/micro-ui/web/micro-ui-internals/packages/modules/death/package.json new file mode 100644 index 00000000000..0680bcce507 --- /dev/null +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/death/package.json @@ -0,0 +1,32 @@ +{ + "name": "@egovernments/digit-ui-module-death", + "version": "0.0.1-sandbox", + "description": "Death Module UI", + "main": "dist/index.js", + "module": "dist/index.modern.js", + "source": "src/Module.js", + "files": [ + "dist" + ], + "scripts": { + "start": "microbundle-crl watch --no-compress --format modern,cjs", + "build": "microbundle-crl --compress --no-sourcemap --format cjs", + "prepublish": "yarn build" + }, + "peerDependencies": { + "react": "17.0.2", + "react-router-dom": "5.3.0" + }, + "dependencies": { + "@egovernments/digit-ui-react-components": "1.7.35", + "react": "17.0.2", + "react-date-range": "^1.4.0", + "react-dom": "17.0.2", + "react-hook-form": "6.15.8", + "react-i18next": "11.16.2", + "react-query": "3.6.1", + "react-router-dom": "5.3.0" + }, + "author": "Mukund ", + "license": "MIT" +} \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/death/src/Module.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/death/src/Module.js new file mode 100644 index 00000000000..b29b1ebaa15 --- /dev/null +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/death/src/Module.js @@ -0,0 +1,43 @@ +import { Loader} from "@egovernments/digit-ui-react-components"; +import React from "react"; +import EmployeeApp from "./pages/employee"; +import { useRouteMatch } from "react-router-dom"; +import DeathCard from "./components/DeathCard"; + +export const DeathModule = ({ stateCode, userType, tenants }) => { + + + const tenantId = Digit.ULBService.getCurrentTenantId(); + const moduleCode = "death"; + const language = Digit.StoreData.getCurrentLanguage(); + const { path, url } = useRouteMatch(); + + const { isLoading, data: store } = Digit.Services.useStore({ + stateCode, + moduleCode, + language, + }); + +if (isLoading) { + return ; + } + if (userType === "employee") { + return ; + } else return
Citizen
+ +} + +const componentsToRegister = { + DeathModule, + DeathCard, + EmployeeApp + }; + +export const initDeathComponents = () => { + Object.entries(componentsToRegister).forEach(([key, value]) => { + Digit.ComponentRegistryService.setComponent(key, value); + }); +} + + + diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/death/src/components/DeathCard.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/death/src/components/DeathCard.js new file mode 100644 index 00000000000..71daee58cdd --- /dev/null +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/death/src/components/DeathCard.js @@ -0,0 +1,44 @@ +import React, { useEffect, useState } from "react"; +import { Link } from "react-router-dom"; +import { useTranslation } from "react-i18next"; +import { EmployeeModuleCard, PropertyHouse } from "@egovernments/digit-ui-react-components"; +import { CaseIcon } from "@egovernments/digit-ui-react-components"; + +const DeathCard = () => { + + if (!Digit.Utils.BnDAccess()) return null; + + const { t } = useTranslation(); + + window.localStorage.setItem("Employee.locale", "en_IN"); + window.localStorage.setItem("locale", "en_IN"); + window.localStorage.setItem("Employee.tenant-id", Digit.ULBService.getCurrentTenantId()); + window.localStorage.setItem("tenant-id",Digit.ULBService.getCurrentTenantId()); + + const links = [ + { + label: t("DEATH_REGISTRATION"), + link: `https://unified-demo.digit.org/employee/death-employee/newRegistration`, + hyperlink: true + + }, + { + label: t("SEARCH_DEATH_CERTIFICATE"), + link: `https://unified-demo.digit.org/employee/death-common/getCertificate`, + hyperlink: true + + }, + ]; + + const propsForModuleCard = { + Icon:, + moduleName: t("COMMON_DEATH"), + links: links, + kpis: [ + ], +} + + return ; +}; + +export default DeathCard; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/death/src/pages/employee/index.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/death/src/pages/employee/index.js new file mode 100644 index 00000000000..bda5f665bdb --- /dev/null +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/death/src/pages/employee/index.js @@ -0,0 +1,25 @@ +import React from "react"; +import { PrivateRoute } from "@egovernments/digit-ui-react-components"; +import { Switch } from "react-router-dom/cjs/react-router-dom.min"; + +const EmployeeApp = ({ path, url, userType }) => { + return ( + + +
+ + ( +
Death Module
+ )} + /> + +
+
+
+ ); + }; + + export default EmployeeApp; + \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/README.md b/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/README.md index a24d236b536..922d6de0269 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/README.md +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/README.md @@ -3,7 +3,7 @@ ## Install ```bash -npm install --save @egovernments/digit-ui-module-dss +npm install --save @1.7.38 ``` ## Limitation @@ -22,7 +22,7 @@ frontend/micro-ui/web/package.json ## Changelog -### Summary for Version [1.7.10] - 2025-02-13 +### Summary for Version [1.7.38] - 2025-03-28 Added tenantId in Dashboard Api calls diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/package.json b/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/package.json index 57e04d7b2a6..aedec5a8e36 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-module-dss", - "version": "1.7.10", + "version": "0.0.2-sandbox", "license": "MIT", "description": "Digit Dashboard Module", "main": "dist/index.js", diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/src/components/DateRange.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/src/components/DateRange.js index 267fecc717c..f8f572a4025 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/src/components/DateRange.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/src/components/DateRange.js @@ -191,6 +191,7 @@ const DateRange = ({ values, onFilterChange, t }) => {
{ setIsModalOpen((prevState) => !prevState)} />
{isModalOpen && ( -
+
{ > {data?.insight?.indicator === "upper_green" ? ArrowUpwardElement("10px") : ArrowDownwardElement("10px")}

- {insight?.[0] && - `${Digit.Utils.dss.formatter(insight[0], "number", value?.denomination, true, t)}% ${t( - Digit.Utils.locale.getTransformedLocale("DSS" + insight?.[1] || "") - )}`} + {insight?.[0] !== undefined && insight?.[0] !== "" + ? (isNaN(insight[0]) + ? `${insight[0]}` + : `${Digit.Utils.dss.formatter(insight[0], "number", value?.denomination, true, t)}%` + ) + : ""}

)} @@ -163,4 +165,4 @@ const MetricChart = ({ data, setChartDenomination, moduleCode }) => { ); }; -export default MetricChart; +export default MetricChart; \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/src/pages/Home.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/src/pages/Home.js index 54242d2deb0..449c006010e 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/src/pages/Home.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/src/pages/Home.js @@ -107,7 +107,13 @@ const Chart = ({ data, moduleLevel, overview = false }) => { {response?.responseData?.data?.[0]?.insight?.value ? (

{response?.responseData?.data?.[0]?.insight?.indicator === "upper_green" ? ArrowUpwardElement("10px") : ArrowDownwardElement("10px")} - {insight?.[0] && `${insight[0]}% ${t(Digit.Utils.locale.getTransformedLocale("DSS" + insight?.[1] || ""))}`} + { + insight && insight[0] !== undefined && insight[0] !== "" + ? isNaN(insight[0]) + ? `${insight[0]} ${t(Digit.Utils.locale.getTransformedLocale("DSS" + (insight[1] ? insight[1] : "")))}` + : `${insight[0]}%` + : "" + }

) : null}
@@ -263,67 +269,67 @@ const Home = ({ stateCode }) => { const shareOptions = navigator.share ? [ - { - label: t("ES_DSS_SHARE_PDF"), - onClick: () => { - setShowOptions(!showOptions); - setTimeout(() => { - return Digit.ShareFiles.PDF(tenantId, fullPageRef, t(dashboardConfig?.[0]?.name)); - }, 500); - }, + { + label: t("ES_DSS_SHARE_PDF"), + onClick: () => { + setShowOptions(!showOptions); + setTimeout(() => { + return Digit.ShareFiles.PDF(tenantId, fullPageRef, t(dashboardConfig?.[0]?.name)); + }, 500); }, - { - label: t("ES_DSS_SHARE_IMAGE"), - onClick: () => { - setShowOptions(!showOptions); - setTimeout(() => { - return Digit.ShareFiles.Image(tenantId, fullPageRef, t(dashboardConfig?.[0]?.name)); - }, 500); - }, + }, + { + label: t("ES_DSS_SHARE_IMAGE"), + onClick: () => { + setShowOptions(!showOptions); + setTimeout(() => { + return Digit.ShareFiles.Image(tenantId, fullPageRef, t(dashboardConfig?.[0]?.name)); + }, 500); }, - ] + }, + ] : [ - { - icon: , - label: t("ES_DSS_SHARE_PDF"), - onClick: () => { - setShowOptions(!showOptions); - setTimeout(() => { - return Digit.ShareFiles.PDF(tenantId, fullPageRef, t(dashboardConfig?.[0]?.name), "mail"); - }, 500); - }, + { + icon: , + label: t("ES_DSS_SHARE_PDF"), + onClick: () => { + setShowOptions(!showOptions); + setTimeout(() => { + return Digit.ShareFiles.PDF(tenantId, fullPageRef, t(dashboardConfig?.[0]?.name), "mail"); + }, 500); }, - { - icon: , - label: t("ES_DSS_SHARE_PDF"), - onClick: () => { - setShowOptions(!showOptions); - setTimeout(() => { - return Digit.ShareFiles.PDF(tenantId, fullPageRef, t(dashboardConfig?.[0]?.name), "whatsapp"); - }, 500); - }, + }, + { + icon: , + label: t("ES_DSS_SHARE_PDF"), + onClick: () => { + setShowOptions(!showOptions); + setTimeout(() => { + return Digit.ShareFiles.PDF(tenantId, fullPageRef, t(dashboardConfig?.[0]?.name), "whatsapp"); + }, 500); }, - { - icon: , - label: t("ES_DSS_SHARE_IMAGE"), - onClick: () => { - setShowOptions(!showOptions); - setTimeout(() => { - return Digit.ShareFiles.Image(tenantId, fullPageRef, t(dashboardConfig?.[0]?.name), "mail"); - }, 500); - }, + }, + { + icon: , + label: t("ES_DSS_SHARE_IMAGE"), + onClick: () => { + setShowOptions(!showOptions); + setTimeout(() => { + return Digit.ShareFiles.Image(tenantId, fullPageRef, t(dashboardConfig?.[0]?.name), "mail"); + }, 500); }, - { - icon: , - label: t("ES_DSS_SHARE_IMAGE"), - onClick: () => { - setShowOptions(!showOptions); - setTimeout(() => { - return Digit.ShareFiles.Image(tenantId, fullPageRef, t(dashboardConfig?.[0]?.name), "whatsapp"); - }, 500); - }, + }, + { + icon: , + label: t("ES_DSS_SHARE_IMAGE"), + onClick: () => { + setShowOptions(!showOptions); + setTimeout(() => { + return Digit.ShareFiles.Image(tenantId, fullPageRef, t(dashboardConfig?.[0]?.name), "whatsapp"); + }, 500); }, - ]; + }, + ]; if (isLoading || localizationLoading) { return ; @@ -383,13 +389,12 @@ const Home = ({ stateCode }) => { } else if (item?.charts?.[0]?.chartType == "map") { return (
@@ -452,20 +457,19 @@ const Home = ({ stateCode }) => { } else { return (
routeTo(`/digit-ui/employee/dss/dashboard/${item.ref.url}`)} + // onClick={() => routeTo(`/digit-ui/employee/dss/dashboard/${item.ref.url}`)} >
diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/src/pages/index.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/src/pages/index.js index 594c1981b51..4bf05ac53f0 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/src/pages/index.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/dss/src/pages/index.js @@ -18,6 +18,7 @@ import FilterContext from "../components/FilterContext"; import Filters from "../components/Filters"; import FiltersNational from "../components/FiltersNational"; import Layout from "../components/Layout"; +import { useLocation } from 'react-router-dom'; const key = "DSS_FILTERS"; @@ -34,6 +35,7 @@ const getInitialRange = () => { }; const DashBoard = ({ stateCode }) => { + const location = useLocation(); const tenantId = Digit.ULBService.getCurrentTenantId(); const { t } = useTranslation(); const [filters, setFilters] = useState(() => { @@ -79,6 +81,7 @@ const DashBoard = ({ stateCode }) => { return serviceJS; }, }); + const { data: nationalInfo, isLoadingNAT } = Digit.Hooks.dss.useMDMS(stateCode, "tenant", ["nationalInfo"], { select: (data) => { let nationalInfo = data?.tenant?.nationalInfo || []; @@ -154,6 +157,7 @@ const DashBoard = ({ stateCode }) => { ...filters, moduleLevel: "", }); + setFilters((prev) => ({ ...prev, moduleLevel: [] })); }; const removeTenant = (id) => { @@ -172,11 +176,40 @@ const DashBoard = ({ stateCode }) => { }; const clearAllSt = () => { handleFilters({ ...filters, filters: { ...filters?.filters, state: [], ulb: [] } }); - }; + }; + + const [refresh, setRefresh] = useState(false); + + // const clearAllServices = () => { + // handleFilters({ ...filters, moduleLevel: "" }); + // setFilters({}); + // setRefresh((prev) => !prev); + // }; const clearAllServices = () => { - handleFilters({ ...filters, moduleLevel: "" }); + // Check if the URL contains /dashboard/overview + if (location.pathname.includes('/dashboard/overview')) { + handleFilters({ ...filters, moduleLevel: "" }); + setFilters({}); + setRefresh((prev) => !prev); + } else { + handleFilters({ ...filters, moduleLevel: "" }); + // setFilters({}); + setRefresh((prev) => !prev); + } }; + + // Check URL during page load (on init) + useEffect(() => { + if (location.pathname.includes('/dashboard/overview')) { + // Do nothing, keep the state intact for /dashboard/overview + console.log('Keeping state for /dashboard/overview'); + } else { + // Perform necessary operations (like clearing services) + clearAllServices(); + } + }, [location.pathname]); + const dashboardConfig = response?.responseData; let tabArrayObj = dashboardConfig?.[0]?.visualizations?.reduce((curr, acc) => { @@ -262,6 +295,7 @@ const DashBoard = ({ stateCode }) => { if (isLoading || isUlbLoading || localizationLoading || isMdmsLoading || isLoadingNAT || isServicesLoading) { return ; } + return (
@@ -484,4 +518,4 @@ const DashBoard = ({ stateCode }) => { ); }; -export default DashBoard; +export default DashBoard; \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/engagement/README.md b/frontend/micro-ui/web/micro-ui-internals/packages/modules/engagement/README.md index 43c336249ed..d8d30d71c66 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/engagement/README.md +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/engagement/README.md @@ -22,10 +22,10 @@ frontend/micro-ui/web/package.json ## Changelog -### Summary for Version [1.7.10] - 2025-02-13 +### Summary for Version [1.7.35] - 2025-03-20 Solved survey create and edit problem by adding tenantId in the api calls ### Contributors -[jagankumar-egov] [hari-egov] [mukund-egov] +[jagankumar-egov] [hari-egov] [mukund-egov] \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/engagement/package.json b/frontend/micro-ui/web/micro-ui-internals/packages/modules/engagement/package.json index 8e7e2b391b8..4171d724515 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/engagement/package.json +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/engagement/package.json @@ -1,6 +1,6 @@ { "name": "@egovernments/digit-ui-module-engagement", - "version": "1.7.10", + "version": "1.7.36", "license": "MIT", "main": "dist/index.js", "module": "dist/index.modern.js", diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/engagement/src/components/EngagementCard.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/engagement/src/components/EngagementCard.js index b1d3c284dfb..16e179f34ad 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/engagement/src/components/EngagementCard.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/engagement/src/components/EngagementCard.js @@ -13,12 +13,17 @@ import { const EngagementCard = () => { const userRoles = Digit.SessionStorage.get("User")?.info?.roles; const isEmployee = userRoles.find((role) => role.code === "EMPLOYEE"); + const isSyAdmin = userRoles.length === 1 && userRoles[0].code === "SY_ADMIN"; + + useEffect(() => { Digit.SessionStorage.set("CITIZENSURVEY.INBOX", null); }, []); - if (!isEmployee) return null; + if (!isSyAdmin && !isEmployee) { + return null; + } const tenantId = Digit.ULBService.getCurrentTenantId(); const { data: documentsCount, isLoading: isLoadingDocs } = Digit.Hooks.engagement.useDocSearch( { tenantIds: tenantId }, @@ -152,16 +157,27 @@ const EngagementCard = () => { }; const engagementSubModulesProps = [propsForDocumentModuleCard, propsForEventsModuleCard, propsForPMBModuleCard, propsForSurveyModuleCard]; - - if (isEmployee) + const surveyModulesProps = [propsForSurveyModuleCard]; + if (isSyAdmin) { result = ( <> - {engagementSubModulesProps.map((propsForModuleCard, index) => ( + {surveyModulesProps.map((propsForModuleCard, index) => ( ))} ); + return result; + } + else if (isEmployee) + result = ( + <> + {engagementSubModulesProps.map((propsForModuleCard, index) => ( + + ))} + + ); + return result; }; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/engagement/src/pages/employee/CitizenSurveys/SurveyDetails.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/engagement/src/pages/employee/CitizenSurveys/SurveyDetails.js index 6b0a17c4db2..c2573ca675a 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/engagement/src/pages/employee/CitizenSurveys/SurveyDetails.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/engagement/src/pages/employee/CitizenSurveys/SurveyDetails.js @@ -195,8 +195,28 @@ const SurveyDetails = ({ location, match }) => { }; const handleMarkInactive = () => { + const toEpoch = (dateStr, timeStr) => { + // Combine date and time to a single ISO string and convert to epoch + return new Date(`${dateStr}T${timeStr}:00`).getTime(); + }; + + const updatedSurveyData = { + ...surveyData, + startDate: toEpoch(surveyData.fromDate, surveyData.fromTime), + endDate: toEpoch(surveyData.toDate, surveyData.toTime), + tenantId, + questions: surveyData.questions.map(filterQuestion), + status: "INACTIVE" + }; + + // Remove fromDate and toDate + delete updatedSurveyData.fromDate; + delete updatedSurveyData.toDate; + delete updatedSurveyData.fromTime; + delete updatedSurveyData.toTime; + const details = { - SurveyEntity: { ...surveyData, tenantId, questions: surveyData.questions.map(filterQuestion), status: "INACTIVE" }, + SurveyEntity: updatedSurveyData, }; history.push("/digit-ui/employee/engagement/surveys/update-response", details); }; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/finance/README.md b/frontend/micro-ui/web/micro-ui-internals/packages/modules/finance/README.md new file mode 100644 index 00000000000..12cbde8a5db --- /dev/null +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/finance/README.md @@ -0,0 +1,31 @@ +# digit-ui-module-finance + +## Install + +```bash +npm install --save @egovernments/digit-ui-module-finance +``` + +## Limitation + +```bash +This Package is more specific to Urban +``` + +## Usage + +After adding the dependency make sure you have this dependency in + +```bash +frontend/micro-ui/web/package.json +``` + +## Changelog + +### Summary for Version [0.0.1] - 2025-06-13 + +Created finance module with submenu card and iframe pages + +### Contributors + +[kamalesh-egov] \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/finance/package.json b/frontend/micro-ui/web/micro-ui-internals/packages/modules/finance/package.json new file mode 100644 index 00000000000..e7bd2452d34 --- /dev/null +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/finance/package.json @@ -0,0 +1,26 @@ +{ + "name": "@egovernments/digit-ui-module-finance", + "version": "0.0.1-sandbox", + "description": "FINANCE", + "license": "MIT", + "main": "dist/index.js", + "module": "dist/index.modern.js", + "source": "src/Module.js", + "files": [ + "dist" + ], + "scripts": { + "start": "microbundle-crl watch --no-compress --format modern,cjs", + "build": "microbundle-crl --compress --no-sourcemap --format cjs", + "prepublish": "yarn build" + }, + "dependencies": { + "@egovernments/digit-ui-react-components": "^1.7.0-beta.2", + "react": "17.0.2", + "react-dom": "17.0.2", + "react-hook-form": "6.15.8", + "react-i18next": "11.16.2", + "react-query": "3.6.1", + "react-router-dom": "5.3.0" + } +} diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/finance/src/FinanceHomeCard.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/finance/src/FinanceHomeCard.js new file mode 100644 index 00000000000..2b8208e30dc --- /dev/null +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/finance/src/FinanceHomeCard.js @@ -0,0 +1,63 @@ +import { CollectionIcon, Header } from "@egovernments/digit-ui-react-components"; +import React from "react"; +import { useTranslation } from "react-i18next"; +import LandingPageSubMenuCard from "./components/LandingPageSubMenuCard"; + +const buildMenuDict = (items) => { + const root = {}; + items?.forEach(item => { + const parts = item.path.split('.'); + let current = root; + parts?.forEach((part, idx) => { + if (!current[part]) current[part] = {}; + if (idx === parts.length - 1) { + // attach leaf data + current[part] = { + ...current[part], + _meta: { + label: item.displayName, + link: item.navigationURL, + } + }; + } + current = current[part]; + }); + }); + return root; +} + +const FinanceCard = () => { + const { t } = useTranslation(); + const userRoles = Digit.SessionStorage.get("User")?.info?.roles; + const allowedRoles = [ + "EMPLOYEE_FINANCE", + "EGF_VOUCHER_CREATOR", + "EGF_MASTER_ADMIN", + "EGF_REPORT_VIEW", + "EGF_BILL_CREATOR", + "EGF_ADMINISTRATOR", + "EGF_BILL_APPROVER", + "SYS_INTEGRATOR_FINANCE", + "EGF_PAYMENT_CREATOR", + "EGF_VOUCHER_APPROVER", + "WORKS_FINANCIAL_APPROVER", + "EGF_PAYMENT_APPROVER" + ]; + const isFinanceEmployee = userRoles.find((role) => allowedRoles.includes(role.code)); + const { isLoading, data } = Digit.Hooks.useAccessControl(); + const menuDict = buildMenuDict(data?.actions)?.Finance; + + if (!isFinanceEmployee || !menuDict) return null; + return ( +
+
{t("ACTION_TEST_FINANCE")}
+
+ {Object.entries(menuDict).map(([key, value]) => ( + } moduleName={key} menuDict={value} /> + ))} +
+
+ ) +}; + +export default FinanceCard; \ No newline at end of file diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/finance/src/Module.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/finance/src/Module.js new file mode 100644 index 00000000000..d0c7830acaa --- /dev/null +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/finance/src/Module.js @@ -0,0 +1,31 @@ +import React, { useEffect } from "react"; +import { useRouteMatch } from "react-router-dom"; +import { useTranslation } from "react-i18next"; +import EmployeeApp from "./pages/employee"; +import FinanceCard from "./FinanceHomeCard"; + +export const FinanceModule = ({ stateCode, userType, tenants }) => { + const tenantId = Digit.SessionStorage.get("CITIZEN.COMMON.HOME.CITY")?.code || Digit.ULBService.getCurrentTenantId(); + const moduleCode = ["finance"]; + + const language = Digit.StoreData.getCurrentLanguage(); + const { isLoading, data: store } = Digit.Services.useStore({ stateCode, moduleCode, language }); + const { path, url } = useRouteMatch(); + + Digit.SessionStorage.set("FINANCE_TENANTS", tenants); + + if (userType === "employee") { + return ; + } else return null; +}; + +const componentsToRegister = { + FinanceModule, + FinanceCard, +}; + +export const initFinanceComponents = () => { + Object.entries(componentsToRegister).forEach(([key, value]) => { + Digit.ComponentRegistryService.setComponent(key, value); + }); +}; diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/finance/src/components/EGF/index.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/finance/src/components/EGF/index.js new file mode 100644 index 00000000000..c0cf80cee16 --- /dev/null +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/finance/src/components/EGF/index.js @@ -0,0 +1,78 @@ +import { fromPairs } from "lodash"; +import React, { Component } from "react"; + +class EGFFinance extends Component { + constructor(props) { + super(props); + this.onFrameLoad = this.onFrameLoad.bind(this); + this.resetIframe = this.resetIframe.bind(this); + } + onFrameLoad() { + document.getElementById("erp_iframe").style.display = "block"; + } + + render() { + let auth_token = Digit.UserService.getUser()?.access_token, + locale = localStorage.getItem("locale"), + menuUrl = this.props.location, + loc = window.location, + subdomainurl, + domainurl, + finEnv, + hostname = loc.hostname, + winheight = window.innerHeight - 200, + erp_url, + tenantId = Digit.ULBService.getCurrentTenantId(); + //Reading domain name from the request url + domainurl = hostname.substring(hostname.indexOf(".") + 1); + // Reading environment name (ex: dev, qa, uat, fin-uat etc) from the globalconfigs if exists else reading from the .env file + finEnv = this.globalConfigExists() ? window.globalConfigs.getConfig("FIN_ENV") : process.env.REACT_APP_FIN_ENV; + // Preparing finance subdomain url using the above environment name and the domain url + subdomainurl = !!(finEnv) ? "-" + finEnv + "." + domainurl : "." + domainurl; + erp_url = loc.protocol + "//" + tenantId.split(".")[1] + subdomainurl + menuUrl; + + return ( +
+