FHIR Chat · Date time · implementers

Stream: implementers

Topic: Date time


view this post on Zulip Dharani Ranasinghe (Nov 02 2020 at 00:00):

As the value to one of the clinical parameters that I'm usin g in my project, I need to set the partial date. That means the value contains only the month and the year . Under observation profile I couldn;t find such data type. It has only date time which accepts the full date vale. Can you please let me know how to do that.

view this post on Zulip Richard Townley-O'Neill (Nov 02 2020 at 00:20):

DateTime accepts partial dates: see http://hl7.org/fhir/R4/datatypes.html#dateTime
If you want to create a profile of Observation that rejects effectiveDateTime elements with days or smaller components, you could use an invariant.

view this post on Zulip Dharani Ranasinghe (Nov 02 2020 at 00:56):

Richard Townley-O'Neill said:

DateTime accepts partial dates: see http://hl7.org/fhir/R4/datatypes.html#dateTime
If you want to create a profile of Observation that rejects effectiveDateTime elements with days or smaller components, you could use an invariant.

Thanks Richard. If Date time accepts partial dates , then I think i can use it

view this post on Zulip Grey Faulkenberry (Feb 03 2021 at 22:16):

I'd like to follow-up on this question. Specifically, have you found dates are used more for calculations or for display? I ask this because I'm trying to structure my methods for return values in these classes. Currently, if I call

final obs = Observation(effectiveDateTime: '2020')
print(obs.effectiveDateTime) // '2020'

I get a string of the full or partial data returned. But since it's a String, I can't calculate anything with it. If I turn it into a DateTime in the language I'm using (Dart), it automatically turns it into a full date, so '2020' will become '2020-01-01', but you can now do DateTime calculations on it. I could also add a couple of methods for each type that I need returned. So it would look something like this:

final obs = Observation(effectiveDateTime: '2020')
print(obs.effectiveDateTime); // '2020-01-01 00:00:00.000' as a DateTime to allow calculations
print(obs.effectiveDateTime.value); // same as above because that's how Dart works
print(obs.effectiveDateTime.toString()); // '2020'
print(obs.effectiveDateTime.toJson()); // "2020"

Or, if it's less likely to use as calculations and more likely to be used as a String for display, I could do:

final obs = Observation(effectiveDateTime: '2020')
print(obs.effectiveDateTime); // '2020' as a String
print(obs.effectiveDateTime.value); // same as above because that's how Dart works
print(obs.effectiveDateTime.toString()); // '2020'
print(obs.effectiveDateTime.toJson()); // "2020"
print(obs.effectiveDateTime.dateTime); //'2020-01-01 00:00:00.000' as a DateTime to allow calculations

I realize it's not a big difference, but I was just curious if anyone else had run into this or had thoughts about which way is the most convenient

view this post on Zulip Daniel Venton (Feb 08 2021 at 15:10):

Partial dates (or low precision dates) are always a challenge and your answer will probably be dependent on the situation. No magic bullet. In your example of wanting to do calculations you are allowing DART to fill in the missing values with the min allowed for each discrete field. This may not always be the correct fill in. Let's assume the calculation is lte2020. Since it's being used as the upper bound then the fill in values will probably be 2020-12-31 23:59:59.999 to resolve correctly. Generally when you have a single point, but low precision then the value (should you need to estimate the higher precision is probably the 1/2 point so 2020, would be 2020-07-01 00:00:00 (or close). Many cases you might have to keep track of the precision as a corollary field (date) 2020-01-01 00:00:00 (precision year). And any math would have to only compare values up to the precision shared by both values.


Last updated: Apr 12 2022 at 19:14 UTC