@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 OnArtCalculation().evaluate(cohort, null, Context.getService(PatientCalculationService.class).createCalculationContext()); Assert.assertThat((Boolean) resultMap.get(6).getValue(), is(false)); Assert.assertThat((Boolean) resultMap.get(7).getValue(), is(false)); Assert.assertThat((Boolean) resultMap.get(8).getValue(), is(true)); }
@Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context) { CalculationResultMap patientArvs = calculate(new CurrentArtRegimenCalculation(), cohort, context); CalculationResultMap ret = new CalculationResultMap(); for (Map.Entry<Integer, CalculationResult> e : patientArvs.entrySet()) { boolean onART = e.getValue() != null && !e.getValue().isEmpty(); ret.put(e.getKey(), new BooleanResult(onART, this, context)); } return ret; }
OnArtCalculation extends AbstractPatientCalculation implements PatientFlagCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context) { CalculationResultMap patientArvs = calculate(new CurrentArtRegimenCalculation(), cohort, context); CalculationResultMap ret = new CalculationResultMap(); for (Map.Entry<Integer, CalculationResult> e : patientArvs.entrySet()) { boolean onART = e.getValue() != null && !e.getValue().isEmpty(); ret.put(e.getKey(), new BooleanResult(onART, this, context)); } return ret; } }
OnArtCalculation extends AbstractPatientCalculation implements PatientFlagCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context) { CalculationResultMap patientArvs = calculate(new CurrentArtRegimenCalculation(), cohort, context); CalculationResultMap ret = new CalculationResultMap(); for (Map.Entry<Integer, CalculationResult> e : patientArvs.entrySet()) { boolean onART = e.getValue() != null && !e.getValue().isEmpty(); ret.put(e.getKey(), new BooleanResult(onART, this, context)); } return ret; }  }
OnArtCalculation extends AbstractPatientCalculation implements PatientFlagCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context) { CalculationResultMap patientArvs = calculate(new CurrentArtRegimenCalculation(), cohort, context); CalculationResultMap ret = new CalculationResultMap(); for (Map.Entry<Integer, CalculationResult> e : patientArvs.entrySet()) { boolean onART = e.getValue() != null && !e.getValue().isEmpty(); ret.put(e.getKey(), new BooleanResult(onART, this, context)); } return ret; }  @Override String getFlagMessage(); @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues,
	                                     PatientCalculationContext context); }
OnArtCalculation extends AbstractPatientCalculation implements PatientFlagCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context) { CalculationResultMap patientArvs = calculate(new CurrentArtRegimenCalculation(), cohort, context); CalculationResultMap ret = new CalculationResultMap(); for (Map.Entry<Integer, CalculationResult> e : patientArvs.entrySet()) { boolean onART = e.getValue() != null && !e.getValue().isEmpty(); ret.put(e.getKey(), new BooleanResult(onART, this, context)); } return ret; }  @Override String getFlagMessage(); @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues,
	                                     PatientCalculationContext context);  }