コード例 #1
0
  /** @see {@link CohortService#addPatientToCohort(Cohort,Patient)} */
  @Test
  @Verifies(
      value = "should not fail if cohort already contains patient",
      method = "addPatientToCohort(Cohort,Patient)")
  public void addPatientToCohort_shouldNotFailIfCohortAlreadyContainsPatient() throws Exception {
    executeDataSet(COHORT_XML);

    // make a patient, add it using the method
    Patient patientToAdd = new Patient(4);
    service.addPatientToCohort(service.getCohort(2), patientToAdd);
    assertTrue(service.getCohort(2).contains(4));

    // do it again to see if it fails
    try {
      service.addPatientToCohort(service.getCohort(2), patientToAdd);
    } catch (Exception e) {
      Assert.fail("addPatientToCohort(Cohort,Patient) fails when cohort already contains patient.");
    }
  }
コード例 #2
0
  /** @see {@link CohortService#addPatientToCohort(Cohort,Patient)} */
  @Test
  @Verifies(
      value = "should add a patient and save the cohort",
      method = "addPatientToCohort(Cohort,Patient)")
  public void addPatientToCohort_shouldAddAPatientAndSaveTheCohort() throws Exception {
    executeDataSet(COHORT_XML);

    // make a patient, add it using the method
    Patient patientToAdd = new Patient(4);
    service.addPatientToCohort(service.getCohort(2), patientToAdd);
    // proof of "save the cohort": see if the patient is in the cohort
    assertTrue(service.getCohort(2).contains(4));
  }
コード例 #3
0
  /**
   * @verifies {@link CohortService#removePatientFromCohort(Cohort,Patient)} test = should save
   *     cohort after removing patient
   */
  @Test
  @Verifies(
      value = "should save cohort after removing patient",
      method = "removePatientFromCohort(Cohort,Patient)")
  public void removePatientFromCohort_shouldSaveCohortAfterRemovingPatient() throws Exception {
    executeDataSet(COHORT_XML);

    // make a patient, add it using the method
    Patient patientToAddThenRemove = new Patient(4);
    service.addPatientToCohort(service.getCohort(2), patientToAddThenRemove);
    assertTrue(service.getCohort(2).contains(patientToAddThenRemove));
    service.removePatientFromCohort(service.getCohort(2), patientToAddThenRemove);
    assertFalse(service.getCohort(2).contains(patientToAddThenRemove));
  }
コード例 #4
0
  /** @see {@link CohortService#getCohortsContainingPatient(Patient)} */
  @Test
  @Verifies(
      value = "should return cohorts that have given patient",
      method = "getCohortsContainingPatient(Patient)")
  public void getCohortsContainingPatient_shouldReturnCohortsThatHaveGivenPatient()
      throws Exception {
    executeDataSet(COHORT_XML);

    Patient patientToAdd = new Patient(4);
    service.addPatientToCohort(service.getCohort(2), patientToAdd);
    assertTrue(service.getCohort(2).contains(patientToAdd));

    List<Cohort> cohortsWithGivenPatient = service.getCohortsContainingPatient(patientToAdd);
    assertTrue(cohortsWithGivenPatient.contains(service.getCohort(2)));
  }
コード例 #5
0
  /** @see {@link CohortService#getCohortsContainingPatient(Patient)} */
  @Test
  @Verifies(
      value = "should not return voided cohorts",
      method = "getCohortsContainingPatient(Patient)")
  public void getCohortsContainingPatient_shouldNotReturnVoidedCohorts() throws Exception {
    executeDataSet(COHORT_XML);

    // make sure we have two cohorts, the first of which is voided
    assertTrue(service.getCohort(1).isVoided());
    assertFalse(service.getCohort(2).isVoided());

    // add a patient to both cohorts
    Patient patientToAdd = new Patient(4);
    service.addPatientToCohort(service.getCohort(1), patientToAdd);
    service.addPatientToCohort(service.getCohort(2), patientToAdd);
    assertTrue(service.getCohort(1).contains(patientToAdd));
    assertTrue(service.getCohort(2).contains(patientToAdd));

    // call the method and it should not return the voided cohort
    List<Cohort> cohortsWithPatientAdded = service.getCohortsContainingPatient(patientToAdd);
    assertNotNull(cohortsWithPatientAdded);
    assertFalse(cohortsWithPatientAdded.contains(service.getCohort(1)));
  }