コード例 #1
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);
  }
コード例 #2
0
  @Test
  public void shouldUpdateMotherWithChildrenDetailsWhenDeliveryOutcome() {
    when(allMothers.findByCaseId("mother id 1"))
        .thenReturn(new Mother("mother id 1", "ec id 1", "tc 1"));
    FormSubmission submission =
        create()
            .withFormName("delivery_outcome")
            .withANMId("anm id 1")
            .withEntityId("mother id 1")
            .addFormField("referenceDate", "2012-01-01")
            .addFormField("didWomanSurvive", "yes")
            .withSubForm(
                new SubFormData(
                    "child_registration",
                    asList(
                        EasyMap.create("id", "child id 1")
                            .put("gender", "male")
                            .put("weight", "2")
                            .put("immunizationsGiven", "bcg")
                            .map(),
                        EasyMap.create("id", "child id 2")
                            .put("gender", "female")
                            .put("weight", "3")
                            .map())))
            .build();

    service.deliveryOutcome(submission);

    verify(allMothers)
        .update(
            new Mother("mother id 1", "ec id 1", "tc 1")
                .withChildrenDetails(
                    asList(
                        EasyMap.create("id", "child id 1")
                            .put("gender", "male")
                            .put("weight", "2")
                            .put("immunizationsAtBirth", "bcg")
                            .map(),
                        EasyMap.create("id", "child id 2")
                            .put("gender", "female")
                            .put("weight", "3")
                            .put("immunizationsAtBirth", null)
                            .map())));
  }
コード例 #3
0
  @Test
  public void shouldNotEnrollPNCIntoSchedulesDuringDeliveryOutcomeIfMotherDoesNotExists() {
    DateTime currentTime = DateUtil.now();
    mockCurrentDate(currentTime);
    when(allMothers.exists("mother id 1")).thenReturn(false);
    FormSubmission submission =
        create()
            .withFormName("delivery_outcome")
            .withANMId("anm id 1")
            .withEntityId("mother id 1")
            .addFormField("referenceDate", "2012-01-01")
            .addFormField("didWomanSurvive", "no")
            .withSubForm(
                new SubFormData("child_registration", Collections.<Map<String, String>>emptyList()))
            .build();
    service.deliveryOutcome(submission);

    verifyZeroInteractions(pncSchedulesService);
  }
コード例 #4
0
  @Test
  public void shouldEnrollPNCIntoSchedulesDuringDeliveryOutcomeIfWomanOrMotherSurvives() {
    DateTime currentTime = DateUtil.now();
    mockCurrentDate(currentTime);
    when(allMothers.findByCaseId("mother id 1"))
        .thenReturn(new Mother("mother id 1", "ec id 1", "1234567"));
    FormSubmission submission =
        create()
            .withFormName("delivery_outcome")
            .withANMId("anm id 1")
            .withEntityId("mother id 1")
            .addFormField("referenceDate", "2012-01-01")
            .addFormField("didWomanSurvive", "yes")
            .addFormField("didMotherSurvive", "")
            .withSubForm(
                new SubFormData("child_registration", Collections.<Map<String, String>>emptyList()))
            .build();
    service.deliveryOutcome(submission);

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

    service.deliveryOutcome(submission);

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