From be9205e816daf53c3fc2a7aa423bc73625b5eca9 Mon Sep 17 00:00:00 2001 From: paulinembabu Date: Wed, 14 Oct 2020 18:44:30 +0300 Subject: [PATCH] Changes the access on methods --- .../java/org/smartregister/chw/core/dao/ChildDao.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/ChildDao.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/ChildDao.java index 69d4c822a3..3481233e34 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/ChildDao.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/dao/ChildDao.java @@ -56,8 +56,8 @@ public static List getFamilyChildren(String familyBaseEntityID) { return values; } - public static Child getChild(String baseEntityID) { - String sql = "select c.base_entity_id , c.first_name , c.last_name , c.middle_name , c.mother_entity_id , c.relational_id , c.dob , c.date_created , lastVisit.last_visit_date , last_visit_not_done_date " + + public static String getChildQuery(String baseEntityID){ + return "select c.base_entity_id , c.first_name , c.last_name , c.middle_name , c.mother_entity_id , c.relational_id , c.dob , c.date_created , lastVisit.last_visit_date , last_visit_not_done_date " + "from ec_child c " + "inner join ec_family_member m on c.base_entity_id = m.base_entity_id COLLATE NOCASE " + "inner join ec_family f on f.base_entity_id = m.relational_id COLLATE NOCASE " + @@ -77,6 +77,10 @@ public static Child getChild(String baseEntityID) { "and m.date_removed is null and m.is_closed = 0 " + "and ((( julianday('now') - julianday(c.dob))/365.25) < 5) and c.is_closed = 0 " + " and (( ( ifnull(entry_point,'') <> 'PNC' ) ) or (ifnull(entry_point,'') = 'PNC' and ( date (c.dob, '+28 days') <= date() and ((SELECT is_closed FROM ec_family_member WHERE base_entity_id = mother_entity_id ) = 0))) or (ifnull(entry_point,'') = 'PNC' and (SELECT is_closed FROM ec_family_member WHERE base_entity_id = mother_entity_id ) = 1)) "; + } + + public static Child getChild(String baseEntityID) { + String sql = getChildQuery(baseEntityID); List values = AbstractDao.readData(sql, getChildDataMap()); if (values == null || values.size() != 1) @@ -85,7 +89,8 @@ public static Child getChild(String baseEntityID) { return values.get(0); } - private static DataMap getChildDataMap() { + + public static DataMap getChildDataMap() { return c -> { Child record = new Child(); record.setBaseEntityID(getCursorValue(c, "base_entity_id"));