if (o.getObsDatetime() == null) { o.setObsDatetime(getEncounterDatetime());
Obs obsWithDifferentDateBefore = null; for (Obs o : enc.getAllObs(false)) { if (enc.getEncounterDatetime().equals(o.getObsDatetime())) { obsWithSameDateBefore.add(o); } else if (obsWithDifferentDateBefore == null) { Obs obsWithDifferentDateAfter = null; for (Obs o : enc.getAllObs(false)) { if (enc.getEncounterDatetime().equals(o.getObsDatetime())) { obsWithSameDateAfter.add(o); assertTrue(obsWithSameDateBefore.contains(o.getPreviousVersion()));
this(obs.getObsDatetime(), null, obs.getValueAsBoolean(), obs.getValueCoded(), obs.getValueDatetime(), obs .getValueNumeric(), obs.getValueText(), obs);
Assert.assertEquals(newObs.getObsDatetime().toString(), newDate.toString()); Assert.assertEquals(member.getObsDatetime().toString(), newDate.toString()); if(member.getGroupMembers()!= null) { Assert.assertEquals(memberChild.getObsDatetime().toString(), newDate.toString()); if (memberChild.getValueText()!= null && memberChild.getValueText().equals("NewObs Value")) { count++;
/** * @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)); }
&& OpenmrsUtil.compare(obs.getObsDatetime(), originalDate) == 0) {
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));
/** * You should be able to add an obs without an obsDatetime to an encounter, save the encounter, * and have the obs automatically persisted with the same date as the encounter. Added to test * bug reported in {@link Ticket#827} * * @see EncounterService#saveEncounter(Encounter) */ @Test public void saveEncounter_shouldCascadeEncounterDatetimeToObs() { EncounterService es = Context.getEncounterService(); // get an encounter from the database Encounter encounter = es.getEncounter(1); assertNotNull(encounter.getEncounterDatetime()); // Now add an obs to it and do NOT set the obs datetime Obs obs = new Obs(); obs.setConcept(Context.getConceptService().getConcept(1)); obs.setValueNumeric(50d); encounter.addObs(obs); es.saveEncounter(encounter); assertTrue(encounter.getEncounterDatetime().equals(obs.getObsDatetime())); }
assertEquals("encounter time propogated", groupObs.getObsDatetime(), enc.getEncounterDatetime()); assertNotNull("obs save succeeds", childObs.getObsId()); assertEquals("encounter id propogated", childObs.getEncounter().getId(), enc.getId()); assertEquals("encounter time propogated", childObs.getObsDatetime(), enc.getEncounterDatetime());
errors.rejectValue("person", "error.null"); if (obs.getObsDatetime() == null) { errors.rejectValue("obsDatetime", "error.null");
@Test public void earliestObs_shouldReturnTheFirstObsGivenThePassedConcepUuid() throws Exception { VelocityFunctions functions = setupFunctionsForPatient(7); DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Obs earliestWeight = functions.earliestObs("c607c80f-1ea9-4da3-bb88-6276ce8868dd"); Assert.assertEquals(50, earliestWeight.getValueNumeric().intValue()); // this is a bit of a hack because for some reason the obsDatetime set for this obs in the standard test dataset changed between 1.7 and 1.8 Assert.assertTrue("Obs datetime not correct", (StringUtils.equals("2008-08-01", df.format(earliestWeight.getObsDatetime())) || StringUtils.equals("2008-07-01", df.format(earliestWeight.getObsDatetime())))); }
/** * @see VelocityFunctions#earliestObs(Integer) * @verifies return the first obs given the passed conceptId */ @Test public void earliestObs_shouldReturnTheFirstObsGivenThePassedConceptId() throws Exception { VelocityFunctions functions = setupFunctionsForPatient(7); DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Obs earliestWeight = functions.earliestObs(5089); Assert.assertEquals(50, earliestWeight.getValueNumeric().intValue()); // this is a bit of a hack because for some reason the obsDatetime set for this obs in the standard test dataset changed between 1.7 and 1.8 Assert.assertTrue("Obs datetime not correct", (StringUtils.equals("2008-08-01", df.format(earliestWeight.getObsDatetime())) || StringUtils.equals("2008-07-01", df.format(earliestWeight.getObsDatetime())))); }
/** * @see VelocityFunctions#latestObs(Integer) * @verifies return the most recent obs given the passed conceptId */ @Test public void latestObs_shouldReturnTheMostRecentObsGivenThePassedConceptId() throws Exception { VelocityFunctions functions = setupFunctionsForPatient(7); DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Obs earliestWeight = functions.latestObs(5089); Assert.assertEquals(61, earliestWeight.getValueNumeric().intValue()); Assert.assertEquals("2008-08-19", df.format(earliestWeight.getObsDatetime())); }
@Test public void latestObs_shouldReturnTheMostRecentObsGivenThePassedConceptUuid() throws Exception { VelocityFunctions functions = setupFunctionsForPatient(7); DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Obs earliestWeight = functions.latestObs("c607c80f-1ea9-4da3-bb88-6276ce8868dd"); Assert.assertEquals(61, earliestWeight.getValueNumeric().intValue()); Assert.assertEquals("2008-08-19", df.format(earliestWeight.getObsDatetime())); }
assertEquals(concept, saved.getConcept()); assertEquals(encounter, saved.getEncounter()); assertEquals(DateUtil.truncateToSeconds(datetime), saved.getObsDatetime()); assertEquals(location, saved.getLocation()); assertEquals(valueGroupId, saved.getValueGroupId());
Obs newObs = new Obs(obsToCopy.getPerson(), obsToCopy.getConcept(), obsToCopy.getObsDatetime(), obsToCopy.getLocation());
@Override public void testResults(SubmissionResults results) { results.assertNoErrors(); List<Obs> obsList = os.getObservationsByPersonAndConcept(results.getPatient(), cs.getConcept("4200")); Assert.assertEquals(obsList.size(),1); Assert.assertEquals("RECOVERED",obsList.get(0).getValueCoded().getDisplayString()); Assert.assertEquals(dateAsString(date),dateAsString(obsList.get(0).getObsDatetime())); }
@Override public void testResults(SubmissionResults results) { results.assertNoErrors(); List<Obs> obsList = os.getObservationsByPersonAndConcept(results.getPatient(), cs.getConcept("4200")); List<Obs> obsDeathList = os.getObservationsByPersonAndConcept(results.getPatient(), cs.getConcept("4300")); Assert.assertEquals(obsList.size(),1); Assert.assertEquals(obsDeathList.size(),1); Assert.assertEquals("PATIENT DIED",obsList.get(0).getValueCoded().getDisplayString()); Assert.assertEquals(dateAsString(date),dateAsString(obsList.get(0).getObsDatetime())); Assert.assertEquals("OTHER NON-CODED",obsDeathList.get(0).getValueCoded().getDisplayString()); Assert.assertEquals("Died from cancer",obsDeathList.get(0).getValueText()); }
@Override public void testResults(SubmissionResults results) { results.assertNoErrors(); List<Obs> obsList = os.getObservationsByPersonAndConcept(results.getPatient(), cs.getConcept("4200")); List<Obs> obsDeathList = os.getObservationsByPersonAndConcept(results.getPatient(), cs.getConcept("4300")); Assert.assertEquals(obsList.size(),1); Assert.assertEquals(obsDeathList.size(),1); Assert.assertEquals("PATIENT DIED",obsList.get(0).getValueCoded().getDisplayString()); Assert.assertEquals(dateAsString(date),dateAsString(obsList.get(0).getObsDatetime())); Assert.assertEquals("STROKE",obsDeathList.get(0).getValueCoded().getDisplayString()); Assert.assertEquals(null,obsList.get(0).getValueText()); }
@Override public void validateDefaultRepresentation() throws Exception { super.validateDefaultRepresentation(); assertPropPresent("person"); assertPropPresent("concept"); assertPropPresent("value"); assertPropEquals("obsDatetime", getObject().getObsDatetime()); assertPropEquals("accessionNumber", getObject().getAccessionNumber()); assertPropEquals("obsGroup", getObject().getObsGroup()); assertPropPresent("groupMembers"); assertPropEquals("comment", getObject().getComment()); assertPropPresent("location"); assertPropPresent("order"); assertPropPresent("encounter"); assertPropEquals("voided", getObject().getVoided()); }