@Test public void evaluate_shouldCalculateCurrentArtRegimen() throws Exception { Concept azt = Context.getConceptService().getConcept(86663); Concept _3tc = Context.getConceptService().getConcept(78643); Concept efv = Context.getConceptService().getConcept(75523); Concept nvp = Context.getConceptService().getConcept(80586); Concept lpv = Context.getConceptService().getConcept(79040); Concept rtv = Context.getConceptService().getConcept(83412); EmrTestUtils.saveRegimenOrder(TestUtils.getPatient(6), Arrays.asList(azt, _3tc, efv), TestUtils.date(2011, 1, 1), TestUtils.date(2012, 1, 1)); EmrTestUtils.saveRegimenOrder(TestUtils.getPatient(6), Arrays.asList(azt, _3tc, efv), TestUtils.date(2012, 1, 1), null); EmrTestUtils.saveRegimenOrder(TestUtils.getPatient(7), Arrays.asList(azt, _3tc, efv), TestUtils.date(2011, 1, 1), TestUtils.date(2012, 1, 1)); EmrTestUtils.saveRegimenOrder(TestUtils.getPatient(7), Arrays.asList(azt, _3tc, nvp), TestUtils.date(2012, 1, 1), null); EmrTestUtils.saveRegimenOrder(TestUtils.getPatient(8), Arrays.asList(azt, _3tc, efv), TestUtils.date(2011, 1, 1), TestUtils.date(2012, 1, 1)); EmrTestUtils.saveRegimenOrder(TestUtils.getPatient(8), Arrays.asList(azt, _3tc, lpv, rtv), TestUtils.date(2012, 1, 1), null); List<Integer> cohort = Arrays.asList(2, 6, 7, 8); CalculationResultMap resultMap = new OnOriginalFirstLineArtCalculation().evaluate(cohort, null, Context.getService(PatientCalculationService.class).createCalculationContext()); Assert.assertFalse((Boolean) resultMap.get(2).getValue()); Assert.assertTrue((Boolean) resultMap.get(6).getValue()); Assert.assertFalse((Boolean) resultMap.get(7).getValue()); Assert.assertFalse((Boolean) resultMap.get(8).getValue()); }
@Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> arg1, PatientCalculationContext context) { CalculationResultMap initialArvs = calculate(new InitialArtRegimenCalculation(), cohort, context); CalculationResultMap currentArvs = calculate(new CurrentArtRegimenCalculation(), cohort, context); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean onOrigFirstLine = false; SimpleResult initialArvsResult = (SimpleResult) initialArvs.get(ptId); SimpleResult currentArvsResult = (SimpleResult) currentArvs.get(ptId); if (initialArvsResult != null && currentArvsResult != null) { RegimenOrder initialRegimen = (RegimenOrder) initialArvsResult.getValue(); RegimenOrder currentRegimen = (RegimenOrder) currentArvsResult.getValue(); onOrigFirstLine = initialRegimen.hasSameDrugs(currentRegimen) && EmrCalculationUtils.regimenInGroup(currentRegimen, "ARV", "adult-first"); } ret.put(ptId, new BooleanResult(onOrigFirstLine, this, context)); } return ret; }
OnOriginalFirstLineArtCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> arg1, PatientCalculationContext context) { CalculationResultMap initialArvs = calculate(new InitialArtRegimenCalculation(), cohort, context); CalculationResultMap currentArvs = calculate(new CurrentArtRegimenCalculation(), cohort, context); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean onOrigFirstLine = false; SimpleResult initialArvsResult = (SimpleResult) initialArvs.get(ptId); SimpleResult currentArvsResult = (SimpleResult) currentArvs.get(ptId); if (initialArvsResult != null && currentArvsResult != null) { RegimenOrder initialRegimen = (RegimenOrder) initialArvsResult.getValue(); RegimenOrder currentRegimen = (RegimenOrder) currentArvsResult.getValue(); onOrigFirstLine = initialRegimen.hasSameDrugs(currentRegimen) && EmrCalculationUtils.regimenInGroup(currentRegimen, "ARV", "adult-first"); } ret.put(ptId, new BooleanResult(onOrigFirstLine, this, context)); } return ret; } }
OnOriginalFirstLineArtCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> arg1, PatientCalculationContext context) { CalculationResultMap initialArvs = calculate(new InitialArtRegimenCalculation(), cohort, context); CalculationResultMap currentArvs = calculate(new CurrentArtRegimenCalculation(), cohort, context); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean onOrigFirstLine = false; SimpleResult initialArvsResult = (SimpleResult) initialArvs.get(ptId); SimpleResult currentArvsResult = (SimpleResult) currentArvs.get(ptId); if (initialArvsResult != null && currentArvsResult != null) { RegimenOrder initialRegimen = (RegimenOrder) initialArvsResult.getValue(); RegimenOrder currentRegimen = (RegimenOrder) currentArvsResult.getValue(); onOrigFirstLine = initialRegimen.hasSameDrugs(currentRegimen) && EmrCalculationUtils.regimenInGroup(currentRegimen, "ARV", "adult-first"); } ret.put(ptId, new BooleanResult(onOrigFirstLine, this, context)); } return ret; }  }
OnOriginalFirstLineArtCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> arg1, PatientCalculationContext context) { CalculationResultMap initialArvs = calculate(new InitialArtRegimenCalculation(), cohort, context); CalculationResultMap currentArvs = calculate(new CurrentArtRegimenCalculation(), cohort, context); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean onOrigFirstLine = false; SimpleResult initialArvsResult = (SimpleResult) initialArvs.get(ptId); SimpleResult currentArvsResult = (SimpleResult) currentArvs.get(ptId); if (initialArvsResult != null && currentArvsResult != null) { RegimenOrder initialRegimen = (RegimenOrder) initialArvsResult.getValue(); RegimenOrder currentRegimen = (RegimenOrder) currentArvsResult.getValue(); onOrigFirstLine = initialRegimen.hasSameDrugs(currentRegimen) && EmrCalculationUtils.regimenInGroup(currentRegimen, "ARV", "adult-first"); } ret.put(ptId, new BooleanResult(onOrigFirstLine, this, context)); } return ret; }  @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> arg1, PatientCalculationContext context); }
OnOriginalFirstLineArtCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> arg1, PatientCalculationContext context) { CalculationResultMap initialArvs = calculate(new InitialArtRegimenCalculation(), cohort, context); CalculationResultMap currentArvs = calculate(new CurrentArtRegimenCalculation(), cohort, context); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean onOrigFirstLine = false; SimpleResult initialArvsResult = (SimpleResult) initialArvs.get(ptId); SimpleResult currentArvsResult = (SimpleResult) currentArvs.get(ptId); if (initialArvsResult != null && currentArvsResult != null) { RegimenOrder initialRegimen = (RegimenOrder) initialArvsResult.getValue(); RegimenOrder currentRegimen = (RegimenOrder) currentArvsResult.getValue(); onOrigFirstLine = initialRegimen.hasSameDrugs(currentRegimen) && EmrCalculationUtils.regimenInGroup(currentRegimen, "ARV", "adult-first"); } ret.put(ptId, new BooleanResult(onOrigFirstLine, this, context)); } return ret; }  @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> arg1, PatientCalculationContext context);  }