FHIR Chat · slicing and pattern · shorthand

Stream: shorthand

Topic: slicing and pattern


view this post on Zulip Mika Tuomainen (Aug 23 2020 at 19:19):

Hi,

I have tried to do slicing with shorthand. Here is the content of the .fsh file which I used for testing slicing:

Profile:        FSHTestObsDeeperSlicev1
Parent:         Observation
Id:             fhstestobsdeeperslicev1
Title:          "FSHTestObsDeeperSlicev1"
Description:    "Test observation version 1, slicing deeper structure Observation.code.coding, done with Shorthand"
* ^status = #draft

* code.coding ^slicing.discriminator.type = #value
* code.coding ^slicing.discriminator.path = "code"
* code.coding ^slicing.rules = #open

* code.coding contains generalCode 1..1 and oralCode 0..1
* code.coding[generalCode].code = #8310-5
* code.coding[oralCode].code = #8331-1

I am trying to make generalCode and oralCode as fixedCode(s). But when I compile this with Sushi, I got StructureDefinition (SD) which shows that they are as patternCode(s). Am I doing something wrong in FSH grammar? The SD looks like this with those slices:

"differential": {
    "element": [
      {
        "id": "Observation.code.coding",
        "path": "Observation.code.coding",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "code"
            }
          ],
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "Observation.code.coding:generalCode",
        "path": "Observation.code.coding",
        "sliceName": "generalCode",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Observation.code.coding:generalCode.code",
        "path": "Observation.code.coding.code",
        "min": 1,
        "patternCode": "8310-5"
      },
      {
        "id": "Observation.code.coding:oralCode",
        "path": "Observation.code.coding",
        "sliceName": "oralCode",
        "min": 0,
        "max": "1"
      },
      {
        "id": "Observation.code.coding:oralCode.code",
        "path": "Observation.code.coding.code",
        "min": 1,
        "patternCode": "8331-1"
      }
    ]
  }

view this post on Zulip Jean Duteau (Aug 23 2020 at 19:59):

Yes, you need to add the "(exactly)" after your code.coding... = ... lines. FSH assumes you want patterns by default so you have to tell it that you want an exact match.

view this post on Zulip Jean Duteau (Aug 23 2020 at 20:00):

having said that, i think you actually want patternCode as that says that one of the codings must match this pattern but that others can be translations of that. Which is generally what we as IG authors want.

view this post on Zulip Mika Tuomainen (Aug 24 2020 at 06:48):

Thank you @Jean Duteau ! "(exactly)" makes the trick I wanted.

My example is just a testing case. I was trying to produce something like this: https://www.hl7.org/fhir/bodyheight.profile.json.html, there "Observation.code.coding:BodyHeightCode.code" is fixedCode.


Last updated: Apr 12 2022 at 19:14 UTC