Stream: implementers
Topic: complex extension with nesting
Sylvia Freeman (Aug 14 2018 at 22:13):
I am using Forge 18.2 for HL7 FHIR DSTU2 and was wondering how I can create a complex extension that has an int element with 1:* cardinality that will define a care plan cycle, then another int element nested under this care plan cycle element with 1:* cardinality to represent which day of the cycle. It would be similar to this existing extension (https://simplifier.net/nccnchemotherapyorde/daysofcycle) but would allow the definition of the cycle that the day(s) are on such as this:
- Cycle: 1
- Day: 1
- Day: 2
- Day: 3
- Cycle 2
- Day: 1
Nick George (Aug 15 2018 at 01:15):
I was about to ask a similar question!
Mine is about complex extensions that contain complex extensions, and whether or not they can be defined in a single structure definition. E.g.,
Extension.extension:foo.extension:bar.valueString
Extension.extension:foo.extension:baz.valueBoolean
Lloyd McKenzie (Aug 15 2018 at 01:28):
There are examples of complex extension definitions here: http://build.fhir.org/extensibility-registry.html (just look for 'complex')
Nick George (Aug 15 2018 at 02:17):
none of those examples have nested complex extensions - I can't find any examples like that, but I also can't find anything that seems to forbid it. I see a requirement that Extensions that are not children of other extensions must have absolute urls, which would seem to rule out defining extensions as slices on resources (e.g., Observation.extension:internalextension.valueString) since there would be no top-level StructureDefinition url for that extension to refer to, but I'm not sure about nested complex extensions in an Extension profile
Nick George (Aug 15 2018 at 02:19):
(one could imagine a single StructureDefinition that describes an arbitrarily complex extension)
Lloyd McKenzie (Aug 15 2018 at 02:19):
You're wanting a 3-level extension? That's still fine
Lloyd McKenzie (Aug 15 2018 at 02:19):
(but you're right, we don't have any examples of anything that deep)
Grahame Grieve (Aug 15 2018 at 02:22):
which would seem to rule out defining extensions as slices on resources
I didn't understand that and the following narrative muddied the water further...
Nick George (Aug 15 2018 at 02:30):
haha fair enough - basically, in a complex extension, we see that we can use slices to define fields on extensions of extension (e.g., for Patient ClinicalTrial extension, specify that Extension.extension:nct.url is fixed at NCT, and it is restricted to being a string by specifying Extension.extension:nct.valueString)
Nick George (Aug 15 2018 at 02:32):
so there I was talking about doing that on resources directly. So in a profile on Observation, for example, specifying Observation.extension:foo.url = Foo, and Observation.extension:foo.valueBoolean instead of value[x]
Nick George (Aug 15 2018 at 02:32):
which I believe is not valid, because spec requires extensions that are not children of extensions to have urls to full structure definitions
Nick George (Aug 15 2018 at 02:34):
however I was unclear if it was valid to have complex extensions within complex extensions, which Lloyd says I can
Grahame Grieve (Aug 15 2018 at 02:45):
I think that the answer is: no, you cannot define extensions in line, they need a separate definition
Grahame Grieve (Aug 15 2018 at 02:45):
but you can nest in the definition as far as you want.
Nick George (Aug 15 2018 at 02:45):
cool, that was my interpretation as well. Thanks!
Nick George (Aug 15 2018 at 02:59):
One more complex extension question while I have you: looking at http://hl7.org/fhir/extension-patient-clinicaltrial.json.html , there's nothing I see, either in snapshot or differential, that constrains Extension.extension (unsliced). So is it correct to conclude that, in addition to extensions with the urls described in slices, you can have any other extensions as well on that?
Nick George (Aug 15 2018 at 03:02):
I guess that's what's implied by the slice rules "open" http://hl7.org/fhir/codesystem-resource-slicing-rules.html
Lloyd McKenzie (Aug 15 2018 at 03:02):
Any extensions that aren't defined in the structure definition whose URL you're using will have to be expressed with a full url rather than a local URL, but yes it's possible to have other extensions - whether generic ones like data-absent-reason that can show up anywhere or extensions specifically created to extend your extension.
Nick George (Aug 15 2018 at 03:02):
gotcha. makes sense, thanks!
Sylvia Freeman (Aug 15 2018 at 15:08):
Thank you all!
Last updated: Apr 12 2022 at 19:14 UTC