@Test
  public void shouldAddNewPNCVisitDateToPNCVisitsDatesThatHappened() throws Exception {
    when(reportFieldsDefinition.get("pnc_visit")).thenReturn(asList("pncVisitDate"));
    Mother mother =
        new Mother("mother id 1", "ec id 1", "TC1")
            .withDetails(
                EasyMap.create("some-key", "some-value").put("pncVisitDates", "2013-01-01").map());
    when(allMothers.findByCaseId("entity id 1")).thenReturn(mother);

    FormSubmission submission =
        create()
            .withFormName("pnc_visit")
            .addFormField("pncVisitDate", "2013-01-02")
            .withSubForm(
                new SubFormData("child_pnc_visit", Collections.<Map<String, String>>emptyList()))
            .build();
    service.pncVisitHappened(submission);

    Mother updatedMother =
        new Mother("mother id 1", "ec id 1", "TC1")
            .withDetails(
                EasyMap.create("some-key", "some-value")
                    .put("pncVisitDates", "2013-01-01 2013-01-02")
                    .map())
            .withPNCVisits(
                asList(
                    new PNCVisit()
                        .withDate("2013-01-02")
                        .withChildrenDetails(Collections.<Map<String, String>>emptyList())));
    verify(allMothers).update(updatedMother);
  }
  @Test
  public void shouldUpdateMotherWithPNCVisitDetails() throws Exception {
    Mother mother =
        new Mother("mother id 1", "ec id 1", "TC1")
            .withDetails(EasyMap.mapOf("some-key", "some-value"));
    when(allMothers.findByCaseId("entity id 1")).thenReturn(mother);

    FormSubmission submission =
        create()
            .withFormName("pnc_visit")
            .addFormField("pncVisitDate", "2013-01-01")
            .addFormField("pncVisitPerson", "ASHA")
            .addFormField("pncVisitPlace", "phc")
            .addFormField("difficulties1", "difficulties 1")
            .addFormField("abdominalProblems", "abdominal Problems")
            .addFormField("vaginalProblems", "vaginal Problems")
            .addFormField("difficulties2", "difficulties 2")
            .addFormField("breastProblems", "breast Problems")
            .withSubForm(
                new SubFormData(
                    "child_pnc_visit",
                    asList(
                        EasyMap.create("id", "child id 1")
                            .put("urineStoolProblems", "vomiting diarrhea")
                            .put("activityProblems", "convulsions")
                            .put("breathingProblems", "breathing_too_fast")
                            .put("skinProblems", "jaundice")
                            .map())))
            .build();
    service.pncVisitHappened(submission);

    Mother updatedMother =
        new Mother("mother id 1", "ec id 1", "TC1")
            .withDetails(
                EasyMap.create("some-key", "some-value").put("pncVisitDates", "2013-01-01").map())
            .withPNCVisits(
                asList(
                    new PNCVisit()
                        .withDate("2013-01-01")
                        .withPerson("ASHA")
                        .withPlace("phc")
                        .withDifficulties("difficulties 1")
                        .withAbdominalProblems("abdominal Problems")
                        .withVaginalProblems("vaginal Problems")
                        .withUrinalProblems("difficulties 2")
                        .withBreastProblems("breast Problems")
                        .withChildrenDetails(
                            asList(
                                EasyMap.create("id", "child id 1")
                                    .put("urineStoolProblems", "vomiting diarrhea")
                                    .put("activityProblems", "convulsions")
                                    .put("breathingProblems", "breathing_too_fast")
                                    .put("skinProblems", "jaundice")
                                    .map()))));
    verify(allMothers).update(updatedMother);
  }
  @Test
  public void shouldNotDoAnythingIfMotherIsNotFoundDuringPNCVisit() throws Exception {
    FormSubmission submission = create().withFormName("pnc_visit").build();

    when(allMothers.exists("entity id 1")).thenReturn(false);

    service.pncVisitHappened(submission);

    verify(allMothers).findByCaseId("entity id 1");
    verifyZeroInteractions(motherReportingService);
    verifyZeroInteractions(childReportingService);
  }
  @Test
  public void shouldReportPNCVisit() throws Exception {
    when(reportFieldsDefinition.get("pnc_visit")).thenReturn(asList("some-key"));
    when(allMothers.findByCaseId("entity id 1"))
        .thenReturn(new Mother("mother id 1", "ec id 1", "TC1"));

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

    SafeMap reportFields = new SafeMap(mapOf("some-key", "value"));
    verify(motherReportingService).pncVisitHappened(reportFields);
  }