hl7-fhirhl7

How to extend a primitive data type in FHIR with an extension?


I'm trying to integrate the FHIR KBV_PR_Base_Observation_Heart_Rate profile. In the coding segment of the FHIR Resource, the profile provides that the display segment is to be provided with an extension for the German-speaking area.

https://fhir.kbv.de/StructureDefinition/KBV_PR_Base_Observation_Heart_Rate

How can I meet the requirements of the profile? I do not understand how I should include the extension at the point?

I tried the following, but the validator didn't seem to like it (which is also logical, since there is no primitive data type any more):

    code: {
        coding: [{
            system: 'http://loinc.org',
            version: '2.69',
            code: '8867-4',
            display: {
                value: 'Heart rate',
                extension: {
                    url: 'https://fhir.kbv.de/StructureDefinition/KBV_EX_Base_Terminology_German',
                    anzeigenameCodeLoinc: {
                        extension: {
                            content: {
                                url: 'content',
                                valueString: 'Herzfrequenz',
                            },
                        },
                    },
                },
            },
        }, {
            system: 'http://snomed.info/sct',
            version: '1.1.3',
            code: '364075005',
            display: {
                value: 'Heart rate (observable entity)',
                extension: {
                    url: 'https://fhir.kbv.de/StructureDefinition/KBV_EX_Base_Terminology_German',
                    anzeigenameCodeLoinc: {
                        extension: {
                            content: {
                                url: 'content',
                                valueString: 'Herzfrequenz',
                            },
                        },
                    },
                },
            },
        }],
        text: 'Heart rate',
   },

The output of the validator:

  Error @ Observation.code.coding[0].display (line 24, col25) : This property must be a simple value, not an object 
  Error @ Observation.code.coding[1].display (line 43, col25) : This property must be a simple value, not an object 

Without the extension:

    code: {
        coding: [{
            system: 'http://loinc.org',
            version: '2.69',
            code: '8867-4',
            display: 'Heart rate'
        }, { 
                ...
        }],
        text: 'Heart rate',
   },

Validator output:

  Error @ Observation.code.coding[0].display (line 28, col8) : Observation.code.coding:loinc.display.extension:anzeigenameCodeLoinc: at least required = 1, but only found 0 
  Error @ Observation.code.coding[1].display (line 34, col8) : Observation.code.coding:codeSnomed.display.extension:anzeigenameCodeSnomed: at least required = 1, but only found 0 

Solution

  • JSON primitives are extended with an _ before the property name https://hl7.org/fhir/json.html#primitive. This is a separate field from the display value itself. So your Observation would look like this

    {
        "code": {
            "coding": [
                {
                    "system": "http://loinc.org",
                    "version": "2.69",
                    "code": "8867-4",
                    "display": "Heart rate",
                    "_display": {
                        "extension": [{
                            "url": "https://fhir.kbv.de/StructureDefinition/KBV_EX_Base_Terminology_German",
                            "extension": [{
                                "url": "content",
                                "valueString": "Herzfrequenz"
                            }]
                        }]
                    }
                },
                {
                    "system": "http://snomed.info/sct",
                    "version": "1.1.3",
                    "code": "364075005",
                    "display": "Heart rate (observable entity)",
                    "_display": {
                        "extension": [{
                            "url": "https://fhir.kbv.de/StructureDefinition/KBV_EX_Base_Terminology_German",
                            "extension": [{
                                "url": "content",
                                "valueString": "Herzfrequenz"
                            }]
                        }]
                    }
                }
            ],
            "text": "Heart rate"
        }
    }