Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.iemr.common.flw</groupId>
<artifactId>flw-api</artifactId>
<version>3.8.3</version>
<version>3.8.4</version>
<packaging>war</packaging>

<name>FLW-API</name>
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/com/iemr/flw/service/impl/UserServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<Integer> target) {
if (csv == null || csv.isBlank()) {
return;
Expand Down
Loading