CurrentArtRegimenCalculation extends BaseEmrCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context) { Concept arvs = Dictionary.getConcept(Dictionary.ANTIRETROVIRAL_DRUGS); CalculationResultMap currentARVDrugOrders = activeDrugOrders(arvs, cohort, context); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { ListResult patientDrugOrders = (ListResult) currentARVDrugOrders.get(ptId); if (patientDrugOrders != null) { RegimenOrder regimen = new RegimenOrder(new HashSet<DrugOrder>(CalculationUtils.<DrugOrder>extractResultValues(patientDrugOrders))); ret.put(ptId, new SimpleResult(regimen, this, context)); } else { ret.put(ptId, null); } } return ret; }  @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues,
	                                     PatientCalculationContext context);  }
@Test public void evaluate_shouldCalculateCurrentArtRegimen() throws Exception { Concept dapsone = Dictionary.getConcept(Dictionary.DAPSONE); TestUtils.saveDrugOrder(TestUtils.getPatient(7), dapsone, TestUtils.date(2011, 1, 1), null); Concept stavudine = Dictionary.getConcept(Dictionary.STAVUDINE); TestUtils.saveDrugOrder(TestUtils.getPatient(8), stavudine, TestUtils.date(2011, 1, 1), null); List<Integer> cohort = Arrays.asList(6, 7, 8); CalculationResultMap resultMap = new CurrentArtRegimenCalculation().evaluate(cohort, null, Context.getService(PatientCalculationService.class).createCalculationContext()); Assert.assertNull(resultMap.get(6)); Assert.assertNull(resultMap.get(7)); RegimenOrder pat8Res = (RegimenOrder)resultMap.get(8).getValue(); Assert.assertEquals(1, pat8Res.getDrugOrders().size()); }