TbCohortLibrary { public CohortDefinition pulmonaryTbSmearNegative() { CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.addSearch("pulmonaryTbPatients", ReportUtils.map(pulmonaryTbPatients(), "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("smearNegative", ReportUtils.map(smearNegativePatients(), "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.setCompositionString("pulmonaryTbPatients AND smearNegative"); return cd; }  CohortDefinition enrolled(); CohortDefinition screenedForTb(); CohortDefinition currentlyOnCareAndScreenedInTheLastVisit(); CohortDefinition screenedForTbAndNotOnTbTreatment(); CohortDefinition screenedForTbAndHivPositive(); CohortDefinition screenedForTbUsingICF(); CohortDefinition died(); CohortDefinition startedTbTreatmentBetweenDates(); CohortDefinition started12MonthsAgo(); CohortDefinition diedAndStarted12MonthsAgo(); CohortDefinition completedTreatment(); CohortDefinition defaulted(); CohortDefinition inTbAndHivProgramsAndOnCtxProphylaxis(); CohortDefinition testedForHivAndInTbProgram(); CohortDefinition testedHivPositiveAndInTbProgram(); CohortDefinition tbRetreatments(); CohortDefinition extraPulmonaryTbPatients(); CohortDefinition pulmonaryTbPatients(); CohortDefinition smearNegativePatients(); CohortDefinition smearPositivePatients(); CohortDefinition pulmonaryTbSmearNegative(); CohortDefinition pulmonaryTbSmearPositive(); CohortDefinition tbNewDetectedCases(); CohortDefinition pulmonaryTbSmearNotDone(); CohortDefinition ptbSmearNotDoneResultsAtMonths(); CohortDefinition startedTbTreatmentResultsAtMonths(Integer months); CohortDefinition completedInitialTreatment(); CohortDefinition totalEnrolledPtbSmearNotDoneResultsAtMonths(int highMonths, int leastMonths  ); CohortDefinition ptbSmearNotDoneResults2MonthsFinalizedInitialtreatment(); CohortDefinition ptbSmearNotDoneResults2MonthsDied(); CohortDefinition ptbSmearNotDoneResults2MonthsAbsconded(); CohortDefinition ptbSmearNotDoneResults2MonthsTransferredOut(); CohortDefinition ptbSmearNotDoneResults2MonthsTotalEvaluated(); CohortDefinition totalEnrolled8Months(int highMonths, int leastMonths ); CohortDefinition totalEnrolled8MonthsHivPositive(); CohortDefinition totalEnrolled8MonthsHivNegative(); CohortDefinition totalEnrolled8MonthsHivTestNotDone(); CohortDefinition totalEnrolled8MonthsHivPositiveNegativeTestNotDone(); CohortDefinition totalEnrolled8MonthsHivPositiveOnCpt(); CohortDefinition totalEnrolled8MonthsHivPositiveOnArt(); CohortDefinition finalizedInitialTreatmentResults8monthsHivPositive(); CohortDefinition diedResults8monthsHivPositive(); CohortDefinition abscondedResults8monthsHivPositive(); CohortDefinition transferredOutResults8monthsHivPositive(); CohortDefinition finalizedInitialTreatmentDiedAbscondedTransferredOutResults8monthsHivPositive(); CohortDefinition finalizedInitialTreatmentTotalEnrolled8MonthsHivNegative(); CohortDefinition diedTotalEnrolled8MonthsHivNegative(); CohortDefinition abscondedTotalEnrolled8MonthsHivNegative(); CohortDefinition transferredOutTotalEnrolled8MonthsHivNegative(); CohortDefinition finalizedInitialTreatmentDiedAbscondedTransferredOutResults8monthsHivNegative(); CohortDefinition finalizedInitialTreatmentTotalEnrolled8MonthsHivTestNotDone(); CohortDefinition diedTotalEnrolled8MonthsHivTestNotDone(); CohortDefinition abscondedTotalEnrolled8MonthsHivTestNotDone(); CohortDefinition transferredOutTotalEnrolled8MonthsHivTestNotDone(); CohortDefinition finalizedInitialTreatmentDiedAbscondedTransferredOutResults8monthsHivTestNotDone(); CohortDefinition finalizedInitialTreatmentTotalEnrolled8MonthsHivPositiveNegativeTestNotDone(); CohortDefinition diedTotalEnrolled8MonthsHivPositiveNegativeTestNotDone(); CohortDefinition abscondedTotalEnrolled8MonthsHivPositiveNegativeTestNotDone(); CohortDefinition transferredOutTotalEnrolled8MonthsHivPositiveNegativeTestNotDone(); CohortDefinition finalizedInitialTreatmentDiedAbscondedTransferredOutResults8monthsHivPositiveNegativeTestNotDone(); CohortDefinition finalizedInitialTreatmentTotalEnrolled8MonthsHivPositiveOnCpt(); CohortDefinition diedTotalEnrolled8MonthsHivPositiveOnCpt(); CohortDefinition abscondedTotalEnrolled8MonthsHivPositiveOnCpt(); CohortDefinition transferredOutTotalEnrolled8MonthsHivPositiveOnCpt(); CohortDefinition finalizedInitialTreatmentDiedAbscondedTransferredOutResults8monthsHivPositiveOnCpt(); CohortDefinition finalizedInitialTreatmentTotalEnrolled8MonthsHivPositiveOnArt(); CohortDefinition diedTotalEnrolled8MonthsHivPositiveOnArt(); CohortDefinition abscondedTotalEnrolled8MonthsHivPositiveOnArt(); CohortDefinition transferOutTotalEnrolled8MonthsHivPositiveOnArt(); CohortDefinition finalizedInitialTreatmentDiedAbscondedTransferredOutResults8monthsHivPositiveOnArt(); CohortDefinition newSputumSmearNegative12to15MonthsEarlierPulmonaryTbResults2Months(int highMonths, int leastMonths); CohortDefinition finalizedInitialTreatmentNewSputumSmearNegative12to15MonthsEarlierPulmonaryTbResults2Months(); CohortDefinition diedNewSputumSmearNegative12to15MonthsEarlierPulmonaryTbResults2Months(); CohortDefinition abscondedNewSputumSmearNegative12to15MonthsEarlierPulmonaryTbResults2Months(); CohortDefinition transferOutNewSputumSmearNegative12to15MonthsEarlierPulmonaryTbResults2Months(); CohortDefinition transferOutAbscondedDiedFinalizedInitialTreatmentNewSputumSmearNegative12to15MonthsEarlierPulmonaryTbResults2Months(); CohortDefinition newSputumSmearNegative12to15MonthsEarlierPulmonaryTbResults8Months(int highMonths, int leastMonths); CohortDefinition treatmentCompletedNewSputumSmearNegative12to15MonthsEarlierPulmonaryTbResults8Months(); CohortDefinition diedNewSputumSmearNegative12to15MonthsEarlierPulmonaryTbResults8Months(); CohortDefinition outOfControlNewSputumSmearNegative12to15MonthsEarlierPulmonaryTbResults8Months(); CohortDefinition transferOutNewSputumSmearNegative12to15MonthsEarlierPulmonaryTbResults8Months(); CohortDefinition becameSmearPositiveNewSputumSmearNegative12to15MonthsEarlierPulmonaryTbResults8Months(); CohortDefinition transferOutOutOfControlDiedCompletedTreatmentNewSputumSmearNegative12to15MonthsEarlierPulmonaryTbResults8Months(); CohortDefinition extraPulmonaryTbResultsAt2Months(int highMonths, int leastMonths); CohortDefinition finalizedInitialTreatmentExtraPulmonaryTbResultsAt2Months(); CohortDefinition diedExtraPulmonaryTbResultsAt2Months(); CohortDefinition abscondedExtraPulmonaryTbResultsAt2Months(); CohortDefinition transferredOutExtraPulmonaryTbResultsAt2Months(); CohortDefinition transferOutAbscondedDiedCompletedTreatmentNewSputumSmearNegative12to15MonthsEarlierPulmonaryTbResults8Months(); CohortDefinition extraPulmonaryTbResultsAt8Months(int highMonths, int leastMonths); CohortDefinition treatmentCompleteExtraPulmonaryTbResultsAt8Months(); CohortDefinition diedExtraPulmonaryTbResultsAt8Months(); CohortDefinition outOfControlExtraPulmonaryTbResultsAt8Months(); CohortDefinition transferredOutExtraPulmonaryTbResultsAt8Months(); CohortDefinition transferOutOutOfControlDiedCompletedTreatmentExtraPulmonaryTbResultsAt8Months();  }
@Test public void pulmonaryTbSmearNegative_shouldReturnPatientsWithPulmonaryTbSmearNegative() throws Exception{ Concept diseaseClassification = Dictionary.getConcept(Dictionary.SITE_OF_TUBERCULOSIS_DISEASE); Concept cultureResults = Dictionary.getConcept(Dictionary.RESULTS_TUBERCULOSIS_CULTURE); Concept extraPulmonary = Dictionary.getConcept(Dictionary.MYCROBACTERIUM_TUBERCULOSIS_EXTRAPULMONARY); Concept pulmonary = Dictionary.getConcept(Dictionary.PULMONARY_TB); Concept smearNegative = Dictionary.getConcept(Dictionary.NEGATIVE); Concept smearPositive = Dictionary.getConcept(Dictionary.POSITIVE); TestUtils.saveObs(TestUtils.getPatient(6), diseaseClassification, pulmonary, TestUtils.date(2012, 6, 10)); TestUtils.saveObs(TestUtils.getPatient(6), cultureResults, smearNegative, TestUtils.date(2012, 6, 11)); TestUtils.saveObs(TestUtils.getPatient(7), diseaseClassification, pulmonary, TestUtils.date(2012, 6, 10)); TestUtils.saveObs(TestUtils.getPatient(7), cultureResults, smearPositive, TestUtils.date(2012, 6, 11)); TestUtils.saveObs(TestUtils.getPatient(2), diseaseClassification, extraPulmonary, TestUtils.date(2012, 6, 10)); CohortDefinition cd = tbCohortLibrary.pulmonaryTbSmearNegative(); 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); }