FHIR Chat · Choices containing Extensions · implementers

Stream: implementers

Topic: Choices containing Extensions


view this post on Zulip Chris Moesel (Jan 26 2017 at 18:22):

I'm creating an extension for which it's value is a choice of other extensions. Looking at the "Extensibility" page in documentation, valueExtension is not listed under possible types for value[x] -- but in the structure for Extension, it shows * for the value[x] type. So... am I allowed to use valueExtension in Extension's value[x] to indicate an extension as an option within the choice? If allowed, would I set the type's code to Extension and profile to the extension's URI?

view this post on Zulip Chris Moesel (Jan 26 2017 at 18:53):

I found the relevant documentation on open types, and it seems that despite the *, there is still a certain set of types allowed, and Extension is not one of them. So does that mean a choice of extensions needs to be implemented using constraints to ensure only one can be chosen?

view this post on Zulip Bryn Rhodes (Jan 26 2017 at 19:03):

The inconsistency should be clarified, that's probably a good tracker.

view this post on Zulip Bryn Rhodes (Jan 26 2017 at 19:03):

As far as having an extension that is a choice of extensions, yeah, that's probably just multiple extensions with an invariant.

view this post on Zulip Bryn Rhodes (Jan 26 2017 at 19:04):

Where you would put that invariant is a good question.

view this post on Zulip Bryn Rhodes (Jan 26 2017 at 19:05):

Seems like you could define an extension, and then specify that each of the possible extensions can be applied as an extension to that extension, that would then give you a place to define the invariant.

view this post on Zulip Chris Moesel (Jan 26 2017 at 22:25):

Yeah, that's what I was thinking. I wasn't *liking* it, but I was *thinking* it. Thanks for the confirmation.

view this post on Zulip Bryn Rhodes (Jan 26 2017 at 22:47):

So, couldn't you just define a complex extension? What's the benefit of having the sub-elements defined by extensions as opposed to just defined as elements within a complex extension?

view this post on Zulip Chris Moesel (Jan 26 2017 at 22:53):

Is this the thread you meant to reply to? It almost sounds like you're talking about the other thread I just started. But I'll attempt to answer for both threads.

(1 - This thread) -- It would be nicer to be able to use the value[x] for choices because it's much simpler and more obvious than invariants.
(2 - Other thread) -- I don't want to fully define the sub-extensions inline because that hinders their re-usability. Now there isn't a way for a system to know for sure that a sub-extension in A represents the same thing as another sub-extension in B. And now I have to define the same sub-extension twice as well.

view this post on Zulip Lloyd McKenzie (Jan 27 2017 at 23:16):

You don't even need to have an invariant - just slice on Extension.extension

view this post on Zulip Lloyd McKenzie (Jan 27 2017 at 23:17):

Or, if you wish, just set Extension.extension to have a value set listing permitted URLs.

view this post on Zulip Chris Moesel (Jan 30 2017 at 13:04):

Hi Lloyd. I was thinking I'd need in invariant because I'd have to set the cardinality low to 0 on all slices of the extension (since a choice implies that any of them might be 0 card) -- but I'd need the invariant to force that one of them must exist in the data.

I hadn't thought about using a value set to list permitted extension URLs. Now that is an interesting idea! Thanks for your help.


Last updated: Apr 12 2022 at 19:14 UTC