Skip to content

Commit 59dbd6c

Browse files
Merge pull request #169 from PSMRI/feature/save_health_id_in_health_maping
Feature/save health id in health maping
2 parents 5367efa + a90fe13 commit 59dbd6c

12 files changed

Lines changed: 352 additions & 9 deletions

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.iemr.common.identity</groupId>
77
<artifactId>identity-api</artifactId>
8-
<version>3.6.2</version>
8+
<version>3.9.0</version>
99

1010
<packaging>war</packaging>
1111

src/main/java/com/iemr/common/identity/controller/IdentityController.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@
3030
import java.util.List;
3131
import java.util.Objects;
3232

33+
import com.iemr.common.identity.data.rmnch.RMNCHBeneficiaryDetailsRmnch;
3334
import org.apache.commons.lang3.StringUtils;
3435
import org.slf4j.Logger;
3536
import org.slf4j.LoggerFactory;
3637
import org.springframework.beans.factory.annotation.Autowired;
38+
import org.springframework.http.HttpStatus;
39+
import org.springframework.http.ResponseEntity;
3740
import org.springframework.web.bind.annotation.GetMapping;
3841
import org.springframework.web.bind.annotation.PostMapping;
3942
import org.springframework.web.bind.annotation.RequestBody;
@@ -315,6 +318,17 @@ public String searchBeneficiaryByVillageIdAndLastModDate(
315318
}
316319
return response;
317320
}
321+
322+
323+
@PostMapping("/getRmnchDataByBenRedID")
324+
public ResponseEntity<RMNCHBeneficiaryDetailsRmnch> getRmnchDataByBenID(@RequestBody BigInteger object) {
325+
try {
326+
RMNCHBeneficiaryDetailsRmnch data = svc.getRmnchDataByBenID(object);
327+
return ResponseEntity.ok(data);
328+
} catch (Exception e) {
329+
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
330+
}
331+
}
318332
// search beneficiary by lastModDate and districtID
319333
@Operation(summary ="Get count of beneficiary by villageId and last modified date-time")
320334
@PostMapping(path = "/countBenByVillageIdAndLastModifiedDate")

src/main/java/com/iemr/common/identity/controller/rmnch/RMNCHMobileAppController.java

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@
2323

2424
import java.sql.Timestamp;
2525

26+
import com.google.gson.Gson;
27+
import com.google.gson.JsonObject;
2628
import org.slf4j.Logger;
2729
import org.slf4j.LoggerFactory;
2830
import org.springframework.beans.factory.annotation.Autowired;
2931
import org.springframework.beans.factory.annotation.Qualifier;
32+
import org.springframework.http.ResponseEntity;
3033
import org.springframework.web.bind.annotation.PostMapping;
3134
import org.springframework.web.bind.annotation.RequestBody;
3235
import org.springframework.web.bind.annotation.RequestHeader;
@@ -56,11 +59,11 @@ public class RMNCHMobileAppController {
5659

5760
@PostMapping(value = "/syncDataToAmrit", consumes = "application/json", produces = "application/json")
5861
@Operation(summary = "Sync data to AMRIT for already regestered beneficiary with AMRIT beneficiary id ")
59-
public String syncDataToAmrit(@RequestBody String requestOBJ) {
62+
public String syncDataToAmrit(@RequestBody String requestOBJ,@RequestHeader(value = "jwttoken") String authorization) {
6063
OutputResponse response = new OutputResponse();
6164
try {
6265
if (requestOBJ != null) {
63-
String s = rmnchDataSyncService.syncDataToAmrit(requestOBJ);
66+
String s = rmnchDataSyncService.syncDataToAmrit(requestOBJ,authorization);
6467
response.setResponse(s);
6568
} else
6669
response.setError(5000, "Invalid/NULL request obj");
@@ -73,6 +76,46 @@ public String syncDataToAmrit(@RequestBody String requestOBJ) {
7376

7477
}
7578

79+
@PostMapping(value = "/syncDataToAmritByHwc", consumes = "application/json", produces = "application/json")
80+
@Operation(summary = "Sync data to AMRIT for already registered beneficiary with AMRIT beneficiary id")
81+
public ResponseEntity<?> syncDataToAmritHwc(@RequestBody String requestOBJ) {
82+
83+
try {
84+
if (requestOBJ == null || requestOBJ.isEmpty()) {
85+
return ResponseEntity.badRequest().body("Invalid/NULL request obj");
86+
}
87+
88+
JsonObject requestObj = new Gson().fromJson(requestOBJ, JsonObject.class);
89+
90+
Long beneficiaryID = requestObj.has("benficieryid") && !requestObj.get("benficieryid").isJsonNull()
91+
? requestObj.get("benficieryid").getAsLong()
92+
: null;
93+
94+
Long beneficiaryRegID = requestObj.has("benRegId") && !requestObj.get("benRegId").isJsonNull()
95+
? requestObj.get("benRegId").getAsLong()
96+
: null;
97+
98+
if (beneficiaryID == null || beneficiaryRegID == null) {
99+
return ResponseEntity.badRequest().body("beneficiaryID or beneficiaryRegID is missing");
100+
}
101+
102+
String result = rmnchDataSyncService.saveBeneficiaryDetailsAfterRegistration(
103+
beneficiaryID,
104+
beneficiaryRegID,
105+
requestOBJ
106+
);
107+
108+
return ResponseEntity.ok(result);
109+
110+
} catch (Exception e) {
111+
logger.error("Error in RMNCH mobile data sync : {}", e.getMessage());
112+
return ResponseEntity.internalServerError()
113+
.body("Error in RMNCH mobile data sync : " + e.getMessage());
114+
}
115+
}
116+
117+
118+
76119
// @Deprecated
77120
@PostMapping(value = "/getBeneficiaryDataForVillage", consumes = "application/json", produces = "application/json")
78121
@Operation(summary = "Get beneficiary data for given village ")

src/main/java/com/iemr/common/identity/data/rmnch/RMNCHBeneficiaryDetailsRmnch.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,4 +550,7 @@ public class RMNCHBeneficiaryDetailsRmnch {
550550
@Expose
551551
private Boolean isDeactivate;
552552

553+
@Expose
554+
@Transient
555+
private String abhaId;
553556
}

src/main/java/com/iemr/common/identity/data/rmnch/RMNCHMBeneficiarydetail.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,8 @@ public class RMNCHMBeneficiarydetail {
214214
@Expose
215215
@Transient
216216
private Integer ProviderServiceMapID;
217+
218+
@Expose
219+
@Transient
220+
private String abhaId;
217221
}

src/main/java/com/iemr/common/identity/dto/BeneficiariesDTO.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ public int compareTo(BeneficiariesDTO ben) {
8989
private BigInteger religionId;
9090
private String religion;
9191
private String monthlyFamilyIncome;
92+
private String reproductiveStatus;
93+
private Integer reproductiveStatusId;
9294
// End Outreach
9395

9496
// Start 1097

src/main/java/com/iemr/common/identity/dto/IdentityDTO.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ public class IdentityDTO {
125125
private Integer incomeStatusId;
126126
private String incomeStatus;
127127
private String monthlyFamilyIncome;
128+
private String reproductiveStatus;
129+
private Integer reproductiveStatusId;
128130

129131
@Expose
130132
private Integer vanID;

src/main/java/com/iemr/common/identity/repo/rmnch/RMNCHBenDetailsRepo.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.math.BigInteger;
2525
import java.util.List;
2626

27+
import io.swagger.v3.oas.annotations.info.License;
2728
import org.springframework.data.jpa.repository.Query;
2829
import org.springframework.data.repository.CrudRepository;
2930
import org.springframework.data.repository.query.Param;
@@ -36,8 +37,16 @@ public interface RMNCHBenDetailsRepo extends CrudRepository<RMNCHMBeneficiarydet
3637
@Query(" SELECT t FROM RMNCHMBeneficiarydetail t WHERE t.id = :vanSerialNo AND t.VanID = :vanID")
3738
public RMNCHMBeneficiarydetail getByIdAndVanID(@Param("vanSerialNo") BigInteger vanSerialNo,
3839
@Param("vanID") int vanID);
39-
40-
@Query(" SELECT t FROM RMNCHMBeneficiarydetail t WHERE t.id = " +
41-
"(SELECT m.benDetailsId from RMNCHMBeneficiarymapping m where m.benRegId = :beneficiaryRegID)")
42-
public List<RMNCHMBeneficiarydetail> getByBenRegID(@Param("beneficiaryRegID") BigInteger beneficiaryRegID);
40+
41+
@Query("""
42+
SELECT t
43+
FROM RMNCHMBeneficiarydetail t
44+
WHERE t.id IN (
45+
SELECT m.benDetailsId
46+
FROM RMNCHMBeneficiarymapping m
47+
WHERE m.benRegId = :beneficiaryRegID
48+
)
49+
""")
50+
List<RMNCHMBeneficiarydetail> getByBenRegID(
51+
@Param("beneficiaryRegID") BigInteger beneficiaryRegID);
4352
}

src/main/java/com/iemr/common/identity/service/IdentityService.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,16 @@ public List<BeneficiariesDTO> searchBeneficiaryByVillageIdAndLastModifyDate(List
809809
return beneficiaryList;
810810
}
811811

812+
813+
public RMNCHBeneficiaryDetailsRmnch getRmnchDataByBenID(BigInteger benID) {
814+
RMNCHBeneficiaryDetailsRmnch rmnchBeneficiaryDetailsRmnch = new RMNCHBeneficiaryDetailsRmnch();
815+
816+
if(!rMNCHBeneficiaryDetailsRmnchRepo.getByRegID(benID).isEmpty()){
817+
rmnchBeneficiaryDetailsRmnch = rMNCHBeneficiaryDetailsRmnchRepo.getByRegID(benID).get(0);
818+
}
819+
return rmnchBeneficiaryDetailsRmnch;
820+
}
821+
812822
public Long countBeneficiaryByVillageIdAndLastModifyDate(List<Integer> villageIDs, Timestamp lastModifiedDate) {
813823
Long beneficiaryCount = 0L;
814824
try {
@@ -1993,6 +2003,7 @@ public List<BeneficiariesDTO> getBeneficiariesDeatilsByBenRegIdList(List<BigInte
19932003
* @return
19942004
*/
19952005
private BeneficiariesDTO getBeneficiariesDTO(MBeneficiarymapping benMap) {
2006+
RMNCHBeneficiaryDetailsRmnch rmnchBeneficiaryDetailsRmnch = new RMNCHBeneficiaryDetailsRmnch();
19962007
BeneficiariesDTO bdto = mapper.mBeneficiarymappingToBeneficiariesDTO(benMap);
19972008
if (null != benMap && null != benMap.getMBeneficiarydetail()
19982009
&& !StringUtils.isEmpty(benMap.getMBeneficiarydetail().getFaceEmbedding())) {
@@ -2008,6 +2019,13 @@ private BeneficiariesDTO getBeneficiariesDTO(MBeneficiarymapping benMap) {
20082019
bdto.setFaceEmbedding(floatList);
20092020
}
20102021
// bdto.setOtherFields(benMap.getMBeneficiarydetail().getOtherFields());
2022+
2023+
if(!rMNCHBeneficiaryDetailsRmnchRepo.getByRegID(benMap.getBenRegId()).isEmpty() ){
2024+
rmnchBeneficiaryDetailsRmnch = rMNCHBeneficiaryDetailsRmnchRepo.getByRegID(benMap.getBenRegId()).get(0);
2025+
bdto.setReproductiveStatus(rmnchBeneficiaryDetailsRmnch.getReproductiveStatus());
2026+
bdto.setReproductiveStatusId(rmnchBeneficiaryDetailsRmnch.getReproductiveStatusId());
2027+
}
2028+
20112029
bdto.setBeneficiaryFamilyTags(
20122030
mapper.mapToMBeneficiaryfamilymappingWithBenFamilyDTOList(benMap.getMBeneficiaryfamilymappings()));
20132031
bdto.setBeneficiaryIdentites(

src/main/java/com/iemr/common/identity/service/rmnch/RmnchDataSyncService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
package com.iemr.common.identity.service.rmnch;
2323

2424
public interface RmnchDataSyncService {
25-
public String syncDataToAmrit(String requestOBJ) throws Exception;
25+
public String syncDataToAmrit(String requestOBJ, String authorization) throws Exception;
26+
public String saveBeneficiaryDetailsAfterRegistration(
27+
Long beneficiaryID,
28+
Long beneficiaryRegID,
29+
String comingRequest);
2630
public String getBenData(String requestOBJ, String authorisation) throws Exception;
2731
public String getBenDataByAsha(String requestOBJ, String authorisation) throws Exception;
2832
}

0 commit comments

Comments
 (0)