@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 lpv = Context.getConceptService().getConcept(79040); Concept rtv = Context.getConceptService().getConcept(83412); EmrTestUtils.saveRegimenOrder(TestUtils.getPatient(7), Arrays.asList(azt, _3tc, efv), TestUtils.date(2011, 1, 1), null); EmrTestUtils.saveRegimenOrder(TestUtils.getPatient(8), Arrays.asList(azt, _3tc, lpv, rtv), TestUtils.date(2011, 1, 1), null); List<Integer> cohort = Arrays.asList(6, 7, 8); CalculationResultMap resultMap = new OnSecondLineArtCalculation().evaluate(cohort, null, Context.getService(PatientCalculationService.class).createCalculationContext()); Assert.assertFalse((Boolean) resultMap.get(6).getValue()); Assert.assertFalse((Boolean) resultMap.get(7).getValue()); Assert.assertTrue((Boolean) resultMap.get(8).getValue()); }
@Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> arg1, PatientCalculationContext context) { CalculationResultMap currentArvs = calculate(new CurrentArtRegimenCalculation(), cohort, context); Set<Integer> ltfu = CalculationUtils.patientsThatPass(calculate(new LostToFollowUpCalculation(), cohort, context)); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean onSecondLine = false; SimpleResult currentArvResult = (SimpleResult) currentArvs.get(ptId); if (currentArvResult != null) { RegimenOrder currentRegimen = (RegimenOrder) currentArvResult.getValue(); onSecondLine = EmrCalculationUtils.regimenInGroup(currentRegimen, "ARV", "adult-second"); } if (ltfu.contains(ptId)) { onSecondLine = false; } ret.put(ptId, new BooleanResult(onSecondLine, this, context)); } return ret; }
OnSecondLineArtCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> arg1, PatientCalculationContext context) { CalculationResultMap currentArvs = calculate(new CurrentArtRegimenCalculation(), cohort, context); Set<Integer> ltfu = CalculationUtils.patientsThatPass(calculate(new LostToFollowUpCalculation(), cohort, context)); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean onSecondLine = false; SimpleResult currentArvResult = (SimpleResult) currentArvs.get(ptId); if (currentArvResult != null) { RegimenOrder currentRegimen = (RegimenOrder) currentArvResult.getValue(); onSecondLine = EmrCalculationUtils.regimenInGroup(currentRegimen, "ARV", "adult-second"); } if (ltfu.contains(ptId)) { onSecondLine = false; } ret.put(ptId, new BooleanResult(onSecondLine, this, context)); } return ret; } }
OnSecondLineArtCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> arg1, PatientCalculationContext context) { CalculationResultMap currentArvs = calculate(new CurrentArtRegimenCalculation(), cohort, context); Set<Integer> ltfu = CalculationUtils.patientsThatPass(calculate(new LostToFollowUpCalculation(), cohort, context)); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean onSecondLine = false; SimpleResult currentArvResult = (SimpleResult) currentArvs.get(ptId); if (currentArvResult != null) { RegimenOrder currentRegimen = (RegimenOrder) currentArvResult.getValue(); onSecondLine = EmrCalculationUtils.regimenInGroup(currentRegimen, "ARV", "adult-second"); } if (ltfu.contains(ptId)) { onSecondLine = false; } ret.put(ptId, new BooleanResult(onSecondLine, this, context)); } return ret; }  }
OnSecondLineArtCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> arg1, PatientCalculationContext context) { CalculationResultMap currentArvs = calculate(new CurrentArtRegimenCalculation(), cohort, context); Set<Integer> ltfu = CalculationUtils.patientsThatPass(calculate(new LostToFollowUpCalculation(), cohort, context)); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean onSecondLine = false; SimpleResult currentArvResult = (SimpleResult) currentArvs.get(ptId); if (currentArvResult != null) { RegimenOrder currentRegimen = (RegimenOrder) currentArvResult.getValue(); onSecondLine = EmrCalculationUtils.regimenInGroup(currentRegimen, "ARV", "adult-second"); } if (ltfu.contains(ptId)) { onSecondLine = false; } ret.put(ptId, new BooleanResult(onSecondLine, this, context)); } return ret; }  @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> arg1, PatientCalculationContext context); }
OnSecondLineArtCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> arg1, PatientCalculationContext context) { CalculationResultMap currentArvs = calculate(new CurrentArtRegimenCalculation(), cohort, context); Set<Integer> ltfu = CalculationUtils.patientsThatPass(calculate(new LostToFollowUpCalculation(), cohort, context)); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean onSecondLine = false; SimpleResult currentArvResult = (SimpleResult) currentArvs.get(ptId); if (currentArvResult != null) { RegimenOrder currentRegimen = (RegimenOrder) currentArvResult.getValue(); onSecondLine = EmrCalculationUtils.regimenInGroup(currentRegimen, "ARV", "adult-second"); } if (ltfu.contains(ptId)) { onSecondLine = false; } ret.put(ptId, new BooleanResult(onSecondLine, this, context)); } return ret; }  @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> arg1, PatientCalculationContext context);  }