FHIR Chat · Am I interpreting this slice correctly? · shorthand

Stream: shorthand

Topic: Am I interpreting this slice correctly?


view this post on Zulip Gino Almondo (Feb 19 2021 at 12:02):

Hi!
I am trying to write a fsh to create a profile. I would like to specify that an attribute has cardinality 1..1 and that it has to be of one of some specified datatypes. Also, I set the short description for the attribute and some of its children. So I wrote the following rules

* value[x] only Quantity
* valueQuantity ^short = "{mätetalet i grader Celsius (kod: cel) med 0-1 decimal}"
* value[x] 1..1
* valueQuantity.unit ^short = "{den mätskala som värdet är uppmätt på i de fall då detta inte uttrycks i attributet typ eller värde}"

I feed it to the sushi chef and get out what you see in the attached picture.
Do you think the output achieves what I want? I am in particular confused by the presence of the slice on value[x], since I don't think I explicitly define a slice..

image.png

view this post on Zulip Chris Moesel (Feb 19 2021 at 14:03):

Hi @Gino Almondo! I think your FSH is technically correct, but as you might guess, there is more than one way to do what you're looking to do!

The reason you see a slice is because you used a path with valueQuantity. Whenever there is a choice in FHIR (e.g., value[x]), you refer to specific elements of the choice by using a type slice. When you use a path like valueQuantity in SUSHI, SUSHI knows to create a slice to refer to that type in the choice. That said, SUSHI will do this no matter what -- even if the choice was restricted to a single type already (in which case, it's probably not necessary to slice).

If you've restricted a choice to a single type, then you can always just continue to refer to it using the choice path (value[x]) in order to avoid unnecessary slicing. Since it's been restricted to only Quantity, SUSHI knows that when you say value[x] you are referring to a Quantity. So you could rewrite your FSH like this if you prefer:

* value[x] only Quantity
* value[x] ^short = "{mätetalet i grader Celsius (kod: cel) med 0-1 decimal}"
* value[x] 1..1
* value[x].unit ^short = "{den mätskala som värdet är uppmätt på i de fall då detta inte uttrycks i attributet typ eller värde}"

If you do it that way, you won't see valueQuantity specifically in the published output, but you will see that value[x] is only a Quantity -- and semantically it's basically the same. Some people prefer this approach because it does look cleaner as well.

view this post on Zulip Gino Almondo (Feb 19 2021 at 14:56):

Thank you @Chris Moesel for the clear explanation!
Slicing is still a bit mystical for me tbh :grimacing:

view this post on Zulip Chris Moesel (Feb 19 2021 at 14:57):

Gino Almondo said:

Slicing is still a bit mystical for me tbh :grimacing:

Don't worry, Gino -- you are in good company on that one! ;-)


Last updated: Apr 12 2022 at 19:14 UTC