Search code examples
hl7-fhir

What is `_code` in `profile-types.json`


for example snapshot/element[2] contains

"type": [
  {
    "fhir_comments": [
      "Note: primitive values do not have an assigned type\r\n      e.g. this is compiler magic\r\n      XML and JSON types provided by extension"
    ],
    "_code": {
      "extension": [
        {
          "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-json-type",
          "valueString": "string"
        },
        {
          "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-xml-type",
          "valueString": "xs:string"
        }
      ]
    }
  }
]

As far as I know there is no property _code defined for StructureDefinition

What's the correct way to treat and interpret this property?


Solution

  • This is the "code" element. _code is used to convey complex children on primitive data types (i.e. the id element or extensions or modifier extensions). This is defined in the specification here. The representation is done this way so you can reference primitive elements by just saying something like Patient.birthDate or Patient.gender instead of Patient.birthDate.value or Patient.gender.value. In order to allow that, we needed to provide a convention for accessing extensions and other elements which are rare, but can still be present on 'primitive' data types.