Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to SyncToAmrit API #44

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,17 @@ public String syncDataToAmrit(@ApiParam(value = "{\r\n" + " \"beneficiaryDetail
+ " \"nishchayPregnancyStatusPosition\": \"Integer\",\r\n"
+ " \"nishchayDeliveryStatus\": \"String\",\r\n"
+ " \"nishchayDeliveryStatusPosition\": \"Integer\",\r\n" + " \"relatedBeneficiaryIds\": [\r\n"
+ " \"Long\"\r\n" + " ]\r\n" + " }\r\n" + " ],\r\n" + " \"bornBirthDeatils\": [\r\n"
+ " \"Long\"\r\n" + " ],\r\n"
+ " \"beneficiaryRegID\":\"Long\",\"firstName\":\"String\",\"lastName\":\"String\",\"\n"
+ " \"dob\":\"Timestamp\",\"fatherName\":\"String\",\"spouseName\":\"String\",\"\n"
+ " \"govtIdentityNo\":\"String\",\"govtIdentityTypeID\":\"Integer\",\"emergencyRegistration\":\"Boolean\",\"\n"
+ " \"maritalstatusId\":\"Short\",\"maritalstatus\":\"String\",\"gender\":\"String\",\"genderId\":\"Integer\",\"i_bendemographics\":{\"educationID\":\"Long\",\"\n"
+ " \"beneficiaryRegID\":\"Long\",\"occupationID\":\"Integer\",\"healthCareWorkerID\":\"Short\",\"incomeStatusID\":\"Integer\",\"\n"
+ " \"communityID\":\"Integer\",\"preferredLangID\":\"Integer\",\"districtID\":\"Integer\",\"stateID\":\"Integer\",\"\n"
+ " \"pinCode\":\"String\",\"blockID\":\"Integer\",\"districtBranchID\":\"Integer\",\"createdBy\":\"String\",\"addressLine1\":\"String\"},\"\n"
+ " \"benPhoneMaps\":{\"parentBenRegID\":\"Long\",\"phoneNo\":\"String\",\"phoneTypeID\":\"Integer\",\"benRelationshipID\":\"Integer\",\"\n"
+ " \"deleted\":\"Boolean\",\"createdBy\":\"String\"},\"\n"
+ " }\r\n" + " ],\r\n" + " \"bornBirthDeatils\": [\r\n"
+ " {\r\n" + " \"BenRegId\": \"Long\",\r\n" + " \"Countyid\": \"Integer\",\r\n"
+ " \"Processed\": \"String\",\r\n" + " \"ProviderServiceMapID\": \"Integer\",\r\n"
+ " \"VanID\": \"Integer\",\r\n" + " \"bcdBatchNo\": \"String\",\r\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ public interface RMNCHBenDetailsRepo extends CrudRepository<RMNCHMBeneficiarydet
@Query(" SELECT t FROM RMNCHMBeneficiarydetail t WHERE t.id = :vanSerialNo AND t.VanID = :vanID")
public RMNCHMBeneficiarydetail getByIdAndVanID(@Param("vanSerialNo") BigInteger vanSerialNo,
@Param("vanID") int vanID);

@Query(" SELECT t FROM RMNCHMBeneficiarydetail t WHERE t.id = " +
"(SELECT m.benDetailsId from RMNCHMBeneficiarymapping m where m.benRegId = :beneficiaryRegID)")
public RMNCHMBeneficiarydetail getByBenRegID(@Param("beneficiaryRegID") BigInteger beneficiaryRegID);
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public String syncDataToAmrit(String requestOBJ) throws Exception {
RMNCHBeneficiaryDetailsRmnch[] objArr = InputMapper.gson()
.fromJson(jsnOBJ.get("beneficiaryDetails"), RMNCHBeneficiaryDetailsRmnch[].class);
List<RMNCHBeneficiaryDetailsRmnch> benDetailsExtraList = Arrays.asList(objArr);
List<RMNCHMBeneficiarydetail> benDetailsList = new ArrayList<>();

if (benDetailsExtraList != null && benDetailsExtraList.size() > 0) {
// benRegID = rMNCHMBenRegIdMapRepo.getRegID(benDetailsExtraList.get(0).getBenficieryid());
Expand Down Expand Up @@ -166,14 +167,30 @@ public String syncDataToAmrit(String requestOBJ) throws Exception {
}
obj.setRelatedBeneficiaryIdsDB(sb.toString());
}


RMNCHMBeneficiarydetail rmnchmBeneficiarydetail =
rMNCHBenDetailsRepo.getByBenRegID(BigInteger.valueOf(obj.getBenRegId()));
if (rmnchmBeneficiarydetail != null) {
rmnchmBeneficiarydetail.setFirstName(obj.getFirstName());
rmnchmBeneficiarydetail.setLastName(obj.getLastName());
rmnchmBeneficiarydetail.setFatherName(obj.getFatherName());
rmnchmBeneficiarydetail.setMotherName(obj.getMotherName());
rmnchmBeneficiarydetail.setDob(obj.getDob());
rmnchmBeneficiarydetail.setSpousename(obj.getSpousename());
rmnchmBeneficiarydetail.setGender(obj.getGender());
rmnchmBeneficiarydetail.setGenderId(obj.getGenderId());
rmnchmBeneficiarydetail.setMaritalstatus(obj.getMaritalstatus());
rmnchmBeneficiarydetail.setMaritalstatusId(obj.getMaritalstatusId());
benDetailsList.add(rmnchmBeneficiarydetail);
}
}

benDetailsExtraList = (ArrayList<RMNCHBeneficiaryDetailsRmnch>) rMNCHBeneficiaryDetailsRmnchRepo
.save(benDetailsExtraList);

benDetailsExtraList.forEach((n) -> beneficiaryDetailsIds.add(n.getId()));
// update beneficiary data in i_beneficiarydetails table
rMNCHBenDetailsRepo.save(benDetailsList);
// } else
// throw new Exception("invalid/empty beneficiary request data.");

Expand Down
Loading