From 1e688f090ab3bf642cda4f9b6b2be2595fa86206 Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Thu, 18 Feb 2021 13:33:35 +0500 Subject: [PATCH 1/3] Bumped up core library version Fixed home tasks dissapearing when sync is enabled --- opensrp-chw/build.gradle | 2 +- .../chw/application/ChwApplicationFlv.java | 5 +++++ .../interactor/DefaultAncHomeVisitInteractorFlv.java | 12 ++++++++---- .../main/java/org/smartregister/chw/util/Utils.java | 4 ++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/opensrp-chw/build.gradle b/opensrp-chw/build.gradle index 0a400b2260..034380a141 100644 --- a/opensrp-chw/build.gradle +++ b/opensrp-chw/build.gradle @@ -318,7 +318,7 @@ android { } dependencies { - implementation('org.smartregister:opensrp-client-chw-core:2.0.17-SNAPSHOT@aar') { + implementation('org.smartregister:opensrp-client-chw-core:2.0.18-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/drc/java/org/smartregister/chw/application/ChwApplicationFlv.java b/opensrp-chw/src/drc/java/org/smartregister/chw/application/ChwApplicationFlv.java index 22320a49d6..28f923ac5d 100644 --- a/opensrp-chw/src/drc/java/org/smartregister/chw/application/ChwApplicationFlv.java +++ b/opensrp-chw/src/drc/java/org/smartregister/chw/application/ChwApplicationFlv.java @@ -2,6 +2,11 @@ public class ChwApplicationFlv extends DefaultChwApplicationFlv { + @Override + public boolean saveOnSubmission() { + return true; + } + @Override public boolean hasFamilyKitCheck() { return true; diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/interactor/DefaultAncHomeVisitInteractorFlv.java b/opensrp-chw/src/main/java/org/smartregister/chw/interactor/DefaultAncHomeVisitInteractorFlv.java index 2669b4fab2..e6c6131474 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/interactor/DefaultAncHomeVisitInteractorFlv.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/interactor/DefaultAncHomeVisitInteractorFlv.java @@ -45,6 +45,8 @@ import timber.log.Timber; +import static org.smartregister.chw.util.Utils.getLastIPTPServiceIteration; + public abstract class DefaultAncHomeVisitInteractorFlv implements AncHomeVisitInteractor.Flavor { protected MemberObject memberObject; @@ -175,8 +177,9 @@ protected void evaluateTTImmunization(VaccineTaskModel vaccineTaskModel) throws return; } // compute the due date + final Triple individualVaccine = VaccineScheduleUtil.getIndividualVaccine(vaccineTaskModel, "TT"); - if (individualVaccine == null || individualVaccine.getLeft().isAfter(new DateTime())) { + if (individualVaccine == null) { return; } @@ -210,7 +213,7 @@ protected void evaluateTTImmunization(VaccineTaskModel vaccineTaskModel) throws .build(); // don't show if its after now - if (!individualVaccine.getLeft().isAfterNow()) { + if (editMode || !individualVaccine.getLeft().isAfterNow()) { actionList.put(title, tt_immunization); } } @@ -247,8 +250,9 @@ protected void evaluateIPTP() throws Exception { if (serviceWrapper == null && !editMode) return; if (!editMode) serviceIteration = serviceWrapper.getName().substring(serviceWrapper.getName().length() - 1); - else - serviceIteration = visitDetail.get(0).getPreProcessedJson().substring(visitDetail.get(0).getPreProcessedJson().length() - 1); + else { + serviceIteration = getLastIPTPServiceIteration(visitDetail.get(0).getVisitKey()); + } String iptp = MessageFormat.format(context.getString(R.string.anc_home_visit_iptp_sp), serviceIteration); String dueState = (overdueMonth < 1) ? context.getString(R.string.due) : context.getString(R.string.overdue); diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/util/Utils.java b/opensrp-chw/src/main/java/org/smartregister/chw/util/Utils.java index 8ce25f4b1c..e3f99a7c8c 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/util/Utils.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/util/Utils.java @@ -132,4 +132,8 @@ public static String getClientName(String firstName, String middleName, String l return Utils.getName(trimFirstName, trimMiddleName); } } + + public static String getLastIPTPServiceIteration(String visitKey) { + return String.valueOf(visitKey.charAt(4)); + } } From e481c963dedf84b84afaf6aab00865081c4a4968 Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Thu, 18 Feb 2021 17:04:27 +0500 Subject: [PATCH 2/3] Fixed arrangement of tasks in AncHomeVisitInteractor --- .../smartregister/chw/interactor/AncHomeVisitInteractorFlv.java | 2 +- .../chw/interactor/DefaultAncHomeVisitInteractorFlv.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/opensrp-chw/src/drc/java/org/smartregister/chw/interactor/AncHomeVisitInteractorFlv.java b/opensrp-chw/src/drc/java/org/smartregister/chw/interactor/AncHomeVisitInteractorFlv.java index 86b6d36add..b4b1dda4e2 100644 --- a/opensrp-chw/src/drc/java/org/smartregister/chw/interactor/AncHomeVisitInteractorFlv.java +++ b/opensrp-chw/src/drc/java/org/smartregister/chw/interactor/AncHomeVisitInteractorFlv.java @@ -64,9 +64,9 @@ public LinkedHashMap calculateActions(BaseAncHom evaluateANCCard(); evaluateDeliveryKit(); evaluateHealthFacilityVisit(dateMap); - evaluateObservation(); evaluateTTImmunization(vaccineTaskModel); evaluateIPTP(); + evaluateObservation(); } catch (BaseAncHomeVisitAction.ValidationException e) { throw (e); } catch (Exception e) { diff --git a/opensrp-chw/src/main/java/org/smartregister/chw/interactor/DefaultAncHomeVisitInteractorFlv.java b/opensrp-chw/src/main/java/org/smartregister/chw/interactor/DefaultAncHomeVisitInteractorFlv.java index e6c6131474..16c7162719 100644 --- a/opensrp-chw/src/main/java/org/smartregister/chw/interactor/DefaultAncHomeVisitInteractorFlv.java +++ b/opensrp-chw/src/main/java/org/smartregister/chw/interactor/DefaultAncHomeVisitInteractorFlv.java @@ -92,9 +92,9 @@ public LinkedHashMap calculateActions(BaseAncHom evaluateSleepingUnderLLITN(); evaluateANCCard(); evaluateHealthFacilityVisit(dateMap); - evaluateObservation(); evaluateTTImmunization(vaccineTaskModel); evaluateIPTP(); + evaluateObservation(); } catch (BaseAncHomeVisitAction.ValidationException e) { throw (e); } catch (Exception e) { From 444e12a8b5279dcb80c1d884d18b355f26ff06b0 Mon Sep 17 00:00:00 2001 From: Qazi Abubakar Date: Fri, 19 Feb 2021 10:49:56 +0500 Subject: [PATCH 3/3] Added new test case --- .../test/java/org/smartregister/chw/util/UtilsTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/opensrp-chw/src/test/java/org/smartregister/chw/util/UtilsTest.java b/opensrp-chw/src/test/java/org/smartregister/chw/util/UtilsTest.java index 6cd5c1590c..802ff2df9c 100644 --- a/opensrp-chw/src/test/java/org/smartregister/chw/util/UtilsTest.java +++ b/opensrp-chw/src/test/java/org/smartregister/chw/util/UtilsTest.java @@ -96,4 +96,11 @@ public void testGetWFHZScore() { double score = org.smartregister.chw.util.Utils.getWFHZScore("Male", "70", "70"); Assert.assertNotEquals(100.0, score, 0.0); } + + @Test + public void testGetLastIPTPServiceIteration() { + String iteration1 = "1"; + String visitKeyOne = "iptp1_dose"; + Assert.assertEquals(iteration1, org.smartregister.chw.util.Utils.getLastIPTPServiceIteration(visitKeyOne)); + } }