QiIndicatorLibrary { public CohortIndicator hivMonitoringCd4() { return cohortIndicator("HIV monitoring - CD4", map(qiCohorts.hasCD4ResultsAdult(), "onOrAfter=${startDate},onOrBefore=${endDate}"), map(qiCohorts.hasHivVisitAdult(), "onOrAfter=${startDate},onOrBefore=${endDate}") ); }  CohortIndicator hivMonitoringCd4(); CohortIndicator hasCd4Results(); CohortIndicator hasVisits(); CohortIndicator complimentHasCd4Results(); CohortIndicator nutritionalAssessment(); CohortIndicator nutritionalAssessmentNum(); CohortIndicator nutritionalAssessmentDen(); CohortIndicator artInitiation(); CohortIndicator patientsWhoAreEligibleAndStartedArt(); CohortIndicator hivInfectedPatientsNotOnArtAndHasHivClinicalVisit(); CohortIndicator complimentPatientsWhoAreEligibleAndStartedArt(); CohortIndicator patientsInCareAndHasAtLeast2Visits(); CohortIndicator patientsWithClinicalVisits(); CohortIndicator complimentPatientsWithClinicalVisits(); CohortIndicator clinicalVisit(); CohortIndicator hivMonitoringViralLoad(); CohortIndicator patientsOnArtHavingAtLeastOneViralLoad(); CohortIndicator onArtWithAtLeastOneClinicalVisit(); CohortIndicator complimentPatientsOnArtHavingAtLeastOneViralLoad(); CohortIndicator hivMonitoringViralLoadSuppression(); CohortIndicator onARTatLeast12MonthsAndVlLess1000(); CohortIndicator hivMonitoringViralLoadNumAndDen(); CohortIndicator complimentOnARTatLeast12MonthsAndVlLess1000(); CohortIndicator tbScreeningServiceCoverage(); CohortIndicator tbScreeningUsingIcfAdult(); CohortIndicator patientsCurrentlyNotOnTbTreatmentAndHaveClinicalVisit(); CohortIndicator complimentTbScreeningUsingIcfAdult(); CohortIndicator patientsEligibleForIPTWhoWereInitiatedOnIPT(); CohortIndicator patientsEligibleForNutritionalSupportAndWhoReceived(); CohortIndicator partnerTesting(); CohortIndicator childrenTesting(); CohortIndicator reproductiveHealthFamilyPlanning(); CohortIndicator reproductiveHealthFamilyPlanningNum(); CohortIndicator reproductiveHealthFamilyPlanningDen(); CohortIndicator complimentNutritionalAssessmentNum(); CohortIndicator complimentReproductiveHealthFamilyPlanningNum();  }
@Test public void hivMonitoringCd4() throws Exception { Concept cd4Percent = Dictionary.getConcept(Dictionary.CD4_PERCENT); EncounterType hivConsultation = MetadataUtils.existing(EncounterType.class, HivMetadata._EncounterType.HIV_CONSULTATION); TestUtils.saveEncounter(TestUtils.getPatient(6), hivConsultation, TestUtils.date(2012, 6, 1)); TestUtils.saveEncounter(TestUtils.getPatient(7), hivConsultation, TestUtils.date(2012, 1, 1)); TestUtils.saveObs(TestUtils.getPatient(7), cd4Percent, 30, TestUtils.date(2012, 6, 1)); Indicator ind = qiIndicatorLibrary.hivMonitoringCd4(); context.addParameterValue("endDate", TestUtils.date(2012, 6, 30)); CohortIndicatorResult result = (CohortIndicatorResult) Context.getService(IndicatorService.class).evaluate(ind, context); Fraction fraction = (Fraction) CohortIndicatorResult.getResultValue(result); Assert.assertThat(fraction.getNumerator(), is(1)); Assert.assertThat(fraction.getDenominator(), is(1)); }