FHIR Chat · How to add extension using Sushi · shorthand

Stream: shorthand

Topic: How to add extension using Sushi


view this post on Zulip Joel Francis (Feb 12 2021 at 14:23):

Hi,

I want to add a stand alone extension https://build.fhir.org/ig/HL7-Canada/ca-baseline/StructureDefinition-ext-aboriginalidentitygroup.html to the Base (R4) Patient resource

I use the following line in the .fsh file: extension [http://hl7.org/fhir/ca/baseline/StructureDefinition/ext-aboriginalidentitygroup]

The error I am receiving is: error no viable alternative at input '* extension [http://hl7.org/fhir/ca/baseline/StructureDefinition/ext-aboriginalidentitygroup]'

Can anyone point me in the right direction? How do I resolve this? Thanks in advance.

@Alex Goel

view this post on Zulip Chris Moesel (Feb 12 2021 at 15:34):

Hi @Joel Francis -- I think there are a few things going on here. The most immediate issue is that you should not have a space between extension and [. So the path representing the extension should be extension[http://hl7.org/fhir/ca/baseline/StructureDefinition/ext-aboriginalidentitygroup].

view this post on Zulip Chris Moesel (Feb 12 2021 at 15:37):

That said, there is an open bug for SUSHI's handling of extension URLs in paths like this. We actually have a fix for this under review, but for now, the way around it is to use an alias for the extension URL. Here is an example (w/ full context for clarity):

Alias: EX_ABIDGRP = http://hl7.org/fhir/ca/baseline/StructureDefinition/ext-aboriginalidentitygroup
Alias: CS_ABIDTYPE = https://fhir.infoway-inforoute.ca/CodeSystem/aboriginalidentitytype

Instance: MyPatient
InstanceOf: Patient
* extension[EX_ABIDGRP].valueCoding = CS_ABIDTYPE#firstnations "First Nations"

view this post on Zulip Chris Moesel (Feb 12 2021 at 15:39):

Since you reference an extension from another IG, you need to specify that IG in your sushi-config.yaml dependencies. It looks like the IG this comes from only has a current build, so that dependency would look like this:

dependencies:
  hl7.fhir.ca.baseline: current

view this post on Zulip Chris Moesel (Feb 12 2021 at 15:46):

Now, as it turns out, this still doesn't work in SUSHI. When I run it, I get a few errors, starting with this:

error Cannot read property 'slicing' of undefined

I looked into it and found that the StructureDefinition for the Aboriginal Identity Group extension has an incomplete snapshot. It does not have an element for Extension.value[x] (which is where the slicing would usually go). Instead it jumps to Extension.value[x]:valueCoding without ever defining the Extension.value[x] element it is sliced from. I think this is invalid, but perhaps someone like @Lloyd McKenzie can confirm. Lloyd, is it valid to have an Extension snapshot without an element for Extension.value[x]? (StructureDefinition XML here).

view this post on Zulip Alex Goel (Feb 12 2021 at 15:46):

@Chris Moesel is that how it would be defined in a Profile too?

view this post on Zulip Chris Moesel (Feb 12 2021 at 15:51):

@Alex Goel -- In a profile, you specify an extension using the contains keyword. So to say that a patient profile can contain that extension, assuming the same alias as defined above, your FSH would look like this:

Profile: PatientProfile
Parent: Patient
* extension contains EX_ABIDGRP named ext-aboriginalidentitygroup 0..1

Then to use it in an instance of the profile, you can now use the local slicename it specified for that extension:

Instance: MyPatient
InstanceOf: Patient
* extension[ext-aboriginalidentitygroup].valueCoding = CS_ABIDTYPE#firstnations "First Nations"

This still breaks in SUSHI, however, due to the incomplete snapshot in that extension's StructureDefinition, as I noted above.

view this post on Zulip Alex Goel (Feb 12 2021 at 15:55):

Chris Moesel said:

Now, as it turns out, this still doesn't work in SUSHI. When I run it, I get a few errors, starting with this:

error Cannot read property 'slicing' of undefined

I looked into it and found that the StructureDefinition for the Aboriginal Identity Group extension has an incomplete snapshot. It does not have an element for Extension.value[x] (which is where the slicing would usually go). Instead it jumps to Extension.value[x]:valueCoding without ever defining the Extension.value[x] element it is sliced from. I think this is invalid, but perhaps someone like Lloyd McKenzie can confirm. Lloyd, is it valid to have an Extension snapshot without an element for Extension.value[x]? (StructureDefinition XML here).

@Michael Savage FYI

view this post on Zulip Chris Moesel (Feb 12 2021 at 16:01):

If instead of using the predefined extension, I define a similar one in FSH, it all works well:

Alias: VS_ABIDGRP = https://fhir.infoway-inforoute.ca/ValueSet/aboriginalidentitygroup
Alias: CS_ABIDTYPE = https://fhir.infoway-inforoute.ca/CodeSystem/aboriginalidentitytype

Extension: ExtensionAboriginalIdentityGroup
Id: ext-aboriginalidentitygroup
* value[x] only Coding
* valueCoding 1..1
* valueCoding from VS_ABIDGRP (preferred)

Profile: PatientProfile
Parent: Patient
Id: profile-patient
* extension contains ExtensionAboriginalIdentityGroup named ext-aboriginalidentitygroup 0..1

Instance: MyPatient
InstanceOf: Patient
* extension[ext-aboriginalidentitygroup].valueCoding = CS_ABIDTYPE#firstnations "First Nations"

I know you want to use the one from the IG, but I just wanted to show that in general it works if the Extension is defined correctly (or at least w/ a complete snapshot).

view this post on Zulip Joel Francis (Feb 12 2021 at 16:02):

Chris Moesel said:

If instead of using the predefined extension, I define a similar one in FSH, it all works well:

Alias: VS_ABIDGRP = https://fhir.infoway-inforoute.ca/ValueSet/aboriginalidentitygroup
Alias: CS_ABIDTYPE = https://fhir.infoway-inforoute.ca/CodeSystem/aboriginalidentitytype

Extension: ExtensionAboriginalIdentityGroup
Id: ext-aboriginalidentitygroup
* value[x] only Coding
* valueCoding 1..1
* valueCoding from VS_ABIDGRP (preferred)

Profile: PatientProfile
Parent: Patient
Id: profile-patient
* extension contains ExtensionAboriginalIdentityGroup named ext-aboriginalidentitygroup 0..1

Instance: MyPatient
InstanceOf: Patient
* extension[ext-aboriginalidentitygroup].valueCoding = CS_ABIDTYPE#firstnations "First Nations"

I know you want to use the one from the IG, but I just wanted to show that in general it works if the Extension is defined correctly (or at least w/ a complete snapshot).

Thaks @Chris Moesel

view this post on Zulip Lloyd McKenzie (Feb 12 2021 at 16:50):

I don't think it's legal anymore. The tooling used to be looser, but we now try hard to be consistent.

view this post on Zulip Alex Goel (Feb 12 2021 at 16:52):

@Michael Savage need a new StructureDefinition for AboriginalIdentityGroup?


Last updated: Apr 12 2022 at 19:14 UTC