Skip to content

Commit

Permalink
Merge branch 'ecd-main-impl' into mnj-23-child-hv-malaria-prevention
Browse files Browse the repository at this point in the history
  • Loading branch information
devcolonel authored Nov 1, 2023
2 parents c72c377 + 1d86020 commit 00bee1f
Show file tree
Hide file tree
Showing 9 changed files with 436 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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;
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ public static final class JsonForm{
public static final String SKIN_TO_SKIN = "child_skin_to_skin";
public static final String CHILD_HV_COMP_FEEDING = "child_complementary_feeding";

public static final String CHILD_SAFETY_FORM = "child_hv_child_safety";

private static final String CHILD_HV_CCD_INTRODUCTION = "child_hv_ccd_introduction";

public static String getCbhsRegistrationForm() {
Expand Down Expand Up @@ -185,9 +187,12 @@ public static String getChildHvMalnutritionScreening() {

public static String getSkinToSkin() { return SKIN_TO_SKIN; }

public static String getChildSafetyForm() { return CHILD_SAFETY_FORM; }

public static String getChildHVCCDIntroduction() {
return CHILD_HV_CCD_INTRODUCTION;
}

public static String getChildHvCompFeeding(){
return CHILD_HV_COMP_FEEDING;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
}
87 changes: 87 additions & 0 deletions opensrp-chw/src/nacp/assets/json.form/child_hv_child_safety.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
}
Loading

0 comments on commit 00bee1f

Please sign in to comment.