Stream: IG creation
Topic: Invariant to check dateTime precision with FHIRPath
Max Masnick (Feb 09 2021 at 01:21):
I have a dateTime
in a FHIR resource, and I want to use an invariant to warn if the precision exceeds the day level. So 2021-02-08
is fine, but 2021-02-08T00:00:01
or 2021-02-08T01
should cause a warning.
Is there a better way to do this than converting to a string and then using a regex like $this.toString().matches('^[0-9]{4}-[0-9]{2}-[0-9]{2}$')
?
Lloyd McKenzie (Feb 09 2021 at 02:31):
You could just use the 'length' property on DataElement. No invariant necessary.
Max Masnick (Feb 09 2021 at 14:08):
Thanks.... * occurrenceDateTime ^maxLength = 10
works but gives me an error rather than a warning. I assume there's not a way to downgrade this to a warning...so if we really want a warning rather than an error, I guess we're back to the invariant?
Grahame Grieve (Feb 09 2021 at 19:59):
yes invariant. But you can use length() in an invariant
Max Masnick (Feb 10 2021 at 13:52):
Thanks!
Last updated: Apr 12 2022 at 19:14 UTC