diff --git a/health-services/household/CHANGELOG.md b/health-services/household/CHANGELOG.md index 11569f76ee5..0cb9052cea7 100644 --- a/health-services/household/CHANGELOG.md +++ b/health-services/household/CHANGELOG.md @@ -1,9 +1,9 @@ All notable changes to this module will be documented in this file. -## 1.1.1 +## 1.1.1 - 2023-11-15 - Added total count for household -- Added a field for HouseholdMember : clientReferenceId +- Added a field for HouseholdMember-clientReferenceId ## 1.1.1-beta diff --git a/health-services/libraries/health-services-models/CHANGELOG.md b/health-services/libraries/health-services-models/CHANGELOG.md index ebef76b1fd0..3f5b9c6ff4e 100644 --- a/health-services/libraries/health-services-models/CHANGELOG.md +++ b/health-services/libraries/health-services-models/CHANGELOG.md @@ -1,6 +1,6 @@ All notable changes to this module will be documented in this file. -## 1.0.11 +## 1.0.11 - 2023-11-15 - Client reference id added for member of household - revert of household search change diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/HouseholdSearch.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/HouseholdSearch.java index 8adfbfeee88..6e31a74c882 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/HouseholdSearch.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/HouseholdSearch.java @@ -33,9 +33,6 @@ public class HouseholdSearch { @JsonProperty("clientReferenceId") private List clientReferenceId = null; -// @JsonProperty("memberCount") -// private Integer memberCount = null; - @JsonProperty("boundaryCode") private String localityCode = null; } diff --git a/health-services/project/CHANGELOG.md b/health-services/project/CHANGELOG.md index 4f8ef2bc6ca..df50f2ba974 100644 --- a/health-services/project/CHANGELOG.md +++ b/health-services/project/CHANGELOG.md @@ -1,6 +1,6 @@ All notable changes to this module will be documented in this file. -## 1.1.1 +## 1.1.1 - 2023-11-15 - Added tag in project beneficiary ## 1.1.1-beta 19-10-2023 diff --git a/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbVoucherTagUniqueForUpdateValidator.java b/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbVoucherTagUniqueForUpdateValidator.java index be699f6b145..8450427492f 100644 --- a/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbVoucherTagUniqueForUpdateValidator.java +++ b/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbVoucherTagUniqueForUpdateValidator.java @@ -20,9 +20,9 @@ import static org.egov.common.utils.CommonUtils.notHavingErrors; import static org.egov.common.utils.CommonUtils.populateErrorDetails; -import static org.egov.common.utils.ValidatorUtils.getErrorForUniqueEntity; /** + * @author kanishq-egov * This class, PbVoucherTagUniqueValidator, is a Spring component that serves as a validator for ensuring the uniqueness * of voucher tags within a list of project beneficiaries. It implements the Validator interface, which allows it to * validate a BeneficiaryBulkRequest containing a list of ProjectBeneficiary objects. Any duplicate voucher tags within @@ -110,11 +110,11 @@ private void validateAndPopulateErrors(List validProjectBene populateErrors(invalidEntities, errorDetailsMap); - List existingVoucherTags = existingProjectBeneficiaries.stream().map(ProjectBeneficiary::getTag).collect(Collectors.toList()); + Map existingProjectBeneficiaryVoucherTagMap = existingProjectBeneficiaries.stream().filter(projectBeneficiary -> projectBeneficiary.getTag() != null).collect(Collectors.toMap(ProjectBeneficiary::getTag, projectBeneficiary -> projectBeneficiary)); invalidEntities = validProjectBeneficiaries.stream() .filter(notHavingErrors()) - .filter(projectBeneficiary -> !existingProjectBeneficiaryMap.get(projectBeneficiary.getId()).getTag().equals(projectBeneficiary.getTag())) - .filter(projectBeneficiary -> isInvalid(projectBeneficiary, existingVoucherTags)) + .filter(projectBeneficiary -> isUpdated(projectBeneficiary, existingProjectBeneficiaryMap)) + .filter(projectBeneficiary -> isInvalid(projectBeneficiary, existingProjectBeneficiaryVoucherTagMap)) .collect(Collectors.toList()); populateErrors(invalidEntities, errorDetailsMap); @@ -129,7 +129,7 @@ private void validateAndPopulateErrors(List validProjectBene private void populateErrors(List invalidEntities, Map> errorDetailsMap) { // For each invalid entity, create an error and populate error details invalidEntities.forEach(projectBeneficiary -> { - Error error = getErrorForUniqueEntity(); + Error error = Error.builder().errorMessage("Project Beneficiary Tag Validation Failed").errorCode("INVALID_TAG").type(Error.ErrorType.NON_RECOVERABLE).exception(new CustomException("INVALID_TAG", "Project Beneficiary Tag Validation Failed")).build(); populateErrorDetails(projectBeneficiary, error, errorDetailsMap); }); } @@ -137,16 +137,38 @@ private void populateErrors(List invalidEntities, Map existingVoucherTags) { + private boolean isInvalid(ProjectBeneficiary entity, Map existingProjectBeneficiaryVoucherTagMap) { String id = entity.getId(); String tag = entity.getTag(); // Check if an entity with the same ID exists in the map and has a different tag - return existingVoucherTags.contains(tag); + return existingProjectBeneficiaryVoucherTagMap.keySet().contains(tag) && !existingProjectBeneficiaryVoucherTagMap.get(tag).getId().equals(id); } + /** + * Checks if a ProjectBeneficiary entity is considered as updated based on its tag. + * + * @param entity The ProjectBeneficiary entity to check. + * @param existingProjectBeneficiaryMap A map containing existing ProjectBeneficiary entities based on their IDs. + * @return true if the entity is updated, false otherwise. + */ + private boolean isUpdated(ProjectBeneficiary entity, Map existingProjectBeneficiaryMap) { + String id = entity.getId(); + String tag = entity.getTag(); + + // Retrieve the existing ProjectBeneficiary object to compare + ProjectBeneficiary projectBeneficiaryFromSearch = existingProjectBeneficiaryMap.get(id); + + // check if existing ProjectBeneficiary Tag is null or not and if it is null whether it is updated or not + if(projectBeneficiaryFromSearch.getTag() == null) return tag != null; + + // Check if the tag of the current entity is equal to the tag of the existing entity + return ( !projectBeneficiaryFromSearch.getTag().equals(tag) + || ( tag != null && !tag.equals(projectBeneficiaryFromSearch.getTag()) )); + } } diff --git a/health-services/referralmanagement/CHANGELOG.md b/health-services/referralmanagement/CHANGELOG.md index b2b3b4325f0..266f4ddf3f5 100644 --- a/health-services/referralmanagement/CHANGELOG.md +++ b/health-services/referralmanagement/CHANGELOG.md @@ -1,10 +1,9 @@ # Changelog All notable changes to this module will be documented in this file. -## 1.0.0 +## 1.0.0 - 2023-11-15 - Added Downsync Feature - ## 1.0.0-beta - Base version - Added functionality for Side-Effects and Refferal management diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/service/DownsyncService.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/service/DownsyncService.java index 4cb8d8be52b..23c5e2328a9 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/service/DownsyncService.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/service/DownsyncService.java @@ -137,7 +137,7 @@ private List searchHouseholds(DownsyncRequest downsyncRequest, Downsync StringBuilder householdUrl = new StringBuilder(configs.getHouseholdHost()) .append(configs.getHouseholdSearchUrl()); - householdUrl = appendUrlParams(householdUrl, criteria); + householdUrl = appendUrlParams(householdUrl, criteria, null, null); HouseholdSearch householdSearch = HouseholdSearch.builder() .localityCode(criteria.getLocality()) @@ -174,7 +174,7 @@ private List searchIndividuals(DownsyncRequest downsyncRequest, Downsync StringBuilder url = new StringBuilder(configs.getIndividualHost()) .append(configs.getIndividualSearchUrl()); - url = appendUrlParams(url, criteria); + url = appendUrlParams(url, criteria, 0, individualIds.size()); IndividualSearch individualSearch = IndividualSearch.builder() .id(new ArrayList<>(individualIds)) @@ -203,13 +203,12 @@ private Set searchMembers(DownsyncRequest downsyncRequest, Downsync down StringBuilder memberUrl = new StringBuilder(configs.getHouseholdHost()) .append(configs.getHouseholdMemberSearchUrl()); - appendUrlParams(memberUrl, downsyncRequest.getDownsyncCriteria()); - String memberIdsquery = "SELECT id from HOUSEHOLD_MEMBER where householdId IN (:householdIds)"; Map paramMap = new HashMap<>(); paramMap.put("householdIds", householdIds); - + appendUrlParams(memberUrl, downsyncRequest.getDownsyncCriteria(), 0, householdIds.size()); + /* FIXME SHOULD BE REMOVED AND SEARCH SHOULD BE enhanced with list of household ids*/ List memberids = jdbcTemplate.queryForList(memberIdsquery, paramMap, String.class); @@ -247,7 +246,7 @@ private List searchBeneficiaries(DownsyncRequest downsyncRequest, Downsy StringBuilder url = new StringBuilder(configs.getProjectHost()) .append(configs.getProjectBeneficiarySearchUrl()); - url = appendUrlParams(url, criteria); + url = appendUrlParams(url, criteria, 0, individualClientRefIds.size()); String beneficiaryIdQuery = "SELECT id from PROJECT_BENEFICIARY where beneficiaryclientreferenceid IN (:beneficiaryIds)"; @@ -291,7 +290,6 @@ private List searchTasks(DownsyncRequest downsyncRequest, Downsync downs StringBuilder url = new StringBuilder(configs.getProjectHost()) .append(configs.getProjectTaskSearchUrl()); - url = appendUrlParams(url, criteria); String taskIdQuery = "SELECT id from PROJECT_TASK where projectBeneficiaryClientReferenceId IN (:beneficiaryClientRefIds)"; @@ -300,7 +298,8 @@ private List searchTasks(DownsyncRequest downsyncRequest, Downsync downs /* FIXME SHOULD BE REMOVED AND TASK SEARCH SHOULD BE enhanced with list of client-ref-beneficiary ids*/ List taskIds = jdbcTemplate.queryForList(taskIdQuery, paramMap, String.class); - + url = appendUrlParams(url, criteria, 0, taskIds.size()); + if(CollectionUtils.isEmpty(taskIds)) return Collections.emptyList(); @@ -333,13 +332,13 @@ private void searchSideEffect(DownsyncRequest downsyncRequest, Downsync downsync RequestInfo requestInfo = downsyncRequest.getRequestInfo(); // search side effect FIXME - tasks id array search not available - String taskIdQuery = "SELECT id from SIDE_EFFECT where taskClientReferenceId IN (:taskClientRefIds)"; + String sEIdQuery = "SELECT id from SIDE_EFFECT where taskClientReferenceId IN (:taskClientRefIds)"; Map paramMap = new HashMap<>(); paramMap.put("taskClientRefIds", taskClientRefIds); /* FIXME SHOULD BE REMOVED AND TASK SEARCH SHOULD BE enhanced with list of client-ref-beneficiary ids*/ - List SEIds = jdbcTemplate.queryForList(taskIdQuery, paramMap, String.class); + List SEIds = jdbcTemplate.queryForList(sEIdQuery, paramMap, String.class); if(CollectionUtils.isEmpty(SEIds)) return; @@ -354,8 +353,8 @@ private void searchSideEffect(DownsyncRequest downsyncRequest, Downsync downsync List effects = sideEffectService.search( effectSearchRequest, - criteria.getLimit(), - criteria.getOffset(), + SEIds.size(), + 0, criteria.getTenantId(), criteria.getLastSyncedTime(), criteria.getIncludeDeleted()); @@ -380,8 +379,8 @@ private void referralSearch(DownsyncRequest downsyncRequest, Downsync downsync, List referrals = referralService.search( searchRequest, - criteria.getLimit(), - criteria.getOffset(), + beneficiaryClientRefIds.size(), + 0, criteria.getTenantId(), criteria.getLastSyncedTime(), criteria.getIncludeDeleted()); @@ -391,22 +390,34 @@ private void referralSearch(DownsyncRequest downsyncRequest, Downsync downsync, - /** - * append url params - * - * @param url - * @param criteria - * @return - */ - private StringBuilder appendUrlParams(StringBuilder url, DownsyncCriteria criteria) { - - return url.append("?tenantId=") - .append(criteria.getTenantId()) - .append("&offset=") - .append(criteria.getOffset()) - .append("&limit=") - .append(criteria.getLimit()) - .append("&includeDeleted=") - .append(criteria.getIncludeDeleted()); - } + /** + * append url params + * + * @param url + * @param criteria + * @param includeLimitOffset + * @return + */ + private StringBuilder appendUrlParams(StringBuilder url, DownsyncCriteria criteria, Integer offset, Integer limit) { + + url.append("?tenantId=") + .append(criteria.getTenantId()) + .append("&includeDeleted=") + .append(criteria.getIncludeDeleted()) + .append("&limit="); + + if (null != limit) + url.append(limit); + else + url.append(criteria.getLimit()); + + url.append("&offset="); + + if(null != offset) + url.append(offset); + else + url.append(criteria.getOffset()); + + return url; } +} diff --git a/health-services/stock/CHANGELOG.md b/health-services/stock/CHANGELOG.md index 8bb88bb178f..c837b842a64 100644 --- a/health-services/stock/CHANGELOG.md +++ b/health-services/stock/CHANGELOG.md @@ -1,5 +1,8 @@ All notable changes to this module will be documented in this file. +## 1.1.1 - 2023-11-15 + - Enhanced inventory flow for last mile delivery with QR code + ## 1.1.1-beta - Enhanced Inventory flow for last mile delivery