forked from opensrp/opensrp-client-chw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ecd-main-impl' into mnj-23-child-hv-malaria-prevention
- Loading branch information
Showing
9 changed files
with
436 additions
and
0 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
...-chw/src/main/java/org/smartregister/chw/actionhelper/ChildHVChildSafetyActionHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
opensrp-chw/src/nacp/assets/json.form-sw/child_hv_child_safety.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
87
opensrp-chw/src/nacp/assets/json.form/child_hv_child_safety.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.