Stream: shorthand
Topic: Slicing under slices
Pétur Valdimarsson (Feb 19 2020 at 08:16):
Working on a composition profile I ran into some problems trying to slice section under a sliced section. Not sure if this is me not doing the right thing or the slicing logic that needs more love. Here is an abbreviated version of my fsh file:
Profile: PatientSummary Parent: http://hl7.org/fhir/StructureDefinition/Composition Id: patient-summary Title: "Patient summary" Description: "" * section MS * section ^slicing.rules = #closed * section contains alerts 1..1 * section[alerts].section 1..1 MS * section[alerts].section ^slicing.rules = #closed * section[alerts].section ^slicing.discriminator.type = #value * section[alerts].section ^slicing.discriminator.path = "code" * section[alerts].section contains allergies 1..1 MS * section[alerts].section[allergies] 1..1 MS * section[alerts].section[allergies].mode = #snapshot
Which will result in:
error No element found at path section[alerts].section[allergies].mode for PatientSummary, skipping rule File: /.../fsh/Simple.fsh
Any thoughts? Known limitation?
Nick Freiter (Feb 19 2020 at 12:38):
I looked into this a little and it looks like you've found a formerly unknown limitation. It seems the issue is that Composition.section:alerts.section:allergies
is a contentReference, and it is also a slice, and our handling of slicing was messing up our handling of contentReferences. I made a fix and I got the output below, which looks correct to my eye:
StructureDefinition-patient-summary.json
Assuming everything is good with the above, I'll push my fix and it will be in the next version of SUSHI.
Ward Weistra (Feb 19 2020 at 13:47):
Sidenote: You could use Simplifier Snippet for sharing longer FHIR resources: https://simplifier.net/snippet/wardweistra/6 Like Github Gists, but for FHIR :smile:
(I did have to change the FHIR version to 4.0.0 though, 4.0.1 will be recognized soon)
Pétur Valdimarsson (Feb 19 2020 at 14:10):
First of all, thanks for a fast reply and of course for an awesome profiling tool.
Nicely done on the quick localization of the problem & corresponding fix. The profile looks correct, will do a validation when I get to my computer again.
If the branch is available somewhere I'd love to try it out on the larger version of my .fsh file (I have migrated a few profiles from json to fsh and am doing diffs on them to validate the changes)
Nick Freiter (Feb 19 2020 at 14:16):
No problem! Glad you're enjoying the tool.
The branch is fix-contentReference-slicing-bug
: https://github.com/FHIR/sushi/tree/fix-contentReference-slicing-bug.
Pétur Valdimarsson (Feb 19 2020 at 19:26):
Works like a charm. The only unexpected thing I'm seeing is the type BackboneElement part, but I guess that's mainly cosmetic.
{ "id": "Composition.section:medicalHistory.section:Immunization", "path": "Composition.section.section", "sliceName": "Immunization", "type": [ { "code": "BackboneElement" } ] },
Nick Freiter (Feb 20 2020 at 13:10):
It feels a little weird, but the reason SUSHI is putting that in there is because the Composition.section.section
element originally does not have a type, because it is a contentReference. So when we take that contentReference and access child elements of it, it is now a BackboneElement, no longer a contentReference in SUSHI's eyes. So the type has changed, so we include it in the differential. That's the reasoning at least.
Last updated: Apr 12 2022 at 19:14 UTC