@Test public void netCohortMonths_shouldReturnPatientsInNetCohortMonths() throws Exception { int months = 12; Concept dapsone = Dictionary.getConcept(Dictionary.DAPSONE); Concept azt = Dictionary.getConcept(Dictionary.ZIDOVUDINE); Concept _3tc = Dictionary.getConcept(Dictionary.LAMIVUDINE); Concept efv = Dictionary.getConcept(Dictionary.EFAVIRENZ); TestUtils.saveDrugOrder(TestUtils.getPatient(7), dapsone, TestUtils.date(2013, 1, 1), null); EmrTestUtils.saveRegimenOrder(TestUtils.getPatient(6), Arrays.asList(azt, _3tc, efv), TestUtils.date(2012, 1, 1), TestUtils.date(2013, 1, 1)); CohortDefinition cd = artCohortLibrary.netCohortMonths(months); context.addParameterValue("onDate", TestUtils.date(2013, 1, 1)); EvaluatedCohort evaluated = Context.getService(CohortDefinitionService.class).evaluate(cd, context); ReportingTestUtils.assertCohortEquals(Arrays.asList(6), evaluated); }
public CohortDefinition netCohortMonths(int months) { CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("in " + months + " month net cohort on date"); cd.addParameter(new Parameter("onDate", "On Date", Date.class)); cd.addSearch("startedArtMonthsAgo", ReportUtils.map(startedArt(), "onOrAfter=${onDate-"+ (months + 1) + "m},onOrBefore=${onDate-" + months + "m}")); cd.addSearch("transferredOut", ReportUtils.map(commonCohorts.transferredOut(), "onOrAfter=${onDate-" + (months + 1) + "m}")); cd.setCompositionString("startedArtMonthsAgo AND NOT transferredOut"); return cd; }
ArtCohortLibrary { public CohortDefinition netCohortMonths(int months) { CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("in " + months + " month net cohort on date"); cd.addParameter(new Parameter("onDate", "On Date", Date.class)); cd.addSearch("startedArtMonthsAgo", ReportUtils.map(startedArt(), "onOrAfter=${onDate-"+ (months + 1) + "m},onOrBefore=${onDate-" + months + "m}")); cd.addSearch("transferredOut", ReportUtils.map(commonCohorts.transferredOut(), "onOrAfter=${onDate-" + (months + 1) + "m}")); cd.setCompositionString("startedArtMonthsAgo AND NOT transferredOut"); return cd; } }
ArtCohortLibrary { public CohortDefinition netCohortMonths(int months) { CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("in " + months + " month net cohort on date"); cd.addParameter(new Parameter("onDate", "On Date", Date.class)); cd.addSearch("startedArtMonthsAgo", ReportUtils.map(startedArt(), "onOrAfter=${onDate-"+ (months + 1) + "m},onOrBefore=${onDate-" + months + "m}")); cd.addSearch("transferredOut", ReportUtils.map(commonCohorts.transferredOut(), "onOrAfter=${onDate-" + (months + 1) + "m}")); cd.setCompositionString("startedArtMonthsAgo AND NOT transferredOut"); return cd; }  }
ArtCohortLibrary { public CohortDefinition netCohortMonths(int months) { CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("in " + months + " month net cohort on date"); cd.addParameter(new Parameter("onDate", "On Date", Date.class)); cd.addSearch("startedArtMonthsAgo", ReportUtils.map(startedArt(), "onOrAfter=${onDate-"+ (months + 1) + "m},onOrBefore=${onDate-" + months + "m}")); cd.addSearch("transferredOut", ReportUtils.map(commonCohorts.transferredOut(), "onOrAfter=${onDate-" + (months + 1) + "m}")); cd.setCompositionString("startedArtMonthsAgo AND NOT transferredOut"); 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 netCohortMonths(int months) { CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("in " + months + " month net cohort on date"); cd.addParameter(new Parameter("onDate", "On Date", Date.class)); cd.addSearch("startedArtMonthsAgo", ReportUtils.map(startedArt(), "onOrAfter=${onDate-"+ (months + 1) + "m},onOrBefore=${onDate-" + months + "m}")); cd.addSearch("transferredOut", ReportUtils.map(commonCohorts.transferredOut(), "onOrAfter=${onDate-" + (months + 1) + "m}")); cd.setCompositionString("startedArtMonthsAgo AND NOT transferredOut"); 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);  }