o.setPerson(getPatient()); if (o.getLocation() == null) { o.setLocation(getLocation());
/** * @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 (!OpenmrsUtil.nullSafeEquals(newLocation, originalLocation) && obs.getLocation().equals(originalLocation)) { obs.setLocation(newLocation);
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));
/** * When you save the encounter with a changed location, the location change should not be * cascaded to all the obs associated with the encounter that had a different location from * encounter's location. * * @see EncounterService#saveEncounter(Encounter) */ @Test public void saveEncounter_shouldNotCascadeLocationChangeForDifferentInitialLocations() { EncounterService es = Context.getEncounterService(); // First, create a new Encounter Encounter enc = buildEncounter(); es.saveEncounter(enc); // Now add an obs to it Obs newObs = buildObs(); enc.addObs(newObs); es.saveEncounter(enc); enc.setLocation(new Location(2)); es.saveEncounter(enc); assertNotSame(enc.getLocation(), newObs.getLocation()); }
/** * When you save the encounter with a changed location, the location change should be cascaded * to all the obs associated with the encounter that had the same location as the encounter. * * @see EncounterService#saveEncounter(Encounter) */ @Test public void saveEncounter_shouldCascadeChangeOfLocationInEncounterToContainedObs() { EncounterService es = Context.getEncounterService(); Encounter enc = buildEncounter(); es.saveEncounter(enc); // Now add an obs to it Obs newObs = new Obs(); newObs.setConcept(Context.getConceptService().getConcept(1)); newObs.setValueNumeric(50d); Location location = new Location(1); newObs.setLocation(location); enc.addObs(newObs); es.saveEncounter(enc); enc.setLocation(location); es.saveEncounter(enc); assertEquals(enc.getLocation(), newObs.getLocation()); }
assertEquals(encounter, saved.getEncounter()); assertEquals(DateUtil.truncateToSeconds(datetime), saved.getObsDatetime()); assertEquals(location, saved.getLocation()); assertEquals(valueGroupId, saved.getValueGroupId()); assertEquals(DateUtil.truncateToSeconds(valueDatetime), saved.getValueDatetime());
obsToCopy.getLocation());
+ o.getConcept().getName(Context.getLocale())); if (o.getLocation() == null && o.getEncounter() != null) { o.setLocation(o.getEncounter().getLocation());