@Test public void evaluate() throws Exception { Concept discontinueReason = Dictionary.getConcept(Dictionary.REASON_FOR_PROGRAM_DISCONTINUATION); Concept died = Dictionary.getConcept(Dictionary.DIED); Concept unknown = Dictionary.getConcept(Dictionary.UNKNOWN); TestUtils.saveObs(TestUtils.getPatient(6), discontinueReason, unknown, TestUtils.date(2012, 12, 1)); TestUtils.saveObs(TestUtils.getPatient(7), discontinueReason, died, TestUtils.date(2010, 12, 1)); List<Integer> ptIds = Arrays.asList(6, 7, 8); CalculationResultMap resultMap = new RecordedDeceasedCalculation().evaluate(ptIds, null, 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) { Set<Integer> alive = Filters.alive(cohort, context); CalculationResultMap exitObss = Calculations.allObs(Dictionary.getConcept(Dictionary.REASON_FOR_PROGRAM_DISCONTINUATION), alive, context); Concept died = Dictionary.getConcept(Dictionary.DIED); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean recordedAsDead = false; ListResult exitObssForPt = (ListResult) exitObss.get(ptId); if (exitObssForPt != null) { List<Obs> exitObsList = CalculationUtils.extractResultValues(exitObssForPt); for (Obs exitObs : exitObsList) { if (died.equals(exitObs.getValueCoded())) { recordedAsDead = true; break; } } } ret.put(ptId, new BooleanResult(recordedAsDead, this, context)); } return ret; }
RecordedDeceasedCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context) { Set<Integer> alive = Filters.alive(cohort, context); CalculationResultMap exitObss = Calculations.allObs(Dictionary.getConcept(Dictionary.REASON_FOR_PROGRAM_DISCONTINUATION), alive, context); Concept died = Dictionary.getConcept(Dictionary.DIED); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean recordedAsDead = false; ListResult exitObssForPt = (ListResult) exitObss.get(ptId); if (exitObssForPt != null) { List<Obs> exitObsList = CalculationUtils.extractResultValues(exitObssForPt); for (Obs exitObs : exitObsList) { if (died.equals(exitObs.getValueCoded())) { recordedAsDead = true; break; } } } ret.put(ptId, new BooleanResult(recordedAsDead, this, context)); } return ret; } }
RecordedDeceasedCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context) { Set<Integer> alive = Filters.alive(cohort, context); CalculationResultMap exitObss = Calculations.allObs(Dictionary.getConcept(Dictionary.REASON_FOR_PROGRAM_DISCONTINUATION), alive, context); Concept died = Dictionary.getConcept(Dictionary.DIED); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean recordedAsDead = false; ListResult exitObssForPt = (ListResult) exitObss.get(ptId); if (exitObssForPt != null) { List<Obs> exitObsList = CalculationUtils.extractResultValues(exitObssForPt); for (Obs exitObs : exitObsList) { if (died.equals(exitObs.getValueCoded())) { recordedAsDead = true; break; } } } ret.put(ptId, new BooleanResult(recordedAsDead, this, context)); } return ret; }  }
RecordedDeceasedCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context) { Set<Integer> alive = Filters.alive(cohort, context); CalculationResultMap exitObss = Calculations.allObs(Dictionary.getConcept(Dictionary.REASON_FOR_PROGRAM_DISCONTINUATION), alive, context); Concept died = Dictionary.getConcept(Dictionary.DIED); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean recordedAsDead = false; ListResult exitObssForPt = (ListResult) exitObss.get(ptId); if (exitObssForPt != null) { List<Obs> exitObsList = CalculationUtils.extractResultValues(exitObssForPt); for (Obs exitObs : exitObsList) { if (died.equals(exitObs.getValueCoded())) { recordedAsDead = true; break; } } } ret.put(ptId, new BooleanResult(recordedAsDead, this, context)); } return ret; }  @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context); }
RecordedDeceasedCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context) { Set<Integer> alive = Filters.alive(cohort, context); CalculationResultMap exitObss = Calculations.allObs(Dictionary.getConcept(Dictionary.REASON_FOR_PROGRAM_DISCONTINUATION), alive, context); Concept died = Dictionary.getConcept(Dictionary.DIED); CalculationResultMap ret = new CalculationResultMap(); for (Integer ptId : cohort) { boolean recordedAsDead = false; ListResult exitObssForPt = (ListResult) exitObss.get(ptId); if (exitObssForPt != null) { List<Obs> exitObsList = CalculationUtils.extractResultValues(exitObssForPt); for (Obs exitObs : exitObsList) { if (died.equals(exitObs.getValueCoded())) { recordedAsDead = true; break; } } } ret.put(ptId, new BooleanResult(recordedAsDead, this, context)); } return ret; }  @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context);  }