Stream: shorthand
Topic: Extensions on a slice
Noemi Deppenwiese (Jan 31 2020 at 13:53):
I'm trying to add an extension only to a specific slice of a coding:
//Set and define icd-10-gm slice * code.coding contains icd-10-gm 1..* * code.coding[icd-10-gm].extension contains HauptKreuzCode 0..*
When I try to run SUSHI on this file I get
error: No element found at path code.coding[icd-10-gm].extension for MIRACUMCondition, skipping rule File: C:\Users\deppenni\MII\fhir-igs\miracum-core-ig\fsh-files\Condition.fsh Line: 34 error: No element found at path code.coding[icd-10-gm].extension[HauptKreuzCode] for MIRACUMCondition, skipping rule File: C:\Users\deppenni\MII\fhir-igs\miracum-core-ig\fsh-files\Condition.fsh Line: 34
So, how can I access the extension array of a slice?
Chris Moesel (Jan 31 2020 at 14:12):
Have you setup the discriminator before declaring the slice? If so, then I would expect this should work (so then maybe you discovered a bug). If not, try setting up the discriminator on code.coding
first, and then try again. (You can use the ^
syntax to setup the discriminator, as shown here).
Noemi Deppenwiese (Jan 31 2020 at 14:24):
Thanks for your respone! I set up the slicing discriminator to use value on system.
I believe now the error is caused by me setting a (non-resolvable) slice profile between the two lines I posted earlier:
//Set and define icd-10-gm slice * code.coding contains icd-10-gm 1..* * code.coding[icd-10-gm] ^type.profile = "http://fhir.de/StructureDefinition/CodingICD10GM" * code.coding[icd-10-gm].extension contains HauptKreuzCode 0..*
(I omitted that before since I did not think it was relevant. I also modify some other ^attributes, but the profile line breaks it. Without it runs fine.)
Chris Moesel (Jan 31 2020 at 15:36):
There are a few possible things going on here.
First, is the http://fhir.de/StructureDefinition/CodingICD10GM
profile accessible to SUSHI? Is it defined in the same SUSHI project and/or included in one of the dependencies listed in the package.json?
Second, if the answer to the first is yes, then does the http://fhir.de/StructureDefinition/CodingICD10GM
zero out extension
on the coding?
Noemi Deppenwiese (Jan 31 2020 at 15:40):
The profile is not accessible. Does it have to be?
(It is a draft on Simplifier https://simplifier.net/Basisprofil-DE-R4/CodingICD10GM)
Chris Moesel (Jan 31 2020 at 15:47):
In order for SUSHI to properly validate that what you're doing is allowed, it probably should be accessible. Otherwise SUSHI doesn't know about any of the constraints the profile introduces. It also causes a problem if a path goes into the profiled things sub-elements, because it needs to then get the sub-elements from the profile to properly create the diffs. I'm guessing that's what is happening here -- it can't find the definition of that profile, so it can't locate the snapshot elements to generate a diff from. (Just a guess without actually debugging it).
Noemi Deppenwiese (Jan 31 2020 at 16:00):
Sounds reasonable. Are there any other ways of providing an "external" profile than using packages (Since SUSHI seems to be ignoring the newly added dependency... Or would I get an error if a dependency could not be resolved?)? E.g. just dumping the json file into the folder?
Chris Moesel (Jan 31 2020 at 18:50):
I feel like we should be reporting when a dependency can't be resolved (I mean, when you add a dependency into the package.json that can't be resolved). We probably also should be reporting if we can't resolve a profile URL when we need it. If we're not reporting either of those, it may be a bug.
We are planning to add support for bring-your-own-JSON, but I think even then we'll require that whatever you bring in have the same canonical root as your FSH project. Supporting truly _external_ profiles (e.g., from another package) without declaring them as a package dependency isn't on our radar, but maybe it should be.
Chris Moesel (Jan 31 2020 at 18:52):
You could try a workaround that might work. What if you flip the order?
//Set and define icd-10-gm slice * code.coding contains icd-10-gm 1..* * code.coding[icd-10-gm].extension contains HauptKreuzCode 0..* * code.coding[icd-10-gm] ^type.profile = "http://fhir.de/StructureDefinition/CodingICD10GM"
Technically that shouldn't make a difference, but I bet it just might. This will make it so that when SUSHI processes the extension, it doesn't yet know you're trying to profile the type. Then it will apply the profile _after_ it's done that. Again, not sure, but it just might work for now.
Noemi Deppenwiese (Feb 03 2020 at 09:29):
Thanks for your help! Now I get a proper 404- the package was not found error. And setting the extension works!
Last updated: Apr 12 2022 at 19:14 UTC