FHIR Chat · References between contained resources · implementers

Stream: implementers

Topic: References between contained resources


view this post on Zulip Michael Sauer (May 19 2020 at 09:21):

Im trying to make a reference between "Practitoner" and "PractitionerRole". Both are contained resources within an appointment.

<contained>
    <Practitioner>
      <id value="1" />
      <text>
        <status value="generated" />
        <div xmlns="http://www.w3.org/1999/xhtml">vorname1 NachnameDesBehandlers</div>
      </text>
      <name>
        <text value="vorname1 NachnameDesBehandlers" />
        <family value="NachnameDesBehandlers" />
        <given value="vorname1" />
        <given value="vorname2" />
      </name>
    </Practitioner>
  </contained>
  <contained>
    <PractitionerRole>
      <id value="0" />
      <text>
        <status value="generated" />
        <div xmlns="http://www.w3.org/1999/xhtml">Behandler: vorname1 NachnameDesBehandlers</div>
      </text>
      <practitioner>
        <reference value="#1" />
      </practitioner>
      <code>
        <coding>
          <system value="http://fhir.uniklinik-freiburg.de/ig/appointment/ValueSet/PractionerRoleVS" />
          <code value="Behandler" />
          <display value="Behandler: vorname1 NachnameDesBehandlers" />
        </coding>
        <text value="vorname1 NachnameDesBehandlers" />
      </code>
    </PractitionerRole>
  </contained>

When validating, I got an error:

<issue>
    <severity value="error"/>
    <code value="processing"/>
    <diagnostics value="ref-1: SHALL have a contained resource if a local reference is provided ( (url: 1; ids: )) [reference.startsWith('#').not() or (reference.substring(1).trace('url') in %resource.contained.id.trace('ids'))]"/>
    <location value="Appointment.contained[1].practitioner"/>
    <location value="Line 31, Col 21"/>
</issue>

view this post on Zulip Michele Mottini (May 19 2020 at 13:05):

The Practitioner should be contained inside the PractitionerRole (...but it gets really weird) (wrong, sorry, see below)

view this post on Zulip Jenni Syed (May 19 2020 at 14:03):

contained resources can't contain other resources :)

view this post on Zulip Jenni Syed (May 19 2020 at 14:06):

"Contained resources SHALL NOT contain additional contained resources." from http://hl7.org/fhir/references.html#contained

view this post on Zulip Jenni Syed (May 19 2020 at 14:07):

That validation seems wrong

view this post on Zulip Jenni Syed (May 19 2020 at 14:08):

unless I'm missing something...

view this post on Zulip René Spronk (May 19 2020 at 14:37):

It's a resource with 2 sibling-contained-resources. That's ok. They should be able to reference each other.

view this post on Zulip Jenni Syed (May 19 2020 at 14:49):

that is what I would expect too - may need to reach out to Hapi (if that's the validator) to see why this fails?

view this post on Zulip Lloyd McKenzie (May 19 2020 at 15:36):

@Jenni Syed is correct. All contained resources must be siblings. You can't have a contained within a contained. The identifiers are all evaluated within the scope of the overall containing resource. It looks like there's a problem with the invariant - it doesn't allow for the possibility of the linkage from the container to a contained resource being through another contained resource. In the short term, you may need an extension to create a link to satisfy the invariant. However, please submit a change request for us to fix the invariant @Michael Sauer

view this post on Zulip Michael Sauer (May 19 2020 at 15:47):

@Lloyd McKenzie Thank you very much for your clarification and for your explanation. I will submit a change request! :-)

view this post on Zulip Shamil Nizamov (Jul 19 2021 at 15:27):

Can one contained resource reference another contained resource within the same container? E.g., the List resource has Patient and Encounter as contained resources, and the contained Encounter reference to the contained Patient.

view this post on Zulip Paul Church (Jul 19 2021 at 15:28):

Yes.

view this post on Zulip Shamil Nizamov (Jul 19 2021 at 15:32):

Then what will be the reference link - in the same way as List references to the contained Patient, e.g., #patient1 , or back to the container and then to the contained, i.e., - #/#patient1 ?

view this post on Zulip Paul Church (Jul 19 2021 at 15:33):

It's just #patient1. Because contained resources cannot be nested, there is only one namespace.

view this post on Zulip Paul Church (Jul 19 2021 at 15:34):

The only special case is that "#" refers to the container.


Last updated: Apr 12 2022 at 19:14 UTC