FHIR Chat · Help with an extension · shorthand

Stream: shorthand

Topic: Help with an extension


view this post on Zulip Richard Kavanagh (May 27 2020 at 23:18):

I'm trying to reverse engineer an existing Extension into FSH.

The differential of the existing extension (created via Forge is
image.png

The FSH so far is very simple (removed all the metadata lines for simplicity)

* value[x] only Reference

Problems
(1) How do I set the target profile (Line 69) - I tried * value[x] only Reference("https://fhir.nhs.uk/R4/StructureDefinition/UKCore-Location") but taht created errors

(2) How do I set the "short" , "definition" and cardinality for the extension element?

(3) Any ideas on how I achieve lines 74-85?

I took a look examples I could see on GitHub but they seemed to have much simpler definitions.

Thanks.

view this post on Zulip Igor Sirkovich (May 27 2020 at 23:21):

@Richard Kavanagh , have you looked at PDEX Plan-Net extensions? There are plenty of complex ones: https://github.com/HL7/davinci-pdex-plan-net/blob/master/fsh/Extensions.fsh

view this post on Zulip Igor Sirkovich (May 27 2020 at 23:24):

Also, there was a hint recently that if you wish to set "short" of a profile or extension you can use ". ^short", e.g.

  • . ^short = "My Profile's Short Description"

view this post on Zulip Chris Moesel (May 28 2020 at 00:35):

Great tips, @Igor Sirkovich! Here are a few more:

(1) There are a few ways to create a reference to a profile... if the thing you're referring to is defined in the same IG as your extension, you can refer to it by name (e.g., Reference(UKCoreLocation)). If it's external to your IG, it needs to be from FHIR core or from one of your declared dependencies. Assuming that's the case, you should be able to refer to it by URL without quotation marks (e.g., Reference(https://fhir.nhs.uk/R4/StructureDefinition/UKCore-Location)) or define an alias to the URL and refer to it by that (e.g., Reference($UKCoreLocation)).

(2) As Igor suggested, you can use the . path to refer to the root element. So you'd be looking at something like:

* . 1..1
* . ^short = "Main location"
* . ^definition = "The main location of the organisation."

(3) To get it to come out exactly like the JSON you posted, I think you should be able to do:

* value[x].identifier.assigner only Reference(https://fhir.nhs.uk/R4/StructureDefinition/UKCore-Organization)

You might need the latest SUSHI (0.12.7 or 0.13.0-beta.2) for that one to work though. Another approach that I think is also valid (but would result in slightly different JSON) is:

* valueReference.identifier.assigner only Reference(https://fhir.nhs.uk/R4/StructureDefinition/UKCore-Organization)

BTW -- I can't help but notice that this extension cannot decide if organization has an s or a z.

view this post on Zulip Richard Kavanagh (May 28 2020 at 07:50):

@Chris Moesel re the spelling issues :sad: if only they were the only issues in the profiles. Attention to detail is not a forte of the developers of the profiles.

view this post on Zulip Richard Kavanagh (May 28 2020 at 07:51):

@Igor Sirkovich thanks for the help and the links to the davinci ig - very useful

view this post on Zulip Richard Kavanagh (May 28 2020 at 07:56):

Based on the help received I think I am close enough. There are a few differences within the resulting StructureDefinition as the output is not sparse like that produced from Forge. I'm not 100% sure about the following part as it appears that SUSHI is making assumptions as it was never declared.

      {
        "id": "Extension.extension",
        "path": "Extension.extension",
        "max": "0"
      },

For info the final FSH used was

Extension: ExtensionUKCoreMainLocation
Id: Extension-UKCore-MainLocation
Title: "Extension UK Core Main Location"
Description: "An extension to support a reference to the main location for an organisation."
* ^publisher = "NHS Digital"
* ^copyright = "Copyright © 2019 NHS Digital"
* ^date =  "2019-12-06T00:00:00+00:00"
* ^status = #draft
* ^contact[0].name = "Interoperability Team"
* ^contact[0].telecom.system = #email
* ^contact[0].telecom.value = "interoperabilityteam@nhs.net"
* ^contact[0].telecom.use = #work
* ^context.expression = #Organization

* . 0..1
* . ^short = "Main location"
* . ^definition = "The main location of the organisation."

* value[x] only Reference(https://fhir.nhs.uk/R4/StructureDefinition/UKCore-Organization)
* value[x] 1..1
* value[x] ^short = "Main location"
* value[x] ^definition = "Reference to the main location for an organization."
* value[x].identifier.assigner only Reference(https://fhir.nhs.uk/R4/StructureDefinition/UKCore-Organization)

This yielded the following which is close enough for me :-)

 "differential": {
    "element": [
      {
        "id": "Extension",
        "path": "Extension",
        "short": "Main location",
        "definition": "The main location of the organisation.",
        "max": "1"
      },
      {
        "id": "Extension.extension",
        "path": "Extension.extension",
        "max": "0"
      },
      {
        "id": "Extension.url",
        "path": "Extension.url",
        "fixedUri": "https://fhir.nhs.uk/R4/StructureDefinition/Extension-UKCore-MainLocation"
      },
      {
        "id": "Extension.value[x]",
        "path": "Extension.value[x]",
        "short": "Main location",
        "definition": "Reference to the main location for an organization.",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.uk/R4/StructureDefinition/UKCore-Organization"
            ]
          }
        ]
      },
      {
        "id": "Extension.value[x].identifier",
        "path": "Extension.value[x].identifier"
      },
      {
        "id": "Extension.value[x].identifier.assigner",
        "path": "Extension.value[x].identifier.assigner",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.uk/R4/StructureDefinition/UKCore-Organization"
            ]
          }
        ]
      }
    ]
  }

view this post on Zulip Richard Kavanagh (May 28 2020 at 07:58):

@Chris Moesel Thanks for your help - this is to be used for some examples for a talk with HL7 UK next month. I think (hope) there will be a lot of interest over here with suppliers who need to create profiles and/or terminology products

view this post on Zulip Nick Freiter (May 28 2020 at 11:50):

The reason SUSHI automatically does:

      {
        "id": "Extension.extension",
        "path": "Extension.extension",
        "max": "0"
      },

is because this is implied by value[x] being 1..1. Since an extension cannot have both a value and extensions, when you make the value[x] 1..1, this implicitly means that extension cannot have extension on it, so SUSHI makes it 0..0, so that this is explicit.


Last updated: Apr 12 2022 at 19:14 UTC