From b608f2f552766e70c985d009de98484a80fcc448 Mon Sep 17 00:00:00 2001 From: vishwab1 Date: Wed, 9 Sep 2026 18:41:54 +0530 Subject: [PATCH 1/2] fix(user): append village ID into villageName so duplicate names are distinguishable Two different villages can legitimately share the same name (confirmed live: Nikshay village IDs 275135 and 275136 are both named "Sanapindapadar", under two different facilities in Boriguma block, Koraput). The mobile app's post-login village dropdown displays only villageName, so a user has no way to tell which entry is which - selecting the wrong one loads zero HH records for that village, since worklists filter by villageID, not by name. getUserDetail now appends the ID into each name segment, e.g. "Sanapindapadar,Sanapindapadar" + "275135,275136" becomes "Sanapindapadar (275135),Sanapindapadar (275136)". villageId and the response shape (two parallel comma-separated strings) are unchanged. Verified this requires zero mobile app changes: the village dropdown (ServiceLocationViewModel -> BindingUtils.setSpinnerItems) is a plain ArrayAdapter that displays villageName verbatim, and selection is by array position + villageId, not by matching name text. Co-Authored-By: Claude Sonnet 5 --- .../flw/service/impl/UserServiceImpl.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/main/java/com/iemr/flw/service/impl/UserServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/UserServiceImpl.java index 52d3eefb1..7537e5917 100644 --- a/src/main/java/com/iemr/flw/service/impl/UserServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/UserServiceImpl.java @@ -31,6 +31,19 @@ public UserServiceRoleDTO getUserDetail(Integer userId) { UserServiceRoleDTO userRole = userServiceRoleRepo.getUserRole(userId).get(0); userRole.setFacilityData(facilityDataService.buildFacilityData(userId, userRole.getRoleName())); + // Two different villages can legitimately share the same name (confirmed live: + // Nikshay village IDs 275135 and 275136 are both named "Sanapindapadar", under + // two different facilities in Boriguma block, Koraput). The mobile app's village + // dropdown displays villageName only, so a user has no way to tell which one + // they're picking - selecting the wrong one loads zero HH records for that + // village, since worklists filter by ID, not name. Append the ID into each name + // segment so duplicates are visually distinguishable. Response shape is + // unchanged - still two parallel comma-separated strings - so this needs zero + // mobile app changes: it just displays whatever text is in the name string + // (confirmed against ServiceLocationViewModel/BindingUtils.setSpinnerItems - + // plain ArrayAdapter, selection is by array position, not by name content). + userRole.setVillageName(appendVillageIds(userRole.getVillageId(), userRole.getVillageName())); + // Stop TB / Nikshay — additive only. This naturally returns nothing for // any user whose rows don't have NikshayTUID set, i.e. every non-Stop-TB // user. Fetched first so the district-by-block patch below can tell @@ -90,6 +103,32 @@ public UserServiceRoleDTO getUserDetail(Integer userId) { return userRole; } + // Zips the parallel villageId/villageName comma lists and rejoins each pair as + // "name (id)", e.g. "Sanapindapadar,Sanapindapadar" + "275135,275136" becomes + // "Sanapindapadar (275135),Sanapindapadar (275136)". Falls back to the original, + // unmodified villageName on any shape mismatch (null/blank, or unequal segment + // counts between the two lists) rather than risk emitting a malformed string. + private String appendVillageIds(String villageId, String villageName) { + if (villageId == null || villageId.isBlank() || villageName == null || villageName.isBlank()) { + return villageName; + } + String[] ids = villageId.split(",", -1); + String[] names = villageName.split(",", -1); + if (ids.length != names.length) { + logger.warn("villageId/villageName segment count mismatch ({} vs {}); leaving villageName unmodified", + ids.length, names.length); + return villageName; + } + StringBuilder result = new StringBuilder(); + for (int i = 0; i < names.length; i++) { + if (i > 0) { + result.append(","); + } + result.append(names[i].trim()).append(" (").append(ids[i].trim()).append(")"); + } + return result.toString(); + } + private void addCsvIds(String csv, Collection target) { if (csv == null || csv.isBlank()) { return; From 8a4360b9f5c619d9d1f7e303aa7558d74eeb74b4 Mon Sep 17 00:00:00 2001 From: vishwab1 Date: Fri, 11 Sep 2026 13:15:35 +0530 Subject: [PATCH 2/2] chore: bump version to 3.8.4 Co-Authored-By: Claude Sonnet 5 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e92d98637..1d3e88724 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.iemr.common.flw flw-api - 3.8.3 + 3.8.4 war FLW-API