@Test public void testedHivPositive_shouldReturnPatientsWhoTestedHivPositive() throws Exception { Concept hivStatus = Dictionary.getConcept(Dictionary.HIV_STATUS); Concept hivInfected = Dictionary.getConcept(Dictionary.HIV_INFECTED); Concept positive = Dictionary.getConcept(Dictionary.POSITIVE); Concept negative = Dictionary.getConcept(Dictionary.NEGATIVE); Concept unknown = Dictionary.getConcept(Dictionary.UNKNOWN); TestUtils.saveObs(TestUtils.getPatient(2), hivStatus, positive, TestUtils.date(2012, 6, 10)); TestUtils.saveObs(TestUtils.getPatient(6), hivStatus, negative, TestUtils.date(2012, 6, 10)); TestUtils.saveObs(TestUtils.getPatient(7), hivInfected, positive, TestUtils.date(2012, 6, 26)); TestUtils.saveObs(TestUtils.getPatient(8), hivInfected, unknown, TestUtils.date(2012, 5, 10)); CohortDefinition cd = hivCohortLibrary.testedHivStatus(positive); 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(2,7), evaluated); }
public CohortDefinition testedHivStatus(Concept status) { Concept hivStatus = Dictionary.getConcept(Dictionary.HIV_STATUS); Concept hivInfected = Dictionary.getConcept(Dictionary.HIV_INFECTED); CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("tested for positive for HIV"); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.addSearch("resultOfHivTestPositive", ReportUtils.map(commonCohorts.hasObs(hivStatus, status), "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("testedForHivHivInfectedPositive", ReportUtils.map(commonCohorts.hasObs(hivInfected ,status), "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.setCompositionString("resultOfHivTestPositive OR testedForHivHivInfectedPositive"); return cd; }
HivCohortLibrary { public CohortDefinition testedHivStatus(Concept status) { Concept hivStatus = Dictionary.getConcept(Dictionary.HIV_STATUS); Concept hivInfected = Dictionary.getConcept(Dictionary.HIV_INFECTED); CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("tested for positive for HIV"); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.addSearch("resultOfHivTestPositive", ReportUtils.map(commonCohorts.hasObs(hivStatus, status), "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("testedForHivHivInfectedPositive", ReportUtils.map(commonCohorts.hasObs(hivInfected ,status), "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.setCompositionString("resultOfHivTestPositive OR testedForHivHivInfectedPositive"); return cd; } }
HivCohortLibrary { public CohortDefinition testedHivStatus(Concept status) { Concept hivStatus = Dictionary.getConcept(Dictionary.HIV_STATUS); Concept hivInfected = Dictionary.getConcept(Dictionary.HIV_INFECTED); CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("tested for positive for HIV"); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.addSearch("resultOfHivTestPositive", ReportUtils.map(commonCohorts.hasObs(hivStatus, status), "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("testedForHivHivInfectedPositive", ReportUtils.map(commonCohorts.hasObs(hivInfected ,status), "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.setCompositionString("resultOfHivTestPositive OR testedForHivHivInfectedPositive"); return cd; }  }
HivCohortLibrary { public CohortDefinition testedHivStatus(Concept status) { Concept hivStatus = Dictionary.getConcept(Dictionary.HIV_STATUS); Concept hivInfected = Dictionary.getConcept(Dictionary.HIV_INFECTED); CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("tested for positive for HIV"); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.addSearch("resultOfHivTestPositive", ReportUtils.map(commonCohorts.hasObs(hivStatus, status), "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("testedForHivHivInfectedPositive", ReportUtils.map(commonCohorts.hasObs(hivInfected ,status), "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.setCompositionString("resultOfHivTestPositive OR testedForHivHivInfectedPositive"); return cd; }  CohortDefinition referredFrom(Concept... entryPoints); CohortDefinition referredNotFrom(Concept... entryPoints); CohortDefinition enrolled(); CohortDefinition enrolledExcludingTransfers(); CohortDefinition enrolledExcludingTransfersAndReferredFrom(Concept... entryPoints); CohortDefinition enrolledExcludingTransfersAndNotReferredFrom(Concept... entryPoints); CohortDefinition hasCd4Result(); CohortDefinition hasHivVisit(); CohortDefinition onCtxProphylaxis(); CohortDefinition transferredOutDeadAndLtf(); CohortDefinition inHivProgramAndOnCtxProphylaxis(); CohortDefinition inHivProgramAndOnFluconazoleProphylaxis(); CohortDefinition inHivProgramAndOnAnyProphylaxis(); CohortDefinition testedForHiv(); CohortDefinition testedHivStatus(Concept status); CohortDefinition startedArtFromTransferringFacilityOnDate(); CohortDefinition firstProgramEnrollment(Integer outcomePeriod); }
HivCohortLibrary { public CohortDefinition testedHivStatus(Concept status) { Concept hivStatus = Dictionary.getConcept(Dictionary.HIV_STATUS); Concept hivInfected = Dictionary.getConcept(Dictionary.HIV_INFECTED); CompositionCohortDefinition cd = new CompositionCohortDefinition(); cd.setName("tested for positive for HIV"); cd.addParameter(new Parameter("onOrAfter", "After Date", Date.class)); cd.addParameter(new Parameter("onOrBefore", "Before Date", Date.class)); cd.addSearch("resultOfHivTestPositive", ReportUtils.map(commonCohorts.hasObs(hivStatus, status), "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.addSearch("testedForHivHivInfectedPositive", ReportUtils.map(commonCohorts.hasObs(hivInfected ,status), "onOrAfter=${onOrAfter},onOrBefore=${onOrBefore}")); cd.setCompositionString("resultOfHivTestPositive OR testedForHivHivInfectedPositive"); return cd; }  CohortDefinition referredFrom(Concept... entryPoints); CohortDefinition referredNotFrom(Concept... entryPoints); CohortDefinition enrolled(); CohortDefinition enrolledExcludingTransfers(); CohortDefinition enrolledExcludingTransfersAndReferredFrom(Concept... entryPoints); CohortDefinition enrolledExcludingTransfersAndNotReferredFrom(Concept... entryPoints); CohortDefinition hasCd4Result(); CohortDefinition hasHivVisit(); CohortDefinition onCtxProphylaxis(); CohortDefinition transferredOutDeadAndLtf(); CohortDefinition inHivProgramAndOnCtxProphylaxis(); CohortDefinition inHivProgramAndOnFluconazoleProphylaxis(); CohortDefinition inHivProgramAndOnAnyProphylaxis(); CohortDefinition testedForHiv(); CohortDefinition testedHivStatus(Concept status); CohortDefinition startedArtFromTransferringFacilityOnDate(); CohortDefinition firstProgramEnrollment(Integer outcomePeriod);  }