@Test public void medicationDispensed() throws Exception { Concept medsOrdered = Dictionary.getConcept(Dictionary.MEDICATION_ORDERS); Concept dapsone = Dictionary.getConcept(Dictionary.DAPSONE); Concept ctx = Dictionary.getConcept(Dictionary.SULFAMETHOXAZOLE_TRIMETHOPRIM); TestUtils.saveObs(TestUtils.getPatient(6), medsOrdered, ctx, TestUtils.date(2012, 6, 15)); TestUtils.saveObs(TestUtils.getPatient(7), medsOrdered, dapsone, TestUtils.date(2012, 6, 15)); TestUtils.saveObs(TestUtils.getPatient(8), medsOrdered, dapsone, TestUtils.date(2012, 7, 1)); CohortDefinition cd = commonCohortLibrary.medicationDispensed(dapsone); 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(7), evaluated); }
public CohortDefinition medicationDispensed(Concept... concepts) { CodedObsCohortDefinition cd = new CodedObsCohortDefinition(); cd.setName("dispensed medication between"); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.setTimeModifier(PatientSetService.TimeModifier.ANY); cd.setQuestion(Dictionary.getConcept(Dictionary.MEDICATION_ORDERS)); cd.setValueList(Arrays.asList(concepts)); cd.setOperator(SetComparator.IN); return cd; }
CommonCohortLibrary { public CohortDefinition medicationDispensed(Concept... concepts) { CodedObsCohortDefinition cd = new CodedObsCohortDefinition(); cd.setName("dispensed medication between"); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.setTimeModifier(PatientSetService.TimeModifier.ANY); cd.setQuestion(Dictionary.getConcept(Dictionary.MEDICATION_ORDERS)); cd.setValueList(Arrays.asList(concepts)); cd.setOperator(SetComparator.IN); return cd; } }
CommonCohortLibrary { public CohortDefinition medicationDispensed(Concept... concepts) { CodedObsCohortDefinition cd = new CodedObsCohortDefinition(); cd.setName("dispensed medication between"); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.setTimeModifier(PatientSetService.TimeModifier.ANY); cd.setQuestion(Dictionary.getConcept(Dictionary.MEDICATION_ORDERS)); cd.setValueList(Arrays.asList(concepts)); cd.setOperator(SetComparator.IN); return cd; }  }
CommonCohortLibrary { public CohortDefinition medicationDispensed(Concept... concepts) { CodedObsCohortDefinition cd = new CodedObsCohortDefinition(); cd.setName("dispensed medication between"); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.setTimeModifier(PatientSetService.TimeModifier.ANY); cd.setQuestion(Dictionary.getConcept(Dictionary.MEDICATION_ORDERS)); cd.setValueList(Arrays.asList(concepts)); cd.setOperator(SetComparator.IN); 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 medicationDispensed(Concept... concepts) { CodedObsCohortDefinition cd = new CodedObsCohortDefinition(); cd.setName("dispensed medication between"); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.setTimeModifier(PatientSetService.TimeModifier.ANY); cd.setQuestion(Dictionary.getConcept(Dictionary.MEDICATION_ORDERS)); cd.setValueList(Arrays.asList(concepts)); cd.setOperator(SetComparator.IN); 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();  }