diff --git a/opensrp-chw/build.gradle b/opensrp-chw/build.gradle index 4f79877dbe..8455a810cf 100644 --- a/opensrp-chw/build.gradle +++ b/opensrp-chw/build.gradle @@ -294,7 +294,7 @@ android { } dependencies { - implementation('org.smartregister:opensrp-client-chw-core:1.5.25-SNAPSHOT@aar') { + implementation('org.smartregister:opensrp-client-chw-core:1.5.22-SNAPSHOT@aar') { transitive = true exclude group: 'com.android.support', module: 'appcompat-v7' exclude group: 'androidx.legacy', module: 'legacy-support-v4' diff --git a/opensrp-chw/src/ba/assets/json.form-sw/community_responder_registration.json b/opensrp-chw/src/ba/assets/json.form-sw/community_responder_registration.json new file mode 100644 index 0000000000..cde23161e4 --- /dev/null +++ b/opensrp-chw/src/ba/assets/json.form-sw/community_responder_registration.json @@ -0,0 +1,112 @@ +{ + "validate_on_submit": true, + "show_errors_on_submit": false, + "count": "1", + "encounter_type": "Community Responder Registration", + "entity_id": "", + "relational_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": "Taarifa ya usafiri wa dharura", + "fields": [ + { + "key": "responder_label", + "type": "label", + "text": "Sajili taarifa ya usafiri wa dharura", + "left_padding": "20dp", + "right_padding": "20dp", + "text_size": "7sp", + "text_color": "#000000" + }, + { + "key": "responder_name", + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_entity_id": "responder_name", + "type": "edit_text", + "hint": "Jina", + "edit_type": "name", + "v_required": { + "value": "true", + "err": "Tafadhali ingiza jina la usafiri wa dharura" + }, + "v_regex": { + "value": "[A-Za-z\\u00C0-\\u017F\\s\\u00C0-\\u017F\\.\\-]*", + "err": "Tafadhali ingiza jina halali" + } + }, + { + "key": "responder_phone_number", + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_entity_id": "responder_phone_number", + "type": "edit_text", + "hint": "Namba ya simu", + "v_numeric": { + "value": "true", + "err": "Nambari lazima iwe jumla ya tarakimu 10 kwa urefu" + }, + "v_regex": { + "value": "(0[0-9]{9})|\\s*", + "err": "Nambari lazima iwe na tarakimu 10 na lazima ianze na 0." + }, + "v_required": { + "value": "true", + "err": "Tafadhali ingiza namba ya simu ya usafiri wa dharura" + } + }, + { + "key": "responder_gps", + "openmrs_entity_parent": "", + "openmrs_entity": "concept", + "openmrs_entity_id": "responder_gps", + "openmrs_data_type": "text", + "hint": "Eneo la kawaida", + "type": "gps" + } + ] + } +} \ No newline at end of file diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/activity/FamilyProfileActivity.java b/opensrp-chw/src/main/java/org/smartregister/chw/activity/FamilyProfileActivity.java index f6da6216d6..f853cb4dc8 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/activity/FamilyProfileActivity.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/activity/FamilyProfileActivity.java @@ -224,4 +224,8 @@ public void goToChildProfileActivity(CommonPersonObjectClient patient, Bundle bu startActivity(intent); } + @Override + public void setEventDate(String s) { + // do nothing + } } diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/activity/MalariaProfileActivity.java b/opensrp-chw/src/main/java/org/smartregister/chw/activity/MalariaProfileActivity.java index 1f170cf0d8..e6421cd073 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/activity/MalariaProfileActivity.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/activity/MalariaProfileActivity.java @@ -162,7 +162,7 @@ public void referToFacility() { try { if (BuildConfig.USE_UNIFIED_REFERRAL_APPROACH) { JSONObject formJson = getFormUtils().getFormJson(Constants.JSON_FORM.getMalariaReferralForm()); - formJson.put(Constants.REFERRAL_TASK_FOCUS, referralTypeModels.get(0).getReferralType()); + formJson.put(Constants.REFERRAL_TASK_FOCUS, referralTypeModels.get(0).getFocus()); ReferralRegistrationActivity.startGeneralReferralFormActivityForResults(this, baseEntityId, formJson, true); } else { startFormActivity(getFormUtils().getFormJson(getReferralTypeModels().get(0).getFormName())); diff --git a/opensrp-chw/src/test/java/org/smartregister/chw/activity/FamilyProfileActivityTest.java b/opensrp-chw/src/test/java/org/smartregister/chw/activity/FamilyProfileActivityTest.java index 552b8fc07d..e5896bd09f 100644 --- a/opensrp-chw/src/test/java/org/smartregister/chw/activity/FamilyProfileActivityTest.java +++ b/opensrp-chw/src/test/java/org/smartregister/chw/activity/FamilyProfileActivityTest.java @@ -35,6 +35,8 @@ import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; +import static org.mockito.Mockito.times; + @RunWith(RobolectricTestRunner.class) @Config(application = ChwApplication.class, sdk = 22) public class FamilyProfileActivityTest { @@ -195,4 +197,16 @@ public void testRefreshMemberFragment() throws Exception { Mockito.verify(spyActivity).refreshMemberList(FetchStatus.fetched); } + + @Test + public void testSetEventDate() { + FamilyProfileActivity spyActivity = Mockito.spy(activity); + spyActivity.setEventDate(Mockito.anyString()); + Mockito.verify(spyActivity, times(1)).setEventDate(Mockito.anyString()); + } + + @Test + public void testGetPresenter(){ + Assert.assertEquals(presenter, activity.getFamilyProfilePresenter()); + } } diff --git a/opensrp-chw/src/test/java/org/smartregister/chw/presenter/FamilyProfileActivityPresenterTest.java b/opensrp-chw/src/test/java/org/smartregister/chw/presenter/FamilyProfileActivityPresenterTest.java index e48f550610..0b95419e3f 100644 --- a/opensrp-chw/src/test/java/org/smartregister/chw/presenter/FamilyProfileActivityPresenterTest.java +++ b/opensrp-chw/src/test/java/org/smartregister/chw/presenter/FamilyProfileActivityPresenterTest.java @@ -4,6 +4,7 @@ import org.junit.Before; import org.junit.Test; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.smartregister.chw.BaseUnitTest; import org.smartregister.family.contract.FamilyProfileActivityContract; @@ -38,4 +39,11 @@ public void testDefaultSort() { Assert.assertEquals("visits.visit_date DESC", familyProfileActivityPresenter.getDefaultSortQuery()); } + @Test + public void testGetMainCondition() { + FamilyProfileActivityPresenter familyProfileActivityPresenter = Mockito.spy((FamilyProfileActivityPresenter) presenter); + familyProfileActivityPresenter.getMainCondition(); + Mockito.verify(familyProfileActivityPresenter, Mockito.times(1)).getMainCondition(); + } + }