예제 #1
0
  /** @see Encounter#addObs(Obs) */
  @Test
  @Verifies(
      value = "should add encounter attrs to obs if attributes are null",
      method = "addObs(Obs)")
  public void addObs_shouldAddEncounterAttrsToObsIfAttributesAreNull() throws Exception {
    /// an encounter that will hav the date/location/patient on it
    Encounter encounter = new Encounter();

    Date date = new Date();
    encounter.setEncounterDatetime(date);

    Location location = new Location(1);
    encounter.setLocation(location);

    Patient patient = new Patient(1);
    encounter.setPatient(patient);

    // add an obs that doesn't have date/location/patient set on it.
    Obs obs = new Obs(123);
    encounter.addObs(obs);

    // make sure it was added
    assertEquals(1, encounter.getAllObs(true).size());

    // check the values of the obs attrs to see if they were added
    assertTrue(obs.getObsDatetime().equals(date));
    assertTrue(obs.getLocation().equals(location));
    assertTrue(obs.getPerson().equals(patient));
  }
예제 #2
0
  /** @see Encounter#addObs(Obs) */
  @Test
  @Verifies(
      value = "should add encounter attrs to obs if attributes are null",
      method = "addObs(Obs)")
  public void addObs_shouldAddEncounterAttrsToObsGroupMembersIfAttributesAreNull()
      throws Exception {
    /// an encounter that will hav the date/location/patient on it
    Encounter encounter = new Encounter();

    Date date = new Date();
    encounter.setEncounterDatetime(date);

    Location location = new Location(1);
    encounter.setLocation(location);

    Patient patient = new Patient(1);
    encounter.setPatient(patient);

    // add an obs that doesn't have date/location/patient set on it.
    Obs obs = new Obs(123);
    Obs childObs = new Obs(456);
    obs.addGroupMember(childObs);

    // check for infinite recursion
    // childObs-->childObs2   and childObs2-->childObs
    Obs childObs2 = new Obs(456);
    childObs.addGroupMember(childObs2);
    childObs2.addGroupMember(childObs);

    assertTrue(obs.getGroupMembers() != null && obs.getGroupMembers().size() == 1);

    encounter.addObs(obs);

    // check the values of the obs attrs to see if they were added
    assertTrue(childObs.getObsDatetime().equals(date));
    assertTrue(childObs.getLocation().equals(location));
    assertTrue(childObs.getPerson().equals(patient));
    assertTrue(childObs2.getObsDatetime().equals(date));
    assertTrue(childObs2.getLocation().equals(location));
    assertTrue(childObs2.getPerson().equals(patient));
  }
예제 #3
0
  /** @see Encounter#copyAndAssignToAnotherPatient(org.openmrs.Patient) */
  @Test
  @Verifies(
      value =
          "should copy all Encounter data except visit and assign copied Encounter to given Patient",
      method = "copy()")
  public void copy_shouldCopyAllEncounterDataExceptVisitAndAssignCopiedEncounterToGivenPatient()
      throws Exception {
    Encounter encounter = new Encounter();

    encounter.setCreator(new User());
    encounter.setDateCreated(new Date());
    encounter.setChangedBy(new User());
    encounter.setDateChanged(new Date());
    encounter.setVoidReason("void");
    encounter.setDateVoided(new Date());

    encounter.setEncounterDatetime(new Date());
    encounter.setEncounterType(new EncounterType());
    encounter.setForm(new Form());
    encounter.setLocation(new Location());
    encounter.setPatient(new Patient());

    encounter.addObs(new Obs());
    encounter.addOrder(new Order());

    EncounterRole encounterRole = new EncounterRole();
    encounter.addProvider(encounterRole, new Provider());

    encounter.setVisit(new Visit());

    Patient patient = new Patient(1234);

    Encounter encounterCopy = encounter.copyAndAssignToAnotherPatient(patient);

    Assert.assertNotEquals(encounter, encounterCopy);

    Assert.assertEquals(encounter.getCreator(), encounterCopy.getCreator());
    Assert.assertEquals(encounter.getDateCreated(), encounterCopy.getDateCreated());
    Assert.assertEquals(encounter.getChangedBy(), encounterCopy.getChangedBy());
    Assert.assertEquals(encounter.getDateChanged(), encounterCopy.getDateChanged());
    Assert.assertEquals(encounter.getVoided(), encounterCopy.getVoided());
    Assert.assertEquals(encounter.getVoidReason(), encounterCopy.getVoidReason());
    Assert.assertEquals(encounter.getDateVoided(), encounterCopy.getDateVoided());

    Assert.assertEquals(encounter.getEncounterDatetime(), encounterCopy.getEncounterDatetime());
    Assert.assertEquals(encounter.getEncounterType(), encounterCopy.getEncounterType());
    Assert.assertEquals(encounter.getForm(), encounterCopy.getForm());
    Assert.assertEquals(encounter.getLocation(), encounterCopy.getLocation());

    Assert.assertEquals(1, encounter.getObs().size());
    Assert.assertEquals(1, encounterCopy.getObs().size());
    Assert.assertEquals(1, encounter.getOrders().size());
    Assert.assertEquals(1, encounterCopy.getOrders().size());

    Assert.assertEquals(1, encounter.getProvidersByRole(encounterRole).size());
    Assert.assertEquals(1, encounterCopy.getProvidersByRole(encounterRole).size());
    Assert.assertEquals(
        true,
        encounter
            .getProvidersByRole(encounterRole)
            .containsAll(encounterCopy.getProvidersByRole(encounterRole)));

    Assert.assertNotNull(encounter.getVisit());
    Assert.assertNull(encounterCopy.getVisit());

    Assert.assertEquals(patient, encounterCopy.getPatient());
  }