Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

development screening and assessment #174

Merged
merged 12 commits into from
Nov 1, 2023
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package org.smartregister.chw.actionhelper;

import android.content.Context;

import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.smartregister.chw.anc.actionhelper.HomeVisitActionHelper;
import org.smartregister.chw.anc.domain.VisitDetail;
import org.smartregister.chw.anc.model.BaseAncHomeVisitAction;
import org.smartregister.chw.util.JsonFormUtils;
import org.smartregister.immunization.domain.ServiceWrapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import timber.log.Timber;

public class ChildDevelopmentScreeningActionHelper extends HomeVisitActionHelper {
private final String visitId;

private final ServiceWrapper serviceWrapper;

private String jsonString;

private final Map<String, Boolean> visitNumberMap = new HashMap<>();

private String child_development_issues;

public ChildDevelopmentScreeningActionHelper(String visitId, ServiceWrapper serviceWrapper) {
this.visitId = visitId;
this.serviceWrapper = serviceWrapper;
}

@Override
public void onPayloadReceived(String jsonPayload) {
try {
JSONObject jsonObject = new JSONObject(jsonPayload);
child_development_issues = JsonFormUtils.getCheckBoxValue(jsonObject, "child_development_issues");
} catch (JSONException e) {
Timber.e(e);
}
}

@Override
public void onJsonFormLoaded(String jsonString, Context context, Map<String, List<VisitDetail>> details) {
this.jsonString = jsonString;
}

@Override
public String getPreProcessed() {
try {
JSONObject jsonObject = new JSONObject(jsonString);
JSONArray fields = JsonFormUtils.fields(jsonObject);
populateVisitNumber();
for (Map.Entry<String, Boolean> entry : visitNumberMap.entrySet()) {
if (entry.getValue()) {
JsonFormUtils.getFieldJSONObject(fields, entry.getKey()).put("value", "true");
}
}
return jsonObject.toString();
} catch (JSONException e) {
Timber.e(e);
}
return super.getPreProcessed();
}

@Override
public String evaluateSubTitle() {
return null;
}

@Override
public BaseAncHomeVisitAction.Status evaluateStatusOnPayload() {
if (StringUtils.isBlank(child_development_issues)) {
return BaseAncHomeVisitAction.Status.PENDING;
} else {
return BaseAncHomeVisitAction.Status.COMPLETED;
}
}

private void populateVisitNumber() {
int visitNumber = visitNumber();
if ((visitNumber >= 3 && visitNumber <= 7) || visitNumber == 9 || (visitNumber >= 11 && visitNumber <= 15)) {
visitNumberMap.put("visit_3_visit_16", true);
} else if (visitNumber == 8 || visitNumber == 10 || visitNumber == 16) {
visitNumberMap.put("visit_3_visit_16", true);
visitNumberMap.put("visit_8_visit_10_visit_16", true);
}
}

private int visitNumber() {
if (this.visitId != null) {
return getPncHomeVisitNumber();
} else {
return getChildHomeVisitNumber();
}
}

private int getPncHomeVisitNumber() {
switch (this.visitId) {
case "1":
return 1;
case "3":
return 2;
case "8":
return 3;
case "21 - 27":
return 4;
case "35 - 41":
return 5;
default:
return 0;
}
}

private int getChildHomeVisitNumber() {
final Pattern lastIntPattern = Pattern.compile("[^0-9]+([0-9]+)$");
Matcher matcher = lastIntPattern.matcher(serviceWrapper.getName());
if (matcher.find()) {
String someNumberStr = matcher.group(1);
if (someNumberStr != null) {
return Integer.parseInt(someNumberStr);
}
}
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public static final class JsonForm{
private static final String CHILD_HV_PROBLEM_SOLVING_FORM = "child_hv_problem_solving";
private static final String CHILD_HV_NEWBORN_CARE_INTRO_FORM = "child_hv_newborn_introduction";
private static final String CHILD_HV_PLAY_ASSESSMENT_COUNSELLING = "child_hv_play_assessment_counselling";
private static final String CHILD_HV_DEVELOPMENT_SCREENING_ASSESSMENT = "child_hv_development_screening_assessment";
private static final String ICCM_MEDICAL_HISTORY = "iccm_medical_history";
private static final String ICCM_PHYSICAL_EXAMINATION = "iccm_physical_examination";
private static final String ICCM_MALARIA = "iccm_malaria";
Expand Down Expand Up @@ -146,10 +147,14 @@ public static String getChildHvProblemSolvingForm() {
public static String getChildHvNewBornCareIntroForm() {
return CHILD_HV_NEWBORN_CARE_INTRO_FORM;
}

public static String getChildHvPlayAssessmentCounselling() {
return CHILD_HV_PLAY_ASSESSMENT_COUNSELLING;
}

public static String getChildHvDevelopmentScreeningAssessment() {
return CHILD_HV_DEVELOPMENT_SCREENING_ASSESSMENT;
}

public static String getIccmMedicalHistory() {
return ICCM_MEDICAL_HISTORY;
Expand Down Expand Up @@ -188,6 +193,7 @@ public static final class Events {
public static final String AGYW_BIO_MEDICAL_SERVICES = "AGYW Bio Medical Services";
public static final String KVP_PREP_FOLLOWUP_VISIT = "Kvp PrEP Follow-up Visit";
public static final String PLAY_ASSESSMENT_COUNSELLING= "Play Assessment and Counselling";
public static final String DEVELOPMENT_SCREENING_AND_ASSESSMENT = "Development Screening and Assessment";
}

public static final class ActionList {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
{
"count": "1",
"encounter_type": "Development Screening and Assessment",
"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": "Tathmini ya maendeleo ya mtoto",
"fields": [
{
"key": "visit_3_visit_16",
"openmrs_entity_parent": "",
"openmrs_entity": "",
"openmrs_entity_id": "",
"type": "hidden"
},
{
"key": "visit_8_visit_10_visit_16",
"openmrs_entity_parent": "",
"openmrs_entity": "",
"openmrs_entity_id": "",
"type": "hidden"
},
{
"key": "child_development_issues",
"openmrs_entity_parent": "",
"openmrs_entity": "concept",
"openmrs_entity_id": "child_development_issues",
"type": "check_box",
"label": "Ninataka kukuuliza maswali mengine mahususi kuhusu ukuaji wa mtoto wako.\nJe, mtoto wako anaonekana kuwa na mojawapo ya yafuatayo?",
"label_text_style": "normal",
"text_color": "#C0C0C0",
"exclusive": [
"chk_none"
],
"options": [
{
"key": "chk_hearing_delay",
"text": "Kuchelewa kusikia",
"openmrs_entity": "concept",
"openmrs_entity_id": "chk_hearing_delay"
},
{
"key": "chk_speech_delay",
"text": "Kuchelewa kuongea",
"openmrs_entity": "concept",
"openmrs_entity_id": "chk_speech_delay"
},
{
"key": "chk_walking_delay",
"text": "Kuchelewa kutembea/kutamba/ ugumu kwenye mikono au miguu, au kukosa nguvu",
"openmrs_entity": "concept",
"openmrs_entity_id": "chk_walking_delay"
},
{
"key": "chk_has_fits",
"text": "Anakakamaa, au anapoteza fahamu",
"openmrs_entity": "concept",
"openmrs_entity_id": "chk_has_fits"
},
{
"key": "chk_none",
"text": "Hamna",
"openmrs_entity": "concept",
"openmrs_entity_id": "chk_none"
}
],
"v_required": {
"value": "true",
"err": "Tafadhali chagua angalau moja"
}
},
{
"key": "child_developmental_delays_note",
"openmrs_entity_parent": "",
"openmrs_entity": "concept",
"openmrs_entity_id": "",
"type": "toaster_notes",
"text": "Kuwa na mtoto aliyechelewa kufanya vitu kama watoto wengine wa umri wake kunaweza kukufanya ujisikie tofauti. Mtoto aliyechelewa katika kufika hatua zake za ukuaji anahitaji muda zaidi wa kucheza/kuongea na uchechemuzi kutoka kwa mlezi. Kwa kufuata hatua hizi mtoto anakuwa katika nafasi nzuri ya kufikia hatua zake za ukuaji. Asante kwa kueza kuzungumza na mimi leo kuhusu mambo haya, nimegundua tatizo ambalo nakushauri uwende kumuona daktari ili akusaidie, nitakupa rufaa uende kituo cha karibu nawe.",
"text_color": "#F91A00",
"toaster_type": "problem",
"relevance": {
"rules-engine": {
"ex-rules": {
"rules-file": "child_hv_development_screening_relevance.yml"
}
}
}
},
{
"key": "spacer_delays_note",
"openmrs_entity_parent": "",
"openmrs_entity": "concept",
"openmrs_entity_id": "",
"type": "spacer",
"spacer_height": "15dp",
"relevance": {
"rules-engine": {
"ex-rules": {
"rules-file": "child_hv_development_screening_relevance.yml"
}
}
}
},
{
"key": "developmental_milestone_info",
"openmrs_entity_parent": "",
"openmrs_entity": "concept",
"openmrs_entity_id": "developmental_milestone_info",
"type": "label",
"text": "Taarifa kwa MJA: Sema, \"Sasa nitakuonesha hatua za maendeleo ya ukuaji wa mtoto zinazoonesha ujuzi, uwezo na utambuzi katika kila hatua ya ukuaji wake. Ikiwa mtoto wako yuko mbele kidogo au nyuma kidogo katika umri fulani, hii ni kawaida. Kila mtoto ni tofauti. Fika katika kituo cha kutolea huduma za afya ili kueleza wasiwasi ulio nao\".",
"text_color": "#2D2E2D",
"label_text_style": "italic",
"has_bg": true
},
{
"key": "spacer",
"openmrs_entity_parent": "",
"openmrs_entity": "concept",
"openmrs_entity_id": "",
"type": "spacer",
"spacer_height": "10dp"
},
{
"key": "bango_kitita_reference",
"openmrs_entity_parent": "",
"openmrs_entity": "concept",
"openmrs_entity_id": "",
"type": "toaster_notes",
"toaster_type": "info",
"text": "Tafadhali rejea ukurasa wa KUJUA MAENDELEO YA AWALI YA MTOTO katika Bango Kitita ya Malezi."
}
]
}
}
Loading