@Test public void revisitsArt() throws Exception { EncounterType hivConsult = MetadataUtils.existing(EncounterType.class, HivMetadata._EncounterType.HIV_CONSULTATION); Concept stavudine = Context.getConceptService().getConcept(84309); Program hivProgram = MetadataUtils.existing(Program.class, HivMetadata._Program.HIV); TestUtils.enrollInProgram(TestUtils.getPatient(7), hivProgram,PERIOD_END); TestUtils.saveDrugOrder(TestUtils.getPatient(6), stavudine, TestUtils.date(2012, 6, 10), null); TestUtils.saveEncounter(TestUtils.getPatient(6), hivConsult, TestUtils.date(2012, 6, 20)); TestUtils.saveDrugOrder(TestUtils.getPatient(7), stavudine, TestUtils.date(2012, 5, 10), null); TestUtils.saveEncounter(TestUtils.getPatient(7), hivConsult, TestUtils.date(2012, 6, 20)); 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); }
public CohortDefinition revisitsArt() { CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.addParameter(new Parameter("fromDate", "From Date", Date.class)); cd.addParameter(new Parameter("toDate", "To Date", Date.class)); cd.addSearch("inCare", ReportUtils.map(currentlyInCare(), "onDate=${toDate}")); cd.addSearch("startedBefore", ReportUtils.map(artCohorts.startedArt(), "onOrBefore=${fromDate-1d}")); cd.addSearch("missedAppointment", ReportUtils.map(missedAppointment(), "onDate=${onDate}")); cd.addSearch("toDeadLtf", ReportUtils.map(hivCohortLibrary.transferredOutDeadAndLtf(), "onOrBefore=${toDate}")); cd.setCompositionString("inCare AND startedBefore AND NOT toDeadLtf"); return cd; }
Moh731CohortLibrary { public CohortDefinition revisitsArt() { CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.addParameter(new Parameter("fromDate", "From Date", Date.class)); cd.addParameter(new Parameter("toDate", "To Date", Date.class)); cd.addSearch("inCare", ReportUtils.map(currentlyInCare(), "onDate=${toDate}")); cd.addSearch("startedBefore", ReportUtils.map(artCohorts.startedArt(), "onOrBefore=${fromDate-1d}")); cd.addSearch("missedAppointment", ReportUtils.map(missedAppointment(), "onDate=${onDate}")); cd.addSearch("toDeadLtf", ReportUtils.map(hivCohortLibrary.transferredOutDeadAndLtf(), "onOrBefore=${toDate}")); cd.setCompositionString("inCare AND startedBefore AND NOT toDeadLtf"); return cd; } }
Moh731CohortLibrary { public CohortDefinition revisitsArt() { CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.addParameter(new Parameter("fromDate", "From Date", Date.class)); cd.addParameter(new Parameter("toDate", "To Date", Date.class)); cd.addSearch("inCare", ReportUtils.map(currentlyInCare(), "onDate=${toDate}")); cd.addSearch("startedBefore", ReportUtils.map(artCohorts.startedArt(), "onOrBefore=${fromDate-1d}")); cd.addSearch("missedAppointment", ReportUtils.map(missedAppointment(), "onDate=${onDate}")); cd.addSearch("toDeadLtf", ReportUtils.map(hivCohortLibrary.transferredOutDeadAndLtf(), "onOrBefore=${toDate}")); cd.setCompositionString("inCare AND startedBefore AND NOT toDeadLtf"); return cd; }  }
Moh731CohortLibrary { public CohortDefinition revisitsArt() { CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.addParameter(new Parameter("fromDate", "From Date", Date.class)); cd.addParameter(new Parameter("toDate", "To Date", Date.class)); cd.addSearch("inCare", ReportUtils.map(currentlyInCare(), "onDate=${toDate}")); cd.addSearch("startedBefore", ReportUtils.map(artCohorts.startedArt(), "onOrBefore=${fromDate-1d}")); cd.addSearch("missedAppointment", ReportUtils.map(missedAppointment(), "onDate=${onDate}")); cd.addSearch("toDeadLtf", ReportUtils.map(hivCohortLibrary.transferredOutDeadAndLtf(), "onOrBefore=${toDate}")); cd.setCompositionString("inCare AND startedBefore AND NOT toDeadLtf"); return cd; }  CohortDefinition currentlyInCare(); CohortDefinition missedAppointment(); CohortDefinition revisitsArt(); CohortDefinition hasAppointmentDateAndStartedArt(); CohortDefinition currentlyOnArt(); CohortDefinition onOriginalFirstLineAt12Months(); CohortDefinition onAlternateFirstLineAt12Months(); CohortDefinition onSecondLineAt12Months(); CohortDefinition onTherapyAt12Months(); }
Moh731CohortLibrary { public CohortDefinition revisitsArt() { CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.addParameter(new Parameter("fromDate", "From Date", Date.class)); cd.addParameter(new Parameter("toDate", "To Date", Date.class)); cd.addSearch("inCare", ReportUtils.map(currentlyInCare(), "onDate=${toDate}")); cd.addSearch("startedBefore", ReportUtils.map(artCohorts.startedArt(), "onOrBefore=${fromDate-1d}")); cd.addSearch("missedAppointment", ReportUtils.map(missedAppointment(), "onDate=${onDate}")); cd.addSearch("toDeadLtf", ReportUtils.map(hivCohortLibrary.transferredOutDeadAndLtf(), "onOrBefore=${toDate}")); cd.setCompositionString("inCare AND startedBefore AND NOT toDeadLtf"); return cd; }  CohortDefinition currentlyInCare(); CohortDefinition missedAppointment(); CohortDefinition revisitsArt(); CohortDefinition hasAppointmentDateAndStartedArt(); CohortDefinition currentlyOnArt(); CohortDefinition onOriginalFirstLineAt12Months(); CohortDefinition onAlternateFirstLineAt12Months(); CohortDefinition onSecondLineAt12Months(); CohortDefinition onTherapyAt12Months();  }