FHIR Chat · Ambiguity of %resource · implementers

Stream: implementers

Topic: Ambiguity of %resource


view this post on Zulip John Timm (Jul 30 2019 at 16:07):

Typically %resource would refer to the current focus of validation whether we are validating the outermost resource (container) or some contained resource either via DomainResource.contained or some other containment mechanism (e.g. Bundle.entry.resource). A good example of this is obs-7:

value.empty() or component.code.where( (coding.code = %resource.code.coding.code) and (coding.system = %resource.code.coding.system)).empty()

In some cases, though, particularly ref-1, it would appear that %resource should always be considered as the outermost resource:

reference.startsWith('#').not() or (reference.substring(1).trace('url') in %resource.contained.id.trace('ids'))

This is because contained resources should never have contained resources. The only thing that tells us the difference, however, is the 'contained' path that immediately follows %resource. Is there some general guidance on what %resource should mean in these different contexts? Any other thoughts on how to resolve this ambiguity?

view this post on Zulip Lloyd McKenzie (Jul 30 2019 at 16:16):

@Bryn Rhodes

view this post on Zulip Bryn Rhodes (Jul 30 2019 at 16:51):

The fhirpath page says "The original resource current context is part of. When evaluating a datatype, this would be the resource the element is part of.". When evaluating an invariant, that means %resource will always be the instance of the resource type on which the invariant is defined.

view this post on Zulip John Timm (Jul 30 2019 at 17:10):

@Bryn Rhodes Mapping that to my example, obs-7 is an invariant on the Observation resource type.The current context may be an Observation that is the root of the tree (outermost) OR it could be some contained observation and the value of %resource should follow that context accordingly. I"m not sure how that maps to the Reference ref-1 case (when reference belongs to a contained resource). If the reference is part of a contained resource and I set %resource to the resource which the reference belongs to, then the constraint would unexpectedly fail.

view this post on Zulip Lee Surprenant (Jul 30 2019 at 17:21):

To me, the issue with the quoted section is this sentence: When evaluating a datatype, this would be the resource the element is part of.

ref-1 is an invariant on Reference data type. when evaluating this on a reference that is in a resource that is contained in another resource, we want %resource to resolve to the outermost resource, not the contained resource its a part of. Doesn't that conflict with the fhirpath page?

view this post on Zulip Grahame Grieve (Jul 30 2019 at 19:44):

ref-1 looks like it is in error to me. Can you create a task?

view this post on Zulip John Timm (Jul 30 2019 at 19:53):

@Grahame Grieve
https://gforge.hl7.org/gf/project/fhir/tracker/?action=TrackerItemEdit&tracker_id=677&tracker_item_id=23018


Last updated: Apr 12 2022 at 19:14 UTC