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..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 @@ -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; @@ -90,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) { @@ -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 00a595f014..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 @@ -133,4 +133,7 @@ public static String getClientName(String firstName, String middleName, String l } } + public static String getLastIPTPServiceIteration(String visitKey) { + return String.valueOf(visitKey.charAt(4)); + } } 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)); + } }