From 4a76ecbcb6aec364c72515b6bc60f6bee936181c Mon Sep 17 00:00:00 2001 From: sowmyas Date: Mon, 20 Oct 2014 12:57:59 +0530 Subject: [PATCH] Sowmya | #1139 | Child Sickness related indicators are now reported only when service provided date and form submission date falls on same reporting month. --- .../drishti/service/reporting/ChildReportingService.java | 7 ++++--- .../service/reporting/ChildReportingServiceTest.java | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drishti-mother-child/src/main/java/org/ei/drishti/service/reporting/ChildReportingService.java b/drishti-mother-child/src/main/java/org/ei/drishti/service/reporting/ChildReportingService.java index 458cf7a3da..de06b553e6 100644 --- a/drishti-mother-child/src/main/java/org/ei/drishti/service/reporting/ChildReportingService.java +++ b/drishti-mother-child/src/main/java/org/ei/drishti/service/reporting/ChildReportingService.java @@ -208,11 +208,12 @@ public void sickVisitHappened(SafeMap reportData) { Location location = loadLocationOfChild(child); LocalDate childDateOfBirth = parse(child.dateOfBirth()); - if (childDateOfBirth.plusYears(CHILD_DIARRHEA_THRESHOLD_IN_YEARS).isAfter(LocalDate.parse(reportData.get(SUBMISSION_DATE_FIELD_NAME)))) { + String submissionDate = reportData.get(SUBMISSION_DATE_FIELD_NAME); + if (childDateOfBirth.plusYears(CHILD_DIARRHEA_THRESHOLD_IN_YEARS).isAfter(LocalDate.parse(submissionDate))) { if (!isBlank(reportData.get(CHILD_SIGNS)) && reportData.get(CHILD_SIGNS).contains(AllConstants.CommonChildFormFields.DIARRHEA_VALUE)) { - reportToBoth(child, CHILD_DIARRHEA, reportData.get(SICK_VISIT_DATE), location); + reportToBoth(child, CHILD_DIARRHEA, reportData.get(SICK_VISIT_DATE), submissionDate, location); } else if (!isBlank(reportData.get(REPORT_CHILD_DISEASE)) && reportData.get(REPORT_CHILD_DISEASE).contains(AllConstants.ChildIllnessFields.DIARRHEA_DEHYDRATION_VALUE)) { - reportToBoth(child, CHILD_DIARRHEA, reportData.get(REPORT_CHILD_DISEASE_DATE), location); + reportToBoth(child, CHILD_DIARRHEA, reportData.get(REPORT_CHILD_DISEASE_DATE), submissionDate, location); } } } diff --git a/drishti-mother-child/src/test/java/org/ei/drishti/service/reporting/ChildReportingServiceTest.java b/drishti-mother-child/src/test/java/org/ei/drishti/service/reporting/ChildReportingServiceTest.java index 1f54948538..d66af85193 100644 --- a/drishti-mother-child/src/test/java/org/ei/drishti/service/reporting/ChildReportingServiceTest.java +++ b/drishti-mother-child/src/test/java/org/ei/drishti/service/reporting/ChildReportingServiceTest.java @@ -1244,7 +1244,7 @@ public void shouldReportChildDiarrheaEpisodeWhenSickVisitHappens() { .withThayiCard("TC 1")); when(allMothers.findByCaseId("MOTHER-CASE-1")).thenReturn(new Mother("MOTHER-CASE-1", "EC-CASE-1", "TC 1")); when(allEligibleCouples.findByCaseId("EC-CASE-1")).thenReturn(new EligibleCouple().withLocation("bherya", "Sub Center", "PHC X")); - when(reportMonth.isDateWithinCurrentReportMonth(LocalDate.parse("2012-01-01"))).thenReturn(true); + when(reportMonth.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-01"))).thenReturn(true); service.sickVisitHappened(new SafeMap(EasyMap.create("sickVisitDate", "2012-01-01") .put("id", "CASE X") @@ -1263,7 +1263,7 @@ public void shouldNotReportDiarrheaEpisodeWhenSickVisitHappensAndChildDoesNotHav .withThayiCard("TC 1")); when(allMothers.findByCaseId("MOTHER-CASE-1")).thenReturn(new Mother("MOTHER-CASE-1", "EC-CASE-1", "TC 1")); when(allEligibleCouples.findByCaseId("EC-CASE-1")).thenReturn(new EligibleCouple().withLocation("bherya", "Sub Center", "PHC X")); - when(reportMonth.isDateWithinCurrentReportMonth(LocalDate.parse("2012-01-01"))).thenReturn(true); + when(reportMonth.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-01"))).thenReturn(true); service.sickVisitHappened(new SafeMap(EasyMap.create("sickVisitDate", "2012-01-01") .put("id", "CASE X") @@ -1283,7 +1283,7 @@ public void shouldReportChildDiarrheaEpisodeWhenSickVisitHappensAndChildHasDiarr .withThayiCard("TC 1")); when(allMothers.findByCaseId("MOTHER-CASE-1")).thenReturn(new Mother("MOTHER-CASE-1", "EC-CASE-1", "TC 1")); when(allEligibleCouples.findByCaseId("EC-CASE-1")).thenReturn(new EligibleCouple().withLocation("bherya", "Sub Center", "PHC X")); - when(reportMonth.isDateWithinCurrentReportMonth(LocalDate.parse("2012-01-01"))).thenReturn(true); + when(reportMonth.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-01"))).thenReturn(true); service.sickVisitHappened(new SafeMap(EasyMap.create("reportChildDiseaseDate", "2012-01-01") .put("id", "CASE X") @@ -1303,7 +1303,7 @@ public void shouldNotReportChildDiarrheaEpisodeWhenSickVisitHappensAndChildAgeIs .withThayiCard("TC 1")); when(allMothers.findByCaseId("MOTHER-CASE-1")).thenReturn(new Mother("MOTHER-CASE-1", "EC-CASE-1", "TC 1")); when(allEligibleCouples.findByCaseId("EC-CASE-1")).thenReturn(new EligibleCouple().withLocation("bherya", "Sub Center", "PHC X")); - when(reportMonth.isDateWithinCurrentReportMonth(LocalDate.parse("2012-01-01"))).thenReturn(true); + when(reportMonth.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-01"))).thenReturn(true); service.sickVisitHappened(new SafeMap(EasyMap.create("reportChildDiseaseDate", "2012-01-01") .put("id", "CASE X")