Skip to content

Commit 524469e

Browse files
committed
list of constraints correction
1 parent fe1df34 commit 524469e

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/MctsBeneficiaryValueProcessorImpl.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ public void setLocationFieldsCSV(LocationFinder locationFinder, Map<String, Obje
265265
beneficiary.setTaluka(taluka);
266266
} else {
267267
beneficiary.setTaluka(null);
268+
beneficiary.setHealthBlock(null);
269+
beneficiary.setHealthFacility(null);
270+
beneficiary.setHealthSubFacility(null);
271+
beneficiary.setVillage(null);
272+
return;
268273
}
269274

270275
String villageSvid = record.get(KilkariConstants.NON_CENSUS_VILLAGE_ID) == null ? "0" : record.get(KilkariConstants.NON_CENSUS_VILLAGE_ID).toString();
@@ -276,7 +281,7 @@ public void setLocationFieldsCSV(LocationFinder locationFinder, Map<String, Obje
276281
LOGGER.debug("State: {}, District: {}, Taluka: {}, VilageSvid: {}, VillageCode: {}, HB: {}, HF: {}, HSF: {}", record.get(KilkariConstants.STATE_ID).toString(), districtCode,
277282
talukaCode.toString(), villageSvid, villageCode, healthBlockCode, healthFacilityCode, healthSubFacilityCode);
278283
Village village = locationFinder.getVillageHashMap().get(mapKey.toString() + "_" + Long.parseLong(villageCode) + "_" + Long.parseLong(villageSvid));
279-
if (village != null && taluka !=null && village.getId() != null) {
284+
if (village != null && village.getId() != null) {
280285
beneficiary.setVillage(village);
281286
} else {
282287
beneficiary.setVillage(null);
@@ -285,26 +290,33 @@ public void setLocationFieldsCSV(LocationFinder locationFinder, Map<String, Obje
285290
mapKey.append("_");
286291
mapKey.append(Long.parseLong(healthBlockCode));
287292
HealthBlock healthBlock = locationFinder.getHealthBlockHashMap().get(mapKey.toString());
288-
if (healthBlock != null && taluka !=null && healthBlock.getId() != null) {
293+
if (healthBlock != null && healthBlock.getId() != null) {
289294
beneficiary.setHealthBlock(healthBlock);
290295
} else {
291296
beneficiary.setHealthBlock(null);
297+
beneficiary.setHealthFacility(null);
298+
beneficiary.setHealthSubFacility(null);
299+
beneficiary.setVillage(null);
300+
return;
292301
}
293302
mapKey.append("_");
294303
mapKey.append(Long.parseLong(healthFacilityCode));
295304
HealthFacility healthFacility = locationFinder.getHealthFacilityHashMap().get(mapKey.toString());
296-
if (healthFacility != null && healthBlock !=null && healthFacility.getId() != null) {
305+
if (healthFacility != null && healthFacility.getId() != null) {
297306
beneficiary.setHealthFacility(healthFacility);
298307
} else {
299308
beneficiary.setHealthFacility(null);
309+
beneficiary.setHealthSubFacility(null);
310+
return;
300311
}
301312
mapKey.append("_");
302313
mapKey.append(Long.parseLong(healthSubFacilityCode));
303314
HealthSubFacility healthSubFacility = locationFinder.getHealthSubFacilityHashMap().get(mapKey.toString());
304-
if (healthSubFacility != null && healthFacility !=null && healthSubFacility.getId() != null) {
315+
if (healthSubFacility != null && healthSubFacility.getId() != null) {
305316
beneficiary.setHealthSubFacility(healthSubFacility);
306317
} else {
307318
beneficiary.setHealthSubFacility(null);
319+
return;
308320
}
309321
} else {
310322
throw new InvalidLocationException(String.format(KilkariConstants.INVALID_LOCATION, KilkariConstants.DISTRICT_ID, record.get(KilkariConstants.DISTRICT_ID)));

0 commit comments

Comments
 (0)