FHIR Chat · Constraining Extension Values in Profiles · IG creation

Stream: IG creation

Topic: Constraining Extension Values in Profiles


view this post on Zulip Chris Moesel (Aug 14 2018 at 01:52):

Is it possible to constrain the valueReference of an extension to a specific profile? See the example below for something the IG publisher outputs in this situation:
pasted image

shr-base-Subject-extension defines a valueReference to DomainResource. In a profile, the profile constrains that extension's valueReference to point to a WoundPresent profile.

You can see in the screenshot above that the IG ends up listing both the original reference (in line with the base extension) and the profile reference (in line with the unrolled valueReference). This doesn't seem quite right, but I'm not sure if I'm doing something unsupported or if the IG publisher just doesn't handle it correctly.

view this post on Zulip Grahame Grieve (Aug 14 2018 at 01:53):

it feels like an IG publisher issue, but I won't know until I debug in detail

view this post on Zulip Chris Moesel (Aug 14 2018 at 02:15):

Alright. Relatively speaking, I'd say this one is low priority. I mainly wanted to be sure that the general idea of what I was doing (applying a type constraint on an extension) wasn't horribly illegal.

view this post on Zulip Sarah Gaunt (Aug 14 2018 at 02:22):

Is this the same use case?

pasted image

And then in the extension:
pasted image

It looks different to yours though...

view this post on Zulip Chris Moesel (Aug 14 2018 at 02:32):

I'm not sure? The first image looks like the use of the extension-rr-routing-entity extension in a profile. The 2nd image looks like the definition of the extension-rr-responsible-agency extension. Are those supposed to be related somehow?

I think mine is more like the first if you had another profile (e.g., Child Routing Entity) and you tried to constrain the extension-rr-routing-entity extension to reference the Child Routing Entity instead.

view this post on Zulip Sarah Gaunt (Aug 14 2018 at 02:34):

Yeah, wrong screen shot...
So the extension-rr-routing-entity references a profile called Routing Entity.
Is that what your extension is doing?

view this post on Zulip Sarah Gaunt (Aug 14 2018 at 02:35):

I'm not sure if I'm doing it correctly - it seems like the same idea, but maybe it isn't....

view this post on Zulip Sarah Gaunt (Aug 14 2018 at 02:37):

It looks like your screen shot is showing where the extension is used, not where it's defined?

view this post on Zulip Chris Moesel (Aug 14 2018 at 02:38):

I think that what you're doing is the pretty typical use case -- and it looks to me like you're doing it right.

view this post on Zulip Sarah Gaunt (Aug 14 2018 at 02:39):

So you are constraining the valueReference when it gets used? Is that the difference?

view this post on Zulip Chris Moesel (Aug 14 2018 at 02:40):

My use case is a little different. In my use case, imagine a profiler says, "I like that extension-rr-routing-entity extension, but I actually want to constrain the profile it references (RoutingEntity) even further! I want it to say the reference must be to StricterRoutingEntity!"

view this post on Zulip Chris Moesel (Aug 14 2018 at 02:41):

Yeah, I think that's the difference. The other approach, of course, would be just to create _another_ whole extension with its own unique name. But maybe that's not necessary?

view this post on Zulip Sarah Gaunt (Aug 14 2018 at 02:41):

Ah ok... Interesting!

view this post on Zulip Sarah Gaunt (Aug 14 2018 at 02:43):

It actually is close to my use case - I've been struggling with it. I have ended up with 3 of almost the same extension - if it's possible to do what you are doing, I might have to change it. Then I'd only have the one extension (entity/agency) which could be further constrained at that higher level to routing/responsible/rules authoring.

I'll have to look into it. It would be less clutter - it's been bothering me to have the 3 extensions.

view this post on Zulip Sarah Gaunt (Aug 14 2018 at 02:45):

Darn it! Didn't want to get sucked into any rabbit holes today! :joy: :joy: :joy:

view this post on Zulip Chris Moesel (Aug 14 2018 at 02:46):

Ha! You're welcome!

view this post on Zulip Grahame Grieve (Aug 14 2018 at 18:28):

so where are we with this now?

view this post on Zulip Sarah Gaunt (Aug 14 2018 at 18:31):

I've updated my IG to use that same pattern and it looks the same as Chris's. (Haven't run it yet this morning though - not sure what changes have happened over night...).

pasted image

view this post on Zulip Grahame Grieve (Aug 14 2018 at 18:32):

which page is that?

view this post on Zulip Sarah Gaunt (Aug 14 2018 at 18:38):

http://build.fhir.org/ig/HL7/case-reporting/StructureDefinition-rr-plandefinition.html

https://github.com/HL7/case-reporting/blob/master/source/resources/profiles/structuredefinition-rr-plandefinition.xml

view this post on Zulip Sarah Gaunt (Aug 16 2018 at 01:25):

Did you take a look at this @Grahame Grieve ? Is it expected behaviour? Is the pattern even legal?

view this post on Zulip Grahame Grieve (Aug 16 2018 at 01:41):

I can't find that reference?

view this post on Zulip Sarah Gaunt (Aug 16 2018 at 01:48):

Oh yeah, I changed the name (for a way longer and clearly superior name :joy: ):

http://build.fhir.org/ig/HL7/case-reporting/StructureDefinition-rr-relevant-reportable-condition-plandefinition.html

https://github.com/HL7/case-reporting/blob/master/source/resources/profiles/structuredefinition-rr-relevant-reportable-condition-plandefinition.xml

view this post on Zulip Sarah Gaunt (Aug 16 2018 at 01:49):

It's the "Rules Authoring Agency Test" bit

view this post on Zulip Grahame Grieve (Aug 16 2018 at 02:00):

so I don't understand what you're trying to do here

view this post on Zulip Sarah Gaunt (Aug 16 2018 at 02:02):

My use case is a little different. In my use case, imagine a profiler says, "I like that extension-rr-routing-entity extension, but I actually want to constrain the profile it references (RoutingEntity) even further! I want it to say the reference must be to StricterRoutingEntity!"

Trying out @Chris Moesel pattern that he explains above. It works for my use case as I could have fewer specific extensions...

view this post on Zulip Grahame Grieve (Aug 16 2018 at 02:02):

this:

    <element id="PlanDefinition.publisher.extension:rulesAuthoringAgency">
      <path value="PlanDefinition.publisher.extension" />
      <sliceName value="rulesAuthoringAgency" />
      <min value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/us/ecr/StructureDefinition/extension-rr-rules-authoring-agency" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="cda-rr" />
        <map value="Rules Authoring Agency" />
      </mapping>
    </element>

That's a standard extension profile, ok. Then this:

    <element id="PlanDefinition.publisher.extension:rulesAuthoringAgencyTest">
      <path value="PlanDefinition.publisher.extension" />
      <sliceName value="rulesAuthoringAgencyTest" />
      <short value="Rules Authoring Agency Test" />
      <definition value="Optional Extension Element - found in all resources." />
      <min value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/us/ecr/StructureDefinition/extension-ecr-organization" />
      </type>
      <mustSupport value="true" />
    </element>

ok that's very similar. but then we walk into the extension, and say:

    <element id="PlanDefinition.publisher.extension:rulesAuthoringAgencyTest.value[x]:valueReference">
      <path value="PlanDefinition.publisher.extension.valueReference" />
      <sliceName value="valueReference" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/us/ecr/StructureDefinition/rr-rules-authoring-agency" />
      </type>
    </element>

I don't understand that pattern at all, but it looks like exactly what's rendered to me...

view this post on Zulip Sarah Gaunt (Aug 16 2018 at 02:04):

It is exactly what is rendered - but my question is - is this even a reasonable pattern? If you scroll to the beginning of topic you can see Chris's original question...

view this post on Zulip Grahame Grieve (Aug 16 2018 at 02:08):

I don't understand the intention?

view this post on Zulip Sarah Gaunt (Aug 16 2018 at 02:11):

So rather than creating 3 extensions, one for each of my different types of organisation, just create one extension that references the base of the 3 different organisations, the when you use the extension, specialise it further at that point.

view this post on Zulip Sarah Gaunt (Aug 16 2018 at 02:14):

I should probably just roll back to my original pattern - if YOU don't understand it, probably not the best idea!

view this post on Zulip Chris Moesel (Aug 16 2018 at 02:51):

Ha. I never claimed that it was a good idea. Only that we do it. ;-)

view this post on Zulip Sarah Gaunt (Aug 16 2018 at 02:58):

I liked it!

view this post on Zulip Sarah Gaunt (Aug 16 2018 at 03:00):

I'm actually rolling it back though - I can't get an example to validate when I use the pattern. Maybe I'm doing something wrong in my example, but no time to debug at this late juncture... Maybe will investigate again after ballot...

view this post on Zulip Grahame Grieve (Aug 16 2018 at 03:18):

create one extension that references the base of the 3 different organisations, the when you use the extension, specialise it further at that point

That part makes sense, I think. I would've thought it would validate

view this post on Zulip Sarah Gaunt (Aug 16 2018 at 03:20):

Who knows - seeing double at this point... As I'm sure you are, actually you're probably at triple ...

view this post on Zulip Sarah Gaunt (Aug 16 2018 at 03:21):

Might test again later

view this post on Zulip Sarah Gaunt (Aug 16 2018 at 04:19):

I'm going for your pattern @Chris Moesel - managed to get it to work - just some dumb errors in my example were causing the errors.

view this post on Zulip Richard Townley-O'Neill (Jul 01 2019 at 03:08):

We want a profile to constrain references in an extension using the technique discussed above. We can constrain the extension values in the profile using a text editor. (See 4/ below) The result displays acceptably in IG Publisher output
pasted image

and in Forge
pasted image

But we cannot create this constraint using Forge. @Vadim Peretokin @Michel Rutten Can Forge do this? How?

1/ The extension: composition-author-role
2/ The profile using the extension at lines 39-50: au-composition
3/ The profile of au-composition in which we constrain the extension with an invariant at lines 50-63: composition-shs-1
4/ How we'd like to constrain the extension

    <element id="Composition.extension:compositionAuthorRole">
      <path value="Composition.extension" />
      <sliceName value="compositionAuthorRole" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Composition.extension:compositionAuthorRole.valueReference:valueReference">
      <path value="Composition.extension.valueReference" />
      <sliceName value="valueReference" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://ns.electronichealth.net.au/ci/fhir/3.0/StructureDefinition/practitionerrole-withpractitionerident-1" />
      </type>
    </element>

Last updated: Apr 12 2022 at 19:14 UTC