From 331bfbbbdf1889b4038f1b32bcefabc404a31995 Mon Sep 17 00:00:00 2001 From: LZRS <12814349+LZRS@users.noreply.github.com> Date: Thu, 18 Nov 2021 16:08:12 +0300 Subject: [PATCH] LMH1-3: Modify query for members to check child's dod dod - date of death --- .../org/smartregister/chw/model/FamilyProfileMemberModel.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/model/FamilyProfileMemberModel.java b/opensrp-chw/src/main/java/org/smartregister/chw/model/FamilyProfileMemberModel.java index e24a1d8c8d..58d46dce56 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/model/FamilyProfileMemberModel.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/model/FamilyProfileMemberModel.java @@ -20,7 +20,9 @@ public String countSelect(String tableName, String mainCondition) { @Override public String mainSelect(String tableName, String mainCondition) { SmartRegisterQueryBuilder queryBuilder = new SmartRegisterQueryBuilder(); - queryBuilder.selectInitiateMainTable(tableName, mainColumns(tableName)); + String slectQuery = queryBuilder.selectInitiateMainTable(tableName, mainColumns(tableName)); + String coalesceDodQuery = slectQuery.replace(tableName + ".dod", String.format("coalesce(%s.dod, %s.dod) as dod", CoreConstants.TABLE_NAME.CHILD, tableName)); + queryBuilder.setSelectquery(coalesceDodQuery); queryBuilder.customJoin("LEFT JOIN " + CoreConstants.TABLE_NAME.CHILD + " ON " + tableName + "." + DBConstants.KEY.BASE_ENTITY_ID + " = " + CoreConstants.TABLE_NAME.CHILD + "." + DBConstants.KEY.BASE_ENTITY_ID + " COLLATE NOCASE "); return queryBuilder.mainCondition(mainCondition); }