o.setObsDatetime(getEncounterDatetime()); if (o.getPerson() == null) { o.setPerson(getPatient());
@Test public void saveObs_shouldOverwriteObsPersonValueWithEncounterPatient() { String changeMessage = "Testing TRUNK-3283"; executeDataSet(ENCOUNTER_OBS_XML); ObsService obsService = Context.getObsService(); Obs obs = obsService.getObs(13); //overwrite ObsPerson with EncounterPatient Obs obsSaved = obsService.saveObs(obs, changeMessage); assertEquals(obs.getPerson(), obsSaved.getEncounter().getPatient()); }
/** * @see Encounter#addObs(Obs) */ @Test public void addObs_shouldAddEncounterAttrsToObsIfAttributesAreNull() { /// 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)); }
if (!obs.getPerson().getPersonId().equals(p.getPatientId())) { obs.setPerson(p);
for (Obs o : e.getAllObs(true)) { if (!originalUnvoidedObs.contains(o)) { assertThat(o.getPerson().getId(), is(v.getPatient().getId()));
assertEquals(patient, saved.getPerson()); assertEquals(comment, saved.getComment()); assertEquals(concept, saved.getConcept());
Obs newObs = new Obs(obsToCopy.getPerson(), obsToCopy.getConcept(), obsToCopy.getObsDatetime(), obsToCopy.getLocation());