@Test public void firstObs_shouldFindFirstObsWithConcept() { Patient patient = TestUtils.getPatient(6); Program tbProgram = MetadataUtils.existing(Program.class, TbMetadata._Program.TB); Enrollment enrollment = new Enrollment(TestUtils.enrollInProgram(patient, tbProgram, TestUtils.date(2012, 1, 1), TestUtils.date(2012, 4, 1))); Assert.assertNull(enrollment.firstObs(Dictionary.getConcept(Dictionary.CD4_COUNT))); Obs obs0 = TestUtils.saveObs(patient, Dictionary.getConcept(Dictionary.CD4_COUNT), 123.0, TestUtils.date(2011, 12, 1)); Obs obs1 = TestUtils.saveObs(patient, Dictionary.getConcept(Dictionary.CD4_PERCENT), 50.0, TestUtils.date(2012, 1, 15)); Obs obs2 = TestUtils.saveObs(patient, Dictionary.getConcept(Dictionary.CD4_COUNT), 234.0, TestUtils.date(2012, 2, 1)); Obs obs3 = TestUtils.saveObs(patient, Dictionary.getConcept(Dictionary.CD4_COUNT), 345.0, TestUtils.date(2012, 3, 1)); Assert.assertEquals(obs2, enrollment.firstObs(Dictionary.getConcept(Dictionary.CD4_COUNT))); enrollment = new Enrollment(TestUtils.enrollInProgram(patient, tbProgram, TestUtils.date(2012, 1, 1))); Assert.assertEquals(obs2, enrollment.firstObs(Dictionary.getConcept(Dictionary.CD4_COUNT))); }
public Obs firstObs(Concept concept) { List<Obs> obss = Context.getObsService().getObservationsByPersonAndConcept(target.getPatient(), concept); Collections.reverse(obss); for (Obs obs : obss) { if (obs.getObsDatetime().compareTo(target.getDateEnrolled()) >= 0 && (target.getDateCompleted() == null || obs.getObsDatetime().compareTo(target.getDateCompleted()) < 0)) { return obs; } } return null; }
Enrollment extends AbstractObjectWrapper<PatientProgram> { public Obs firstObs(Concept concept) { List<Obs> obss = Context.getObsService().getObservationsByPersonAndConcept(target.getPatient(), concept); Collections.reverse(obss); for (Obs obs : obss) { if (obs.getObsDatetime().compareTo(target.getDateEnrolled()) >= 0 && (target.getDateCompleted() == null || obs.getObsDatetime().compareTo(target.getDateCompleted()) < 0)) { return obs; } } return null; } }
Enrollment extends AbstractObjectWrapper<PatientProgram> { public Obs firstObs(Concept concept) { List<Obs> obss = Context.getObsService().getObservationsByPersonAndConcept(target.getPatient(), concept); Collections.reverse(obss); for (Obs obs : obss) { if (obs.getObsDatetime().compareTo(target.getDateEnrolled()) >= 0 && (target.getDateCompleted() == null || obs.getObsDatetime().compareTo(target.getDateCompleted()) < 0)) { return obs; } } return null; } Enrollment(PatientProgram target); }
Enrollment extends AbstractObjectWrapper<PatientProgram> { public Obs firstObs(Concept concept) { List<Obs> obss = Context.getObsService().getObservationsByPersonAndConcept(target.getPatient(), concept); Collections.reverse(obss); for (Obs obs : obss) { if (obs.getObsDatetime().compareTo(target.getDateEnrolled()) >= 0 && (target.getDateCompleted() == null || obs.getObsDatetime().compareTo(target.getDateCompleted()) < 0)) { return obs; } } return null; } Enrollment(PatientProgram target); Obs firstObs(Concept concept); Encounter lastEncounter(EncounterType type); Encounter encounterByForm(EncounterType encounterType, Form form); }
Enrollment extends AbstractObjectWrapper<PatientProgram> { public Obs firstObs(Concept concept) { List<Obs> obss = Context.getObsService().getObservationsByPersonAndConcept(target.getPatient(), concept); Collections.reverse(obss); for (Obs obs : obss) { if (obs.getObsDatetime().compareTo(target.getDateEnrolled()) >= 0 && (target.getDateCompleted() == null || obs.getObsDatetime().compareTo(target.getDateCompleted()) < 0)) { return obs; } } return null; } Enrollment(PatientProgram target); Obs firstObs(Concept concept); Encounter lastEncounter(EncounterType type); Encounter encounterByForm(EncounterType encounterType, Form form);  }