private ResultLimit ageBasedResultLimit(List<ResultLimit> resultLimits, Patient patient) { ResultLimit resultLimit = null; // First we look for a limit with no gender for (ResultLimit limit : resultLimits) { if (GenericValidator.isBlankOrNull(limit.getGender()) && !limit.ageLimitsAreDefault() && getCurrPatientAge(patient) >= limit.getMinAge() && getCurrPatientAge(patient) <= limit.getMaxAge()) { resultLimit = limit; break; } } // if none is found then drop the no gender requirement if (resultLimit == null) { for (ResultLimit limit : resultLimits) { if (!limit.ageLimitsAreDefault() && getCurrPatientAge(patient) >= limit.getMinAge() && getCurrPatientAge(patient) <= limit.getMaxAge()) { resultLimit = limit; break; } } } return resultLimit == null ? defaultResultLimit(resultLimits) : resultLimit; }
private boolean patientInAgeRange(Patient patient, ResultLimit limit) { return getCurrPatientAge(patient) >= limit.getMinAge() && getCurrPatientAge(patient) <= limit.getMaxAge(); }