Stream: implementers
Topic: No Extension in Resource
Brian Reinhold (Jan 19 2022 at 10:37):
I never really thought about this before but I noted in the FHIR specification that the Resource has no Extension, yet we use Extensions to resources all the time, not just extensions of resource elements (which we do have). Can anyone tell me why the Resource has no Extension element? I am assuming that if it were in the definition it would be 0..* but I am not 100% sure.
Ankita Srivastava (Jan 19 2022 at 10:47):
Not sure if I understood your query. But, we do have extension in DomainResource
image.png
Brian Reinhold (Jan 19 2022 at 11:37):
@Ankita Srivastava
Okay, so its not at the base but higher up in the hierarchy. So that means it should not be after the resource but if the resource is a DomainResource (and I think they all are) the extension occurs after the logical id and meta data, etc. Not exactly what I expected and not exactly what I have seen. How strict is the order of the elements in an instance? My understanding is that the elements should follow the structure definition exactly (except in JSON because some libraries can't do that).
I want to know where I should place the extension element to a Resource (not an Element) in my Resource.
To add to that, when an Extension contains and extension, where is that extension located? Is it before or after the url element? In the Extension structure definition I see the extension as part of the Element which is before the url element.
As an add, personally I like the extension (in JSON) in the location of the Value[x] . I am writing my own library so I can make the JSON follow any order I want. I would like it to follow the rules.
To make it clearer for the Extension in extension ordering here are the two options
{
"url": "http://hl7.org/fhir/StructureDefinition/upper",
"extension": [
{
"url": "http://hl7.org/fhir/something/StructureDefinition/real-time-collection",
"extension": [
{
"url": "code",
"valueCoding": {
"system": "urn:iso:std:iso:11073:10101",
"code": "150021",
"display": "MDC_PRESS_BLD_NONINV_SYS"
}
},
{
"url": "name",
"valueString": "Observation.component.where(code.coding.where(code='150021')).value"
}
]
},
{
"url": "http://hl7.org/fhir/something/StructureDefinition/real-time-collection",
"extension": [
{
"url": "code",
"valueCoding": {
"system": "urn:iso:std:iso:11073:10101",
"code": "150022",
"display": "MDC_PRESS_BLD_NONINV_DIA"
}
},
{
"url": "name",
"valueString": "Observation.component.where(code.coding.where(code='150022')).value"
}
]
}
]
}
{
"extension": [
{
"extension": [
{
"url": "code",
"valueCoding": {
"system": "urn:iso:std:iso:11073:10101",
"code": "150021",
"display": "MDC_PRESS_BLD_NONINV_SYS"
}
},
{
"url": "name",
"valueString": "Observation.component.where(code.coding.where(code='150021')).value"
}
],
"url": "http://hl7.org/fhir/something/StructureDefinition/real-time-collection"
},
{
"extension": [
{
"url": "code",
"valueCoding": {
"system": "urn:iso:std:iso:11073:10101",
"code": "150022",
"display": "MDC_PRESS_BLD_NONINV_DIA"
}
},
{
"url": "name",
"valueString": "Observation.component.where(code.coding.where(code='150022')).value"
}
],
"url": "http://hl7.org/fhir/something/StructureDefinition/real-time-collection"
}
],
"url": "http://hl7.org/fhir/StructureDefinition/upper"
}
Gino Canessa (Jan 19 2022 at 16:10):
The official ordering is fixed by the specification. However, in JSON elements can be in any order. So either choice is fine in JSON, though not in XML (edit: XML has fixed ordering).
If you want the official ordering, you can look at the StructureDefinition
for Extension (e.g., in one of the downloaded packages, you can find a file such as StructureDefinition-Extension.json
). From there, you can see the snapshot
, which includes all the elements in order:
- Extension (root element definition)
- Element.id
- Element.extension
- Extension.url
- Extension.value[x]
Lloyd McKenzie (Jan 20 2022 at 02:44):
It's not available on Resource because there are a limited set of resources that don't allow extension at the root. Specifically: Binary, Bundle and Parameters.
Last updated: Apr 12 2022 at 19:14 UTC