private void deletePatient(OpenMRSPatient patient)
      throws PatientNotFoundException, InterruptedException {

    String facilityId = patient.getFacility().getFacilityId();

    patientAdapter.deletePatient(patient.getPatientId());
    assertNull(patientAdapter.getPatientByUuid(patient.getPatientId()));

    facilityAdapter.deleteFacility(facilityId);
  }
  @After
  public void tearDown() throws InterruptedException, PatientNotFoundException {

    String uuid = patient.getFacility().getFacilityId();

    deletePatient(patient);

    if (uuid != null) {
      facilityAdapter.deleteFacility(uuid);
    }

    conceptAdapter.deleteConcept(causeOfDeath.getUuid());

    eventListenerRegistry.clearListenersForBean("mrsTestListener");
  }
  private OpenMRSPatient preparePatient() {

    OpenMRSPerson person = new OpenMRSPerson();
    person.setFirstName("John");
    person.setLastName("Smith");
    person.setAddress("10 Fifth Avenue");
    person.setBirthDateEstimated(false);
    person.setGender("M");

    OpenMRSAttribute attr = new OpenMRSAttribute("Birthplace", "Motech");
    List<OpenMRSAttribute> attributes = new ArrayList<>();
    attributes.add(attr);
    person.setAttributes(attributes);
    OpenMRSFacility facility =
        facilityAdapter.createFacility(
            new OpenMRSFacility(
                "FooName", "FooCountry", "FooRegion", "FooCountryDistrict", "FooStateProvince"));

    assertNotNull(facility);

    OpenMRSPatient patient = new OpenMRSPatient("602", person, facility);

    return patient;
  }