From 5f7f200dd8a652c6a31e90a714fa207450429c3f Mon Sep 17 00:00:00 2001 From: devcolonel Date: Thu, 19 Oct 2023 08:59:21 +0300 Subject: [PATCH 1/8] added Child Safety form with swahili content --- .../json.form-sw/child_hv_child_safety.json | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 opensrp-chw/src/nacp/assets/json.form-sw/child_hv_child_safety.json diff --git a/opensrp-chw/src/nacp/assets/json.form-sw/child_hv_child_safety.json b/opensrp-chw/src/nacp/assets/json.form-sw/child_hv_child_safety.json new file mode 100644 index 0000000000..254a36d8be --- /dev/null +++ b/opensrp-chw/src/nacp/assets/json.form-sw/child_hv_child_safety.json @@ -0,0 +1,87 @@ +{ + "count": "1", + "encounter_type": "Child Home Visit - Child Safety", + "entity_id": "", + "metadata": { + "start": { + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_data_type": "start", + "openmrs_entity_id": "163137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + "end": { + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_data_type": "end", + "openmrs_entity_id": "163138AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + "today": { + "openmrs_entity_parent": "", + "openmrs_entity": "encounter", + "openmrs_entity_id": "encounter_date" + }, + "deviceid": { + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_data_type": "deviceid", + "openmrs_entity_id": "163149AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + "subscriberid": { + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_data_type": "subscriberid", + "openmrs_entity_id": "163150AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + "simserial": { + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_data_type": "simserial", + "openmrs_entity_id": "163151AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + "phonenumber": { + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_data_type": "phonenumber", + "openmrs_entity_id": "163152AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + "encounter_location": "" + }, + "step1": { + "title": "Usalama wa Mtoto", + "fields": [ + { + "key": "counsel_child_Safety_note", + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_entity_id": "", + "type": "label", + "text": "Muelimishe mama juu ya usalama wa mtoto nyumbani.\nTafadhali fungua kitendea kazi namba 25 kwenye bango kitita ili kuendelea na mazungumzo", + "text_color": "#000000", + "label_text_style": "italic", + "has_bg": true + }, + { + "key": "child_safety_counselled", + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_entity_id": "", + "openmrs_data_type": "select one", + "type": "spinner", + "hint": "Je, umetoa ushauri juu ya usalama wa mtoto?", + "label_info_text": "Je, umetoa ushauri juu ya usalama wa mtoto?", + "values": [ + "Ndio", + "Hapana" + ], + "keys": [ + "Yes", + "No" + ], + "v_required": { + "value": "true", + "err": "Tafadhali chagua chaguo" + } + } + ] + } +} \ No newline at end of file From 0b1b48b5d7be09dc3b4ba1a1bc66d1e58a128cc0 Mon Sep 17 00:00:00 2001 From: devcolonel Date: Thu, 19 Oct 2023 08:59:45 +0300 Subject: [PATCH 2/8] added Child Safety form with english content --- .../json.form/child_hv_child_safety.json | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 opensrp-chw/src/nacp/assets/json.form/child_hv_child_safety.json diff --git a/opensrp-chw/src/nacp/assets/json.form/child_hv_child_safety.json b/opensrp-chw/src/nacp/assets/json.form/child_hv_child_safety.json new file mode 100644 index 0000000000..87591f5d02 --- /dev/null +++ b/opensrp-chw/src/nacp/assets/json.form/child_hv_child_safety.json @@ -0,0 +1,87 @@ +{ + "count": "1", + "encounter_type": "Child Home Visit - Child Safety", + "entity_id": "", + "metadata": { + "start": { + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_data_type": "start", + "openmrs_entity_id": "163137AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + "end": { + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_data_type": "end", + "openmrs_entity_id": "163138AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + "today": { + "openmrs_entity_parent": "", + "openmrs_entity": "encounter", + "openmrs_entity_id": "encounter_date" + }, + "deviceid": { + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_data_type": "deviceid", + "openmrs_entity_id": "163149AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + "subscriberid": { + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_data_type": "subscriberid", + "openmrs_entity_id": "163150AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + "simserial": { + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_data_type": "simserial", + "openmrs_entity_id": "163151AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + "phonenumber": { + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_data_type": "phonenumber", + "openmrs_entity_id": "163152AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + }, + "encounter_location": "" + }, + "step1": { + "title": "Child Safety ", + "fields": [ + { + "key": "counsel_child_Safety_note", + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_entity_id": "", + "type": "label", + "text": "Educate the mother on child safety at home. \nPlease refer to card number 25 in Bango Kitita to continue with the discussion", + "text_color": "#000000", + "label_text_style": "italic", + "has_bg": true + }, + { + "key": "child_safety_counselled", + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_entity_id": "", + "openmrs_data_type": "select one", + "type": "spinner", + "hint": "Did you conduct counselling on child safety?", + "label_info_text": "Did you conduct counselling on child safety?", + "values": [ + "Yes", + "No" + ], + "keys": [ + "Yes", + "No" + ], + "v_required": { + "value": "true", + "err": "Please select one option" + } + } + ] + } +} \ No newline at end of file From e0f75e52b434a13cf78424a3c48336a960bf7cc1 Mon Sep 17 00:00:00 2001 From: devcolonel Date: Thu, 19 Oct 2023 09:12:21 +0300 Subject: [PATCH 3/8] added action helper for child safety --- .../ChildHVChildSafetyActionHelper.java | 68 +++++++++++++++++++ .../org/smartregister/chw/util/Constants.java | 4 ++ .../ChildHomeVisitInteractorFlv.java | 28 ++++++++ .../src/nacp/res/values-sw/strings.xml | 1 + opensrp-chw/src/nacp/res/values/strings.xml | 1 + 5 files changed, 102 insertions(+) create mode 100644 opensrp-chw/src/main/java/org/smartregister/chw/actionhelper/ChildHVChildSafetyActionHelper.java diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/actionhelper/ChildHVChildSafetyActionHelper.java b/opensrp-chw/src/main/java/org/smartregister/chw/actionhelper/ChildHVChildSafetyActionHelper.java new file mode 100644 index 0000000000..6154817a22 --- /dev/null +++ b/opensrp-chw/src/main/java/org/smartregister/chw/actionhelper/ChildHVChildSafetyActionHelper.java @@ -0,0 +1,68 @@ +package org.smartregister.chw.actionhelper; + +import org.apache.commons.lang3.StringUtils; +import org.json.JSONException; +import org.json.JSONObject; +import org.smartregister.chw.R; +import org.smartregister.chw.anc.actionhelper.HomeVisitActionHelper; +import org.smartregister.chw.anc.model.BaseAncHomeVisitAction; +import org.smartregister.chw.util.JsonFormUtils; +import org.smartregister.immunization.domain.ServiceWrapper; + +import java.text.MessageFormat; + +import timber.log.Timber; + +public class ChildHVChildSafetyActionHelper extends HomeVisitActionHelper { + private String child_safety_counselled; + ServiceWrapper serviceWrapper; + + public ChildHVChildSafetyActionHelper(ServiceWrapper serviceWrapper){ + this.serviceWrapper = serviceWrapper; + } + + @Override + public void onPayloadReceived(String s) { + try { + JSONObject jsonObject = new JSONObject(s); + child_safety_counselled = JsonFormUtils.getValue(jsonObject, "child_safety_counselled"); + } catch (JSONException e) { + Timber.e(e); + } + } + + @Override + public String evaluateSubTitle() { + child_safety_counselled = getYesNoTranslation(child_safety_counselled); + return MessageFormat.format("{0}: {1}", context.getString(R.string.child_safety), child_safety_counselled); + } + + public String getYesNoTranslation(String subtitleText) { + if ("yes".equals(subtitleText)) { + return context.getString(R.string.yes); + } else if ("no".equals(subtitleText)) { + return context.getString(R.string.no); + } else { + return subtitleText; + } + } + + @Override + public String postProcess(String jsonPayload) { + return super.postProcess(jsonPayload); + } + + @Override + public BaseAncHomeVisitAction.Status evaluateStatusOnPayload() { + if (StringUtils.isBlank(child_safety_counselled)) { + return BaseAncHomeVisitAction.Status.PENDING; + } + + if (StringUtils.isNotBlank(child_safety_counselled)) { + return BaseAncHomeVisitAction.Status.COMPLETED; + } else { + return BaseAncHomeVisitAction.Status.PARTIALLY_COMPLETED; + } + } +} + diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/util/Constants.java b/opensrp-chw/src/main/java/org/smartregister/chw/util/Constants.java index da65b9be18..4ab65ace47 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/util/Constants.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/util/Constants.java @@ -106,6 +106,8 @@ public static final class JsonForm{ public static final String SKIN_TO_SKIN = "child_skin_to_skin"; + public static final String CHILD_SAFETY_FORM = "child_hv_child_safety"; + public static String getCbhsRegistrationForm() { return CBHS_REGISTRATION_FORM; } @@ -168,6 +170,8 @@ public static String getChildHvMalnutritionScreening() { public static String getSkinToSkin() { return SKIN_TO_SKIN; } + public static String getChildSafetyForm() { return CHILD_SAFETY_FORM; } + } public static final class Events { diff --git a/opensrp-chw/src/nacp/java/org/smartregister/chw/interactor/ChildHomeVisitInteractorFlv.java b/opensrp-chw/src/nacp/java/org/smartregister/chw/interactor/ChildHomeVisitInteractorFlv.java index 7858946ba7..c5fc8c6edb 100644 --- a/opensrp-chw/src/nacp/java/org/smartregister/chw/interactor/ChildHomeVisitInteractorFlv.java +++ b/opensrp-chw/src/nacp/java/org/smartregister/chw/interactor/ChildHomeVisitInteractorFlv.java @@ -11,6 +11,7 @@ import org.json.JSONException; import org.json.JSONObject; import org.smartregister.chw.R; +import org.smartregister.chw.actionhelper.ChildHVChildSafetyActionHelper; import org.smartregister.chw.actionhelper.ExclusiveBreastFeedingAction; import org.smartregister.chw.actionhelper.ToddlerDangerSignsBabyHelper; import org.smartregister.chw.actionhelper.MalnutritionScreeningActionHelper; @@ -44,6 +45,7 @@ protected void bindEvents(Map serviceWrapperMap) throws evaluateObsAndIllness(); evaluateMalnutritionScreening(serviceWrapperMap); evaluateProblemSolving(); + evaluateChildSafety(serviceWrapperMap); } catch (BaseAncHomeVisitAction.ValidationException e) { throw (e); } catch (Exception e) { @@ -383,4 +385,30 @@ protected void evaluateExclusiveBreastFeeding(Map servic .build(); actionList.put(title, action); } + + private void evaluateChildSafety(Map serviceWrapperMap) throws Exception { + ServiceWrapper serviceWrapper = serviceWrapperMap.get("Child Safety"); + if (serviceWrapper == null) return; + Alert alert = serviceWrapper.getAlert(); + if (alert == null || new LocalDate().isBefore(new LocalDate(alert.startDate()))) return; + + boolean isOverdue = new LocalDate().isAfter(new LocalDate(alert.startDate()).plusDays(14)); + String dueState = !isOverdue ? context.getString(R.string.due) : context.getString(R.string.overdue); + + ChildHVChildSafetyActionHelper childHVChildSafetyActionHelper = new ChildHVChildSafetyActionHelper(serviceWrapper); + Map> details = getDetails(Constants.EventType.CHILD_HOME_VISIT); + + String title = context.getString(R.string.child_safety); + + BaseAncHomeVisitAction childSafetyAction = new BaseAncHomeVisitAction.Builder(context, title) + .withOptional(false) + .withDetails(details) + .withFormName(Constants.JsonForm.getChildSafetyForm()) + .withScheduleStatus(!isOverdue ? BaseAncHomeVisitAction.ScheduleStatus.DUE : BaseAncHomeVisitAction.ScheduleStatus.OVERDUE) + .withProcessingMode(BaseAncHomeVisitAction.ProcessingMode.COMBINED) + .withSubtitle(MessageFormat.format("{0}{1}", dueState, DateTimeFormat.forPattern("dd MMM yyyy").print(new DateTime(serviceWrapper.getVaccineDate())))) + .withHelper(childHVChildSafetyActionHelper) + .build(); + actionList.put(title, childSafetyAction); + } } diff --git a/opensrp-chw/src/nacp/res/values-sw/strings.xml b/opensrp-chw/src/nacp/res/values-sw/strings.xml index 88cc36cf6e..57e0e69ddd 100644 --- a/opensrp-chw/src/nacp/res/values-sw/strings.xml +++ b/opensrp-chw/src/nacp/res/values-sw/strings.xml @@ -490,6 +490,7 @@ Matembeleo ya huduma za iCCM + Usalama wa Mtoto \ No newline at end of file diff --git a/opensrp-chw/src/nacp/res/values/strings.xml b/opensrp-chw/src/nacp/res/values/strings.xml index c9a60eec2b..6a8ec21bd9 100644 --- a/opensrp-chw/src/nacp/res/values/strings.xml +++ b/opensrp-chw/src/nacp/res/values/strings.xml @@ -533,5 +533,6 @@ Problem Solving Playing and Communicating challenge + Child Safety \ No newline at end of file From cd6b223866ab08b3c1c0b77513d6657ea1aad6fb Mon Sep 17 00:00:00 2001 From: devcolonel Date: Thu, 19 Oct 2023 09:22:13 +0300 Subject: [PATCH 4/8] added recurring service for child safety --- .../nacp/assets/recurring_service_types.json | 157 ++++++++++++++++++ opensrp-chw/src/nacp/assets/services.json | 3 + 2 files changed, 160 insertions(+) diff --git a/opensrp-chw/src/nacp/assets/recurring_service_types.json b/opensrp-chw/src/nacp/assets/recurring_service_types.json index e2c63d4742..4112176116 100644 --- a/opensrp-chw/src/nacp/assets/recurring_service_types.json +++ b/opensrp-chw/src/nacp/assets/recurring_service_types.json @@ -763,5 +763,162 @@ } } ] + }, + { + "type": "Child safety", + "service_logic": "", + "service_group": "child", + "openmrs_service_name": { + "parent_entity": "", + "entity": "concept", + "entity_id": "" + }, + "openmrs_date": { + "parent_entity": "", + "entity": "encounter", + "entity_id": "encounter_date" + }, + "services": [ + { + "id": "160", + "name": "Child safety6", + "schedule": { + "due": { + "reference": "dob", + "offset": "+3m" + }, + "expiry": { + "reference": "dob", + "offset": "+4m" + } + } + }, + { + "id": "161", + "name": "Child safety7", + "schedule": { + "due": { + "reference": "dob", + "offset": "+1m" + }, + "expiry": { + "reference": "dob", + "offset": "+5m" + } + } + }, + { + "id": "162", + "name": "Child safety8", + "schedule": { + "due": { + "reference": "dob", + "offset": "+1m" + }, + "expiry": { + "reference": "dob", + "offset": "+6m" + } + } + }, + { + "id": "163", + "name": "Child safety9", + "schedule": { + "due": { + "reference": "dob", + "offset": "+1m" + }, + "expiry": { + "reference": "dob", + "offset": "+7m" + } + } + }, + { + "id": "164", + "name": "Child safety10", + "schedule": { + "due": { + "reference": "dob", + "offset": "+1m" + }, + "expiry": { + "reference": "dob", + "offset": "+8m" + } + } + }, + { + "id": "165", + "name": "Child safety11", + "schedule": { + "due": { + "reference": "dob", + "offset": "+1m" + }, + "expiry": { + "reference": "dob", + "offset": "+9m" + } + } + }, + { + "id": "166", + "name": "Child safety12", + "schedule": { + "due": { + "reference": "dob", + "offset": "+1m" + }, + "expiry": { + "reference": "dob", + "offset": "+10m" + } + } + }, + { + "id": "167", + "name": "Child safety13", + "schedule": { + "due": { + "reference": "dob", + "offset": "+1m" + }, + "expiry": { + "reference": "dob", + "offset": "+11m" + } + } + }, + { + "id": "168", + "name": "Child safety14", + "schedule": { + "due": { + "reference": "dob", + "offset": "+1m" + }, + "expiry": { + "reference": "dob", + "offset": "+12m" + } + } + }, + { + "id": "169", + "name": "Child safety15", + "schedule": { + "due": { + "reference": "dob", + "offset": "+1m" + }, + "expiry": { + "reference": "dob", + "offset": "+13m" + } + } + } + ] } ] \ No newline at end of file diff --git a/opensrp-chw/src/nacp/assets/services.json b/opensrp-chw/src/nacp/assets/services.json index 1ec2eea29c..7e95657602 100644 --- a/opensrp-chw/src/nacp/assets/services.json +++ b/opensrp-chw/src/nacp/assets/services.json @@ -14,6 +14,9 @@ }, { "type": "Malnutrition Screening" + }, + { + "type": "Child safety" } ] } From 98ab848bfcb7861e25655e0a77a129db9ace43f3 Mon Sep 17 00:00:00 2001 From: devcolonel Date: Fri, 20 Oct 2023 12:50:45 +0300 Subject: [PATCH 5/8] update recurring service for child safety module --- .../nacp/assets/recurring_service_types.json | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/opensrp-chw/src/nacp/assets/recurring_service_types.json b/opensrp-chw/src/nacp/assets/recurring_service_types.json index 4112176116..8d55dd96c4 100644 --- a/opensrp-chw/src/nacp/assets/recurring_service_types.json +++ b/opensrp-chw/src/nacp/assets/recurring_service_types.json @@ -785,11 +785,11 @@ "schedule": { "due": { "reference": "dob", - "offset": "+3m" + "offset": "+2m" }, "expiry": { "reference": "dob", - "offset": "+4m" + "offset": "+3m" } } }, @@ -803,7 +803,7 @@ }, "expiry": { "reference": "dob", - "offset": "+5m" + "offset": "+4m" } } }, @@ -817,7 +817,7 @@ }, "expiry": { "reference": "dob", - "offset": "+6m" + "offset": "+5m" } } }, @@ -831,7 +831,7 @@ }, "expiry": { "reference": "dob", - "offset": "+7m" + "offset": "+6m" } } }, @@ -845,7 +845,7 @@ }, "expiry": { "reference": "dob", - "offset": "+8m" + "offset": "+7m" } } }, @@ -859,7 +859,7 @@ }, "expiry": { "reference": "dob", - "offset": "+9m" + "offset": "+8m" } } }, @@ -873,7 +873,7 @@ }, "expiry": { "reference": "dob", - "offset": "+10m" + "offset": "+9m" } } }, @@ -887,7 +887,7 @@ }, "expiry": { "reference": "dob", - "offset": "+11m" + "offset": "+10m" } } }, @@ -901,7 +901,7 @@ }, "expiry": { "reference": "dob", - "offset": "+12m" + "offset": "+11m" } } }, @@ -915,7 +915,7 @@ }, "expiry": { "reference": "dob", - "offset": "+13m" + "offset": "+1yr" } } } From 9789e3e4e34414f48ee6a880cab15af86461afeb Mon Sep 17 00:00:00 2001 From: devcolonel Date: Mon, 23 Oct 2023 12:09:44 +0300 Subject: [PATCH 6/8] update recurring service name --- opensrp-chw/src/nacp/assets/services.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensrp-chw/src/nacp/assets/services.json b/opensrp-chw/src/nacp/assets/services.json index 7e95657602..9a3646a476 100644 --- a/opensrp-chw/src/nacp/assets/services.json +++ b/opensrp-chw/src/nacp/assets/services.json @@ -16,7 +16,7 @@ "type": "Malnutrition Screening" }, { - "type": "Child safety" + "type": "Child Safety" } ] } From b5b8e1afda31b41ed9f87069557d740f9e47da70 Mon Sep 17 00:00:00 2001 From: devcolonel Date: Wed, 1 Nov 2023 13:22:53 +0300 Subject: [PATCH 7/8] update service type --- opensrp-chw/src/nacp/assets/recurring_service_types.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensrp-chw/src/nacp/assets/recurring_service_types.json b/opensrp-chw/src/nacp/assets/recurring_service_types.json index 2d3ef35712..5fc1daab82 100644 --- a/opensrp-chw/src/nacp/assets/recurring_service_types.json +++ b/opensrp-chw/src/nacp/assets/recurring_service_types.json @@ -765,7 +765,7 @@ ] }, { - "type": "Child safety", + "type": "Child Safety", "service_logic": "", "service_group": "child", "openmrs_service_name": { From c626de91c601f91dd26cdcbbea6a57cef0ec4bf4 Mon Sep 17 00:00:00 2001 From: devcolonel Date: Wed, 1 Nov 2023 13:26:28 +0300 Subject: [PATCH 8/8] update translation value --- .../chw/actionhelper/ChildHVChildSafetyActionHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/actionhelper/ChildHVChildSafetyActionHelper.java b/opensrp-chw/src/main/java/org/smartregister/chw/actionhelper/ChildHVChildSafetyActionHelper.java index 6154817a22..feaadf16b9 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/actionhelper/ChildHVChildSafetyActionHelper.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/actionhelper/ChildHVChildSafetyActionHelper.java @@ -38,9 +38,9 @@ public String evaluateSubTitle() { } public String getYesNoTranslation(String subtitleText) { - if ("yes".equals(subtitleText)) { + if ("Yes".equals(subtitleText)) { return context.getString(R.string.yes); - } else if ("no".equals(subtitleText)) { + } else if ("No".equals(subtitleText)) { return context.getString(R.string.no); } else { return subtitleText;