FHIR Chat · Slicing with discriminator.type = #value · shorthand

Stream: shorthand

Topic: Slicing with discriminator.type = #value


view this post on Zulip Martin Höcker (Feb 19 2021 at 15:20):

I wrote a profile that contains a discriminator that is based on "value" (example online):

Profile: SlicedPatient
Parent: Patient
* name ^slicing.discriminator.path = "name"
* name ^slicing.discriminator.type = #value
* name contains officialName 1..1
* name[officialName].use = #official
* name[officialName].given 1..1

The output contains

...
      {
        "id": "Patient.name:officialName.use",
        "path": "Patient.name.use",
        "patternCode": "official"
      },
...

Is "patternCode" correct here, or should the output rather say "fixedCode"?

view this post on Zulip ryan moehrke (Feb 19 2021 at 15:29):

if you want fixed[x] use the (exactly) keyword after the fsh where you set the value
otherwise it assumes pattern[x]

view this post on Zulip Martin Höcker (Feb 19 2021 at 16:41):

@ryan moehrke: Thank you! With your suggestion

* name[officialName].use = #official (exactly)

I now get a fixedCode in the output.

Reading about (exactly) in the FSH spec. I understand that its usage is discouraged. Just for my understanding and out of curiosity: Would it be better to switch to discriminator.type = #pattern instead, or are both discriminators equivalent in this case (since the datatype is code)? I'm still a beginner when it comes to slicing...

view this post on Zulip ryan moehrke (Feb 19 2021 at 16:48):

I believe that the distinction (and why it is discouraged) is that fixed[x] defines that no other information can be possible
ex. valueCoding = http://system.name#code123 (exactly) can not have a display value
while pattern[x] allows for other information, just specifies that the pattern has to exist.

view this post on Zulip Chris Moesel (Feb 19 2021 at 17:32):

That's correct. We default to pattern[x] because fixed[x] can be overly prescriptive (for the reason @ryan moehrke provided above). When applying it to complex types (like CodeableConcept and Coding), it is a particularly important distinction. When applying it to primitives (like code), however, it's a little less crucial. If you use fixed[x] on a primitive it basically means that no one could put an id or extension on that primitive, but that's about it. So in your situation (code), I don't think there is a wrong answer.


Last updated: Apr 12 2022 at 19:14 UTC