MchcsCohortLibrary { public CohortDefinition serologyAntBodyTestBetween9And12Months() { CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.addSearch("serologyAntBodyTest", ReportUtils.map(serologyAntBodyTest(), "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("ageBetween9And12Months", ReportUtils.map(ageBetween9And12Months(), "effectiveDate=${onOrBefore}")); cd.setCompositionString("serologyAntBodyTest AND ageBetween9And12Months"); return cd; }  CohortDefinition pcrWithinMonths(); CohortDefinition pcrInitialTest(); CohortDefinition age2Months(); CohortDefinition pcrInitialWithin2Months(); CohortDefinition ageBetween3And8Months(); CohortDefinition pcrInitialBetween3To8Months(); CohortDefinition serologyAntBodyTest(); CohortDefinition ageBetween9And12Months(); CohortDefinition serologyAntBodyTestBetween9And12Months(); CohortDefinition pcrBetween9And12MonthsAge(); CohortDefinition totalHeitestedBy12Months(); CohortDefinition detectedConfirmedStatus(); CohortDefinition pcrConfirmedPositive2Months(); CohortDefinition pcrConfirmedPositiveBetween3To8Months(); CohortDefinition pcrConfirmedPositiveBetween9To12Months(); CohortDefinition pcrTotalConfirmedPositive(); CohortDefinition ageAt6Months(); CohortDefinition exclusiveBreastFeeding(); CohortDefinition exclusiveReplacementFeeding(); CohortDefinition mixedFeeding(); CohortDefinition exclusiveBreastFeedingAtSixMonths(); CohortDefinition exclusiveReplacementFeedingAtSixMonths(); CohortDefinition mixedFeedingAtSixMonths(); CohortDefinition totalExposedAgedSixMoths(); CohortDefinition motherOnTreatmentAndBreastFeeding(); CohortDefinition motherOnTreatmentAndNotBreastFeeding(); CohortDefinition motherOnTreatmentAndNotBreastFeedingUnknown(); CohortDefinition totalBreastFeedingMotherOnTreatment(); CohortDefinition hivExposedInfants(); CohortDefinition hivExposedInfantsWithin2Months(); CohortDefinition hivExposedInfantsEligibleForCTX(); CohortDefinition hivExposedInfantsWithin2MonthsAndEligibleForCTX(); CohortDefinition scheduledVisitsInCWC();  }
@Test public void serologyAntBodyTestBetween9And12Months_shouldReturnPatientsWithSerologyAntBodyTestBetween9And12Months() throws Exception{ Concept hivRapidTest = Dictionary.getConcept(Dictionary.HIV_RAPID_TEST_1_QUALITATIVE); Concept negative = Dictionary.getConcept(Dictionary.NEGATIVE); Concept poorSampleQuality = Dictionary.getConcept(Dictionary.POOR_SAMPLE_QUALITY); Concept unknown = Dictionary.getConcept(Dictionary.UNKNOWN); TestUtils.saveObs(TestUtils.getPatient(6), hivRapidTest, negative, TestUtils.date(2008, 5, 19)); TestUtils.saveObs(TestUtils.getPatient(7), hivRapidTest, unknown, TestUtils.date(2012, 6, 15)); TestUtils.saveObs(TestUtils.getPatient(8), hivRapidTest, poorSampleQuality, TestUtils.date(2008, 5, 19)); CohortDefinition cd = mchcsCohortLibrary.serologyAntBodyTestBetween9And12Months(); context.addParameterValue("onOrAfter", TestUtils.date(2008, 4, 19)); context.addParameterValue("onOrBefore", TestUtils.date(2008, 5, 19)); EvaluatedCohort evaluated = Context.getService(CohortDefinitionService.class).evaluate(cd, context); ReportingTestUtils.assertCohortEquals(Arrays.asList(6), evaluated); }