FHIR Chat · Slicing by profile · shorthand

Stream: shorthand

Topic: Slicing by profile


view this post on Zulip David Hay (Apr 23 2020 at 22:40):

Does sushi support slicing by profile?

Profile (On Observation):

* partOf ^slicing.discriminator.type = #profile
* partOf ^slicing.discriminator.path = "reference"
* partOf ^slicing.rules = #open
* partOf 1..1
* partOf contains ultrasoundScan 1..1
* partOf[ultrasoundScan] only Reference(Procedure)

Instance of that profile

 * partOf = Reference(aupc-procedureUltraSound)

(where aupc-procedureUltraSound is an instance of Procedure)

Error:

error Element Observation.partOf:ultrasoundScan has minimum cardinality 1 but occurs 0 time(s).

view this post on Zulip Jean Duteau (Apr 23 2020 at 23:05):

don't you have to do:

  • partOf[ultrasoundScan] = Refernece(aupc-procedureUltrasound)

?

view this post on Zulip David Hay (Apr 23 2020 at 23:19):

In the instance? That gives me this error:

error Cannot resolve element from path: partOf[ultrasoundScan]

view this post on Zulip David Hay (Apr 23 2020 at 23:29):

Not sure if its related, but heres another one:

Profile (on Observation)

* code.coding ^slicing.discriminator.type = #value
* code.coding ^slicing.discriminator.path = "system"
* code.coding ^slicing.rules = #open
* code.coding contains sliceCoding 1..1
* code.coding[sliceCoding] from http://aehrc.com/valueset/expecteddateofdeliverytypes (required)

Instance of profile

* code.coding.system = $SNOMED
* code.coding.code = #366322004
* code.coding.display = "Finding of estimated date of delivery (finding)"

Error:

error Element Observation.code.coding:sliceCoding has minimum cardinality 1 but occurs 0 time(s).

Note that the error goes away if "* code.coding contains sliceCoding 1..1" becomes "* code.coding contains sliceCoding 0..1" (perhaps unsurprisingly) :)

view this post on Zulip Nick Freiter (Apr 24 2020 at 11:25):

I think @Jean Duteau does have the right idea, you need to specify for SUSHI which slice you are setting. So in your second example, on the Instance, instead of doing:

* code.coding.system = $SNOMED
* code.coding.code = #366322004
* code.coding.display = "Finding of estimated date of delivery (finding)"

you would want to do

* code.coding[sliceCoding].system = $SNOMED
* code.coding[sliceCoding].code = #366322004
* code.coding[sliceCoding].display = "Finding of estimated date of delivery (finding)"

You will note that the output is actually the same for both. But SUSHI will emit an error in the first case, because to SUSHI it looks like you aren't setting the sliceCoding slice, but that slice is 1..1. In the first situation, you would want to do partOf[ultrasoundScan]. I'm not sure why SUSHI couldn't find that path, I tried a similar setup, with

* partOf ^slicing.discriminator.type = #profile
* partOf ^slicing.discriminator.path = "reference"
* partOf ^slicing.rules = #open
* partOf 1..1
* partOf contains ultrasoundScan 1..1
* partOf[ultrasoundScan] only Reference(Procedure)

on a profile of Observation, and

* partOf[ultrasoundScan] = Reference(aupc-procedureUltraSound)

on an instance of that profile, and SUSHI was able to find that path. It doesn't look like you are trying to do anything funky there, so I'm not sure why SUSHI would fail to find the path.

view this post on Zulip Nick Freiter (Apr 24 2020 at 11:29):

One more thing to note is that instead of writing three lines of FSH to set the system, code, and display, you can do that in one line, so this:

* code.coding[sliceCoding].system = $SNOMED
* code.coding[sliceCoding].code = #366322004
* code.coding[sliceCoding].display = "Finding of estimated date of delivery (finding)"

can be accomplished by doing this:

* code.coding[sliceCoding] = $SNOMED#366322004  "Finding of estimated date of delivery (finding)"

Of course that's just a stylistic preference, if you prefer having a one to one relationship between lines and setting values, that's totally understandable.

view this post on Zulip Chris Moesel (Apr 24 2020 at 13:16):

All that said, it would be kind of cool if SUSHI was sophisticated enough to identify slices in an array when the author hasn't specifically called them out. E.g., given @David Hay's second example above, a more advanced SUSHI could theoretically identify the following element as being in the sliceCoding slice (assuming that SNOMED 366322004 is in the VS bound to the slice):

* code.coding = $SNOMED#366322004  "Finding of estimated date of delivery (finding)"

But... supporting automatic slice membership in SUSHI would be difficult given the many different variations there may be on slices and given the requirement of resolving external value sets and/or profiles in some cases. Maybe we'll support it some day, but probably not soon. Until then, you need to explicitly identify the slice when setting it in SUSHI (as @Nick Freiter demonstrated above).

view this post on Zulip David Hay (Apr 24 2020 at 21:11):

Thanks guys - that all worked. Key to this is properly understanding the sliceName - making progress!

Incidentally, I did notice (I think) an error.

I have a profile on Observation (called AUPrimaryCareObservation-GestationOnScan) that requires an element to be a specific profiled type:

  • partOf[ultrasoundScan] = Reference(AUPrimaryCareProcedure-UltrasoundScanObstetric)

where AUPrimaryCareProcedure-UltrasoundScanObstetric is a profile on Procedure

However, when I create an instance of AUPrimaryCareObservation-GestationOnScan, and set partOf[ultrasoundScan] to any Instance, sushi compiles just fine. Shouldn't it generate an error ?

view this post on Zulip Nick Freiter (Apr 27 2020 at 12:41):

That's an interesting point. I think part of the reason we aren't checking this is because we don't want to disallow you from making an example where you set a Reference to an Instance that doesn't exist. Because maybe you want to make an example of a Profile, which has a Reference to Patient or something, but you don't want to actually have to make your own example for Patient.

That being said, I think in the situations where SUSHI does resolve the Reference to a defined Instance, you're right, we are able to, and should, check that that resolved Instance has a matching type. I'll add an issue for this on GitHub.

view this post on Zulip Nick Freiter (Apr 27 2020 at 12:47):

Added: https://github.com/FHIR/sushi/issues/395.

view this post on Zulip David Hay (Apr 27 2020 at 19:20):

Ta. Perhaps a warning if there is no resolved instance?

view this post on Zulip Chris Moesel (May 04 2020 at 17:41):

@David Hay said:

However, when I create an instance of AUPrimaryCareObservation-GestationOnScan, and set partOf[ultrasoundScan] to any Instance, sushi compiles just fine. Shouldn't it generate an error ?

Just to be clear, even though the profile says it should be instances of AUPrimaryCareProcedure-UltrasoundScanObstetric, SUSHI should allow an example to refer to any Procedure instance -- this is because profile conformance is not exclusive (one instance can conform to multiple profiles) and true conformance validation is outside of the scope of SUSHI (or at least outside of the current scope of SUSHI).

view this post on Zulip David Hay (May 04 2020 at 18:08):

Fair enough - understand that it's not sushi's role to validate this.

I guess full validation would require the referenced resource to be validated against the profile, which is not a simple thing! Though - when you say non exclusive, although the referenced instance could conform to multiple profiles, it must at least be conformant to AUPrimaryCareProcedure-UltrasoundScanObstetric in this case though...

view this post on Zulip Chris Moesel (May 04 2020 at 18:46):

Though - when you say non exclusive, although the referenced instance could conform to multiple profiles, it must at least be conformant to AUPrimaryCareProcedure-UltrasoundScanObstetric in this case though...

What I was trying to get at is that even if it points at an instance defined in SUSHI, we can't assume the the thing referred to by InstanceOf: is the only thing it conforms to. So even though the profile calls for an instance of AUPrimaryCareProcedure-UltrasoundScanObstetric, if you set it to an an instance that declares InstanceOf: SomeOtherProcedureProfile, SUSHI can't say for sure that it is wrong; it would need full validation capabilities to be able to definitively make that determination.

view this post on Zulip David Hay (May 04 2020 at 19:22):

Oh I agree - not something to expect sushi to be going at the moment...


Last updated: Apr 12 2022 at 19:14 UTC