Skip to content

Commit

Permalink
Sowmya | #1139 | Child Sickness related indicators are now reported o…
Browse files Browse the repository at this point in the history
…nly when service provided date and form submission date falls on same reporting month.
  • Loading branch information
SowmyaSMR committed Oct 20, 2014
1 parent 6d98064 commit 4a76ecb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Expand Up @@ -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);
}
}
}
Expand Down
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand Down

0 comments on commit 4a76ecb

Please sign in to comment.