ChildReportingService { public void registerChild(SafeMap reportData) { String id = reportData.get(ChildReportingService.CHILD_ID_FIELD); Child child = allChildren.findByCaseId(id); List<String> immunizations = child.immunizationsGiven(); Location location = loadLocationOfChild(child); String submissionDate = reportData.get(SUBMISSION_DATE_FIELD_NAME); reportImmunizations(child, immunizations, location, child.dateOfBirth(), submissionDate); reportNRHMImmunizations(reportData, child, immunizations, location); reportBirthWeight(child, submissionDate, location); reportBFPostBirth(reportData.get(BF_POSTBIRTH), child, location, reportData.get(DELIVERY_PLACE), submissionDate); reportToBoth(child, INFANT_REGISTRATION, child.dateOfBirth(), submissionDate, location); reportLiveBirthByGender(reportData, child, location); reportToBoth(child, INFANT_BALANCE_TOTAL, child.dateOfBirth(), submissionDate, location); reportMCTSIndicators(reportData, child, immunizations); } @Autowired  ChildReportingService(ReportingService reportingService, AllChildren allChildren, AllMothers allMothers,
                                 AllEligibleCouples allEligibleCouples,
                                 AllInfantBalanceOnHandReportTokens allInfantBalanceOnHandReportTokens, ReportMonth reportMonth, MCTSReporter mctsReporter); void registerChild(SafeMap reportData); void immunizationProvided(SafeMap reportData, List<String> previousImmunizations); void vitaminAProvided(SafeMap reportData); void pncVisitHappened(SafeMap reportData); void sickVisitHappened(SafeMap reportData); void closeChild(SafeMap reportData); void reportToBoth(Child child, Indicator indicator, String serviceProvidedDate, String submissionDate, Location location); void reportToBoth(Child child, Indicator indicator, String serviceProvidedDate, Location location); void reportInfantAndChildBalance(); void reportInfantBalanceOnHand(); void reportInfantBalanceTurningOneYearOld(); void reportInfantBalanceTotalNumberOfOAChildren(); void reportInfantBalanceLessThanOneYearOld(); void reportChildBalanceLessThanFiveYearOld(); static final String CHILD_ID_FIELD; }
@Test public void shouldReportChildImmunizationDataWhenChildIsRegistered() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "opv_0", "5", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "phc"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("registrationDate", "2012-01-02"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyBothReportingCalls(OPV, "2012-01-01"); }
@Test public void shouldReportNRHMChildImmunizationDataWhenChildIsRegisteredInSubCenter() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "opv_0", "5", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "subcenter"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("registrationDate", "2012-01-02"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyBothReportingCalls(NRHM_OPV_0_1YR, "2012-01-01"); }
@Test public void shouldReportNRHMOPV0ChildImmunizationDataWhenChildIsRegisteredInSubCenter() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "opv_0", "5", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "subcenter"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("registrationDate", "2012-01-02"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyBothReportingCalls(NRHM_OPV_0_1YR, "2012-01-01"); }
@Test public void shouldReportNRHMBCGChildImmunizationDataWhenChildIsRegisteredInSubCenter() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "bcg", "5", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "subcenter"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("registrationDate", "2012-01-01"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyBothReportingCalls(NRHM_BCG_1YR, "2012-01-01"); }
@Test public void shouldReportNRHMHepB0ChildImmunizationDataWhenChildIsRegisteredInSubCenter() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "hepb_0", "5", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "subcenter"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("registrationDate", "2012-01-02"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyBothReportingCalls(NRHM_HEPB_0_1YR, "2012-01-01"); }
@Test public void shouldNotReportNRHMChildImmunizationDataWhenChildIsRegisteredNotInSubCenter() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "opv_0", "5", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "phc"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("registrationDate", "2012-01-02"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyNoReportingCalls(NRHM_OPV_0_1YR, "2012-01-01"); }
@Test public void shouldReportInfantRegistrationAndInfantTotalBalance() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "opv_0", "5", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "phc"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("registrationDate", "2012-01-02"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyBothReportingCalls(INFANT_REGISTRATION, "2012-01-01"); verifyBothReportingCalls(INFANT_BALANCE_TOTAL, "2012-01-01"); }
@Test public void shouldReportLowWeightDuringChildRegistration() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "2.2", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "phc"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyBothReportingCalls(LBW, "2012-01-01"); }
@Test public void shouldReportIfBreastFeedingInitiatedDuringChildRegistration() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "2.2", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", "yes"); reportData.put("deliveryPlace", "phc"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyBothReportingCalls(BF_POST_BIRTH, "2012-01-01"); }
@Test public void shouldReportIfNRHMBreastFeedingInitiatedDuringChildRegistrationIfDeliveryPlaceIsHome() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "2.2", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", "yes"); reportData.put("deliveryPlace", "home"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyBothReportingCalls(NRHM_BF_POST_BIRTH, "2012-01-01"); }
@Test public void shouldReportIfNRHMBreastFeedingInitiatedDuringChildRegistrationIfDeliveryPlaceIsSubCenter() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "2.2", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", "yes"); reportData.put("deliveryPlace", "subcenter"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyBothReportingCalls(NRHM_BF_POST_BIRTH, "2012-01-01"); }
@Test public void shouldNotReportIfNRHMBreastFeedingInitiatedDuringChildRegistrationIfDeliveryPlaceIsNotSubCenterOrHome() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "2.2", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", "yes"); reportData.put("deliveryPlace", "phc"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyNoReportingCalls(NRHM_BF_POST_BIRTH, "2012-01-01"); }
@Test public void shouldReportIfWeightIsMeasuredDuringChildRegistration() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "2.2", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "phc"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyBothReportingCalls(WEIGHED_AT_BIRTH, "2012-01-01"); }
@Test public void shouldNotReportIfWeightIsNotMeasuredDuringChildRegistration() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "phc"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyNoReportingCalls(WEIGHED_AT_BIRTH, "2012-01-01"); }
@Test public void shouldNotReportBreastFeedingIfNotInitiatedDuringChildRegistration() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "2.2", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "phc"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyNoReportingCalls(BF_POST_BIRTH, "2012-01-01"); }
@Test public void shouldNotReportNormalWeight() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "2.5", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "phc"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyNoReportingCalls(LBW, "2012-01-01"); }
@Test public void shouldNotReportInvalidWeightValue() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "---", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "phc"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyNoReportingCalls(LBW, "2012-01-01"); }
@Test public void shouldReportMaleLiveBirthWhenMaleChildIsRegisteredAndDeliveryHappenedAtHome() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "2.2", "male") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "home"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyBothReportingCalls(MALE_LIVE_BIRTH, "2012-01-01"); }
@Test public void shouldReportMaleLiveBirthWhenMaleChildIsRegisteredAndDeliveryHappenedAtSubCenter() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "2.2", "male") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "subcenter"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyBothReportingCalls(MALE_LIVE_BIRTH, "2012-01-01"); }
@Test public void shouldNotReportMaleLiveBirthWhenFemaleChildIsRegistered() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "2.2", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "subcenter"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyNoReportingCalls(MALE_LIVE_BIRTH, "2012-01-01"); }
@Test public void shouldNotReportMaleLiveBirthWhenMaleChildIsRegisteredAndDeliveryHappenedAtNeigherHomeNorSubCenter() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "2.2", "male") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "phc"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyNoReportingCalls(MALE_LIVE_BIRTH, "2012-01-01"); }
@Test public void shouldReportFemaleLiveBirthWhenFemaleChildIsRegisteredAndDeliveryHappenedAtHome() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "2.2", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "home"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyBothReportingCalls(FEMALE_LIVE_BIRTH, "2012-01-01"); }
@Test public void shouldReportFemaleLiveBirthWhenFemaleChildIsRegisteredAndDeliveryHappenedAtSubCenter() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "2.2", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "subcenter"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyBothReportingCalls(FEMALE_LIVE_BIRTH, "2012-01-01"); }
@Test public void shouldNotReportFemaleLiveBirthWhenMaleChildIsRegistered() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "2.2", "male") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "subcenter"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyNoReportingCalls(FEMALE_LIVE_BIRTH, "2012-01-01"); }
@Test public void shouldNotReportFemaleLiveBirthWhenFemaleChildIsRegisteredAndDeliveryHappenedAtNeigherHomeNorSubCenter() throws Exception { when(allChildren.findByCaseId("CASE X")).thenReturn(new Child("CASE X", "MOTHER-CASE-1", "boo", "2.2", "female") .withAnm("ANM X") .withDateOfBirth("2012-01-01") .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.areDatesBelongToSameReportingMonth(LocalDate.parse("2012-01-01"), LocalDate.parse("2012-01-02"))).thenReturn(true); SafeMap reportData = new SafeMap(); reportData.put("childId", "CASE X"); reportData.put("didBreastfeedingStart", ""); reportData.put("deliveryPlace", "phc"); reportData.put("deliveryDate", "2012-01-01"); reportData.put("deliveryOutcome", "live_birth"); reportData.put("submissionDate", "2012-01-02"); service.registerChild(reportData); verifyNoReportingCalls(FEMALE_LIVE_BIRTH, "2012-01-01"); }