Stream: fhirpath
Topic: Discrepancy in Timing.repeat
Ose Umolu (Feb 08 2022 at 20:57):
I wanted to get some clarity on one of the constraints in Timing.repeat (http://hl7.org/fhir/R4/datatypes-definitions.html#Timing.repeat) ; tim-9
:
offset.empty() or (when.exists() and ((when in ('C' | 'CM' | 'CD' | 'CV')).not()))
It looks like when
is a repeated field: http://hl7.org/fhir/R4/datatypes-definitions.html#Timing.repeat
But it also looks like the in
operation does not allow repeated fields on its LHS (it is supposed to error out): http://hl7.org/fhirpath/index.html#in-membership; If the left operand has multiple items, an exception is thrown.
So is when in ('C' | 'CM' | 'CD' | 'CV')
an invalid expression? or am I misunderstanding how in
works.
And if it is invalid, what would the replacement be?
Bryn Rhodes (Feb 08 2022 at 21:22):
Yeah, this will run fine so long as there is only ever one "when" in an instance. It should probably be:
offset.empty() or (when.exists() and when.all(($this in ('C' | 'CM' | 'CD' | 'CV')).not()))
Nick George (Feb 08 2022 at 21:42):
So just to be 100% clear, in a case where the when clause is satisfied for one but not all of the Timing.repeat.when,
a) the current expression evalatuates to an exception
b) it should evaluate to false
Nick George (Feb 08 2022 at 21:57):
is that accurate?
Ose Umolu (Feb 08 2022 at 21:58):
Bryn Rhodes said:
Yeah, this will run fine so long as there is only ever one "when" in an instance. It should probably be:
offset.empty() or (when.exists() and when.all(($this in ('C' | 'CM' | 'CD' | 'CV')).not()))
Interesting, okay. What happens when there is more than one "when" instance?
Is there an implied restriction in the constraint that there should be only one instance of "when"?
Bryn Rhodes (Feb 09 2022 at 00:18):
No, an exception evaluating a constraint is, I would think, an error condition, not part of the constraint definition.
Nick George (Feb 09 2022 at 01:53):
I guess my point being - If I asked you, "does this resource pass this fhirpath constraint", on a multi-valued when resource, how would you answer?
Our current plan is to just in place replace the expression with your sugggested replacement - does that make sense to you. Do you think we can propose it e.g., for r5?
Bryn Rhodes (Feb 09 2022 at 03:18):
This language indicates that the invariant must evaluate to true, so by that requirement, no, an exception during evaluation of the constraint would have to be considered a failure of the constraint and the resource don't pass the constraint. I would suggest submitting a tracker to correct the invariant with the suggested expression, that's just my read of the intent, should definitely be brought up with FHIR-I to confirm my interpretation there and to get the spec invariant corrected.
Bryn Rhodes (Feb 09 2022 at 03:37):
As far as the interpretation of an exception when evaluating a constraint, that's probably worth some clarifying language in the spec as well. I'll submit a tracker on that: https://jira.hl7.org/browse/FHIR-35990
Last updated: Apr 12 2022 at 19:14 UTC