EligibleForTbProgramCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context) { CalculationResultMap ret = new CalculationResultMap(); Set<Integer> alive = Filters.alive(cohort, context); for (int ptId : cohort) { boolean eligible = alive.contains(ptId); ret.put(ptId, new BooleanResult(eligible, this)); } return ret; }  @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context);  }
@Test public void evaluate_shouldReturnTrueForAllAlivePatients() { TestUtils.getPatient(8).setDead(true); TestUtils.getPatient(8).setDeathDate(TestUtils.date(2012, 1, 1)); List<Integer> ptIds = Arrays.asList(2, 6, 7, 8); CalculationResultMap resultMap = Context.getService(PatientCalculationService.class).evaluate(ptIds, new EligibleForTbProgramCalculation()); Assert.assertTrue((Boolean) resultMap.get(2).getValue()); Assert.assertTrue((Boolean) resultMap.get(6).getValue()); Assert.assertTrue((Boolean) resultMap.get(7).getValue()); Assert.assertFalse((Boolean) resultMap.get(8).getValue()); }