@Test public void evaluate() throws Exception { Program hivProgram = MetadataUtils.existing(Program.class, HivMetadata._Program.HIV); Program tbProgram = MetadataUtils.existing(Program.class, TbMetadata._Program.TB); TestUtils.enrollInProgram(TestUtils.getPatient(6), tbProgram, TestUtils.date(2012, 1, 1)); TestUtils.enrollInProgram(TestUtils.getPatient(7), hivProgram, TestUtils.date(2012, 1, 1)); TestUtils.enrollInProgram(TestUtils.getPatient(8), tbProgram, TestUtils.date(2012, 1, 1), TestUtils.date(2012, 6, 1)); List<Integer> ptIds = Arrays.asList(6, 7, 8); Map<String, Object> params = new HashMap<String, Object>(); params.put("program", hivProgram); CalculationResultMap resultMap = new InProgramCalculation().evaluate(ptIds, params, Context.getService(PatientCalculationService.class).createCalculationContext()); Assert.assertFalse((Boolean) resultMap.get(6).getValue()); Assert.assertTrue((Boolean) resultMap.get(7).getValue()); Assert.assertFalse((Boolean) resultMap.get(8).getValue()); }
@Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context) { Program program = (params != null && params.containsKey("program")) ? (Program) params.get("program") : null; return passing(Calculations.activeEnrollment(program, Filters.alive(cohort, context), context)); }
InProgramCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context) { Program program = (params != null && params.containsKey("program")) ? (Program) params.get("program") : null; return passing(Calculations.activeEnrollment(program, Filters.alive(cohort, context), context)); } }
InProgramCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context) { Program program = (params != null && params.containsKey("program")) ? (Program) params.get("program") : null; return passing(Calculations.activeEnrollment(program, Filters.alive(cohort, context), context)); }  }
InProgramCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context) { Program program = (params != null && params.containsKey("program")) ? (Program) params.get("program") : null; return passing(Calculations.activeEnrollment(program, Filters.alive(cohort, context), context)); }  @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context); }
InProgramCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context) { Program program = (params != null && params.containsKey("program")) ? (Program) params.get("program") : null; return passing(Calculations.activeEnrollment(program, Filters.alive(cohort, context), context)); }  @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context);  }