@Test public void hadNutritionalAssessmentAtLastVisit() throws Exception { Concept weight = Dictionary.getConcept(Dictionary.WEIGHT_KG); Concept height = Dictionary.getConcept(Dictionary.HEIGHT_CM); Concept muac = Dictionary.getConcept(Dictionary.MUAC); EncounterType hivConsultation = MetadataUtils.existing(EncounterType.class, HivMetadata._EncounterType.HIV_CONSULTATION); VisitType outpatient = MetadataUtils.existing(VisitType.class, CommonMetadata._VisitType.OUTPATIENT); TestUtils.saveVisit(TestUtils.getPatient(6), outpatient, TestUtils.date(2012, 6, 1, 8, 0, 0), TestUtils.date(2012, 6, 1, 10, 0, 0), TestUtils.saveEncounter(TestUtils.getPatient(6), hivConsultation, TestUtils.date(2012, 6, 1, 9, 0, 0), TestUtils.saveObs(TestUtils.getPatient(6), weight, 80, TestUtils.date(2012, 6, 1, 9, 0, 0)), TestUtils.saveObs(TestUtils.getPatient(6), height, 150, TestUtils.date(2012, 6, 1, 9, 0, 0)) ) ); TestUtils.saveVisit(TestUtils.getPatient(7), outpatient, TestUtils.date(2012, 6, 1, 8, 0, 0), TestUtils.date(2012, 6, 1, 10, 0, 0), TestUtils.saveEncounter(TestUtils.getPatient(7), hivConsultation, TestUtils.date(2012, 6, 1, 9, 0, 0), TestUtils.saveObs(TestUtils.getPatient(7), muac, 10, TestUtils.date(2012, 6, 1, 9, 0, 0)) ) ); TestUtils.saveVisit(TestUtils.getPatient(8), outpatient, TestUtils.date(2012, 6, 1, 8, 0, 0), TestUtils.date(2012, 6, 1, 10, 0, 0), TestUtils.saveEncounter(TestUtils.getPatient(8), hivConsultation, TestUtils.date(2012, 6, 1, 9, 0, 0), TestUtils.saveObs(TestUtils.getPatient(8), muac, 10, TestUtils.date(2012, 6, 1, 9, 0, 0)) ) ); TestUtils.saveVisit(TestUtils.getPatient(8), outpatient, TestUtils.date(2012, 6, 2, 8, 0, 0), TestUtils.date(2012, 6, 2, 10, 0, 0), TestUtils.saveEncounter(TestUtils.getPatient(8), hivConsultation, TestUtils.date(2012, 6, 2, 9, 0, 0)) ); TestUtils.saveVisit(TestUtils.getPatient(2), outpatient, TestUtils.date(2012, 7, 1, 8, 0, 0), TestUtils.date(2012, 7, 1, 10, 0, 0), TestUtils.saveEncounter(TestUtils.getPatient(2), hivConsultation, TestUtils.date(2012, 7, 1, 9, 0, 0), TestUtils.saveObs(TestUtils.getPatient(2), muac, 10, TestUtils.date(2012, 7, 1, 9, 0, 0)) ) ); CohortDefinition cd = qiICohortLibrary.hadNutritionalAssessmentAtLastVisit(); context.addParameterValue("onOrBefore", TestUtils.date(2012, 6, 30)); EvaluatedCohort cohort = Context.getService(CohortDefinitionService.class).evaluate(cd, context); ReportingTestUtils.assertCohortEquals(Arrays.asList(7), cohort); }
public CohortDefinition hadNutritionalAssessmentAtLastVisit() { Concept weight = Dictionary.getConcept(Dictionary.WEIGHT_KG); Concept height = Dictionary.getConcept(Dictionary.HEIGHT_CM); Concept muac = Dictionary.getConcept(Dictionary.MUAC); ObsInLastVisitCohortDefinition hadWeight = new ObsInLastVisitCohortDefinition(); hadWeight.setName("patients with weight obs in last visit Child"); hadWeight.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); hadWeight.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); hadWeight.setQuestion(weight); ObsInLastVisitCohortDefinition hadHeight = new ObsInLastVisitCohortDefinition(); hadHeight.setName("patients with height obs in last visit Child"); hadHeight.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); hadHeight.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); hadHeight.setQuestion(height); ObsInLastVisitCohortDefinition hadMuac = new ObsInLastVisitCohortDefinition(); hadMuac.setName("patients with MUAC obs in last visit Child"); hadMuac.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); hadMuac.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); hadMuac.setQuestion(muac); CompositionCohortDefinition cd =new CompositionCohortDefinition(); hadMuac.setName("patients with nutritional assessment in last visit Child"); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addSearch("hadWeight", ReportUtils.map(hadWeight, "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("hadHeight", ReportUtils.map(hadHeight, "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("hadMuac", ReportUtils.map(hadMuac, "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("adult", ReportUtils.map(commonCohorts.agedAtLeast(15), "effectiveDate=${onOrBefore}")); cd.addSearch("deceased", ReportUtils.map(commonCohorts.deceasedPatients(), "onDate=${onOrBefore}")); cd.setCompositionString("((hadWeight AND hadHeight AND adult) OR hadMuac) AND NOT deceased"); return cd; }
QiCohortLibrary { public CohortDefinition hadNutritionalAssessmentAtLastVisit() { Concept weight = Dictionary.getConcept(Dictionary.WEIGHT_KG); Concept height = Dictionary.getConcept(Dictionary.HEIGHT_CM); Concept muac = Dictionary.getConcept(Dictionary.MUAC); ObsInLastVisitCohortDefinition hadWeight = new ObsInLastVisitCohortDefinition(); hadWeight.setName("patients with weight obs in last visit Child"); hadWeight.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); hadWeight.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); hadWeight.setQuestion(weight); ObsInLastVisitCohortDefinition hadHeight = new ObsInLastVisitCohortDefinition(); hadHeight.setName("patients with height obs in last visit Child"); hadHeight.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); hadHeight.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); hadHeight.setQuestion(height); ObsInLastVisitCohortDefinition hadMuac = new ObsInLastVisitCohortDefinition(); hadMuac.setName("patients with MUAC obs in last visit Child"); hadMuac.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); hadMuac.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); hadMuac.setQuestion(muac); CompositionCohortDefinition cd =new CompositionCohortDefinition(); hadMuac.setName("patients with nutritional assessment in last visit Child"); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addSearch("hadWeight", ReportUtils.map(hadWeight, "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("hadHeight", ReportUtils.map(hadHeight, "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("hadMuac", ReportUtils.map(hadMuac, "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("adult", ReportUtils.map(commonCohorts.agedAtLeast(15), "effectiveDate=${onOrBefore}")); cd.addSearch("deceased", ReportUtils.map(commonCohorts.deceasedPatients(), "onDate=${onOrBefore}")); cd.setCompositionString("((hadWeight AND hadHeight AND adult) OR hadMuac) AND NOT deceased"); return cd; } }
QiCohortLibrary { public CohortDefinition hadNutritionalAssessmentAtLastVisit() { Concept weight = Dictionary.getConcept(Dictionary.WEIGHT_KG); Concept height = Dictionary.getConcept(Dictionary.HEIGHT_CM); Concept muac = Dictionary.getConcept(Dictionary.MUAC); ObsInLastVisitCohortDefinition hadWeight = new ObsInLastVisitCohortDefinition(); hadWeight.setName("patients with weight obs in last visit Child"); hadWeight.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); hadWeight.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); hadWeight.setQuestion(weight); ObsInLastVisitCohortDefinition hadHeight = new ObsInLastVisitCohortDefinition(); hadHeight.setName("patients with height obs in last visit Child"); hadHeight.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); hadHeight.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); hadHeight.setQuestion(height); ObsInLastVisitCohortDefinition hadMuac = new ObsInLastVisitCohortDefinition(); hadMuac.setName("patients with MUAC obs in last visit Child"); hadMuac.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); hadMuac.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); hadMuac.setQuestion(muac); CompositionCohortDefinition cd =new CompositionCohortDefinition(); hadMuac.setName("patients with nutritional assessment in last visit Child"); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addSearch("hadWeight", ReportUtils.map(hadWeight, "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("hadHeight", ReportUtils.map(hadHeight, "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("hadMuac", ReportUtils.map(hadMuac, "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("adult", ReportUtils.map(commonCohorts.agedAtLeast(15), "effectiveDate=${onOrBefore}")); cd.addSearch("deceased", ReportUtils.map(commonCohorts.deceasedPatients(), "onDate=${onOrBefore}")); cd.setCompositionString("((hadWeight AND hadHeight AND adult) OR hadMuac) AND NOT deceased"); return cd; }  }
QiCohortLibrary { public CohortDefinition hadNutritionalAssessmentAtLastVisit() { Concept weight = Dictionary.getConcept(Dictionary.WEIGHT_KG); Concept height = Dictionary.getConcept(Dictionary.HEIGHT_CM); Concept muac = Dictionary.getConcept(Dictionary.MUAC); ObsInLastVisitCohortDefinition hadWeight = new ObsInLastVisitCohortDefinition(); hadWeight.setName("patients with weight obs in last visit Child"); hadWeight.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); hadWeight.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); hadWeight.setQuestion(weight); ObsInLastVisitCohortDefinition hadHeight = new ObsInLastVisitCohortDefinition(); hadHeight.setName("patients with height obs in last visit Child"); hadHeight.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); hadHeight.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); hadHeight.setQuestion(height); ObsInLastVisitCohortDefinition hadMuac = new ObsInLastVisitCohortDefinition(); hadMuac.setName("patients with MUAC obs in last visit Child"); hadMuac.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); hadMuac.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); hadMuac.setQuestion(muac); CompositionCohortDefinition cd =new CompositionCohortDefinition(); hadMuac.setName("patients with nutritional assessment in last visit Child"); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addSearch("hadWeight", ReportUtils.map(hadWeight, "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("hadHeight", ReportUtils.map(hadHeight, "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("hadMuac", ReportUtils.map(hadMuac, "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("adult", ReportUtils.map(commonCohorts.agedAtLeast(15), "effectiveDate=${onOrBefore}")); cd.addSearch("deceased", ReportUtils.map(commonCohorts.deceasedPatients(), "onDate=${onOrBefore}")); cd.setCompositionString("((hadWeight AND hadHeight AND adult) OR hadMuac) AND NOT deceased"); return cd; }  CohortDefinition hadNutritionalAssessmentAtLastVisit(); CohortDefinition hadNutritionalAssessmentAtLastVisitAndhasHivVisitAdult(); CohortDefinition hivInfectedAndNotOnARTAndHasHivClinicalVisit(); CohortDefinition inCareHasAtLeast2Visits(); CohortDefinition clinicalVisit(); CohortDefinition complimentClinicalVisit(); CohortDefinition patientsInCareAndHasAtLeast2Visits(); CohortDefinition enrolledIn4To6MonthOfReviewPeriod(); CohortDefinition viralLoadResultsDuringLast12Months(int months); CohortDefinition onARTatLeast12MonthsAndHaveAtLeastVLResultsDuringTheLast12Months(); CohortDefinition onARTatLeast12MonthAndHaveAtLeastOneVisitDuringTheLast6MonthsReview(); CohortDefinition hivMonitoringViralLoadNumAndDen(); CohortDefinition onARTatLeast12MonthsAndHaveAtLeastOneVisitDuringTheLast6MonthsReview(); CohortDefinition onARTatLeast12MonthsAndVlLess1000(); CohortDefinition onARTatLeast12MonthsAndVlLess1000AndHivMonitoringViralLoadNumAndDen(); CohortDefinition hivInfectedNotOnTbTreatmentHaveAtLeastOneHivClinicalVisitDuring6Months(); CohortDefinition patientWithNegativeTbScreenWhoHaveNotHadIPT(); CohortDefinition onINHProphylaxis(); CohortDefinition patientsWhoHaveHadNoIptWithinLast2YearsTbNegativeDuring6MonthsReviewPeriod(); CohortDefinition patientsWhoMeetNutritionalSupportAtLastClinicVisit(); CohortDefinition patientsWhoMeetCriteriaForNutritionalSupport(); CohortDefinition hivPositivePatientsWhosePartnersAreHivPositive(); CohortDefinition hivPositivePatientsWithAtLeastOnePartner(); CohortDefinition hivPositivePatientsWhoseChildrenAreHivPositive(); CohortDefinition hivPositivePatientsWithAtLeastOneChildOrMinor(); CohortDefinition nonPregnantWomen15To49YearsOnModernContraceptives(); CohortDefinition nonPregnantWomen15To49YearsOnModernContraceptivesAndHasVisits(); CohortDefinition nonPregnantWomen15To49YearsWithAtLeastOneHivClinicalVisit(); CohortDefinition hasCD4ResultsAdult(); CohortDefinition hasHivVisitAdult(); CohortDefinition hasCD4ResultsAndHasHivVisitAdult(); CohortDefinition screenedForTBUsingICF(); CohortDefinition screenedForTBUsingICFNotOnTbTreatmentAndHsaClinicalVisits(); CohortDefinition complimentHasCd4Results(); CohortDefinition complimentPatientsWhoAreEligibleAndStartedArt(); CohortDefinition complimentPatientsOnArtHavingAtLeastOneViralLoad(); CohortDefinition complimentOnARTatLeast12MonthsAndVlLess1000(); CohortDefinition complimentTbScreeningUsingIcfAdult(); CohortDefinition complimentNutritionalAssessmentNum(); CohortDefinition complimentReproductiveHealthFamilyPlanningNum(); }
QiCohortLibrary { public CohortDefinition hadNutritionalAssessmentAtLastVisit() { Concept weight = Dictionary.getConcept(Dictionary.WEIGHT_KG); Concept height = Dictionary.getConcept(Dictionary.HEIGHT_CM); Concept muac = Dictionary.getConcept(Dictionary.MUAC); ObsInLastVisitCohortDefinition hadWeight = new ObsInLastVisitCohortDefinition(); hadWeight.setName("patients with weight obs in last visit Child"); hadWeight.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); hadWeight.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); hadWeight.setQuestion(weight); ObsInLastVisitCohortDefinition hadHeight = new ObsInLastVisitCohortDefinition(); hadHeight.setName("patients with height obs in last visit Child"); hadHeight.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); hadHeight.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); hadHeight.setQuestion(height); ObsInLastVisitCohortDefinition hadMuac = new ObsInLastVisitCohortDefinition(); hadMuac.setName("patients with MUAC obs in last visit Child"); hadMuac.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); hadMuac.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); hadMuac.setQuestion(muac); CompositionCohortDefinition cd =new CompositionCohortDefinition(); hadMuac.setName("patients with nutritional assessment in last visit Child"); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addSearch("hadWeight", ReportUtils.map(hadWeight, "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("hadHeight", ReportUtils.map(hadHeight, "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("hadMuac", ReportUtils.map(hadMuac, "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("adult", ReportUtils.map(commonCohorts.agedAtLeast(15), "effectiveDate=${onOrBefore}")); cd.addSearch("deceased", ReportUtils.map(commonCohorts.deceasedPatients(), "onDate=${onOrBefore}")); cd.setCompositionString("((hadWeight AND hadHeight AND adult) OR hadMuac) AND NOT deceased"); return cd; }  CohortDefinition hadNutritionalAssessmentAtLastVisit(); CohortDefinition hadNutritionalAssessmentAtLastVisitAndhasHivVisitAdult(); CohortDefinition hivInfectedAndNotOnARTAndHasHivClinicalVisit(); CohortDefinition inCareHasAtLeast2Visits(); CohortDefinition clinicalVisit(); CohortDefinition complimentClinicalVisit(); CohortDefinition patientsInCareAndHasAtLeast2Visits(); CohortDefinition enrolledIn4To6MonthOfReviewPeriod(); CohortDefinition viralLoadResultsDuringLast12Months(int months); CohortDefinition onARTatLeast12MonthsAndHaveAtLeastVLResultsDuringTheLast12Months(); CohortDefinition onARTatLeast12MonthAndHaveAtLeastOneVisitDuringTheLast6MonthsReview(); CohortDefinition hivMonitoringViralLoadNumAndDen(); CohortDefinition onARTatLeast12MonthsAndHaveAtLeastOneVisitDuringTheLast6MonthsReview(); CohortDefinition onARTatLeast12MonthsAndVlLess1000(); CohortDefinition onARTatLeast12MonthsAndVlLess1000AndHivMonitoringViralLoadNumAndDen(); CohortDefinition hivInfectedNotOnTbTreatmentHaveAtLeastOneHivClinicalVisitDuring6Months(); CohortDefinition patientWithNegativeTbScreenWhoHaveNotHadIPT(); CohortDefinition onINHProphylaxis(); CohortDefinition patientsWhoHaveHadNoIptWithinLast2YearsTbNegativeDuring6MonthsReviewPeriod(); CohortDefinition patientsWhoMeetNutritionalSupportAtLastClinicVisit(); CohortDefinition patientsWhoMeetCriteriaForNutritionalSupport(); CohortDefinition hivPositivePatientsWhosePartnersAreHivPositive(); CohortDefinition hivPositivePatientsWithAtLeastOnePartner(); CohortDefinition hivPositivePatientsWhoseChildrenAreHivPositive(); CohortDefinition hivPositivePatientsWithAtLeastOneChildOrMinor(); CohortDefinition nonPregnantWomen15To49YearsOnModernContraceptives(); CohortDefinition nonPregnantWomen15To49YearsOnModernContraceptivesAndHasVisits(); CohortDefinition nonPregnantWomen15To49YearsWithAtLeastOneHivClinicalVisit(); CohortDefinition hasCD4ResultsAdult(); CohortDefinition hasHivVisitAdult(); CohortDefinition hasCD4ResultsAndHasHivVisitAdult(); CohortDefinition screenedForTBUsingICF(); CohortDefinition screenedForTBUsingICFNotOnTbTreatmentAndHsaClinicalVisits(); CohortDefinition complimentHasCd4Results(); CohortDefinition complimentPatientsWhoAreEligibleAndStartedArt(); CohortDefinition complimentPatientsOnArtHavingAtLeastOneViralLoad(); CohortDefinition complimentOnARTatLeast12MonthsAndVlLess1000(); CohortDefinition complimentTbScreeningUsingIcfAdult(); CohortDefinition complimentNutritionalAssessmentNum(); CohortDefinition complimentReproductiveHealthFamilyPlanningNum();  }