FHIR Chat · value[x] type based slicing · shorthand

Stream: shorthand

Topic: value[x] type based slicing


view this post on Zulip Patrick Werner (Oct 05 2021 at 07:50):

i can't figure out how to do type based slicing on a value[x] element: https://fshschool.org/FSHOnline/#/share/3ixAYHH

view this post on Zulip Patrick Werner (Oct 05 2021 at 07:50):

Profile: Test
Parent: MedicationRequest
* medication[x] ^slicing.discriminator.type = #type
* medication[x] ^slicing.discriminator.path = "$this"
* medication[x] contains test 0..1 MS
* medication[x][test] only Reference

view this post on Zulip Patrick Werner (Oct 05 2021 at 07:50):

results in an illegal element: "id": "MedicationRequest.test"

view this post on Zulip Patrick Werner (Oct 05 2021 at 07:52):

i started with: * medication[test] only Referencewhich leads to: error No element found at path medication[test] for OnlyRule in Test, skipping rule

view this post on Zulip Chris Moesel (Oct 05 2021 at 11:54):

What are you trying to accomplish? If you just use a path like medicationReference or medicationCodeableConcept, the type slicing will happen behind the scenes for you. You might not see it in the differential (due to choice type renaming), but after you run it through the IG Publisher, you'll see that type slicing is, in fact, applied in the snapshot.

All that said, in theory, I would expect the above to work -- but it's possible we haven't run into someone trying to manually slice a [x] path, since it happens automatically for you. So it looks like there is probably a bug in SUSHI when you do it manually.

view this post on Zulip Chris Moesel (Oct 05 2021 at 11:58):

SUSHI#927

view this post on Zulip Patrick Werner (Oct 05 2021 at 13:56):

@Chris Moesel thanks will try the implicit slicing approach (tried it before, but failed. Will try harder and update this thread)

view this post on Zulip Michaela Ziegler (Oct 13 2021 at 11:47):

May I have an related problem? Or I would need some help please.

The goal of my Observation profile is to say, you can have a value, either Quantity or CodeableConcept (that worked):
http://build.fhir.org/ig/ahdis/ch-crl/branches/master/StructureDefinition-ch-crl-observation-msuffixofpt.html
https://fshschool.org/FSHOnline/#/share/3iZYJZg

Additionally I tried to specify this (that worked, but just in the profile):
If you have a valueQuantity, you have to have one valueQuantity.value.
If you have a valueCodeableConcept, you have to have one valueCodeableConcept.coding.
https://fshschool.org/FSHOnline/#/share/3mNLnjQ

But then the validation of the example doesn't work anymore:
https://fshschool.org/FSHOnline/#/share/3FG4zZt

Sushi: error Element Observation.value[x]:valueQuantity.value has minimum cardinality 1 but occurs 0 time(s). (00:14.0880)
Sushi: File: C:\Users\micha\Documents\GitHub\ch-crl\input\fsh\content-until-v0.2.1\instances\m-SuffixOfpT-unspecified.fsh (00:14.0881)
Sushi: Line: 1 - 10                                                              (00:14.0882)
Sushi: error Element Observation.value[x]:valueCodeableConcept.coding has minimum cardinality 1 but occurs 0 time(s). (00:14.0900)
Sushi: File: C:\Users\micha\Documents\GitHub\ch-crl\input\fsh\content-until-v0.2.1\instances\m-SuffixOfpT.fsh (00:14.0902)
Sushi: Line: 1 - 10                                                              (00:14.0903)

view this post on Zulip Chris Moesel (Oct 13 2021 at 12:20):

Hi @Michaela Ziegler. This is a bug in SUSHI 2.0.1. If you upgrade SUSHI to 2.1.1, you'll find that the errors go away. We will be updating FSH Online to use SUSHI 2.1.1 very soon!

A few other notes about your FSH:

  • If you want to say that value[x] can only be a Quantity or CodeableConcept, then you can use this line to say that * value[x] only Quantity or CodeableConcept
  • You don't have to say valueQuantity only Quantity -- if you reference a valueQuantity slice, SUSHI will automatically add the appropriate type constraint for you (since, by definition, valueQuantity is only a Quantity). The same applies for valueCodeableConcept (or any other specific type slice).
  • You also don't have to explicitly specify the slicings for type slices. As soon as you reference a type slice like valueQuantity, SUSHI will automatically apply the standard type-slicing definition for you. Note that SUSHI applies #open rules, however, so if you really want it #closed you would have to specify that. But... if you say * value[x] only Quantity or CodeableConcept then I don't think you need #closed rules anyway since you already said why types are allowed.

view this post on Zulip Michaela Ziegler (Oct 13 2021 at 12:33):

@Chris Moesel
Thanks a lot, it works!
And thanks for your helpful notes, always something to learn! (It is from an IG where I used goFSH.)

view this post on Zulip Roeland Luykx (Oct 13 2021 at 12:37):

@Chris Moesel
The version 2.1.1 solves also other problems with some SDC extensions! i.e. valueExpression.language has minimum cardinality 1 but occurs 0

view this post on Zulip Chris Moesel (Oct 13 2021 at 12:51):

@Michaela Ziegler - Oh... GoFSH did that? OK. That's good to know. Sounds like something we should tweak in GoFSH then!

view this post on Zulip Janaka Peiris (Oct 14 2021 at 15:43):

@Chris Moesel A suggestion related to "No element found at path [element] for [X]" error message format:

It would have been great if the [X] has a meaningful description. I see CardRule, OnlyRule and CaretValue kind of shortened form words used (guessing can sometimes be risky if we got a wrong intepretation)

error No element found at path valueRatio for CardRule in HnDomainVitalSignsObservationOxygenSaturation, skipping rule
  File: D:\_dev\Git_Repo\DIPS\FhirObservation.R4\IG\input\fsh\profiles\HnDomainVitalSignsObservationOxygenSaturation.fsh
  Line: 78
error No element found at path valueRatio for OnlyRule in HnDomainVitalSignsObservationOxygenSaturation, skipping rule
  File: D:\_dev\Git_Repo\DIPS\FhirObservation.R4\IG\input\fsh\profiles\HnDomainVitalSignsObservationOxygenSaturation.fsh
  Line: 79
error No element found at path valueRatio for CaretValueRule in HnDomainVitalSignsObservationOxygenSaturation, skipping rule
  File: D:\_dev\Git_Repo\DIPS\FhirObservation.R4\IG\input\fsh\profiles\HnDomainVitalSignsObservationOxygenSaturation.fsh
  Line: 80

view this post on Zulip Chris Moesel (Oct 18 2021 at 21:57):

@Patrick Werner -- we're taking a deeper look at the issue you reported above in order to fix it, but... @Nick Freiter brought up a good point: Is it even valid to use an arbitrary slice name on a type slice for a 0..1 polymorphic element? The spec for ElementDefinition.id says:

For type choice elements, the id reflects the type slice. e.g. For path = Patient.deceasedBoolean, the id is Patient.deceased[x]:deceasedBoolean

Does this imply that for your example of medication[x], the slice for the Reference type must have slice name medicationReference (and thus, slice name test would be invalid anyway)?

view this post on Zulip Patrick Werner (Oct 22 2021 at 10:07):

i think you are right. value[x] slicing is a special form of slicing, and the slice name for a type specific slice is fix. So the slice must be named medicationReference and can't be named test

view this post on Zulip Patrick Werner (Oct 22 2021 at 10:07):

it would be nice to throw a meaningful error in this case (and maybe point to implicite type slicing, as it is easier/ more elegant)


Last updated: Apr 12 2022 at 19:14 UTC