@Test public void enrolledExcludingTransfers() throws Exception { Program hivProgram = MetadataUtils.existing(Program.class, HivMetadata._Program.HIV); Concept transferInDate = Dictionary.getConcept(Dictionary.TRANSFER_IN_DATE); TestUtils.enrollInProgram(TestUtils.getPatient(6), hivProgram, TestUtils.date(2012, 6, 1)); TestUtils.enrollInProgram(TestUtils.getPatient(7), hivProgram, TestUtils.date(2012, 6, 1)); TestUtils.saveObs(TestUtils.getPatient(7), transferInDate, TestUtils.date(2012, 6, 1), TestUtils.date(2012, 6, 1)); TestUtils.enrollInProgram(TestUtils.getPatient(8), hivProgram, TestUtils.date(2012, 7, 1)); CohortDefinition cd = commonCohortLibrary.enrolledExcludingTransfers(hivProgram); context.addParameterValue("onOrAfter", TestUtils.date(2012, 6, 1)); context.addParameterValue("onOrBefore", TestUtils.date(2012, 6, 30)); EvaluatedCohort evaluated = Context.getService(CohortDefinitionService.class).evaluate(cd, context); ReportingTestUtils.assertCohortEquals(Arrays.asList(6), evaluated); }
public CohortDefinition enrolledExcludingTransfers(Program... programs) { CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("enrolled excluding transfers in program between dates"); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.addSearch("enrolled", ReportUtils.map(enrolled(programs), "enrolledOnOrAfter=${onOrAfter},enrolledOnOrBefore=${onOrBefore}")); cd.addSearch("transferIn", ReportUtils.map(transferredIn(), "onOrBefore=${onOrBefore}")); cd.addSearch("completeProgram", ReportUtils.map(compltedProgram(), "completedOnOrBefore=${onOrBefore}")); cd.setCompositionString("enrolled AND NOT (transferIn OR completeProgram)"); return cd; }
CommonCohortLibrary { public CohortDefinition enrolledExcludingTransfers(Program... programs) { CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("enrolled excluding transfers in program between dates"); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.addSearch("enrolled", ReportUtils.map(enrolled(programs), "enrolledOnOrAfter=${onOrAfter},enrolledOnOrBefore=${onOrBefore}")); cd.addSearch("transferIn", ReportUtils.map(transferredIn(), "onOrBefore=${onOrBefore}")); cd.addSearch("completeProgram", ReportUtils.map(compltedProgram(), "completedOnOrBefore=${onOrBefore}")); cd.setCompositionString("enrolled AND NOT (transferIn OR completeProgram)"); return cd; } }
CommonCohortLibrary { public CohortDefinition enrolledExcludingTransfers(Program... programs) { CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("enrolled excluding transfers in program between dates"); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.addSearch("enrolled", ReportUtils.map(enrolled(programs), "enrolledOnOrAfter=${onOrAfter},enrolledOnOrBefore=${onOrBefore}")); cd.addSearch("transferIn", ReportUtils.map(transferredIn(), "onOrBefore=${onOrBefore}")); cd.addSearch("completeProgram", ReportUtils.map(compltedProgram(), "completedOnOrBefore=${onOrBefore}")); cd.setCompositionString("enrolled AND NOT (transferIn OR completeProgram)"); return cd; }  }
CommonCohortLibrary { public CohortDefinition enrolledExcludingTransfers(Program... programs) { CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("enrolled excluding transfers in program between dates"); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.addSearch("enrolled", ReportUtils.map(enrolled(programs), "enrolledOnOrAfter=${onOrAfter},enrolledOnOrBefore=${onOrBefore}")); cd.addSearch("transferIn", ReportUtils.map(transferredIn(), "onOrBefore=${onOrBefore}")); cd.addSearch("completeProgram", ReportUtils.map(compltedProgram(), "completedOnOrBefore=${onOrBefore}")); cd.setCompositionString("enrolled AND NOT (transferIn OR completeProgram)"); return cd; }  CohortDefinition females(); CohortDefinition males(); CohortDefinition agedAtMost(int maxAge); CohortDefinition agedAtLeast(int minAge); CohortDefinition agedAtLeastAgedAtMost(int minAge, int maxAge); CohortDefinition femalesAgedAtLeast18(); CohortDefinition hasEncounter(EncounterType... types); CohortDefinition hasObs(Concept question, Concept... answers); CohortDefinition transferredIn(); CohortDefinition transferredOut(); CohortDefinition enrolled(Program... programs); CohortDefinition enrolledExcludingTransfers(Program... programs); CohortDefinition enrolledExcludingTransfersOnDate(Program... programs); CohortDefinition pregnant(); CohortDefinition inProgram(Program program); CohortDefinition medicationDispensed(Concept... concepts); CohortDefinition compltedProgram(); CohortDefinition deceasedPatients(); CohortDefinition markedAsDeadButNotDeceased(); }
CommonCohortLibrary { public CohortDefinition enrolledExcludingTransfers(Program... programs) { CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("enrolled excluding transfers in program between dates"); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.addSearch("enrolled", ReportUtils.map(enrolled(programs), "enrolledOnOrAfter=${onOrAfter},enrolledOnOrBefore=${onOrBefore}")); cd.addSearch("transferIn", ReportUtils.map(transferredIn(), "onOrBefore=${onOrBefore}")); cd.addSearch("completeProgram", ReportUtils.map(compltedProgram(), "completedOnOrBefore=${onOrBefore}")); cd.setCompositionString("enrolled AND NOT (transferIn OR completeProgram)"); return cd; }  CohortDefinition females(); CohortDefinition males(); CohortDefinition agedAtMost(int maxAge); CohortDefinition agedAtLeast(int minAge); CohortDefinition agedAtLeastAgedAtMost(int minAge, int maxAge); CohortDefinition femalesAgedAtLeast18(); CohortDefinition hasEncounter(EncounterType... types); CohortDefinition hasObs(Concept question, Concept... answers); CohortDefinition transferredIn(); CohortDefinition transferredOut(); CohortDefinition enrolled(Program... programs); CohortDefinition enrolledExcludingTransfers(Program... programs); CohortDefinition enrolledExcludingTransfersOnDate(Program... programs); CohortDefinition pregnant(); CohortDefinition inProgram(Program program); CohortDefinition medicationDispensed(Concept... concepts); CohortDefinition compltedProgram(); CohortDefinition deceasedPatients(); CohortDefinition markedAsDeadButNotDeceased();  }