Replies: 2 comments
-
We should consider transforming all |
Beta Was this translation helpful? Give feedback.
-
This may not be relevant to the topic of the discussion, but I will give my thoughts on working with dates in FHIR from an analytical point of view In the context of working with dates, I would distinguish three areas
ValidationIt is a fact that in practice we often work with data that was downloaded from various sources and can contain errors. Sometimes it is critical for the next step of cast to date Example: Finding invalid select id
from "Observation"
where resource#>>'{ issued }' NOT SIMILAR TO '([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]{1,9})?)?)?(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)?)?)?' ); Cast to dateIt would be great to think about casts FHIR string and complex dates to native date types FHIR date types
Example: Patient select id
, ("resource"#>>'{ birthDate }')::date birthdate
, ("resource"#>>'{ deceased,dateTime }')::date deceased
from Patient ExtractionIn analytics tasks, we rarely operate with raw times with millisecond precision, instead, we often work with years, months, quarters, and weeks. something like this
Example: Patient flat view SELECT id
, DATE_PART('year', AGE(date("resource" #>>'{birthDate}'))) age
, ("resource"#>>'{ birthDate }')::date birthdate
, extract('YEAR' from ("resource"#>>'{ birthDate }')::date) birth_year
, ("resource"#>>'{ deceased,dateTime }')::date deceased
, extract('YEAR' from ("resource"#>>'{ deceased,dateTime }')::date) deceased_year
, extract('year' FROM age(("resource"#>>'{ deceased,dateTime }')::date
, ("resource"#>>'{ birthDate }')::date)) death_age
FROM Patient Example: Encounter flat view duration SELECT id
, ("resource"#>>'{ period,start }')::date start
, ("resource"#>>'{ period,end }')::date end
, ("resource"#>>'{ period,end }')::timestamp - ("resource"#>>'{ period,start }')::timestamp duration
FROM Encounter |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
All reactions