public Date calculateDateToCollect(Integer num, OutPatientDuration duration) { //can't perform calculation if(num == null || duration == null) return null; Date result = null; Date today = new Date(); if(duration.equals(OutPatientDuration.DAYS)) { result = today.addDay(num.intValue()); } else if(duration.equals(OutPatientDuration.WEEKS)) { result = today.addDay(num.intValue() * 7); } else if(duration.equals(OutPatientDuration.MONTHS)) { result = today.addMonth(num.intValue()); } else if(duration.equals(OutPatientDuration.YEARS)) { result = today.addYear(num.intValue()); } return result; }
protected final OutPatientDuration getDuration() { return duration; }
protected final void setDuration(OutPatientDuration duration) { this.duration = duration; }