FHIR Chat · Profile for bundle with constraints on resource types · Profiling Academy - archived

Stream: Profiling Academy - archived

Topic: Profile for bundle with constraints on resource types


view this post on Zulip Johanna Eicher (Feb 11 2021 at 16:52):

Hi,
I want to create a FHIR profile for a bundle with the following constraints:

  • the bundle should contain exactly one patient resource
  • the bundle may contain any number of encounter resources.

I'm using Forge where I sliced on the bundle entry and created two slices for each resource type see here. I'm not sure which discriminator type to use and I don't know how to specify which of the two new slices is for the patient and which one is for the encounter.

Does anyone have any tips of how to accomplish this or maybe an example of a structure definition where a bundle was sliced this way?

view this post on Zulip Richard Townley-O'Neill (Feb 12 2021 at 05:02):

This should work

<differential>
<element id="Bundle">
<path value="Bundle" />
</element>
<element id="Bundle.entry">
<path value="Bundle.entry" />
<slicing>
<discriminator>
<type value="type" />
<path value="resource" />
</discriminator>
<rules value="open" />
</slicing>
<min value="1" />
</element>
<element id="Bundle.entry:pat">
<path value="Bundle.entry" />
<sliceName value="pat" />
<max value="1" />
</element>
<element id="Bundle.entry:pat.resource">
<path value="Bundle.entry.resource"/>
<min value="1"/>
<type>
<code value="Patient"/>
</type>
</element>
<element id="Bundle.entry:per">
<path value="Bundle.entry" />
<sliceName value="per" />
<min value="1" />
</element>
<element id="Bundle.entry:per.resource">
<path value="Bundle.entry.resource"/>
<min value="1"/>
<type>
<code value="Person"/>
</type>
</element>
</differential>

view this post on Zulip Johanna Eicher (Feb 12 2021 at 11:20):

I will check it out, thank you!

view this post on Zulip Johanna Eicher (Feb 12 2021 at 14:08):

This is the result from my attempt. Does that look okay to you?

<differential>
<element id="Bundle.entry">
<path value="Bundle.entry"/>
<slicing>
<discriminator>
<type value="type"/>
<path value="resource"/>
</discriminator>
<rules value="open"/>
</slicing>
<min value="1"/>
</element>
<element id="Bundle.entry:patientEntry">
<path value="Bundle.entry"/>
<sliceName value="patientEntry"/>
<min value="1"/>
<max value="1"/>
</element>
<element id="Bundle.entry:patientEntry.resource">
<path value="Bundle.entry.resource"/>
<min value="1"/>
<type>
<code value="Resource"/>
<profile value="Patient"/>
</type>
</element>
<element id="Bundle.entry:encounterEntry">
<path value="Bundle.entry"/>
<sliceName value="encounterEntry"/>
</element>
<element id="Bundle.entry:encounterEntry.resource">
<path value="Bundle.entry.resource"/>
<type>
<code value="Resource"/>
<profile value="Encounter"/>
</type>
</element>
</differential>

view this post on Zulip Richard Townley-O'Neill (Feb 14 2021 at 23:00):

Looks OK to me.
If you want to prohibit entries that are neither Patient nor Encounter, make the slicing closed.

        <slicing>
            <discriminator>
                <type value="type"/>
                <path value="resource"/>
            </discriminator>
            <rules value="closed"/>
        </slicing>```

view this post on Zulip Richard Townley-O'Neill (Feb 14 2021 at 23:04):

If slicing is open, the encounterEncounter slice constrains nothing. If you want to allow Patient, Encounter and anything else, you do not need the Encounter slice, though you might want it as documentation for humans to show you are interested in encounters.

view this post on Zulip Richard Townley-O'Neill (Feb 14 2021 at 23:15):

On reflection, I think that

<type>
    <code value="Resource"/>
    <profile value="Encounter"/>
</type>

should be

<type>
    <code value="Encounter"/>
</type>

As Encounter is a valid type.

view this post on Zulip Johanna Eicher (Feb 15 2021 at 13:24):

I actually want to prohibit any other resources, thank you for the tip about the closed slicing.

About the type definition, I didn't know how to create this

 <type>
      <code value="Encounter"/>
 </type>

in Forge. I tried to set it in the Element properties of the resource (see image.png ), but the result is

<type>
   <code value="Resource"/>
   <profile value="Encounter"/>
</type>

Any tips for how to do this in Forge?

view this post on Zulip Richard Townley-O'Neill (Feb 16 2021 at 00:31):

If Forge does it that way it should work just fine.

view this post on Zulip Matthijs van der Wielen (Feb 16 2021 at 13:16):

Although it doesn't seem intuitive, you can specify the resource type by defining a "profile" on resource. Since all other core resources are technically profiles on resource. In the screenshot attached you can see how to define that you can only use "Patient" in this slice. You can add other canonical URLs to define other options, which can be core resources or local profiles.
This would result in the following:

 <type>
       <code value="Resource"/>
       <profile value="http://hl7.org/fhir/StructureDefinition/Patient"/>
</type>

image.png

view this post on Zulip Johanna Eicher (Feb 16 2021 at 16:56):

Thank you very much, it was the canonical URL that I was missing!

view this post on Zulip Johanna Eicher (Feb 23 2021 at 08:57):

I have now created my own profiles for the different entries as well (Patient, Encounter, etc). But when I link them in the Bundle via the URL I get the following error: image.png .
Do you have any idea where this problem might originate from?


Last updated: Apr 12 2022 at 19:14 UTC