FHIR Chat · Age from birthdate? · fhirpath

Stream: fhirpath

Topic: Age from birthdate?


view this post on Zulip Paul Lynch (Jan 04 2019 at 20:34):

Is there a way to compute a patient's current age from their birth date?

view this post on Zulip Michel Rutten (Jan 07 2019 at 10:40):

Use now() function? http://hl7.org/fhirpath/#utility-functions

view this post on Zulip Paul Lynch (Jan 07 2019 at 16:40):

It would be nice to be able write "now() - Patient.birthDate", but I don't see any support in the spec for subtracting two dates. The section on Date/Time Arithmetic says, "The left operand must be a dateTime or time value, and the right operand must be a quantity with a time-valued unit".

view this post on Zulip Michel Rutten (Jan 07 2019 at 16:48):

Indeed, seem's like an oversight.

view this post on Zulip Rick Geimer (Jan 07 2019 at 17:37):

@Paul Lynch Sounds like a good gForge tracker item if you care to submit it

view this post on Zulip Paul Lynch (Jan 07 2019 at 18:02):

Sure-- GF#19896.

view this post on Zulip Brian Postlethwaite (Jan 08 2019 at 01:51):

And while we're there, maybe the date/time primitives should be able to expose their components, so you can use Patient.birthDate.year

view this post on Zulip Chris Moesel (Jan 08 2019 at 14:25):

I'm more of a CQL guy than FHIRPath, but in regard to now() - Patient.birthDate, CQL has a few approaches. One is something like this: duration in years between Patient.birthDate and now(). But for this specific use case, you could use CalculateAgeInYears(Patient.birthDate). I guess those aren't exposed in FHIRPath though?

view this post on Zulip Chris Moesel (Jan 08 2019 at 14:27):

As for Patient.birthDate.year, CQL does this as year from Patient.birthDate -- but again, I don't know if that made it into the subset that is FHIRPath.

view this post on Zulip Brian Postlethwaite (Jan 16 2020 at 04:05):

Did we end up adding year, month and day properties to the date/datetime types?

view this post on Zulip Brian Postlethwaite (Jan 16 2020 at 04:06):

Looks like it is still open.
https://jira.hl7.org/browse/FHIR-19896
I was looking to do something here around data extraction (for search fields & Questionnaire pre-population)

view this post on Zulip Brian Postlethwaite (Jan 16 2020 at 04:08):

This is a sample of what I would kinda like (as was contemplating adding to my server's custom fhirpath functions)
%LaunchPatient.birthDate.ageAt(today())
%LaunchPatient.birthDate.ageAt(%LaunchPatient.deceasedDate)

view this post on Zulip Paul Lynch (Jan 16 2020 at 14:52):

Since the age calculation involves the difference of two dates, which might have other applications, why limit the functionality to just "age" calculations?


Last updated: Apr 12 2022 at 19:14 UTC