FHIR Chat · Referencing containing resource · implementers

Stream: implementers

Topic: Referencing containing resource


view this post on Zulip Josh Haskins (Apr 05 2019 at 21:09):

Hi,
I am trying to reference the containing resource, however I continue to receive errors when I reference from inside of the contained resource.

I will receive

"Unable to resolve resource '#person1'",

"If the resource is contained in another resource, it SHALL be referred to from elsewhere in the resource or SHALL refer to the containing resource ( (unmatched: provenance1)) [contained.where((('#'+id in (%resource.descendants().reference | %resource.descendants().as(canonical) | %resource.descendants().as(uri) | %resource.descendants().as(url))) or descendants().where(reference = '#').exists() or descendants().where(as(canonical) = '#').exists() or descendants().where(as(canonical) = '#').exists()).not()).trace('unmatched', id).empty()]"

and "SHALL have a contained resource if a local reference is provided ( (url: person1; ids: provenance1)) [reference.startsWith('#').not() or (reference.substring(1).trace('url') in %resource.contained.id.trace('ids'))]".

Here is what I am trying to send:

{
"id": "person1",
"name": [{
"given": ["Test"],
"family": "User"
}],
"contained": [ {
"id": "provenance1",
"agent": [{
"who": {
"display": "Tester"
}
}],
"target": [{
"reference": "#person1"
}],
"recorded": "2015-06-27T08:39:24+10:00",
"resourceType": "Provenance"
}],
"resourceType": "Person"
}

I believe I am doing the reference correctly with the #. Am I doing something else wrong? Thanks.

view this post on Zulip Yunwei Wang (Apr 11 2019 at 16:32):

Try to put Provenance as the outer resource and Person as contained.

view this post on Zulip Lloyd McKenzie (Apr 11 2019 at 20:27):

To point from a contained resource to the container, the reference is just "#". (See towards the end of http://hl7.org/fhir/references.html#contained)

view this post on Zulip Josh Haskins (Apr 11 2019 at 20:50):

Thank you @Lloyd McKenzie I must have missed that the other day when reading on referencing contained resources.

view this post on Zulip Lloyd McKenzie (Apr 11 2019 at 20:59):

No worries. There's more than a few things to read :)


Last updated: Apr 12 2022 at 19:14 UTC