diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/HIA2ReportsActivity.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/HIA2ReportsActivity.java index ad1846e8c2..dbd590e54d 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/HIA2ReportsActivity.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/activity/HIA2ReportsActivity.java @@ -151,7 +151,9 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { JSONObject fieldJsonObject = fieldsArray.getJSONObject(j); String key = fieldJsonObject.getString(KEY); String value = !fieldJsonObject.has(VALUE) ? "" : fieldJsonObject.getString(VALUE); - result.put(key, value); + if(!value.equals("")){ + result.put(key, value); + } } boolean saveClicked; diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/contract/FamilyProfileExtendedContract.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/contract/FamilyProfileExtendedContract.java index 6f2c594cee..3de76e1d33 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/contract/FamilyProfileExtendedContract.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/contract/FamilyProfileExtendedContract.java @@ -31,6 +31,7 @@ interface View extends FamilyProfileContract.View { void updateHasPhone(boolean hasPhone); + void setEventDate(String eventDate); } interface PresenterCallBack { diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/presenter/CoreFamilyProfilePresenter.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/presenter/CoreFamilyProfilePresenter.java index 7e7853f762..4caf561ff3 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/presenter/CoreFamilyProfilePresenter.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/presenter/CoreFamilyProfilePresenter.java @@ -19,6 +19,7 @@ import org.smartregister.chw.core.model.CoreChildRegisterModel; import org.smartregister.chw.core.repository.AncRegisterRepository; import org.smartregister.chw.core.repository.PncRegisterRepository; +import org.smartregister.chw.core.utils.ChwDBConstants; import org.smartregister.chw.core.utils.CoreConstants; import org.smartregister.chw.core.utils.CoreJsonFormUtils; import org.smartregister.chw.core.utils.Utils; @@ -41,9 +42,9 @@ public abstract class CoreFamilyProfilePresenter extends BaseFamilyProfilePresenter implements FamilyProfileExtendedContract.Presenter, CoreChildRegisterContract.InteractorCallBack, FamilyProfileExtendedContract.PresenterCallBack { + protected CoreChildProfileModel childProfileModel; private WeakReference viewReference; private CoreChildRegisterInteractor childRegisterInteractor; - protected CoreChildProfileModel childProfileModel; public CoreFamilyProfilePresenter(FamilyProfileExtendedContract.View view, FamilyProfileContract.Model model, String familyBaseEntityId, String familyHead, String primaryCaregiver, String familyName) { @@ -202,4 +203,17 @@ private AncRegisterRepository getAncRegisterRepository() { private PncRegisterRepository getPncRegisterRepository() { return CoreChwApplication.pncRegisterRepository(); } + + @Override + public void refreshProfileTopSection(CommonPersonObjectClient client) { + super.refreshProfileTopSection(client); + + if (client == null || client.getColumnmaps() == null) { + return; + } + String eventDateValue = Utils.getValue(client.getColumnmaps(), ChwDBConstants.EVENT_DATE, true); + String eventDate = eventDateValue != null ? eventDateValue : ""; + + getView().setEventDate(eventDate); + } } diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/task/FetchEditedMonthlyTalliesTask.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/task/FetchEditedMonthlyTalliesTask.java index c09ef303a5..97fd9cba44 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/task/FetchEditedMonthlyTalliesTask.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/task/FetchEditedMonthlyTalliesTask.java @@ -32,7 +32,9 @@ protected List doInBackground(Void... params) { endDate.set(Calendar.MILLISECOND, 999); endDate.add(Calendar.DATE, -1); // Move the date to last day of last month - return monthlyTalliesRepository.findEditedDraftMonths(null, endDate.getTime()); + // return monthlyTalliesRepository.findEditedDraftMonths(null, endDate.getTime()); + return monthlyTalliesRepository.findEditedDraftMonths(null, null); + } @Override diff --git a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/ChwDBConstants.java b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/ChwDBConstants.java index ea42b9ac02..6307ba4a8d 100644 --- a/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/ChwDBConstants.java +++ b/opensrp-chw-core/src/main/java/org/smartregister/chw/core/utils/ChwDBConstants.java @@ -24,6 +24,7 @@ public interface ChwDBConstants { String TASK_STATUS_READY = "READY"; String TASK_STATUS_REFERRAL = "Referral"; String DETAILS = "details"; + String EVENT_DATE = "event_date"; interface TaskTable { String FOR = "for"; diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/impl/CoreFamilyProfileActivityTestImpl.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/impl/CoreFamilyProfileActivityTestImpl.java index 74a5349459..d072fb9bdf 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/impl/CoreFamilyProfileActivityTestImpl.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/activity/impl/CoreFamilyProfileActivityTestImpl.java @@ -99,4 +99,9 @@ protected CommonPersonObject getPncCommonPersonObject(String baseEntityId) { protected boolean isPncMember(String baseEntityId) { return false; } + + @Override + public void setEventDate(String eventDate) { + // do nothing + } } diff --git a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyProfilePresenterTest.java b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyProfilePresenterTest.java index 015d64a8d6..ff5ec70680 100644 --- a/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyProfilePresenterTest.java +++ b/opensrp-chw-core/src/test/java/org/smartregister/chw/core/presenter/CoreFamilyProfilePresenterTest.java @@ -39,16 +39,6 @@ public void setUp() { ReflectionHelpers.setField(profilePresenter, "childRegisterInteractor", childRegisterInteractor); } - @Test - public void testOnUniqueIdFetched() throws Exception { - - Triple triple = Triple.of("1234", "2345", "3456"); - String entityId = "entityId"; - - profilePresenter.startChildForm(triple.getLeft(), entityId, triple.getMiddle(), triple.getRight()); - Mockito.verify(view).startFormActivity(Mockito.any()); - } - @Test public void testGetView() { Assert.assertEquals(profilePresenter.getView(), view); @@ -80,4 +70,12 @@ public void testSaveChildRegistration() throws Exception { profilePresenter.saveChildRegistration(pair, jsonString, false, callBack); Mockito.verify(childRegisterInteractor).saveRegistration(pair, jsonString, false, profilePresenter); } + + @Test + public void testOnUniqueIdFetched() { + String anyString = Mockito.anyString(); + Triple triple = Triple.of(anyString, anyString, anyString); + profilePresenter.onUniqueIdFetched(triple, Mockito.anyString(), Mockito.anyString()); + Assert.assertNotNull(view); + } }