From 1ffa5181cc3e2cc9be340ab7907c90af2a6410f7 Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Mon, 16 Dec 2024 16:09:39 +0530 Subject: [PATCH 01/19] CFL downsync implementation by view --- .../libraries/health-services-models/pom.xml | 2 +- .../common/models/household/Household.java | 2 +- .../DownsyncCLFHousehold.java | 24 ++ .../DownsyncCLFHouseholdResponse.java | 25 ++ .../beneficiarydownsync/DownsyncCriteria.java | 2 + .../repository/HouseholdRepository.java | 47 +++ .../rowmapper/HouseholdRowMapper.java | 76 ++++ .../service/DownsyncService.java | 326 ++++++++++++++---- .../BeneficiaryDownsyncController.java | 30 +- 9 files changed, 458 insertions(+), 76 deletions(-) create mode 100644 health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHousehold.java create mode 100644 health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHouseholdResponse.java create mode 100644 health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HouseholdRepository.java create mode 100644 health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/rowmapper/HouseholdRowMapper.java diff --git a/health-services/libraries/health-services-models/pom.xml b/health-services/libraries/health-services-models/pom.xml index dc4e4c878ca..79222b5b9a7 100644 --- a/health-services/libraries/health-services-models/pom.xml +++ b/health-services/libraries/health-services-models/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.egov.common health-services-models - 1.0.23-SNAPSHOT + 1.0.23-dev-SNAPSHOT 17 ${java.version} diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/Household.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/Household.java index 63c982ff07f..24f7a15f20e 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/Household.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/Household.java @@ -27,7 +27,7 @@ public class Household extends EgovOfflineModel { @JsonProperty("memberCount") @NotNull - @Range(min = 0, max = 1000) +// @Range(min = 0, max = 1000) private Integer memberCount = null; @JsonProperty("address") diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHousehold.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHousehold.java new file mode 100644 index 00000000000..ece8054b92d --- /dev/null +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHousehold.java @@ -0,0 +1,24 @@ +package org.egov.common.models.referralmanagement.beneficiarydownsync; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.egov.common.models.household.Household; + +import java.util.Map; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class DownsyncCLFHousehold { + + @JsonProperty("Household") + Map householdMemberCountMap; + + @JsonProperty("DownsyncCriteria") + DownsyncCriteria downsyncCriteria; + +} diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHouseholdResponse.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHouseholdResponse.java new file mode 100644 index 00000000000..27c2bbd7cb6 --- /dev/null +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHouseholdResponse.java @@ -0,0 +1,25 @@ +package org.egov.common.models.referralmanagement.beneficiarydownsync; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.egov.common.contract.response.ResponseInfo; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class DownsyncCLFHouseholdResponse { + + + @JsonProperty("ResponseInfo") + private ResponseInfo responseInfo; + + @JsonProperty("Households") + private DownsyncCLFHousehold Households; + +} diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCriteria.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCriteria.java index 71816f7849f..400de52948b 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCriteria.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCriteria.java @@ -35,5 +35,7 @@ public class DownsyncCriteria { private Integer limit = 50; private Long totalCount; + + private String householdId; } diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HouseholdRepository.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HouseholdRepository.java new file mode 100644 index 00000000000..818e0e663e0 --- /dev/null +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HouseholdRepository.java @@ -0,0 +1,47 @@ +package org.egov.referralmanagement.repository; + +import org.egov.common.ds.Tuple; +import org.egov.common.models.household.Household; +import org.egov.referralmanagement.repository.rowmapper.HouseholdRowMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; +import org.springframework.stereotype.Repository; +import org.springframework.util.StringUtils; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Repository +public class HouseholdRepository { + + @Autowired + private NamedParameterJdbcTemplate namedParameterJdbcTemplate; + + @Autowired + private HouseholdRowMapper householdRowMapper; + + + public Tuple> findByViewCLF(String localityCode, Integer limit, Integer offset, String tenantId, Long lastModifiedTime, String householdId) { + String query = null; + Map paramsMap = new HashMap<>(); + + query = "select * from household_address_clf_mv where localitycode=:localitycode and rank between :start and :end "; + if (StringUtils.hasLength(householdId)) { + query = query + " and householdId=:householdId"; + paramsMap.put("householdId", householdId); + } + paramsMap.put("start", offset); + paramsMap.put("end", offset+limit); + + Map paramsMapCount = new HashMap<>(); + paramsMapCount.put("localitycode", localityCode); + paramsMapCount.put("lastModifiedTime", lastModifiedTime); + + + Integer maxRank = namedParameterJdbcTemplate.queryForObject("select max(rank) from household_address_clf_mv where localitycode=:localitycode and lastModifiedTime>=:lastModifiedTime", paramsMapCount, Integer.class); + Long totalCount = maxRank == null ? 0L : Long.valueOf(maxRank); + return new Tuple<>(totalCount, this.namedParameterJdbcTemplate.query(query, paramsMap, householdRowMapper)); + + } +} diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/rowmapper/HouseholdRowMapper.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/rowmapper/HouseholdRowMapper.java new file mode 100644 index 00000000000..83efd0ed86d --- /dev/null +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/rowmapper/HouseholdRowMapper.java @@ -0,0 +1,76 @@ +package org.egov.referralmanagement.repository.rowmapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.egov.common.contract.models.AuditDetails; +import org.egov.common.models.core.AdditionalFields; +import org.egov.common.models.household.Address; +import org.egov.common.models.household.AddressType; +import org.egov.common.models.core.Boundary; +import org.egov.common.models.household.Household; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.stereotype.Component; + +@Component +public class HouseholdRowMapper implements RowMapper { + private final ObjectMapper objectMapper = new ObjectMapper(); + + @Override + public Household mapRow(ResultSet resultSet, int i) throws SQLException { + try { + AuditDetails auditDetails = AuditDetails.builder() + .createdBy(resultSet.getString("createdBy")) + .createdTime(resultSet.getLong("createdTime")) + .lastModifiedBy(resultSet.getString("lastModifiedBy")) + .lastModifiedTime(resultSet.getLong("lastModifiedTime")) + .build(); + AuditDetails clientAuditDetails = AuditDetails.builder() + .createdTime(resultSet.getLong("clientCreatedTime")) + .createdBy(resultSet.getString("clientCreatedBy")) + .lastModifiedTime(resultSet.getLong("clientLastModifiedTime")) + .lastModifiedBy(resultSet.getString("clientLastModifiedBy")) + .build(); + Household household = Household.builder() + .id(resultSet.getString("id")) + .rowVersion(resultSet.getInt("rowVersion")) + .isDeleted(resultSet.getBoolean("isDeleted")) + .tenantId(resultSet.getString("tenantId")) + .memberCount(resultSet.getInt("numberOfMembers")) + .clientReferenceId(resultSet.getString("clientReferenceId")) + .auditDetails(auditDetails) + .clientAuditDetails(clientAuditDetails) + .additionalFields(resultSet.getString("additionalDetails") == null ? null : objectMapper.readValue(resultSet + .getString("additionalDetails"), AdditionalFields.class)) + .address(Address.builder() + .id(resultSet.getString("aid")) + .clientReferenceId(resultSet.getString("aclientreferenceid")) + .tenantId(resultSet.getString("atenantid")) + .doorNo(resultSet.getString("doorNo")) + .latitude(resultSet.getDouble("latitude")) + .longitude(resultSet.getDouble("longitude")) + .locationAccuracy(resultSet.getDouble("locationAccuracy")) + .type(AddressType.fromValue(resultSet.getString("type"))) + .addressLine1(resultSet.getString("addressLine1")) + .addressLine2(resultSet.getString("addressLine2")) + .landmark(resultSet.getString("landmark")) + .city(resultSet.getString("city")) + .pincode(resultSet.getString("pinCode")) + .buildingName(resultSet.getString("buildingName")) + .street(resultSet.getString("street")) + .locality(resultSet.getString("localityCode") != null ? + Boundary.builder().code(resultSet.getString("localityCode")).build() : null) + .build()) + .build(); + if (household.getAddress().getId() == null) { + household.setAddress(null); + } + return household; + } catch (JsonProcessingException e) { + throw new SQLException(e); + } + + } +} 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 7db34924dd4..fbfc9bef82b 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 @@ -10,7 +10,9 @@ import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.tuple.Pair; import org.egov.common.contract.request.RequestInfo; +import org.egov.common.ds.Tuple; import org.egov.common.http.client.ServiceRequestClient; import org.egov.common.models.household.Household; import org.egov.common.models.household.HouseholdBulkResponse; @@ -36,16 +38,19 @@ import org.egov.common.models.referralmanagement.ReferralSearch; import org.egov.common.models.referralmanagement.ReferralSearchRequest; import org.egov.common.models.referralmanagement.beneficiarydownsync.Downsync; +import org.egov.common.models.referralmanagement.beneficiarydownsync.DownsyncCLFHousehold; import org.egov.common.models.referralmanagement.beneficiarydownsync.DownsyncCriteria; import org.egov.common.models.referralmanagement.beneficiarydownsync.DownsyncRequest; import org.egov.common.models.referralmanagement.sideeffect.SideEffect; import org.egov.common.models.referralmanagement.sideeffect.SideEffectSearch; import org.egov.common.models.referralmanagement.sideeffect.SideEffectSearchRequest; import org.egov.referralmanagement.config.ReferralManagementConfiguration; +import org.egov.referralmanagement.repository.HouseholdRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; @Service @Slf4j @@ -62,14 +67,17 @@ public class DownsyncService { private ReferralManagementService referralService; private MasterDataService masterDataService; + private HouseholdRepository householdRepository; + + private static final Integer SEARCH_MAX_COUNT = 1000; @Autowired - public DownsyncService( ServiceRequestClient serviceRequestClient, - ReferralManagementConfiguration referralManagementConfiguration, - NamedParameterJdbcTemplate jdbcTemplate, - SideEffectService sideEffectService, - ReferralManagementService referralService, - MasterDataService masterDataService ) { + public DownsyncService(ServiceRequestClient serviceRequestClient, + ReferralManagementConfiguration referralManagementConfiguration, + NamedParameterJdbcTemplate jdbcTemplate, + SideEffectService sideEffectService, + ReferralManagementService referralService, + MasterDataService masterDataService, HouseholdRepository householdRepository) { this.restClient = serviceRequestClient; this.configs = referralManagementConfiguration; @@ -77,7 +85,7 @@ public DownsyncService( ServiceRequestClient serviceRequestClient, this.sideEffectService=sideEffectService; this.referralService=referralService; this.masterDataService=masterDataService; - + this.householdRepository = householdRepository; } /** @@ -85,7 +93,7 @@ public DownsyncService( ServiceRequestClient serviceRequestClient, * @param downsyncRequest * @return Downsync */ - public Downsync prepareDownsyncData(DownsyncRequest downsyncRequest) { + public Downsync prepareDownsyncData(DownsyncRequest downsyncRequest, boolean isCLF) { Downsync downsync = new Downsync(); DownsyncCriteria downsyncCriteria = downsyncRequest.getDownsyncCriteria(); @@ -104,7 +112,15 @@ public Downsync prepareDownsyncData(DownsyncRequest downsyncRequest) { LinkedHashMap projectType = masterDataService.getProjectType(downsyncRequest); /* search household */ - householdIds = searchHouseholds(downsyncRequest, downsync); + List households = null; + if (isCLF) { + households = searchHouseholdsCLF(downsyncRequest); + downsyncCriteria.setTotalCount(null); + }else { + householdIds = searchHouseholds(downsyncRequest, downsync); + } + + /* search household member using household ids */ if (isSyncTimeAvailable || !CollectionUtils.isEmpty(householdIds)) { @@ -122,8 +138,13 @@ public Downsync prepareDownsyncData(DownsyncRequest downsyncRequest) { beneficiaryClientRefIds = individualClientRefIds; - if("HOUSEHOLD".equalsIgnoreCase(beneficiaryType)) - beneficiaryClientRefIds = downsync.getHouseholds().stream().map(Household::getClientReferenceId).collect(Collectors.toList()); + if("HOUSEHOLD".equalsIgnoreCase(beneficiaryType)) { + if (households == null) + beneficiaryClientRefIds = downsync.getHouseholds().stream().map(Household::getClientReferenceId).collect(Collectors.toList()); + else + beneficiaryClientRefIds = households.stream().map(Household::getClientReferenceId).toList(); + } + //fetch beneficiary in the db if (isSyncTimeAvailable || !CollectionUtils.isEmpty(beneficiaryClientRefIds)) { @@ -147,6 +168,97 @@ public Downsync prepareDownsyncData(DownsyncRequest downsyncRequest) { return downsync; } + public DownsyncCLFHousehold prepareDownsyncCLFDataHousehold(DownsyncRequest downsyncRequest) { + DownsyncCLFHousehold downsyncCLFHousehold = new DownsyncCLFHousehold(); + downsyncCLFHousehold.setDownsyncCriteria(downsyncRequest.getDownsyncCriteria()); + + long startTime = System.currentTimeMillis(); + log.info("The household search start time : " + startTime); + List householdList = searchHouseholdsCLF(downsyncRequest); + + Map householdIdMemberCountMap = gethouseholdMemberCountMap(householdList.stream() + .map(Household::getId).collect(Collectors.toList())); + + Map householdMemberCountMap = new HashMap<>(); + for (Household household : householdList) { + householdMemberCountMap.put(household, householdIdMemberCountMap.getOrDefault(household.getId(), 0)); + } + + downsyncCLFHousehold.setHouseholdMemberCountMap(householdMemberCountMap); + log.info("The search time : " + (System.currentTimeMillis() - startTime)/1000); + return downsyncCLFHousehold; + } + + + /** + * The function returns communal living household ids if isCommunity flag is true and householdId is null + * It returns all the household data for a particular household if id is passed; within given offset and limit + */ + public Downsync downsyncForCLF(DownsyncRequest downsyncRequest) { + Downsync downsync = Downsync.builder().downsyncCriteria(downsyncRequest.getDownsyncCriteria()).build(); + DownsyncCriteria downsyncCriteria = downsyncRequest.getDownsyncCriteria(); + + downsyncCriteria.setLastSyncedTime(null); + + boolean isSyncTimeAvailable = null != downsyncCriteria.getLastSyncedTime(); + downsync.setDownsyncCriteria(downsyncCriteria); + + boolean isSyncTimeAvalable = null != downsyncCriteria.getLastSyncedTime(); + + Long requestStartTime = System.currentTimeMillis(); + Long startTime = System.currentTimeMillis(); + + Set individualIds = null; + List individualClientRefIds = null; + List beneficiaryClientRefIds = null; + List taskClientRefIds = null; + + //Project project = getProjectType(downsyncRequest); + LinkedHashMap projectType = masterDataService.getProjectType(downsyncRequest); + + /* search household */ + List households = searchHouseholdsCLF(downsyncRequest); + downsyncCriteria.setTotalCount(null); + + /* search household member using household ids */ + if (isSyncTimeAvailable || StringUtils.hasLength(downsyncCriteria.getHouseholdId())) { + individualIds = searchMembers(downsyncRequest, downsync, Collections.singletonList(downsyncCriteria.getHouseholdId())); + } + + /* search individuals using individual ids */ + if (isSyncTimeAvailable || !CollectionUtils.isEmpty(individualIds) ) { + individualClientRefIds = searchIndividuals(downsyncRequest, downsync, individualIds); + } + + /* search beneficiary using individual ids OR household ids */ + String beneficiaryType = (String) projectType.get("beneficiaryType"); + beneficiaryClientRefIds = individualClientRefIds; + + + if("HOUSEHOLD".equalsIgnoreCase(beneficiaryType)) { + beneficiaryClientRefIds = households.stream().map(Household::getClientReferenceId).toList(); + } + + //fetch beneficiary in the db + if (isSyncTimeAvailable || !CollectionUtils.isEmpty(beneficiaryClientRefIds)) { + beneficiaryClientRefIds = searchBeneficiaries(downsyncRequest, downsync, beneficiaryClientRefIds); + } + + /* search tasks using beneficiary uuids */ + if (isSyncTimeAvailable || !CollectionUtils.isEmpty(beneficiaryClientRefIds)) { + taskClientRefIds = searchTasks(downsyncRequest, downsync, beneficiaryClientRefIds, projectType); + + /* ref search */ + referralSearch(downsyncRequest, downsync, beneficiaryClientRefIds); + } + + if (isSyncTimeAvailable || !CollectionUtils.isEmpty(taskClientRefIds)) { + searchSideEffect(downsyncRequest, downsync, taskClientRefIds); + } + + return downsync; + } + /** * @@ -167,6 +279,9 @@ private List searchHouseholds(DownsyncRequest downsyncRequest, Downsync .localityCode(criteria.getLocality()) .build(); + if (StringUtils.hasLength(criteria.getHouseholdId())) { + householdSearch.setId(Collections.singletonList(criteria.getHouseholdId())); + } HouseholdSearchRequest searchRequest = HouseholdSearchRequest.builder() .household(householdSearch) .requestInfo(requestInfo) @@ -183,6 +298,21 @@ private List searchHouseholds(DownsyncRequest downsyncRequest, Downsync return households.stream().map(Household::getId).collect(Collectors.toList()); } + private List searchHouseholdsCLF(DownsyncRequest downsyncRequest) { + + DownsyncCriteria criteria = downsyncRequest.getDownsyncCriteria(); + + //HouseholdBulkResponse res = restClient.fetchResult(householdUrl, searchRequest, HouseholdBulkResponse.class); + Tuple> res = null; + + res = householdRepository.findByViewCLF(criteria.getLocality(), criteria.getLimit(), criteria.getOffset(), null, criteria.getLastSyncedTime() != null ? criteria.getLastSyncedTime() : 0L, criteria.getHouseholdId()); + + downsyncRequest.getDownsyncCriteria().setTotalCount(res.getX()); + + List households = res.getY(); + return households; + } + /** * * @param downsyncRequest @@ -196,26 +326,31 @@ private List searchIndividuals(DownsyncRequest downsyncRequest, Downsync DownsyncCriteria criteria = downsyncRequest.getDownsyncCriteria(); RequestInfo requestInfo = downsyncRequest.getRequestInfo(); - StringBuilder url = new StringBuilder(configs.getIndividualHost()) - .append(configs.getIndividualSearchUrl()); + List individuals = new ArrayList<>(); + List> subLists = splitList(individualIds.stream().toList(), SEARCH_MAX_COUNT); - url = appendUrlParams(url, criteria, 0, individualIds.size(),true); + for (List list : subLists) { + StringBuilder url = new StringBuilder(configs.getIndividualHost()) + .append(configs.getIndividualSearchUrl()); + url = appendUrlParams(url, criteria, 0, list.size(), true); - IndividualSearch individualSearch = IndividualSearch.builder() - .build(); + IndividualSearch individualSearch = IndividualSearch.builder() + .build(); - if(!CollectionUtils.isEmpty(individualIds)) - individualSearch.setId(new ArrayList<>(individualIds)); + if(!CollectionUtils.isEmpty(individualIds)) + individualSearch.setId(new ArrayList<>(individualIds)); - IndividualSearchRequest searchRequest = IndividualSearchRequest.builder() - .individual(individualSearch) - .requestInfo(requestInfo) - .build(); + IndividualSearchRequest searchRequest = IndividualSearchRequest.builder() + .individual(individualSearch) + .requestInfo(requestInfo) + .build(); - List individuals = restClient.fetchResult(url, searchRequest, IndividualBulkResponse.class).getIndividual(); + IndividualBulkResponse res = restClient.fetchResult(url, searchRequest, IndividualBulkResponse.class); + individuals.addAll(res.getIndividual()); + } downsync.setIndividuals(individuals); - return individuals.stream().map(Individual::getClientReferenceId).collect(Collectors.toList()); + return individuals.stream().map(Individual::getClientReferenceId).toList(); } /** @@ -229,26 +364,30 @@ private Set searchMembers(DownsyncRequest downsyncRequest, Downsync down Long lastChangedSince = downsyncRequest.getDownsyncCriteria().getLastSyncedTime(); - List memberids = getPrimaryIds(householdIds, "householdId","HOUSEHOLD_MEMBER",lastChangedSince); + List memberids = getPrimaryIds(householdIds, "householdId","HOUSEHOLD_MEMBER", + lastChangedSince, downsyncRequest.getDownsyncCriteria().getLimit(), downsyncRequest.getDownsyncCriteria().getOffset()); if (CollectionUtils.isEmpty(memberids)) return Collections.emptySet(); - StringBuilder memberUrl = new StringBuilder(configs.getHouseholdHost()) - .append(configs.getHouseholdMemberSearchUrl()); - - appendUrlParams(memberUrl, downsyncRequest.getDownsyncCriteria(), 0, householdIds.size(), false); - - HouseholdMemberSearch memberSearch = HouseholdMemberSearch.builder() - .id(memberids) - .build(); - - HouseholdMemberSearchRequest searchRequest = HouseholdMemberSearchRequest.builder() - .householdMemberSearch(memberSearch) - .requestInfo(downsyncRequest.getRequestInfo()) - .build(); - - List members = restClient.fetchResult(memberUrl, searchRequest, HouseholdMemberBulkResponse.class).getHouseholdMembers(); + List> subLists = splitList(memberids, SEARCH_MAX_COUNT); + List members = new ArrayList<>(); + for (List list : subLists) { + StringBuilder memberUrl = new StringBuilder(configs.getHouseholdHost()) + .append(configs.getHouseholdMemberSearchUrl()); + appendUrlParams(memberUrl, downsyncRequest.getDownsyncCriteria(), 0, list.size(), false); + HouseholdMemberSearch memberSearch = HouseholdMemberSearch.builder() + .id(list) + .build(); + + HouseholdMemberSearchRequest searchRequest = HouseholdMemberSearchRequest.builder() + .householdMemberSearch(memberSearch) + .requestInfo(downsyncRequest.getRequestInfo()) + .build(); + + List membersSublist = restClient.fetchResult(memberUrl, searchRequest, HouseholdMemberBulkResponse.class).getHouseholdMembers(); + members.addAll(membersSublist); + } downsync.setHouseholdMembers(members); return members.stream().map(HouseholdMember::getIndividualId).collect(Collectors.toSet()); @@ -272,31 +411,36 @@ private List searchBeneficiaries(DownsyncRequest downsyncRequest, Downsy beneficiaryClientRefIds, "beneficiaryclientreferenceid", "PROJECT_BENEFICIARY", - lastChangedSince + lastChangedSince, null, null ); if(CollectionUtils.isEmpty(beneficiaryIds)) return Collections.emptyList(); - StringBuilder url = new StringBuilder(configs.getProjectHost()) - .append(configs.getProjectBeneficiarySearchUrl()); + List> subLists = splitList(beneficiaryIds, SEARCH_MAX_COUNT); + List beneficiaries = new ArrayList<>(); - url = appendUrlParams(url, criteria, 0, beneficiaryClientRefIds.size(),false); + for (List list : subLists) { + StringBuilder url = new StringBuilder(configs.getProjectHost()) + .append(configs.getProjectBeneficiarySearchUrl()); + url = appendUrlParams(url, criteria, 0, list.size(), false); - ProjectBeneficiarySearch search = ProjectBeneficiarySearch.builder() - .id(beneficiaryIds) - .projectId(Collections.singletonList(downsyncRequest.getDownsyncCriteria().getProjectId())) - .build(); + ProjectBeneficiarySearch search = ProjectBeneficiarySearch.builder() + .id(list) + .projectId(Collections.singletonList(downsyncRequest.getDownsyncCriteria().getProjectId())) + .build(); - BeneficiarySearchRequest searchRequest = BeneficiarySearchRequest.builder() - .projectBeneficiary(search) - .requestInfo(requestInfo) - .build(); + BeneficiarySearchRequest searchRequest = BeneficiarySearchRequest.builder() + .projectBeneficiary(search) + .requestInfo(requestInfo) + .build(); - List beneficiaries = restClient.fetchResult(url, searchRequest, BeneficiaryBulkResponse.class).getProjectBeneficiaries(); + List beneficiariesSubList = restClient.fetchResult(url, searchRequest, BeneficiaryBulkResponse.class).getProjectBeneficiaries(); + beneficiaries.addAll(beneficiariesSubList); + } downsync.setProjectBeneficiaries(beneficiaries); - return beneficiaries.stream().map(ProjectBeneficiary::getClientReferenceId).collect(Collectors.toList()); + return beneficiaries.stream().map(ProjectBeneficiary::getClientReferenceId).toList(); } @@ -315,30 +459,35 @@ private List searchTasks(DownsyncRequest downsyncRequest, Downsync downs DownsyncCriteria criteria = downsyncRequest.getDownsyncCriteria(); RequestInfo requestInfo = downsyncRequest.getRequestInfo(); List taskIds = getPrimaryIds(beneficiaryClientRefIds, "projectBeneficiaryClientReferenceId", "PROJECT_TASK", - criteria.getLastSyncedTime()); + criteria.getLastSyncedTime(), null, null); if(CollectionUtils.isEmpty(taskIds)) return Collections.emptyList(); - StringBuilder url = new StringBuilder(configs.getProjectHost()) - .append(configs.getProjectTaskSearchUrl()); + List> subLists = splitList(taskIds, SEARCH_MAX_COUNT); + List tasks = new ArrayList<>(); - url = appendUrlParams(url, criteria, 0, taskIds.size(), false); + for (List list : subLists) { + StringBuilder url = new StringBuilder(configs.getProjectHost()) + .append(configs.getProjectTaskSearchUrl()); - TaskSearch search = TaskSearch.builder() - .id(taskIds) - .projectId(Collections.singletonList(downsyncRequest.getDownsyncCriteria().getProjectId())) - .build(); + url = appendUrlParams(url, criteria, 0, list.size(), false); - TaskSearchRequest searchRequest = TaskSearchRequest.builder() - .task(search) - .requestInfo(requestInfo) - .build(); + TaskSearch search = TaskSearch.builder() + .id(list) + .projectId(Collections.singletonList(downsyncRequest.getDownsyncCriteria().getProjectId())) + .build(); - List tasks = restClient.fetchResult(url, searchRequest, TaskBulkResponse.class).getTasks(); + TaskSearchRequest searchRequest = TaskSearchRequest.builder() + .task(search) + .requestInfo(requestInfo) + .build(); + List tasksSubList = restClient.fetchResult(url, searchRequest, TaskBulkResponse.class).getTasks(); + tasks.addAll(tasksSubList); + } downsync.setTasks(tasks); - return tasks.stream().map(Task::getClientReferenceId).collect(Collectors.toList()); + return tasks.stream().map(Task::getClientReferenceId).toList(); } /** @@ -354,7 +503,8 @@ private void searchSideEffect(DownsyncRequest downsyncRequest, Downsync downsync RequestInfo requestInfo = downsyncRequest.getRequestInfo(); /* FIXME SHOULD BE REMOVED AND TASK SEARCH SHOULD BE enhanced with list of client-ref-beneficiary ids*/ - List SEIds = getPrimaryIds(taskClientRefIds, "taskClientReferenceId", "SIDE_EFFECT", criteria.getLastSyncedTime()); + List SEIds = getPrimaryIds(taskClientRefIds, "taskClientReferenceId", + "SIDE_EFFECT", criteria.getLastSyncedTime(), null, null); if(CollectionUtils.isEmpty(SEIds)) return; @@ -412,6 +562,27 @@ private void referralSearch(DownsyncRequest downsyncRequest, Downsync downsync, downsync.setReferrals(referrals); } + private Map gethouseholdMemberCountMap(List idList) { + + Map memberCountMap = new HashMap<>(); + + if (!CollectionUtils.isEmpty(idList)) { + StringBuilder memberIdsquery = new StringBuilder("SELECT householdId, COUNT(*) AS memberCount " + + "FROM HOUSEHOLD_MEMBER WHERE householdId IN (:householdId) GROUP BY householdId"); + + Map paramMap = new HashMap<>(); + paramMap.put("householdId", idList); + List> memberCountList = jdbcTemplate.queryForList(memberIdsquery.toString(), paramMap); + return memberCountList.stream() + .collect(Collectors.toMap( + row -> (String) row.get("householdId"), + row -> ((Number) row.get("memberCount")).intValue() + )); + + } + return memberCountMap; + } + /** * common method to fetch Ids with list of relation Ids like id of member with householdIds @@ -421,7 +592,8 @@ private void referralSearch(DownsyncRequest downsyncRequest, Downsync downsync, * @param lastChangedSince * @return */ - private List getPrimaryIds(List idList, String idListFieldName, String tableName, Long lastChangedSince) { + private List getPrimaryIds(List idList, String idListFieldName, String tableName, + Long lastChangedSince, Integer limit, Integer offset) { /** * Adding lastShangedSince to id query to avoid load on API search for members @@ -445,6 +617,12 @@ private List getPrimaryIds(List idList, String idListFieldName, paramMap.put("lastChangedSince", lastChangedSince); } + if (tableName.equalsIgnoreCase("HOUSEHOLD_MEMBER")) { + memberIdsquery.append(" ORDER BY lastModifiedTime ASC LIMIT :limit OFFSET :offset"); + paramMap.put("limit", limit); + paramMap.put("offset", offset); + } + String finalQuery = String.format(memberIdsquery.toString(), tableName, idListFieldName, idListFieldName); /* FIXME SHOULD BE REMOVED AND SEARCH SHOULD BE enhanced with list of household ids*/ List memberids = jdbcTemplate.queryForList(finalQuery, paramMap, String.class); @@ -486,4 +664,12 @@ private StringBuilder appendUrlParams(StringBuilder url, DownsyncCriteria criter return url; } + + private List> splitList(List list, int size) { + List> subLists = new ArrayList<>(); + for (int i = 0; i < list.size(); i += size) { + subLists.add(list.subList(i, Math.min(i + size, list.size()))); + } + return subLists; + } } diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/web/controllers/BeneficiaryDownsyncController.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/web/controllers/BeneficiaryDownsyncController.java index d780ef1cce0..d8e3f3d55ac 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/web/controllers/BeneficiaryDownsyncController.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/web/controllers/BeneficiaryDownsyncController.java @@ -4,9 +4,7 @@ import io.swagger.annotations.ApiParam; import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; -import org.egov.common.models.referralmanagement.beneficiarydownsync.Downsync; -import org.egov.common.models.referralmanagement.beneficiarydownsync.DownsyncRequest; -import org.egov.common.models.referralmanagement.beneficiarydownsync.DownsyncResponse; +import org.egov.common.models.referralmanagement.beneficiarydownsync.*; import org.egov.common.utils.ResponseInfoFactory; import org.egov.referralmanagement.service.DownsyncService; import org.springframework.beans.factory.annotation.Autowired; @@ -42,7 +40,7 @@ public ResponseEntity getBeneficaryData (@ApiParam(value = "Ca Downsync.builder(). downsyncCriteria(request.getDownsyncCriteria()) .build(); - Downsync downsync = downsyncService.prepareDownsyncData(request); + Downsync downsync = downsyncService.prepareDownsyncData(request, false); DownsyncResponse response = DownsyncResponse.builder() .downsync(downsync) .responseInfo(ResponseInfoFactory @@ -51,4 +49,28 @@ public ResponseEntity getBeneficaryData (@ApiParam(value = "Ca return ResponseEntity.status(HttpStatus.ACCEPTED).body(response); } + + @PostMapping(value = "/v1/_get/CLF/household") + public ResponseEntity getBeneficaryDataCFLHousehold (@ApiParam(value = "Capture details of Side Effect", required = true) @Valid @RequestBody DownsyncRequest request) { + log.info("UserUUID: {}", request.getRequestInfo().getUserInfo().getUuid()); + log.info("Downsync RequestBody: {}", mapper.valueToTree(request).toString()); + DownsyncCLFHousehold downsyncCLFHousehold = downsyncService.prepareDownsyncCLFDataHousehold(request); + DownsyncCLFHouseholdResponse response = DownsyncCLFHouseholdResponse.builder() + .Households(downsyncCLFHousehold).responseInfo(ResponseInfoFactory.createResponseInfo(request.getRequestInfo(), true)).build(); + return ResponseEntity.status(HttpStatus.ACCEPTED).body(response); + } + + @PostMapping(value = "/v1/_get/CLF/memberData") + public ResponseEntity getBeneficaryDataCFLMember (@ApiParam(value = "Capture details of Side Effect", required = true) @Valid @RequestBody DownsyncRequest request) { + log.info("UserUUID: {}", request.getRequestInfo().getUserInfo().getUuid()); + log.info("Downsync RequestBody: {}", mapper.valueToTree(request).toString()); + Downsync downsyncCLFMember = downsyncService.prepareDownsyncData(request, true); + DownsyncResponse response = DownsyncResponse.builder() + .downsync(downsyncCLFMember).responseInfo(ResponseInfoFactory.createResponseInfo(request.getRequestInfo(), true)).build(); + return ResponseEntity.status(HttpStatus.ACCEPTED).body(response); + } + + } + + From 3f45a78aa57377113086dc6e029b925f691d9b07 Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Mon, 16 Dec 2024 16:10:30 +0530 Subject: [PATCH 02/19] Removed duplicate function --- .../service/DownsyncService.java | 71 ------------------- 1 file changed, 71 deletions(-) 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 fbfc9bef82b..e042ff3d7dd 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 @@ -189,77 +189,6 @@ public DownsyncCLFHousehold prepareDownsyncCLFDataHousehold(DownsyncRequest down return downsyncCLFHousehold; } - - /** - * The function returns communal living household ids if isCommunity flag is true and householdId is null - * It returns all the household data for a particular household if id is passed; within given offset and limit - */ - public Downsync downsyncForCLF(DownsyncRequest downsyncRequest) { - Downsync downsync = Downsync.builder().downsyncCriteria(downsyncRequest.getDownsyncCriteria()).build(); - DownsyncCriteria downsyncCriteria = downsyncRequest.getDownsyncCriteria(); - - downsyncCriteria.setLastSyncedTime(null); - - boolean isSyncTimeAvailable = null != downsyncCriteria.getLastSyncedTime(); - downsync.setDownsyncCriteria(downsyncCriteria); - - boolean isSyncTimeAvalable = null != downsyncCriteria.getLastSyncedTime(); - - Long requestStartTime = System.currentTimeMillis(); - Long startTime = System.currentTimeMillis(); - - Set individualIds = null; - List individualClientRefIds = null; - List beneficiaryClientRefIds = null; - List taskClientRefIds = null; - - //Project project = getProjectType(downsyncRequest); - LinkedHashMap projectType = masterDataService.getProjectType(downsyncRequest); - - /* search household */ - List households = searchHouseholdsCLF(downsyncRequest); - downsyncCriteria.setTotalCount(null); - - /* search household member using household ids */ - if (isSyncTimeAvailable || StringUtils.hasLength(downsyncCriteria.getHouseholdId())) { - individualIds = searchMembers(downsyncRequest, downsync, Collections.singletonList(downsyncCriteria.getHouseholdId())); - } - - /* search individuals using individual ids */ - if (isSyncTimeAvailable || !CollectionUtils.isEmpty(individualIds) ) { - individualClientRefIds = searchIndividuals(downsyncRequest, downsync, individualIds); - } - - /* search beneficiary using individual ids OR household ids */ - String beneficiaryType = (String) projectType.get("beneficiaryType"); - beneficiaryClientRefIds = individualClientRefIds; - - - if("HOUSEHOLD".equalsIgnoreCase(beneficiaryType)) { - beneficiaryClientRefIds = households.stream().map(Household::getClientReferenceId).toList(); - } - - //fetch beneficiary in the db - if (isSyncTimeAvailable || !CollectionUtils.isEmpty(beneficiaryClientRefIds)) { - beneficiaryClientRefIds = searchBeneficiaries(downsyncRequest, downsync, beneficiaryClientRefIds); - } - - /* search tasks using beneficiary uuids */ - if (isSyncTimeAvailable || !CollectionUtils.isEmpty(beneficiaryClientRefIds)) { - taskClientRefIds = searchTasks(downsyncRequest, downsync, beneficiaryClientRefIds, projectType); - - /* ref search */ - referralSearch(downsyncRequest, downsync, beneficiaryClientRefIds); - } - - if (isSyncTimeAvailable || !CollectionUtils.isEmpty(taskClientRefIds)) { - searchSideEffect(downsyncRequest, downsync, taskClientRefIds); - } - - return downsync; - } - - /** * * @param downsyncRequest From 57df1cb1d47a8556a9c1fb8f17385716e0803a39 Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Wed, 18 Dec 2024 09:42:01 +0530 Subject: [PATCH 03/19] Changing model --- .../DownsyncCLFHousehold.java | 5 +++-- .../HouseholdMemberMap.java | 20 +++++++++++++++++++ .../repository/HouseholdRepository.java | 1 + .../service/DownsyncService.java | 15 +++++++------- 4 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/HouseholdMemberMap.java diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHousehold.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHousehold.java index ece8054b92d..6324a47d3ba 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHousehold.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHousehold.java @@ -7,6 +7,7 @@ import lombok.NoArgsConstructor; import org.egov.common.models.household.Household; +import java.util.List; import java.util.Map; @Data @@ -15,8 +16,8 @@ @Builder public class DownsyncCLFHousehold { - @JsonProperty("Household") - Map householdMemberCountMap; + @JsonProperty("HouseholdCountMap") + List householdMemberCountMap; @JsonProperty("DownsyncCriteria") DownsyncCriteria downsyncCriteria; diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/HouseholdMemberMap.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/HouseholdMemberMap.java new file mode 100644 index 00000000000..4cc84ae19ae --- /dev/null +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/HouseholdMemberMap.java @@ -0,0 +1,20 @@ +package org.egov.common.models.referralmanagement.beneficiarydownsync; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.egov.common.models.household.Household; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class HouseholdMemberMap { + + private Household household; + + private Integer numberOfMembers; + + +} diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HouseholdRepository.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HouseholdRepository.java index 818e0e663e0..2cb547342b4 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HouseholdRepository.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HouseholdRepository.java @@ -31,6 +31,7 @@ public Tuple> findByViewCLF(String localityCode, Integer l query = query + " and householdId=:householdId"; paramsMap.put("householdId", householdId); } + paramsMap.put("localitycode", localityCode); paramsMap.put("start", offset); paramsMap.put("end", offset+limit); 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 e042ff3d7dd..359e61eb538 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 @@ -37,10 +37,7 @@ import org.egov.common.models.referralmanagement.Referral; import org.egov.common.models.referralmanagement.ReferralSearch; import org.egov.common.models.referralmanagement.ReferralSearchRequest; -import org.egov.common.models.referralmanagement.beneficiarydownsync.Downsync; -import org.egov.common.models.referralmanagement.beneficiarydownsync.DownsyncCLFHousehold; -import org.egov.common.models.referralmanagement.beneficiarydownsync.DownsyncCriteria; -import org.egov.common.models.referralmanagement.beneficiarydownsync.DownsyncRequest; +import org.egov.common.models.referralmanagement.beneficiarydownsync.*; import org.egov.common.models.referralmanagement.sideeffect.SideEffect; import org.egov.common.models.referralmanagement.sideeffect.SideEffectSearch; import org.egov.common.models.referralmanagement.sideeffect.SideEffectSearchRequest; @@ -178,11 +175,13 @@ public DownsyncCLFHousehold prepareDownsyncCLFDataHousehold(DownsyncRequest down Map householdIdMemberCountMap = gethouseholdMemberCountMap(householdList.stream() .map(Household::getId).collect(Collectors.toList())); + List householdMemberCountMap = new ArrayList<>(); - Map householdMemberCountMap = new HashMap<>(); - for (Household household : householdList) { - householdMemberCountMap.put(household, householdIdMemberCountMap.getOrDefault(household.getId(), 0)); - } + for (Household household : householdList) { + Integer memberCount = householdIdMemberCountMap.get(household.getId()) == null ? 0 : householdIdMemberCountMap.get(household.getId()); + HouseholdMemberMap householdMemberMap = HouseholdMemberMap.builder().household(household).numberOfMembers(memberCount).build(); + householdMemberCountMap.add(householdMemberMap); + } downsyncCLFHousehold.setHouseholdMemberCountMap(householdMemberCountMap); log.info("The search time : " + (System.currentTimeMillis() - startTime)/1000); From de12ab7b2a6ae1879c517142b8ac686550e42c5e Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Wed, 18 Dec 2024 13:10:22 +0530 Subject: [PATCH 04/19] changing id to householdId --- .../referralmanagement/repository/HouseholdRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HouseholdRepository.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HouseholdRepository.java index 2cb547342b4..74b89e04b13 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HouseholdRepository.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HouseholdRepository.java @@ -28,8 +28,8 @@ public Tuple> findByViewCLF(String localityCode, Integer l query = "select * from household_address_clf_mv where localitycode=:localitycode and rank between :start and :end "; if (StringUtils.hasLength(householdId)) { - query = query + " and householdId=:householdId"; - paramsMap.put("householdId", householdId); + query = query + " and id=:id"; + paramsMap.put("id", householdId); } paramsMap.put("localitycode", localityCode); paramsMap.put("start", offset); From afebcf2a0908e7dabe493d1ef682f59bc35880a7 Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Wed, 18 Dec 2024 13:43:37 +0530 Subject: [PATCH 05/19] enriching householdIds --- .../org/egov/referralmanagement/service/DownsyncService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 359e61eb538..9423f7ebcb9 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 @@ -116,8 +116,9 @@ public Downsync prepareDownsyncData(DownsyncRequest downsyncRequest, boolean isC }else { householdIds = searchHouseholds(downsyncRequest, downsync); } - - + if (CollectionUtils.isEmpty(householdIds)) { + householdIds = households.stream().map(Household::getId).collect(Collectors.toList()); + } /* search household member using household ids */ if (isSyncTimeAvailable || !CollectionUtils.isEmpty(householdIds)) { From 915c55071d3a9fc151c10d68a86b358196e2cdd1 Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Wed, 18 Dec 2024 14:35:26 +0530 Subject: [PATCH 06/19] Making referral list mutable --- .../org/egov/referralmanagement/service/DownsyncService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 9423f7ebcb9..57263671ce9 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 @@ -209,7 +209,9 @@ private List searchHouseholds(DownsyncRequest downsyncRequest, Downsync .build(); if (StringUtils.hasLength(criteria.getHouseholdId())) { - householdSearch.setId(Collections.singletonList(criteria.getHouseholdId())); + List householdIds = new ArrayList<>(); + householdIds.add(criteria.getHouseholdId()); + householdSearch.setId(householdIds); } HouseholdSearchRequest searchRequest = HouseholdSearchRequest.builder() .household(householdSearch) From 710920d3574bf2bf305b5409b7a806e09a4ebbae Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Wed, 18 Dec 2024 15:08:28 +0530 Subject: [PATCH 07/19] making collectors.toList instead of tolist --- .../referralmanagement/service/DownsyncService.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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 57263671ce9..ac4faea682f 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 @@ -140,7 +140,7 @@ public Downsync prepareDownsyncData(DownsyncRequest downsyncRequest, boolean isC if (households == null) beneficiaryClientRefIds = downsync.getHouseholds().stream().map(Household::getClientReferenceId).collect(Collectors.toList()); else - beneficiaryClientRefIds = households.stream().map(Household::getClientReferenceId).toList(); + beneficiaryClientRefIds = households.stream().map(Household::getClientReferenceId).collect(Collectors.toList()); } @@ -209,9 +209,7 @@ private List searchHouseholds(DownsyncRequest downsyncRequest, Downsync .build(); if (StringUtils.hasLength(criteria.getHouseholdId())) { - List householdIds = new ArrayList<>(); - householdIds.add(criteria.getHouseholdId()); - householdSearch.setId(householdIds); + householdSearch.setId(Collections.singletonList(criteria.getHouseholdId())); } HouseholdSearchRequest searchRequest = HouseholdSearchRequest.builder() .household(householdSearch) @@ -281,7 +279,7 @@ private List searchIndividuals(DownsyncRequest downsyncRequest, Downsync } downsync.setIndividuals(individuals); - return individuals.stream().map(Individual::getClientReferenceId).toList(); + return individuals.stream().map(Individual::getClientReferenceId).collect(Collectors.toList()); } /** @@ -371,7 +369,7 @@ private List searchBeneficiaries(DownsyncRequest downsyncRequest, Downsy } downsync.setProjectBeneficiaries(beneficiaries); - return beneficiaries.stream().map(ProjectBeneficiary::getClientReferenceId).toList(); + return beneficiaries.stream().map(ProjectBeneficiary::getClientReferenceId).collect(Collectors.toList()); } @@ -418,7 +416,7 @@ private List searchTasks(DownsyncRequest downsyncRequest, Downsync downs } downsync.setTasks(tasks); - return tasks.stream().map(Task::getClientReferenceId).toList(); + return tasks.stream().map(Task::getClientReferenceId).collect(Collectors.toList()); } /** From d696e3892846d23977c818c090288ffbf36a8c10 Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Wed, 18 Dec 2024 15:45:41 +0530 Subject: [PATCH 08/19] limit offset change --- .../repository/HouseholdRepository.java | 23 ++++++++++--------- .../service/DownsyncService.java | 1 - 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HouseholdRepository.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HouseholdRepository.java index 74b89e04b13..082fe188765 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HouseholdRepository.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HouseholdRepository.java @@ -25,23 +25,24 @@ public class HouseholdRepository { public Tuple> findByViewCLF(String localityCode, Integer limit, Integer offset, String tenantId, Long lastModifiedTime, String householdId) { String query = null; Map paramsMap = new HashMap<>(); + Long totalCount = null; - query = "select * from household_address_clf_mv where localitycode=:localitycode and rank between :start and :end "; + query = "select * from household_address_clf_mv where localitycode=:localitycode "; if (StringUtils.hasLength(householdId)) { query = query + " and id=:id"; paramsMap.put("id", householdId); + } else { + paramsMap.put("start", offset); + paramsMap.put("end", offset+limit); + query = query + " and rank between :start and :end "; + + Map paramsMapCount = new HashMap<>(); + paramsMapCount.put("localitycode", localityCode); + paramsMapCount.put("lastModifiedTime", lastModifiedTime); + Integer maxRank = namedParameterJdbcTemplate.queryForObject("select max(rank) from household_address_clf_mv where localitycode=:localitycode and lastModifiedTime>=:lastModifiedTime", paramsMapCount, Integer.class); + totalCount = maxRank == null ? 0L : Long.valueOf(maxRank); } paramsMap.put("localitycode", localityCode); - paramsMap.put("start", offset); - paramsMap.put("end", offset+limit); - - Map paramsMapCount = new HashMap<>(); - paramsMapCount.put("localitycode", localityCode); - paramsMapCount.put("lastModifiedTime", lastModifiedTime); - - - Integer maxRank = namedParameterJdbcTemplate.queryForObject("select max(rank) from household_address_clf_mv where localitycode=:localitycode and lastModifiedTime>=:lastModifiedTime", paramsMapCount, Integer.class); - Long totalCount = maxRank == null ? 0L : Long.valueOf(maxRank); return new Tuple<>(totalCount, this.namedParameterJdbcTemplate.query(query, paramsMap, householdRowMapper)); } 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 ac4faea682f..c0414a118bd 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 @@ -112,7 +112,6 @@ public Downsync prepareDownsyncData(DownsyncRequest downsyncRequest, boolean isC List households = null; if (isCLF) { households = searchHouseholdsCLF(downsyncRequest); - downsyncCriteria.setTotalCount(null); }else { householdIds = searchHouseholds(downsyncRequest, downsync); } From 2e5dc2cf5d202939e521ce744eb8969196631967 Mon Sep 17 00:00:00 2001 From: shubhang-eGov <70943369+shubhang-eGov@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:08:03 +0530 Subject: [PATCH 09/19] Update pom.xml --- health-services/referralmanagement/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/health-services/referralmanagement/pom.xml b/health-services/referralmanagement/pom.xml index 4bf32a9765a..6668afdda9a 100644 --- a/health-services/referralmanagement/pom.xml +++ b/health-services/referralmanagement/pom.xml @@ -51,7 +51,7 @@ org.egov.common health-services-models - 1.0.23-dev-SNAPSHOT + 1.0.24-dev-SNAPSHOT compile @@ -132,4 +132,4 @@ https://nexus-repo.digit.org/nexus/content/repositories/snapshots/ - \ No newline at end of file + From 787b53ec5686040d0e0e3f0208a22228a0d194ab Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Thu, 19 Dec 2024 17:19:01 +0530 Subject: [PATCH 10/19] adding nexus releases repo --- health-services/referralmanagement/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/health-services/referralmanagement/pom.xml b/health-services/referralmanagement/pom.xml index 6668afdda9a..b12948a46cf 100644 --- a/health-services/referralmanagement/pom.xml +++ b/health-services/referralmanagement/pom.xml @@ -131,5 +131,10 @@ eGov DIGIT Releases Repository https://nexus-repo.digit.org/nexus/content/repositories/snapshots/ + + repo.digit.org + eGov DIGIT Releases Repository + https://nexus-repo.digit.org/nexus/content/repositories/releases/ + From 25df95993a8abddddce4596b08871d4c266cd86a Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Thu, 19 Dec 2024 17:27:31 +0530 Subject: [PATCH 11/19] removed snapshot repo --- health-services/referralmanagement/pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/health-services/referralmanagement/pom.xml b/health-services/referralmanagement/pom.xml index b12948a46cf..41380a1f7fd 100644 --- a/health-services/referralmanagement/pom.xml +++ b/health-services/referralmanagement/pom.xml @@ -126,11 +126,6 @@ eGov Public Repository Group https://nexus-repo.egovernments.org/nexus/content/groups/public/ - - repo.digit.org - eGov DIGIT Releases Repository - https://nexus-repo.digit.org/nexus/content/repositories/snapshots/ - repo.digit.org eGov DIGIT Releases Repository From 360badcef0ab127b1583d072e83e02a5f7e4b22a Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Thu, 19 Dec 2024 17:38:05 +0530 Subject: [PATCH 12/19] removed snapshot repo --- health-services/referralmanagement/pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/health-services/referralmanagement/pom.xml b/health-services/referralmanagement/pom.xml index 41380a1f7fd..5a7ba6cd1a4 100644 --- a/health-services/referralmanagement/pom.xml +++ b/health-services/referralmanagement/pom.xml @@ -111,11 +111,6 @@ - - repo.egovernments.org - eGov ERP Releases Repository - https://nexus-repo.egovernments.org/nexus/content/repositories/releases/ - repo.egovernments.org.snapshots eGov ERP Releases Repository From 0d07bc8a38ca0941468d305ce4781db9cb2c8e23 Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Thu, 19 Dec 2024 17:42:21 +0530 Subject: [PATCH 13/19] removed other repositories --- health-services/referralmanagement/pom.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/health-services/referralmanagement/pom.xml b/health-services/referralmanagement/pom.xml index 5a7ba6cd1a4..7644608b504 100644 --- a/health-services/referralmanagement/pom.xml +++ b/health-services/referralmanagement/pom.xml @@ -111,16 +111,6 @@ - - repo.egovernments.org.snapshots - eGov ERP Releases Repository - https://nexus-repo.egovernments.org/nexus/content/repositories/snapshots/ - - - repo.egovernments.org.public - eGov Public Repository Group - https://nexus-repo.egovernments.org/nexus/content/groups/public/ - repo.digit.org eGov DIGIT Releases Repository From 4f7ee4d26d55d9e2e08e88419a5b41c36a27beff Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Thu, 19 Dec 2024 18:01:48 +0530 Subject: [PATCH 14/19] removed other repositories --- .../models/household/HouseHoldType.java | 31 +++++++++++++++++++ .../common/models/household/Household.java | 3 ++ .../models/household/HouseholdSearch.java | 3 ++ health-services/referralmanagement/pom.xml | 19 ++++++++++-- 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/HouseHoldType.java diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/HouseHoldType.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/HouseHoldType.java new file mode 100644 index 00000000000..08e1487dbdf --- /dev/null +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/HouseHoldType.java @@ -0,0 +1,31 @@ +package org.egov.common.models.household; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public enum HouseHoldType { + + FAMILY("FAMILY"), + + COMMUNITY("COMMUNITY"), + + OTHER("OTHER"); + + private String value; + + HouseHoldType(String value) { + this.value = value; + } + + @JsonCreator + public static HouseHoldType fromValue(String text) { + for (HouseHoldType b : HouseHoldType.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + +} diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/Household.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/Household.java index 24f7a15f20e..f43bc53e2f2 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/Household.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/Household.java @@ -34,6 +34,9 @@ public class Household extends EgovOfflineModel { @Valid private Address address = null; + @JsonProperty("householdType") + private HouseHoldType householdType = null; + //TODO remove @JsonProperty("isDeleted") private Boolean isDeleted = Boolean.FALSE; 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 4ff5ccec51e..57612ce5835 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 @@ -25,6 +25,9 @@ public class HouseholdSearch extends EgovOfflineSearchModel { @JsonProperty("boundaryCode") private String localityCode = null; + @JsonProperty("householdType") + private String householdType = null; + @Exclude @JsonProperty("latitude") @DecimalMin("-90") diff --git a/health-services/referralmanagement/pom.xml b/health-services/referralmanagement/pom.xml index 7644608b504..8b819e03376 100644 --- a/health-services/referralmanagement/pom.xml +++ b/health-services/referralmanagement/pom.xml @@ -51,7 +51,7 @@ org.egov.common health-services-models - 1.0.24-dev-SNAPSHOT + 1.0.23-dev-SNAPSHOT compile @@ -111,10 +111,25 @@ + + repo.egovernments.org + eGov ERP Releases Repository + https://nexus-repo.egovernments.org/nexus/content/repositories/releases/ + + + repo.egovernments.org.snapshots + eGov ERP Releases Repository + https://nexus-repo.egovernments.org/nexus/content/repositories/snapshots/ + + + repo.egovernments.org.public + eGov Public Repository Group + https://nexus-repo.egovernments.org/nexus/content/groups/public/ + repo.digit.org eGov DIGIT Releases Repository - https://nexus-repo.digit.org/nexus/content/repositories/releases/ + https://nexus-repo.digit.org/nexus/content/repositories/snapshots/ From 822014d2f6a58f9161f09b4c7d9046cedf88da03 Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Fri, 20 Dec 2024 13:40:08 +0530 Subject: [PATCH 15/19] Fetching only family households for normal downsync --- .../org/egov/referralmanagement/service/DownsyncService.java | 1 + 1 file changed, 1 insertion(+) 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 c0414a118bd..323dbd542b8 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 @@ -205,6 +205,7 @@ private List searchHouseholds(DownsyncRequest downsyncRequest, Downsync HouseholdSearch householdSearch = HouseholdSearch.builder() .localityCode(criteria.getLocality()) + .householdType("FAMILY") .build(); if (StringUtils.hasLength(criteria.getHouseholdId())) { From 62d876a4fabdccbda999e624e9aee5e00291b5ec Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Fri, 20 Dec 2024 17:04:01 +0530 Subject: [PATCH 16/19] not streaming empty list --- .../egov/referralmanagement/service/DownsyncService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 323dbd542b8..b30e67f18f7 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 @@ -116,7 +116,11 @@ public Downsync prepareDownsyncData(DownsyncRequest downsyncRequest, boolean isC householdIds = searchHouseholds(downsyncRequest, downsync); } if (CollectionUtils.isEmpty(householdIds)) { - householdIds = households.stream().map(Household::getId).collect(Collectors.toList()); + householdIds = (households == null) + ? Collections.emptyList() + : households.stream() + .map(Household::getId) + .collect(Collectors.toList()); } /* search household member using household ids */ From c1749cc0ec833d19d3bbc94bebef57e354e58d1a Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Mon, 23 Dec 2024 18:03:13 +0530 Subject: [PATCH 17/19] removing type family for demo --- .../org/egov/referralmanagement/service/DownsyncService.java | 1 - 1 file changed, 1 deletion(-) 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 b30e67f18f7..b4fa32b3780 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 @@ -209,7 +209,6 @@ private List searchHouseholds(DownsyncRequest downsyncRequest, Downsync HouseholdSearch householdSearch = HouseholdSearch.builder() .localityCode(criteria.getLocality()) - .householdType("FAMILY") .build(); if (StringUtils.hasLength(criteria.getHouseholdId())) { From 6c24de92d1ce755580a26e0531c4211f514bdfef Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Thu, 2 Jan 2025 15:49:47 +0530 Subject: [PATCH 18/19] Removing from models as already handled in different PR. --- .../models/household/HouseHoldType.java | 31 ------------------- .../common/models/household/Household.java | 5 +-- .../models/household/HouseholdSearch.java | 3 -- .../DownsyncCLFHousehold.java | 25 --------------- .../DownsyncCLFHouseholdResponse.java | 25 --------------- .../beneficiarydownsync/DownsyncCriteria.java | 2 -- .../HouseholdMemberMap.java | 20 ------------ health-services/referralmanagement/pom.xml | 2 +- 8 files changed, 2 insertions(+), 111 deletions(-) delete mode 100644 health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/HouseHoldType.java delete mode 100644 health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHousehold.java delete mode 100644 health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHouseholdResponse.java delete mode 100644 health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/HouseholdMemberMap.java diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/HouseHoldType.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/HouseHoldType.java deleted file mode 100644 index 08e1487dbdf..00000000000 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/HouseHoldType.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.egov.common.models.household; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -@JsonIgnoreProperties(ignoreUnknown = true) -public enum HouseHoldType { - - FAMILY("FAMILY"), - - COMMUNITY("COMMUNITY"), - - OTHER("OTHER"); - - private String value; - - HouseHoldType(String value) { - this.value = value; - } - - @JsonCreator - public static HouseHoldType fromValue(String text) { - for (HouseHoldType b : HouseHoldType.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - -} diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/Household.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/Household.java index f43bc53e2f2..63c982ff07f 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/Household.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/household/Household.java @@ -27,16 +27,13 @@ public class Household extends EgovOfflineModel { @JsonProperty("memberCount") @NotNull -// @Range(min = 0, max = 1000) + @Range(min = 0, max = 1000) private Integer memberCount = null; @JsonProperty("address") @Valid private Address address = null; - @JsonProperty("householdType") - private HouseHoldType householdType = null; - //TODO remove @JsonProperty("isDeleted") private Boolean isDeleted = Boolean.FALSE; 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 57612ce5835..4ff5ccec51e 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 @@ -25,9 +25,6 @@ public class HouseholdSearch extends EgovOfflineSearchModel { @JsonProperty("boundaryCode") private String localityCode = null; - @JsonProperty("householdType") - private String householdType = null; - @Exclude @JsonProperty("latitude") @DecimalMin("-90") diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHousehold.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHousehold.java deleted file mode 100644 index 6324a47d3ba..00000000000 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHousehold.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.egov.common.models.referralmanagement.beneficiarydownsync; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.egov.common.models.household.Household; - -import java.util.List; -import java.util.Map; - -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class DownsyncCLFHousehold { - - @JsonProperty("HouseholdCountMap") - List householdMemberCountMap; - - @JsonProperty("DownsyncCriteria") - DownsyncCriteria downsyncCriteria; - -} diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHouseholdResponse.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHouseholdResponse.java deleted file mode 100644 index 27c2bbd7cb6..00000000000 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCLFHouseholdResponse.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.egov.common.models.referralmanagement.beneficiarydownsync; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.egov.common.contract.response.ResponseInfo; - -import java.util.List; - -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class DownsyncCLFHouseholdResponse { - - - @JsonProperty("ResponseInfo") - private ResponseInfo responseInfo; - - @JsonProperty("Households") - private DownsyncCLFHousehold Households; - -} diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCriteria.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCriteria.java index 400de52948b..71816f7849f 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCriteria.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/DownsyncCriteria.java @@ -35,7 +35,5 @@ public class DownsyncCriteria { private Integer limit = 50; private Long totalCount; - - private String householdId; } diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/HouseholdMemberMap.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/HouseholdMemberMap.java deleted file mode 100644 index 4cc84ae19ae..00000000000 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/beneficiarydownsync/HouseholdMemberMap.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.egov.common.models.referralmanagement.beneficiarydownsync; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.egov.common.models.household.Household; - -@Data -@NoArgsConstructor -@AllArgsConstructor -@Builder -public class HouseholdMemberMap { - - private Household household; - - private Integer numberOfMembers; - - -} diff --git a/health-services/referralmanagement/pom.xml b/health-services/referralmanagement/pom.xml index 8b819e03376..9fedd00ee74 100644 --- a/health-services/referralmanagement/pom.xml +++ b/health-services/referralmanagement/pom.xml @@ -51,7 +51,7 @@ org.egov.common health-services-models - 1.0.23-dev-SNAPSHOT + 1.0.25-dev-SNAPSHOT compile From 94ec3c46e3303790e179f9b3662ac6586320de8e Mon Sep 17 00:00:00 2001 From: shubhang-egov Date: Thu, 2 Jan 2025 16:57:25 +0530 Subject: [PATCH 19/19] Adding comment for household api --- .../web/controllers/BeneficiaryDownsyncController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/web/controllers/BeneficiaryDownsyncController.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/web/controllers/BeneficiaryDownsyncController.java index d8e3f3d55ac..dfcb22d8203 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/web/controllers/BeneficiaryDownsyncController.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/web/controllers/BeneficiaryDownsyncController.java @@ -52,6 +52,7 @@ public ResponseEntity getBeneficaryData (@ApiParam(value = "Ca @PostMapping(value = "/v1/_get/CLF/household") public ResponseEntity getBeneficaryDataCFLHousehold (@ApiParam(value = "Capture details of Side Effect", required = true) @Valid @RequestBody DownsyncRequest request) { + // API response only contains household data and number of members present in that household log.info("UserUUID: {}", request.getRequestInfo().getUserInfo().getUuid()); log.info("Downsync RequestBody: {}", mapper.valueToTree(request).toString()); DownsyncCLFHousehold downsyncCLFHousehold = downsyncService.prepareDownsyncCLFDataHousehold(request);