/** @see Moh731CohortLibrary#revisitsArt() */ @Test public void revisitsArt() throws Exception { EncounterType hivConsult = MetadataUtils.getEncounterType(HivMetadata._EncounterType.HIV_CONSULTATION); Concept stavudine = Context.getConceptService().getConcept(84309); // Start patient #6 this month and give them a visit in the reporting period + 2 months TestUtils.saveDrugOrder(TestUtils.getPatient(6), stavudine, TestUtils.date(2012, 6, 10), null); TestUtils.saveEncounter(TestUtils.getPatient(6), hivConsult, TestUtils.date(2012, 6, 20)); // Start patient #7 in previous month and give them a visit in the reporting period + 2 months TestUtils.saveDrugOrder(TestUtils.getPatient(7), stavudine, TestUtils.date(2012, 5, 10), null); TestUtils.saveEncounter(TestUtils.getPatient(7), hivConsult, TestUtils.date(2012, 6, 20)); // Start patient #8 and give them visit outside of reporting period + 2 month window TestUtils.saveDrugOrder(TestUtils.getPatient(8), stavudine, TestUtils.date(2012, 1, 10), null); TestUtils.saveEncounter(TestUtils.getPatient(8), hivConsult, TestUtils.date(2012, 1, 20)); CohortDefinition cd = moh731Cohorts.revisitsArt(); context.addParameterValue("fromDate", PERIOD_START); context.addParameterValue("toDate", PERIOD_END); EvaluatedCohort evaluated = Context.getService(CohortDefinitionService.class).evaluate(cd, context); ReportingTestUtils.assertCohortEquals(Arrays.asList(7), evaluated); }
/** @see Moh731CohortLibrary#currentlyInCare() */ @Test public void currentlyInCare() throws Exception { EncounterType triage = MetadataUtils.getEncounterType(CommonMetadata._EncounterType.TRIAGE); EncounterType hivConsult = MetadataUtils.getEncounterType(HivMetadata._EncounterType.HIV_CONSULTATION); // Give patient #2 irrelevant encounter during 90 day window TestUtils.saveEncounter(TestUtils.getPatient(2), triage, TestUtils.date(2012, 6, 15)); // Give patient #6 relevant encounter before and after 90 day window TestUtils.saveEncounter(TestUtils.getPatient(6), hivConsult, TestUtils.date(2012, 3, 31)); TestUtils.saveEncounter(TestUtils.getPatient(6), hivConsult, TestUtils.date(2012, 7, 1)); // Give patient #7 relevant encounter at start of 90 day window TestUtils.saveEncounter(TestUtils.getPatient(7), hivConsult, TestUtils.date(2012, 4, 1)); // Give patient #8 relevant encounter at end of 90 day window TestUtils.saveEncounter(TestUtils.getPatient(8), hivConsult, TestUtils.date(2012, 6, 30)); CohortDefinition cd = moh731Cohorts.currentlyInCare(); context.addParameterValue("onDate", PERIOD_END); EvaluatedCohort evaluated = Context.getService(CohortDefinitionService.class).evaluate(cd, context); ReportingTestUtils.assertCohortEquals(Arrays.asList(7, 8), evaluated); }