FHIR Chat · Reference instances between IGs · implementers

Stream: implementers

Topic: Reference instances between IGs


view this post on Zulip Thea Mentz Soerensen (Dec 17 2021 at 11:30):

Hi, we have a problem which concerns referencing instances created in one IG (1) in Bundle.entry.resource from another IG (2) in FSH.  
@Anders Jensen
In IG (2) we have declared dependencies to (1) in the sushi-config.yaml file.
In IG (1) is the following Organization-instance is created:
Instance.png
In IG (2) we want to reference the above-mentioned Organization from the Bundle.entry.resource element.
ReferenceToInstance.png
It work just fine in the Bundle.entry.fullUrl element, but not in the resource element and we get the following error.
Error.png
We would really appreciate any input on how to solve this problem.
Thank you in advance.

view this post on Zulip Grahame Grieve (Dec 17 2021 at 12:51):

seems like a question for #shorthand

view this post on Zulip Chris Moesel (Dec 17 2021 at 13:57):

You're creating these as examples (when Usage: is not specified, it defaults to #example for Instances). @Grahame Grieve -- should one IG be able to reference examples from another IG? Or is the expectation that only the non-example resources can be referenced and used by other IGs?

view this post on Zulip John Moehrke (Dec 17 2021 at 14:02):

would be nice to be able to use examples from dependencies (core + IGs) as if they were part of your IG. I keep having to create core examples to build the story in my IG, these get copy/pasted around.

view this post on Zulip Chris Moesel (Dec 17 2021 at 14:11):

I think a challenge is that examples don't necessarily have a canonical URL, and therefore don't necessarily have a unique id. For example (no pun intended), the reference Patient/Patient1 could exist in multiple dependency IGs; which one should be used?

view this post on Zulip John Moehrke (Dec 17 2021 at 14:11):

yup, but it does exist within an IG (or core); which do have a canonical root

view this post on Zulip Chris Moesel (Dec 17 2021 at 14:14):

@John Moehrke -- that's a good point. I suppose we could try appending the IG canonical w/ /{type}/{id} to see if that gets us anywhere. I can experiment a little to see if/how the IG Publisher handles this situation. I have no idea if it is supported or not.

view this post on Zulip Vassil Peytchev (Dec 17 2021 at 14:42):

Examples from the core spec can be used - see here

view this post on Zulip John Moehrke (Dec 17 2021 at 14:51):

certainly structureDefinition from core; I didn't know (and that chat stream doesn't make it clear) that example resources from core can be used. I admit, I tried once and it was easier to copy/paste than try to figure it out

view this post on Zulip Vassil Peytchev (Dec 17 2021 at 14:57):

There is a separate package for core examples that needs to be included as a dependency, that is what the other stream is showing

view this post on Zulip Chris Moesel (Dec 17 2021 at 15:45):

Thanks for the pointer @Vassil Peytchev. That will help as I try to figure out how this should work. Hopefully whatever works for FHIR core examples would also work for IG examples...

view this post on Zulip John Moehrke (Dec 17 2021 at 15:54):

ah, I missed that

view this post on Zulip Chris Moesel (Dec 17 2021 at 15:57):

Just a heads up: I'm running into weirdness trying to declare the examples packages as a dependency in my SUSHI project. For some reason it is forcing it to try to re-download FHIR R4 core (not sure why) and then failing. I'm just reporting it now before @John Moehrke reports it. ;-)

view this post on Zulip John Moehrke (Dec 17 2021 at 15:57):

drat...

view this post on Zulip Chris Moesel (Dec 17 2021 at 16:00):

What's weird is if I declare it as a dependency, the first time I run SUSHI it actually runs fine! But then the next time it encounters errors. If I then delete the examples from the FHIR cache, it runs fine again! But then running it after that (once again) causes errors. Sigh. I guess I'll break out the debugger!

view this post on Zulip Chris Moesel (Dec 17 2021 at 16:17):

OK. I see what is happening here (sort of). The main problem is that the hl7.fhir.r4.examples package also happens to contain all of the FHIR core resource definitions. So SUSHI loads that up and then tries to load up the actual FHIR R4 core and gets confused because it seems like nothing happened (since all of the core resources were already loaded). That's an interesting one, but I think that some changes that @Julia Afeltra is working on might fix that (maybe). BUT... should the examples package contain all of the FHIR core resources too? That means we have two different packages (w/ different ids) that provide resources with the same canonicals and versions.

view this post on Zulip Vassil Peytchev (Dec 17 2021 at 17:19):

@Grahame Grieve

view this post on Zulip Chris Moesel (Dec 17 2021 at 21:09):

I experimented with this by creating a simple IG that depends on the mCODE IG. In my IG, I created a Patient instance that depends on mCODEPractitionerExample01 from mCODE.

I separately tried each of the following variations:

  • reference by id: "reference": "mCODEPractitionerExample01"
  • reference by type/id: "reference": "Practitioner/mCODEPractitionerExample01"
  • reference by canonical/type/idL "reference": "http://hl7.org/fhir/us/mcode/Practitioner/mCODEPractitionerExample01"

In all cases, the IG Publisher reported an error that it couldn't resolve the reference and the link in the generated example narrative was broken. So... it seems to me that you can't reference examples from other IGs (or if you can, someone needs to tell me how).

view this post on Zulip Elliot Silver (Dec 17 2021 at 21:14):

Are the example instances in the package?

view this post on Zulip Chris Moesel (Dec 17 2021 at 21:16):

@Elliot Silver - YES, in the package's examples folder. I double-checked that.

view this post on Zulip Chris Moesel (Dec 17 2021 at 21:16):

BUT... I just looked at @Thea Mentz Soerensen's original question and now realize that they were not trying to use a reference. They were trying to inline an example from another IG as a Bundle entry.resource (since entry.resource is not a Reference). OK. So that's a little different, but I expect we'd still run into issues if that inlined instance referenced any other examples from the IG.

So... SUSHI is not allowing an example from another IG to be inlined into an example in the current IG. Looking at the SUSHI code and how we load dependencies, this does not surprise me. Honestly, it will be a bit of work to support something like this because we currently drop most examples when we load the package. In fact, we even drop some non-examples (like ConceptMap) when we load dependencies -- so we do need to make some improvements here anyway.

view this post on Zulip Grahame Grieve (Dec 18 2021 at 18:38):

SUSHI is not allowing an example from another IG to be inlined into an example in the current IG

and it shouldn't. There is a proposal to allow inlining descriptions of a resource from another IG, and I'm working on that at some stage, but I think it's mainly not FSH business. It'll probably be a parameter in the IG resource.

view this post on Zulip Grahame Grieve (Dec 18 2021 at 18:40):

should the examples package contain all of the FHIR core resources too?

Good question, and you're welcome to raise that for R4B/R5, but the packages are published now, so we have to deal with what I did there, and I agree that it's challenging. I have a special rule, that I don't load examples over core. (and someone just found a place where I'm still am, so I need to make another fix in that regard)

view this post on Zulip Grahame Grieve (Dec 18 2021 at 18:41):

should the examples package contain all of the FHIR core resources too?

totally. Just refer to them by {canonical-root}/{type}/{id} and they should totally work for both validation and presentation. If someone wants to make up an example that shows how they're not working, I'll add it to my todo list

view this post on Zulip Thea Mentz Soerensen (Dec 20 2021 at 08:10):

Thank you so much for your answers - they were very helpful!


Last updated: Apr 12 2022 at 19:14 UTC