Skip to content
This repository has been archived by the owner on Jan 18, 2020. It is now read-only.

Commit

Permalink
Fix #71 (error in age formatter)
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Murphy <murphyke@email.chop.edu>
  • Loading branch information
murphyke committed Sep 14, 2016
1 parent c4b9fc8 commit 3f4c0d4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions openmrs/formatters.py
Expand Up @@ -45,6 +45,15 @@ def to_html(self, values, **context):
else:
return "{0} {1} old".format(age, time)

# `get_html_header` is not strictly needed, but it is used here
# to set the name of the column to "Age"; the column name would
# otherwise be the name of the first field of the concept ('Patient
# Birthdate').
def get_html_header(self):
header = self.get_default_header()[:1]
header[0]['label'] = 'Age'
return header

@process_multiple
def to_csv(self, values, **context):
dob = values.birthdate
Expand All @@ -56,10 +65,17 @@ def to_csv(self, values, **context):

return str(age)

# When the number of input fields for `to_FOO` is not equal to the number
# of output fields, `get_FOO_header` is required (except for `to_html`)
# when using Harvest 2.4+.
get_csv_header = get_html_header

@process_multiple
def to_excel(self, values, **context):
return self.to_csv(values, **context)

get_excel_header = get_html_header


class EncounterAgeFormatter(Formatter):
@process_multiple
Expand Down

0 comments on commit 3f4c0d4

Please sign in to comment.