diff --git a/src/main/java/com/iemr/common/identity/controller/IdentityController.java b/src/main/java/com/iemr/common/identity/controller/IdentityController.java index 02a5320..c3658c6 100644 --- a/src/main/java/com/iemr/common/identity/controller/IdentityController.java +++ b/src/main/java/com/iemr/common/identity/controller/IdentityController.java @@ -697,26 +697,30 @@ public String getPartialBeneficiariesByBenRegIds( @Operation(summary = "Get beneficiaries by beneficiary registration id") @PostMapping(path = "/getByBenRegIdList", headers = "Authorization") public String getBeneficiariesByBenRegIds( - @Param(value = " {\"beneficiaryRegID\": \"Long\"}") @RequestBody String benRegIds) { - logger.info("IdentityController.getBeneficiariesByBenRegIds - start. benRegIdList = " + benRegIds); - BigInteger[] benRegIdarray = null; - JsonElement json = JsonParser.parseString(benRegIds); - - if (json instanceof JsonNull) { - return getErrorResponseString("Null/Empty Phone Number.", 200, "success", ""); - } - - benRegIdarray = InputMapper.getInstance().gson().fromJson(json, BigInteger[].class); - - List list = svc.getBeneficiariesDeatilsByBenRegIdList(Arrays.asList(benRegIdarray)); - list.removeIf(Objects::isNull); - Collections.sort(list); - String response = getSuccessResponseString(list, 200, "success", "getBeneficiariesByBenRegIds"); - - logger.info("IdentityController.getBeneficiariesByBenRegIds - end : "); - return response; + @RequestBody Long[] benRegIds) { // Accepting an array of Longs directly + logger.info("IdentityController.getBeneficiariesByBenRegIds - start. benRegIdList = " + benRegIds.length); + + // If benRegIds is null or empty, return an error response + if (benRegIds == null || benRegIds.length == 0) { + return getErrorResponseString("No beneficiary registration IDs provided", 400, "error", "Array is empty"); + } + + // Convert the Long[] to BigInteger[] for further processing + BigInteger[] benRegIdArray = Arrays.stream(benRegIds) + .map(BigInteger::valueOf) + .toArray(BigInteger[]::new); + + List list = svc.getBeneficiariesDeatilsByBenRegIdList(Arrays.asList(benRegIdArray)); + list.removeIf(Objects::isNull); + Collections.sort(list); + + String response = getSuccessResponseString(list, 200, "success", "getBeneficiariesByBenRegIds"); + + logger.info("IdentityController.getBeneficiariesByBenRegIds - end : "); + return response; } + /** * Overloaded method with string * diff --git a/src/main/java/com/iemr/common/identity/service/IdentityService.java b/src/main/java/com/iemr/common/identity/service/IdentityService.java index 2e243bb..b8c3214 100644 --- a/src/main/java/com/iemr/common/identity/service/IdentityService.java +++ b/src/main/java/com/iemr/common/identity/service/IdentityService.java @@ -570,7 +570,7 @@ public List searhBeneficiaryByGovIdentity(String identity) } return beneficiaryList; } - + private MBeneficiarymapping getBeneficiariesDTONew(Object[] benMapArr) { MBeneficiarymapping benMapOBJ = new MBeneficiarymapping(); if (benMapArr != null && benMapArr.length == 12 && benMapArr[8] != null && benMapArr[9] != null) { @@ -579,8 +579,11 @@ private MBeneficiarymapping getBeneficiariesDTONew(Object[] benMapArr) { benMapOBJ.setCreatedDate((Timestamp) benMapArr[11]); benMapOBJ = mappingRepo.getMapping(getBigIntegerValueFromObject(benMapArr[9]), (Integer) benMapArr[8]); + + BigInteger benRegId = new BigInteger(benMapArr[5].toString()); RMNCHBeneficiaryDetailsRmnch obj = rMNCHBeneficiaryDetailsRmnchRepo - .getByRegID(((BigInteger) benMapArr[5])); + .getByRegID(benRegId); + if (obj != null) { if (obj.getHouseoldId() != null) benMapOBJ.setHouseHoldID(obj.getHouseoldId());