@Test public void valuate_shouldEvaluatePatientsInAGivenCohortMonthSinceBirth() throws Exception { { Patient patient = TestUtils.getPatient(6); patient.setBirthdate(computeWithinRangeEncounterDate(49)); Patient patient_two = TestUtils.getPatient(7); patient_two.setBirthdate(computeWithinRangeEncounterDate(15)); Patient patient_three = TestUtils.getPatient(8); patient_three.setBirthdate(computeWithinRangeEncounterDate(3)); } List<Integer> ptIds = Arrays.asList(7, 8, 999, 6); Map<String, Object> params = new HashMap<String, Object>(); params.put("turnedMonths", 12); params.put("reviewMonths", 6); CalculationResultMap resultMap = new HEICohortsXMonthsDuringReviewCalculation().evaluate(ptIds, params, Context.getService(PatientCalculationService.class).createCalculationContext()); Assert.assertTrue((Boolean) resultMap.get(7).getValue()); Assert.assertFalse((Boolean) resultMap.get(8).getValue()); Assert.assertNull(resultMap.get(999)); Assert.assertFalse((Boolean) resultMap.get(6).getValue()); }
@Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context) { CalculationResultMap ret = new CalculationResultMap(); Integer turnedMonths = (Integer)parameterValues.get("turnedMonths"); Integer reviewMonths = (Integer)parameterValues.get("reviewMonths"); PatientService service = Context.getPatientService(); Calendar upper_boundary = setCalendarTime(context.getNow()); Calendar lower_boundary = setCalendarTime(context.getNow()); lower_boundary.add(Calendar.MONTH, -(reviewMonths)); for (Integer ptId : cohort) { boolean eligibility = false; Date dob = service.getPatient(ptId).getBirthdate(); if (dob != null) { Calendar nthBirthDay = getDateOfNthBirthday(dob, turnedMonths); if ((nthBirthDay.equals(lower_boundary) || nthBirthDay.after(lower_boundary)) && (nthBirthDay.equals(upper_boundary) || nthBirthDay.before(upper_boundary))) { eligibility = true; } ret.put(ptId, new BooleanResult(eligibility, this)); } } return ret; }
HEICohortsXMonthsDuringReviewCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context) { CalculationResultMap ret = new CalculationResultMap(); Integer turnedMonths = (Integer)parameterValues.get("turnedMonths"); Integer reviewMonths = (Integer)parameterValues.get("reviewMonths"); PatientService service = Context.getPatientService(); Calendar upper_boundary = setCalendarTime(context.getNow()); Calendar lower_boundary = setCalendarTime(context.getNow()); lower_boundary.add(Calendar.MONTH, -(reviewMonths)); for (Integer ptId : cohort) { boolean eligibility = false; Date dob = service.getPatient(ptId).getBirthdate(); if (dob != null) { Calendar nthBirthDay = getDateOfNthBirthday(dob, turnedMonths); if ((nthBirthDay.equals(lower_boundary) || nthBirthDay.after(lower_boundary)) && (nthBirthDay.equals(upper_boundary) || nthBirthDay.before(upper_boundary))) { eligibility = true; } ret.put(ptId, new BooleanResult(eligibility, this)); } } return ret; } }
HEICohortsXMonthsDuringReviewCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context) { CalculationResultMap ret = new CalculationResultMap(); Integer turnedMonths = (Integer)parameterValues.get("turnedMonths"); Integer reviewMonths = (Integer)parameterValues.get("reviewMonths"); PatientService service = Context.getPatientService(); Calendar upper_boundary = setCalendarTime(context.getNow()); Calendar lower_boundary = setCalendarTime(context.getNow()); lower_boundary.add(Calendar.MONTH, -(reviewMonths)); for (Integer ptId : cohort) { boolean eligibility = false; Date dob = service.getPatient(ptId).getBirthdate(); if (dob != null) { Calendar nthBirthDay = getDateOfNthBirthday(dob, turnedMonths); if ((nthBirthDay.equals(lower_boundary) || nthBirthDay.after(lower_boundary)) && (nthBirthDay.equals(upper_boundary) || nthBirthDay.before(upper_boundary))) { eligibility = true; } ret.put(ptId, new BooleanResult(eligibility, this)); } } return ret; }  }
HEICohortsXMonthsDuringReviewCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context) { CalculationResultMap ret = new CalculationResultMap(); Integer turnedMonths = (Integer)parameterValues.get("turnedMonths"); Integer reviewMonths = (Integer)parameterValues.get("reviewMonths"); PatientService service = Context.getPatientService(); Calendar upper_boundary = setCalendarTime(context.getNow()); Calendar lower_boundary = setCalendarTime(context.getNow()); lower_boundary.add(Calendar.MONTH, -(reviewMonths)); for (Integer ptId : cohort) { boolean eligibility = false; Date dob = service.getPatient(ptId).getBirthdate(); if (dob != null) { Calendar nthBirthDay = getDateOfNthBirthday(dob, turnedMonths); if ((nthBirthDay.equals(lower_boundary) || nthBirthDay.after(lower_boundary)) && (nthBirthDay.equals(upper_boundary) || nthBirthDay.before(upper_boundary))) { eligibility = true; } ret.put(ptId, new BooleanResult(eligibility, this)); } } return ret; }  @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context); }
HEICohortsXMonthsDuringReviewCalculation extends AbstractPatientCalculation { @Override public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context) { CalculationResultMap ret = new CalculationResultMap(); Integer turnedMonths = (Integer)parameterValues.get("turnedMonths"); Integer reviewMonths = (Integer)parameterValues.get("reviewMonths"); PatientService service = Context.getPatientService(); Calendar upper_boundary = setCalendarTime(context.getNow()); Calendar lower_boundary = setCalendarTime(context.getNow()); lower_boundary.add(Calendar.MONTH, -(reviewMonths)); for (Integer ptId : cohort) { boolean eligibility = false; Date dob = service.getPatient(ptId).getBirthdate(); if (dob != null) { Calendar nthBirthDay = getDateOfNthBirthday(dob, turnedMonths); if ((nthBirthDay.equals(lower_boundary) || nthBirthDay.after(lower_boundary)) && (nthBirthDay.equals(upper_boundary) || nthBirthDay.before(upper_boundary))) { eligibility = true; } ret.put(ptId, new BooleanResult(eligibility, this)); } } return ret; }  @Override CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> parameterValues, PatientCalculationContext context);  }