FHIR Chat · constraining a bundle to a profiled composition · implementers

Stream: implementers

Topic: constraining a bundle to a profiled composition


view this post on Zulip Oliver Egger (Feb 08 2017 at 21:31):

i would like to constrain a bundle to a specific profiled composition. i'm not successful with my structuredefinition, the validator doesn't raise an error if i don't put the profile on the composition. does anybody know an example for STU3 how a slice for a bundle would work? I tried it the following way:

    <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Bundle" />
    <derivation value="constraint" />
    <differential>
        <element id="Bundle">
            <path value="Bundle" />
            <base>
                <path value="Bundle" />
                <min value="1" />
                <max value="1" />
            </base>
        </element>
        <element id="Bundle.type">
            <path value="Bundle.type" />
            <fixedCode value="document" />
        </element>
        <element id="Bundle.entry">
            <path value="Bundle.entry"/>
            <slicing>
                <discriminator value="resource"/>
                <ordered value="true"/>
                <rules value="open"/>
            </slicing>
            <min value="1"/>
            <max value="*"/>
        </element>
        <element id="Bundle.entry.resource:Composition">
            <path value="Bundle.entry.resource"/>
            <type>
                <code value="Composition"/>
                <profile value="http://snip"/>
            </type>
        </element>
    </differential>

Any hints or link to a sample highly appreciated.

view this post on Zulip Lloyd McKenzie (Feb 08 2017 at 23:49):

Well, you've defined slicing but haven't actually declared your slice - you need to have an additional element with path "Bundle.entry" with a slice name that then has the child element. As well, your slice discriminator is just a path - which means you're slicing by fixed value, value set or existence. I think you probably want the discriminator to be resource.@type.

view this post on Zulip Lloyd McKenzie (Feb 08 2017 at 23:49):

Even if you fix this, it may not work - not sure if the validator supports slicing elements of type Resource as that requires somewhat special behavior.

view this post on Zulip Oliver Egger (Feb 09 2017 at 21:51):

Thanks for your input @Lloyd McKenzie. I adjusted it to your recommendations and have not the following:

    <differential>
        <element id="Bundle">
            <path value="Bundle" />
            <min value="1" />
            <max value="1" />
        </element>
        <element id="Bundle.type">
            <path value="Bundle.type" />
            <fixedCode value="document" />
        </element>
        <element id="Bundle.entry">
            <path value="Bundle.entry" />
            <slicing>
                <discriminator value="resource.@type" />
                <ordered value="true" />
                <rules value="openAtEnd" />
            </slicing>
            <min value="1" />
            <max value="*" />
        </element>
        <!-- first slice -->
        <element id="Bundle.entry:Composition">
            <path value="Bundle.entry" />
<!--            <sliceName value="Composition" /> IG Publisher does not like the slicename -->
            <min value="1" />
            <max value="1" />
        </element>
        <element id="Bundle.entry.resource:Composition">
            <path value="Bundle.entry.resource" />
<!--            <sliceName value="Composition" /> -->
            <min value="1" />
            <max value="1" />
            <type>
                <code value="Composition" />
                <profile value="http://snip"/>
            </type>
        </element>

validating with discriminator resource.@type works. when i enter another type an error is thrown. the profile is somehow honored, but I don't think the composition is then directly validated against the profile (i can change the composition content with errors and don't get a validation error afterwards).

the ig publisher does not like the xml sample file which works with the validator (Unable to find discriminator definition for Bundle.entry.resource.@type in resource.@type at Bundle.entry[1]), there seems to be a difference between validator and ig publisher which i have to find out.

if i have put discriminator with resource.@profile the validator throws an error (Validating against slices with discriminators based on profiles is not yet supported by the FHIRPath engine: resource.@profile).

So I think I'm on a good path, I will try to figure out whats the difference between validating from ig publisher/validator and if successful send in a patch, thanks one more time for guiding me to the right direction.

view this post on Zulip Lloyd McKenzie (Feb 10 2017 at 01:09):

Not sure why it's yelling about slice name on your Bundle.entry. Don't need one on Bundle.entry.resource


Last updated: Apr 12 2022 at 19:14 UTC