FHIR Chat · Extensions for R5 elements in an R4 IG · shorthand

Stream: shorthand

Topic: Extensions for R5 elements in an R4 IG


view this post on Zulip Kevin Power (Dec 23 2021 at 19:58):

I am trying to use a newly defined attribute from R5 in an R4 based IG. I am using the guidance here:
https://fshschool.org/docs/sushi/configuration/#dependencies
http://build.fhir.org/versions.html#extensions

I tried a few things, and couldn't get it to work. To verify:

(and sorry, this is likely not a shorthand specific thing, but I started here since I am using FSH :smile:)

view this post on Zulip Chris Moesel (Jan 04 2022 at 20:28):

Hi @Kevin Power -- sorry for the delay! This one got lost in the holiday shuffle! You should be able to do this by setting up the dependency in sushi-config.yaml:

dependencies:
  hl7.fhir.extensions.r5: 4.0.1

Then using it in a profile and/or instance. I usually create an alias for the extension URL to simplify things. For example:

Alias: R5DiagnosticReportNote = http://hl7.org/fhir/5.0/StructureDefinition/extension-DiagnosticReport.note

Profile: MyDiagnosticReportProfile
Parent: DiagnosticReport
Description: "An example profile showing how to use an R5 extension."
* extension contains R5DiagnosticReportNote named note 0..*

I'm attaching a working project as a zip file with an example profile and two instances.

DiagnosticReportNoteExample.zip

view this post on Zulip Chris Moesel (Jan 04 2022 at 20:31):

Note that this will use the current R5 build from the build server -- and it attempts to download it every time (since current can change multiple times per day). Unfortunately, this means that this will not currently work due to the expired security certificate on build.fhir.org. Until that is fixed, the R5 download will fail. I posted a workaround here if you really need to make progress on this while we wait for the build server issue to be fixed.

view this post on Zulip Chris Moesel (Jan 04 2022 at 20:33):

Oh! But since this uses a current build and attempts to download every time, you shouldn't remove the special environment variable until you're done working on it, because as soon as you remove it, local builds will fail again.

view this post on Zulip Kevin Power (Jan 04 2022 at 20:40):

Ha, just noticed that :smile: So left the environment variable set for now.

So, if I start with just the dependency, it seems to download packages and builds fine. However, I get this error when I build a 2nd time:

Sushi: error Failed to load supplemental FHIR package hl7.fhir.r5.core#current: ENOTEMPTY: directory not empty, rename '/Users/kmpower/.fhir/packages/hl7.fhir.r5.core#current/openapi' -> '/Users/kmpower/.fhir/packages/hl7.fhir.r5.core#current/package/openapi'

view this post on Zulip Kevin Power (Jan 04 2022 at 20:58):

@Chris Moesel - If I delete the package folder, it seems to then work. However, once I try to add the extension to my profile, I get the following stack dump:

Stack Dump (for debugging):                                                      (00:37.0827)
java.lang.Exception: Error generating snapshot for /Users/kmpower/Documents/GitHub/genomics-reporting/fsh-generated/resources/StructureDefinition-genomics-report(genomics-report): Unable to generate snapshot for http://hl7.org/fhir/uv/genomics-reporting/StructureDefinition/genomics-report in /Users/kmpower/Documents/GitHub/genomics-reporting/fsh-generated/resources/StructureDefinition-genomics-report
        at org.hl7.fhir.igtools.publisher.Publisher.generateSnapshots(Publisher.java:4810)
        at org.hl7.fhir.igtools.publisher.Publisher.loadConformance(Publisher.java:4094)
        at org.hl7.fhir.igtools.publisher.Publisher.createIg(Publisher.java:944)
        at org.hl7.fhir.igtools.publisher.Publisher.execute(Publisher.java:795)
        at org.hl7.fhir.igtools.publisher.Publisher.main(Publisher.java:8975)
Caused by: org.hl7.fhir.exceptions.FHIRException: Unable to generate snapshot for http://hl7.org/fhir/uv/genomics-reporting/StructureDefinition/genomics-report in /Users/kmpower/Documents/GitHub/genomics-reporting/fsh-generated/resources/StructureDefinition-genomics-report
        at org.hl7.fhir.igtools.publisher.Publisher.generateSnapshot(Publisher.java:4859)
        at org.hl7.fhir.igtools.publisher.Publisher.generateSnapshots(Publisher.java:4808)
        ... 4 more
Caused by: org.hl7.fhir.exceptions.FHIRException: Reference to unknown extension http://hl7.org/fhir/5.0/StructureDefinition/extension-DiagnosticReport.note
        at org.hl7.fhir.r5.conformance.ProfileUtilities.processPaths(ProfileUtilities.java:1163)
        at org.hl7.fhir.r5.conformance.ProfileUtilities.processPaths(ProfileUtilities.java:1529)
        at org.hl7.fhir.r5.conformance.ProfileUtilities.generateSnapshot(ProfileUtilities.java:654)
        at org.hl7.fhir.igtools.publisher.Publisher.generateSnapshot(Publisher.java:4857)
        ... 5 more

Not sure if that is another symptom of the first problem I mentioned or not.

view this post on Zulip Chris Moesel (Jan 04 2022 at 21:16):

Hopefully you don't have to delete the package folder every time! If so, that doesn't seem right...

view this post on Zulip Chris Moesel (Jan 04 2022 at 21:19):

As for the error, my only guess is that the IG Publisher is using an older version of FHIR R5 to resolve the special cross-version extensions. The note element was only added to DiagnosticReport in the last snapshot release. So if the IG Publisher is using FHIR R5 4.6.0 or lesser, then it wouldn't recognize the http://hl7.org/fhir/5.0/StructureDefinition/extension-DiagnosticReport.note extension. @Grahame Grieve -- is my guess right? Is the IG publisher possibly using an older R5 package to try to resolve cross-version extensions?

view this post on Zulip Kevin Power (Jan 04 2022 at 21:27):

Thanks for all the help @Chris Moesel
https://media4.giphy.com/media/uWlpPGquhGZNFzY90z/giphy.gif?cid=c623cb359pulbwj2mskzt0d529afq0yeznm9t7jjknkttn6e&rid=giphy.gif&ct=g

view this post on Zulip Chris Moesel (Jan 04 2022 at 21:29):

My pleasure! Let's see what Grahame says and we'll take it from there...

view this post on Zulip Kevin Power (Jan 04 2022 at 23:44):

@Chris Moesel - Just FYI, you might be onto something. I switched over to a different attribute that is also being added in R5 (composition) and everything works as I would expect (so maybe it was in an earlier snapshot that the IG is using).

I will also add that I am not sure what changed, but the weird error I was getting with the build failing the 2nd time has now stopped happening. So, not sure what that is about.

view this post on Zulip Kevin Power (Jan 06 2022 at 00:19):

Chris Moesel said:

As for the error, my only guess is that the IG Publisher is using an older version of FHIR R5 to resolve the special cross-version extensions. The note element was only added to DiagnosticReport in the last snapshot release. So if the IG Publisher is using FHIR R5 4.6.0 or lesser, then it wouldn't recognize the http://hl7.org/fhir/5.0/StructureDefinition/extension-DiagnosticReport.note extension. Grahame Grieve -- is my guess right? Is the IG publisher possibly using an older R5 package to try to resolve cross-version extensions?

@Grahame Grieve - I know you are swamped, but wanted to tag you on this one again to see if you have any thoughts.


Last updated: Apr 12 2022 at 19:14 UTC