コード例 #1
0
  @Test
  public void shouldUpdateANMInformationOfEligibleCoupleWhenOAPNCIsRegistered() {
    DateTime currentTime = DateUtil.now();
    mockCurrentDate(currentTime);
    when(allMothers.findByEcCaseId("ec id 1"))
        .thenReturn(asList(new Mother("mother id 1", "ec id 1", "tc 1")));
    when(allEligibleCouples.findByCaseId("ec id 1"))
        .thenReturn(new EligibleCouple("ec id 1", "123"));
    FormSubmission submission =
        create()
            .withFormName("pnc_registration_oa")
            .withANMId("anm id 1")
            .withEntityId("ec id 1")
            .addFormField("referenceDate", "2012-01-01")
            .addFormField("didWomanSurvive", "yes")
            .withSubForm(
                new SubFormData(
                    "child_registration_oa", Collections.<Map<String, String>>emptyList()))
            .build();

    service.pncRegistrationOA(submission);

    verify(allEligibleCouples)
        .update(new EligibleCouple("ec id 1", "123").withANMIdentifier("anm id 1"));
  }
コード例 #2
0
  @Test
  public void shouldUpdateMotherWithNewFamilyPlanningFSWhenPPFPIsSubmitted() throws Exception {
    FormSubmission submission =
        create()
            .withFormName("postpartum_family_planning")
            .withEntityId("mother id 1")
            .addFormField("some-key", "value")
            .addFormField("currentMethod", "female_sterilization")
            .addFormField("familyPlanningMethodChangeDate", "2010-01-01")
            .addFormField("femaleSterilizationType", "minilap")
            .build();
    Mother mother = new Mother("mother id 1", "ec id 1", "thayi card number 1");
    EligibleCouple eligibleCouple =
        new EligibleCouple("ec id 1", "ec number 1")
            .withIUDFPDetails(Collections.<IUDFPDetails>emptyList())
            .withCondomFPDetails(Collections.<CondomFPDetails>emptyList())
            .withOCPFPDetails(Collections.<OCPFPDetails>emptyList())
            .withFemaleSterilizationFPDetails(new ArrayList<FemaleSterilizationFPDetails>())
            .withMaleSterilizationFPDetails(Collections.<MaleSterilizationFPDetails>emptyList());
    when(allMothers.findByCaseId("mother id 1")).thenReturn(mother);
    when(allEligibleCouples.findByCaseId("ec id 1")).thenReturn(eligibleCouple);

    service.reportPPFamilyPlanning(submission);

    ArrayList<FemaleSterilizationFPDetails> femaleSterilizationFPDetails = new ArrayList<>();
    femaleSterilizationFPDetails.add(new FemaleSterilizationFPDetails("minilap", "2010-01-01"));
    EligibleCouple expectedEC =
        new EligibleCouple("ec id 1", "ec number 1")
            .withIUDFPDetails(Collections.<IUDFPDetails>emptyList())
            .withCondomFPDetails(Collections.<CondomFPDetails>emptyList())
            .withOCPFPDetails(Collections.<OCPFPDetails>emptyList())
            .withMaleSterilizationFPDetails(Collections.<MaleSterilizationFPDetails>emptyList())
            .withFemaleSterilizationFPDetails(femaleSterilizationFPDetails);
    verify(allEligibleCouples).update(expectedEC);
  }
コード例 #3
0
  @Test
  public void shouldCloseMotherAndECDuringDeliveryOutcomeIfWomanDied() {
    DateTime currentTime = DateUtil.now();
    mockCurrentDate(currentTime);
    when(allMothers.exists("mother id 1")).thenReturn(true);
    when(allMothers.findByCaseId("mother id 1"))
        .thenReturn(new Mother("mother id 1", "ec id 1", "1234567"));
    when(allEligibleCouples.findByCaseId("ec id 1"))
        .thenReturn(new EligibleCouple("ec id 1", "123"));

    FormSubmission submission =
        create()
            .withFormName("delivery_outcome")
            .withANMId("anm id 1")
            .withEntityId("mother id 1")
            .addFormField("referenceDate", "2012-01-01")
            .addFormField("didWomanSurvive", "")
            .addFormField("didMotherSurvive", "no")
            .withSubForm(
                new SubFormData("child_registration", Collections.<Map<String, String>>emptyList()))
            .build();
    service.deliveryOutcome(submission);

    Mother expectedMother = new Mother("mother id 1", "ec id 1", "1234567").setIsClosed(true);
    EligibleCouple expectedEC = new EligibleCouple("ec id 1", "123").setIsClosed(true);

    verify(allMothers).update(expectedMother);
    verify(allEligibleCouples).update(expectedEC);
    verify(actionService).markAllAlertsAsInactive("mother id 1");
    verify(pncSchedulesService).unEnrollFromSchedules("mother id 1");
    verifyZeroInteractions(pncSchedulesService);
  }
コード例 #4
0
  @Test
  public void shouldUpdateMotherWithChildrenDetailsWhenPNCRegistrationOA() {
    when(allMothers.findByEcCaseId("ec id 1"))
        .thenReturn(asList(new Mother("mother id 1", "ec id 1", "tc 1")));
    when(allEligibleCouples.findByCaseId("ec id 1"))
        .thenReturn(new EligibleCouple("ec id 1", "123"));
    FormSubmission submission =
        create()
            .withFormName("pnc_registration_oa")
            .withANMId("anm id 1")
            .withEntityId("ec id 1")
            .addFormField("referenceDate", "2012-01-01")
            .addFormField("didWomanSurvive", "yes")
            .withSubForm(
                new SubFormData(
                    "child_registration_oa",
                    asList(
                        EasyMap.create("id", "child id 1")
                            .put("gender", "male")
                            .put("weight", "2")
                            .map(),
                        EasyMap.create("id", "child id 2")
                            .put("gender", "female")
                            .put("weight", "3")
                            .map())))
            .build();

    service.pncRegistrationOA(submission);

    verify(allMothers)
        .update(
            new Mother("mother id 1", "ec id 1", "tc 1")
                .withAnm("anm id 1")
                .withChildrenDetails(
                    asList(
                        EasyMap.create("id", "child id 1")
                            .put("gender", "male")
                            .put("weight", "2")
                            .put("immunizationsAtBirth", null)
                            .map(),
                        EasyMap.create("id", "child id 2")
                            .put("gender", "female")
                            .put("weight", "3")
                            .put("immunizationsAtBirth", null)
                            .map())));
  }
コード例 #5
0
  @Test
  public void shouldReportPNCRegistrationOA() throws Exception {
    when(reportFieldsDefinition.get("pnc_registration_oa")).thenReturn(asList("some-key"));
    when(allMothers.findByEcCaseId("entity id 1"))
        .thenReturn(asList(new Mother("entity id 1", "ec id 1", "tc 1")));
    when(allEligibleCouples.findByCaseId("ec id 1"))
        .thenReturn(new EligibleCouple("ec id 1", "123"));

    FormSubmission submission =
        create()
            .withFormName("pnc_registration_oa")
            .addFormField("some-key", "value")
            .withSubForm(
                new SubFormData(
                    "child_registration_oa", Collections.<Map<String, String>>emptyList()))
            .build();
    service.pncRegistrationOA(submission);

    SafeMap reportFields = new SafeMap(mapOf("some-key", "value"));
    verify(motherReportingService).pncRegistrationOA(reportFields);
  }
コード例 #6
0
  @Test
  public void shouldNotEnrollPNCIntoSchedulesPNCRegistrationIfWomanDied() {
    DateTime currentTime = DateUtil.now();
    mockCurrentDate(currentTime);
    when(allMothers.findByEcCaseId("ec id 1"))
        .thenReturn(asList(new Mother("mother id 1", "ec id 1", "tc 1")));
    when(allEligibleCouples.findByCaseId("ec id 1"))
        .thenReturn(new EligibleCouple("ec id 1", "123"));
    FormSubmission submission =
        create()
            .withFormName("pnc_registration_oa")
            .withANMId("anm id 1")
            .withEntityId("ec id 1")
            .addFormField("referenceDate", "2012-01-01")
            .addFormField("didWomanSurvive", "no")
            .withSubForm(
                new SubFormData(
                    "child_registration_oa", Collections.<Map<String, String>>emptyList()))
            .build();

    service.pncRegistrationOA(submission);

    verifyZeroInteractions(pncSchedulesService);
  }
コード例 #7
0
  @Test
  public void shouldNotAddChildrenDetailsInTheCaseOfStillBirthDuringPNCRegistrationOA()
      throws Exception {
    when(allMothers.findByEcCaseId("ec id 1"))
        .thenReturn(asList(new Mother("mother id 1", "ec id 1", "tc 1")));
    when(allEligibleCouples.findByCaseId("ec id 1"))
        .thenReturn(new EligibleCouple("ec id 1", "123"));
    FormSubmission submission =
        create()
            .withFormName("pnc_registration_oa")
            .withANMId("anm id 1")
            .withEntityId("ec id 1")
            .addFormField("referenceDate", "2012-01-01")
            .addFormField("deliveryOutcome", "still_birth")
            .addFormField("didWomanSurvive", "yes")
            .withSubForm(
                new SubFormData(
                    "child_registration_oa", asList(EasyMap.create("id", "child id 1").map())))
            .build();

    service.pncRegistrationOA(submission);

    verify(allMothers).update(new Mother("mother id 1", "ec id 1", "tc 1").withAnm("anm id 1"));
  }