private double getCurrPatientAge(Patient patient) { if (currPatientAge == INVALID_PATIENT_AGE && patient.getBirthDate() != null) { Calendar dob = Calendar.getInstance(); dob.setTime(patient.getBirthDate()); currPatientAge = DateUtil.getAgeInMonths(patient.getBirthDate(), new Date()); } return currPatientAge; }
public ResultLimit getResultLimitForTestAndPatient(Test test, Patient patient) { currPatientAge = INVALID_PATIENT_AGE; @SuppressWarnings("unchecked") List<ResultLimit> resultLimits = resultLimitDAO.getAllResultLimitsForTest(test); if (resultLimits.isEmpty()) { return null; } else if (patient == null || patient.getBirthDate() == null && GenericValidator.isBlankOrNull(patient.getGender())) { return defaultResultLimit(resultLimits); } else if (GenericValidator.isBlankOrNull(patient.getGender())) { return ageBasedResultLimit(resultLimits, patient); } else if (patient.getBirthDate() == null) { return genderBasedResultLimit(resultLimits, patient); } else { return ageAndGenderBasedResultLimit(resultLimits, patient); } }