@Test public void onRegimen_shouldReturnPatientsOnGivenRegimen() throws Exception { EncounterType scheduled = Context.getEncounterService().getEncounterType("Scheduled"); TestUtils.saveEncounter(TestUtils.getPatient(6), scheduled, TestUtils.date(2012, 1, 1)); TestUtils.saveEncounter(TestUtils.getPatient(7), scheduled, TestUtils.date(2012, 6, 1)); CohortDefinition cd = artCohortLibrary.onRegimen(Arrays.asList(azt, _3tc, efv)); context.addParameterValue("onDate", TestUtils.date(2012, 6, 30)); EvaluatedCohort evaluated = Context.getService(CohortDefinitionService.class).evaluate(cd, context); ReportingTestUtils.assertCohortEquals(Arrays.asList(7), evaluated); }
public CohortDefinition onRegimen(List<Concept> drugConcepts) { RegimenOrderCohortDefinition regCd = new RegimenOrderCohortDefinition(); Set<Concept> drugConceptSet = new HashSet<Concept>(drugConcepts); regCd.setName("ART regimen"); regCd.addParameter(new Parameter("onDate", "On Date", Date.class)); regCd.setMasterConceptSet(regimenManager.getMasterSetConcept("ARV")); regCd.setConceptSet(drugConceptSet); CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("Has an encounter in last 3 months and on regimen"); cd.addParameter(new Parameter("onDate", "On Date", Date.class)); cd.addSearch("onRegimen", ReportUtils.map(regCd, "onDate=${onDate}")); cd.addSearch("hasEncounterInLast3Months", ReportUtils.map(commonCohorts.hasEncounter(), "onOrBefore=${onDate},onOrAfter=${onDate-90d}")); cd.setCompositionString("onRegimen AND hasEncounterInLast3Months"); return cd; }
ArtCohortLibrary { public CohortDefinition onRegimen(List<Concept> drugConcepts) { RegimenOrderCohortDefinition regCd = new RegimenOrderCohortDefinition(); Set<Concept> drugConceptSet = new HashSet<Concept>(drugConcepts); regCd.setName("ART regimen"); regCd.addParameter(new Parameter("onDate", "On Date", Date.class)); regCd.setMasterConceptSet(regimenManager.getMasterSetConcept("ARV")); regCd.setConceptSet(drugConceptSet); CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("Has an encounter in last 3 months and on regimen"); cd.addParameter(new Parameter("onDate", "On Date", Date.class)); cd.addSearch("onRegimen", ReportUtils.map(regCd, "onDate=${onDate}")); cd.addSearch("hasEncounterInLast3Months", ReportUtils.map(commonCohorts.hasEncounter(), "onOrBefore=${onDate},onOrAfter=${onDate-90d}")); cd.setCompositionString("onRegimen AND hasEncounterInLast3Months"); return cd; } }
ArtCohortLibrary { public CohortDefinition onRegimen(List<Concept> drugConcepts) { RegimenOrderCohortDefinition regCd = new RegimenOrderCohortDefinition(); Set<Concept> drugConceptSet = new HashSet<Concept>(drugConcepts); regCd.setName("ART regimen"); regCd.addParameter(new Parameter("onDate", "On Date", Date.class)); regCd.setMasterConceptSet(regimenManager.getMasterSetConcept("ARV")); regCd.setConceptSet(drugConceptSet); CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("Has an encounter in last 3 months and on regimen"); cd.addParameter(new Parameter("onDate", "On Date", Date.class)); cd.addSearch("onRegimen", ReportUtils.map(regCd, "onDate=${onDate}")); cd.addSearch("hasEncounterInLast3Months", ReportUtils.map(commonCohorts.hasEncounter(), "onOrBefore=${onDate},onOrAfter=${onDate-90d}")); cd.setCompositionString("onRegimen AND hasEncounterInLast3Months"); return cd; }  }
ArtCohortLibrary { public CohortDefinition onRegimen(List<Concept> drugConcepts) { RegimenOrderCohortDefinition regCd = new RegimenOrderCohortDefinition(); Set<Concept> drugConceptSet = new HashSet<Concept>(drugConcepts); regCd.setName("ART regimen"); regCd.addParameter(new Parameter("onDate", "On Date", Date.class)); regCd.setMasterConceptSet(regimenManager.getMasterSetConcept("ARV")); regCd.setConceptSet(drugConceptSet); CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("Has an encounter in last 3 months and on regimen"); cd.addParameter(new Parameter("onDate", "On Date", Date.class)); cd.addSearch("onRegimen", ReportUtils.map(regCd, "onDate=${onDate}")); cd.addSearch("hasEncounterInLast3Months", ReportUtils.map(commonCohorts.hasEncounter(), "onOrBefore=${onDate},onOrAfter=${onDate-90d}")); cd.setCompositionString("onRegimen AND hasEncounterInLast3Months"); return cd; }  CohortDefinition eligibleForArt(); CohortDefinition EligibleForArtExclusive(); CohortDefinition lostToFollowUpPatients(); CohortDefinition onArt(); CohortDefinition missedAppointments(); CohortDefinition onArtAndMissedAppointments(); CohortDefinition onArtAndPregnant(); CohortDefinition onArtAndNotPregnant(); CohortDefinition onOriginalFirstLine(); CohortDefinition onAlternateFirstLine(); CohortDefinition onSecondLine(); CohortDefinition netCohortMonths(int months); CohortDefinition netCohortMonthsBetweenDatesGivenMonths(Integer period); CohortDefinition onRegimen(List<Concept> drugConcepts); CohortDefinition inHivProgramAndOnRegimen(List<Concept> drugConcepts); CohortDefinition pregnantAtArtStart(); CohortDefinition tbPatientAtArtStart(); CohortDefinition whoStageAtArtStart(int stage); CohortDefinition startedArt(); CohortDefinition eligibleAndStartedARTAdult(); CohortDefinition eligibleAndStartedARTAndHivInfectedAndNotOnARTAndHasHivClinicalVisit(); CohortDefinition eligibleAndStartedARTPeds(); CohortDefinition eligibleAndStartedARTPedsAndhivInfectedAndNotOnARTAndHasHivClinicalVisit(); CohortDefinition startedArtExcludingTransferinsOnDate(); CohortDefinition startedArtWhilePregnant(); CohortDefinition startedArtWhileTbPatient(); CohortDefinition startedArtWithWhoStage(int stage); }
ArtCohortLibrary { public CohortDefinition onRegimen(List<Concept> drugConcepts) { RegimenOrderCohortDefinition regCd = new RegimenOrderCohortDefinition(); Set<Concept> drugConceptSet = new HashSet<Concept>(drugConcepts); regCd.setName("ART regimen"); regCd.addParameter(new Parameter("onDate", "On Date", Date.class)); regCd.setMasterConceptSet(regimenManager.getMasterSetConcept("ARV")); regCd.setConceptSet(drugConceptSet); CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("Has an encounter in last 3 months and on regimen"); cd.addParameter(new Parameter("onDate", "On Date", Date.class)); cd.addSearch("onRegimen", ReportUtils.map(regCd, "onDate=${onDate}")); cd.addSearch("hasEncounterInLast3Months", ReportUtils.map(commonCohorts.hasEncounter(), "onOrBefore=${onDate},onOrAfter=${onDate-90d}")); cd.setCompositionString("onRegimen AND hasEncounterInLast3Months"); return cd; }  CohortDefinition eligibleForArt(); CohortDefinition EligibleForArtExclusive(); CohortDefinition lostToFollowUpPatients(); CohortDefinition onArt(); CohortDefinition missedAppointments(); CohortDefinition onArtAndMissedAppointments(); CohortDefinition onArtAndPregnant(); CohortDefinition onArtAndNotPregnant(); CohortDefinition onOriginalFirstLine(); CohortDefinition onAlternateFirstLine(); CohortDefinition onSecondLine(); CohortDefinition netCohortMonths(int months); CohortDefinition netCohortMonthsBetweenDatesGivenMonths(Integer period); CohortDefinition onRegimen(List<Concept> drugConcepts); CohortDefinition inHivProgramAndOnRegimen(List<Concept> drugConcepts); CohortDefinition pregnantAtArtStart(); CohortDefinition tbPatientAtArtStart(); CohortDefinition whoStageAtArtStart(int stage); CohortDefinition startedArt(); CohortDefinition eligibleAndStartedARTAdult(); CohortDefinition eligibleAndStartedARTAndHivInfectedAndNotOnARTAndHasHivClinicalVisit(); CohortDefinition eligibleAndStartedARTPeds(); CohortDefinition eligibleAndStartedARTPedsAndhivInfectedAndNotOnARTAndHasHivClinicalVisit(); CohortDefinition startedArtExcludingTransferinsOnDate(); CohortDefinition startedArtWhilePregnant(); CohortDefinition startedArtWhileTbPatient(); CohortDefinition startedArtWithWhoStage(int stage);  }