FHIR / GoFSH

GoFSH is a FHIR Shorthand (FSH) decompiler, able to convert formal FHIR definitions from JSON/XML to FSH.
Apache License 2.0
35 stars 6 forks source link

GoFSH handles inline CodeSystems poorly #252

Open cmoesel opened 9 months ago

cmoesel commented 9 months ago

Given:

{
  "resourceType": "ValueSet",
  "id": "example-valueset",
  "contained": [
    {
      "resourceType": "CodeSystem",
      "id": "example-codesystem",
      "url": "http://example.org/codesystem",
      "version": "1.0.0",
      "content": "complete",
      "status": "active",
      "concept": [
        {
          "code": "example-code-1",
          "display": "Example Code 1"
        },
        {
          "code": "example-code-2",
          "display": "Example Code 2"
        },
        {
          "code": "example-code-3",
          "display": "Example Code 3"
        }
      ]
    }
  ],
  "url": "http://example.org/valueset",
  "version": "1.0.0",
  "status": "active",
  "compose": {
    "include": [
      {
        "system": "#example-codesystem"
      }
    ]
  }
}

GoFSH produces:

ValueSet: ExampleValueset
Id: example-valueset
* ^contained.resourceType = "CodeSystem"
* ^contained.id = "example-codesystem"
* ^contained.url = "http://example.org/codesystem"
* ^contained.version = "1.0.0"
* ^contained.content = #complete
* ^contained.concept[0] = #example-code-1 "Example Code 1"
* ^contained.concept[+] = #example-code-2 "Example Code 2"
* ^contained.concept[+] = #example-code-3 "Example Code 3"
* ^url = "http://example.org/valueset"
* ^version = "1.0.0"
* ^status = #active
* include codes from system #example-codesystem

There are multiple issues with this:

  1. Instead of defining the whole CodeSystem inline (which SUSHI currently errors on, see SUSHI#1404), it should probably create a separate Instance w/ Usage: #inline.
  2. Since contained.concept is not a code/Coding/CodeableConcept, I don't think it's valid to assign a FSH code (and SUSHI rightfully complains). If using Instance/caret syntax for contained.concept, the code and display need to be assigned separately.
  3. SUSHI doesn't handle include codes from system #example-codesystem well (due to the #). SUSHI probably should handle this, but we need to track SUSHI#1403 and only export the # if SUSHI supports it. It may be better practice to just export the id (although SUSHI also doesn't handle this correctly per SUSHI#1402).