Stream: shorthand
Topic: Slicing with profile discriminator
Torben M. Hagensen (Aug 20 2020 at 08:28):
Can anyone please help me?
I'm trying to slice a bundle entry using the profile as discriminator, but SUSHI give me an "Value does not match element type" error.
I have provided a simple example of my approach below. What am I missing?
Thanks, Torben
Profile: MyBundle
Parent: Bundle
...
- entry ^slicing.discriminator.type = #profile
- entry ^slicing.discriminator.path = "item.resolve()"
- entry contains myPatient 1..1 and ...
- entry[myPatient ].resource 1..1
- entry[myPatient ].resource only MyPatient
...
Profile: MyPatient
Parent: Patient
...
Instance: TestPatient
InstanceOf: MyPatient
...
Instance: TestBundle
InstanceOf: MyBundle
...
- entry[myPatient ].resource = Reference(TestPatient) // Fails: Cannot fix Reference value: Reference(Patient/TestPatient). Value does not match element type: Patient
...
Torben M. Hagensen (Aug 20 2020 at 09:32):
Torben M. Hagensen said:
- entry ^slicing.discriminator.path = "item.resolve()"
It seems to ignore the path entirely???
Tried "resource" and "adkfkjhk" with no effect at all.
I hope someone can tell me how to do this :sweat:
Torben M. Hagensen (Aug 20 2020 at 12:23):
Torben M. Hagensen said:
- entry[myPatient ].resource = Reference(TestPatient) // Fails: Cannot fix Reference value: Reference(Patient/TestPatient). Value does not match element type: Patient
Stupid me. This line should be:
- entry[myPatient].resource = TestPatient
Actually, what the error said :weary:
Chris Moesel (Aug 20 2020 at 18:15):
Ha. Yeah, it was complaining because you used a reference where a inline instance (not reference) was needed. That said, although the error did say that, it didn't say it as clearly as it could have. I can see how the error could be misunderstood to mean that the reference is of the wrong type (which it's not). I'll file an issue to see if we can provide a clearer error for this type of situation. Maybe something like:
Chris Moesel (Aug 20 2020 at 18:18):
Cannot fix Reference value: Reference(Patient/TestPatient). References are not allowed at this path; use a value directly instead.
Chris Moesel (Aug 20 2020 at 18:23):
Logged: https://github.com/FHIR/sushi/issues/575
Last updated: Apr 12 2022 at 19:14 UTC