gnumed-devel
[Top][All Lists]

## Re: [Gnumed-devel] Re: CCHIT

 From: Karsten Hilbert Subject: Re: [Gnumed-devel] Re: CCHIT Date: Sat, 7 Nov 2009 16:45:10 +0100 User-agent: Mutt/1.5.20 (2009-06-14)

```On Sat, Nov 07, 2009 at 04:31:05PM +0100, Hilbert, Sebastian wrote:

> In the CCHIT document I found this requirement.
>
> The system shall allow the recording of date and time of birth (hour and
> minutes if known) and subsequently be able to express age in hours for the
> first 4 days of life, then in days from the 5th day of life through the first
> 28 days, then in weeks beginning on the 29th day of life through the first
> three completed months of life, and then in months beginning with the 4th
> month of life through age 2 years.  Subsequent expressions of age may be
> expressed by year and month (2 years 6 months) or with a decimal place for
> expressing part of years (i.e. 2.5 years old) through age 18.
>
>
> We are doing some of this already don't we ?

Absolutely. Try it. We use different boundary conditions,
though, which were discussed with a pediatrician:

pycommon/gmDate.Time.py:

def format_interval_medically(interval=None):
"""Formats an interval.

This isn't mathematically correct but close enough for display.
"""
# years available ?
if interval.days > 364:
years, days = divmod(interval.days, 365)
months, day = divmod(days, 30)
if months == 0:
return "%sy" % int(years)
return "%sy %sm" % (int(years), int(months))

# months available ?
if interval.days > 30:
months, days = divmod(interval.days, 30)
weeks = days // 7
return "%sm %sw" % (int(months), int(weeks))

# weeks available ?
if interval.days > 7:
return "%sd" % interval.days

# days available ?
if interval.days > 1:
hours, seconds = divmod(interval.seconds, 3600)
return "%sd (%sh)" % (interval.days, int(hours))

# hours available ?
if interval.seconds > (3*3600):
return "%sh" % int(interval.seconds // 3600)
# hours + minutes
if interval.seconds > 3600:
hours, seconds = divmod(interval.seconds, 3600)
minutes = seconds // 60
return "%sh %sm" % (int(hours), int(minutes))
# minutes only
if interval.seconds > (5*60):
return "%sm" % (int(interval.seconds // 60))
# seconds
minutes, seconds = divmod(interval.seconds, 60)
return "%sm %ss" % (int(minutes), int(seconds))

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346

```