def pretty_age(self): "Returns the patient's current age in a pretty format." # we need today's date to compare against the adjusted dob. we cannot # have a negative age, therefore if the randomized offset is greater # than the patient's current age, we must round up to 0 today = date.today() dob = self.dob if (today - self.dob).days < 0: dob = today return conversions.dates_to_age(dob, today)
def _set_age(self): "Helper method to set the age for this visit." self.age = conversions.dates_to_age(self.visit_date, self.patient.patientphi.dob, to_string=False)