Potential limits to Complex Extensions

Hi All,
Is there a limit to the number of “levels” that a complex extension can have? For example the extensibility page has an example of an extension that has been extended. Something similar to this:

{
“resourceType”: “Patient”,
“extension”: [
{
“url”: “http://hl7.org/fhir/StructureDefinition/patient-citizenship”,
“extension”: [
{
“url”: “startDate”,
“valueDate”: “YYYY-MM-DD”
}
]
}
]
}

Are there any suggestions or limits for extending even further? Something like this with three “levels” of extensions:

{
“resourceType”: “Patient”,
“extension”: [
{
“url”: “http://hl7.org/fhir/StructureDefinition/patient-citizenship”,
“extension”: [
{
“url”: “period”,
“extension”: [
{
“url”: “startDate”,
“valueDate”: “YYYY-MM-DD”
},
{
“url”: “endDate”,
“valueDate”: “YYYY-MM-DD”
}
]
}
]
}
]
}

This example is not realistic, but it hopefully gets my point across. Thanks!

Nope. If you want to define an extension that’s 50 levels deep, you’d still be compliant. (But don’t count on an enthusiastic reception from any partners you ask to implement it… :>)

2 Likes

Just to add onto @lloyd s comment, its good to perhaps ask for a second opinion once your extension starts to look complicated, chances are there is a simpler way to present the same information.

1 Like

@lloyd @blessed_tabvirwa1 Sounds good, thank you both for the input!