FHIR Chat · Choice of BackboneElement · implementers

Stream: implementers

Topic: Choice of BackboneElement


view this post on Zulip Chris Moesel (Oct 20 2016 at 18:30):

I am writing StructureDefinitions for logical models. Is there a way to define a choice in which each individual option is a BackBone element?

Looking through some of the resources, I haven't found any examples. Most things that have a choice (e.g., value[x]) list out the options as an array in the "type" field -- which works if the choice option is a named resource, datatype, or primitive -- but doesn't work so well if it is structure defined inline using BackboneElement.

Is there a way to do this using foo[x]? If not, is there another way? Could I define the individual elements (fooBar, fooBaz, fooBat, etc) and then use invariants to specify it's choice? Or is there some fancy way to do it with slicing?

view this post on Zulip Grahame Grieve (Oct 20 2016 at 19:34):

I'm not exactly sure what you're trying to do. We don't use BackboneElement in logical models because we don't think modifierExtensions make sense. Perhaps you disagree with that?

view this post on Zulip Grahame Grieve (Oct 20 2016 at 19:34):

but how are you writing the logical models?

view this post on Zulip Chris Moesel (Oct 20 2016 at 19:57):

We use BackboneElement because we want an inline nested structure (an example in FHIR resources would be that Patient.contact is a BackboneElement). Is there something else I should use instead?

view this post on Zulip Chris Moesel (Oct 20 2016 at 19:59):

However inline nested structures get represented, we want to be able to say that there is a choice between some of them (in other words, you must use one or the other, but not both).

view this post on Zulip Grahame Grieve (Oct 20 2016 at 20:42):

well, you can use Element for an inline nested structure. You don't need to use BackboneElement

view this post on Zulip Grahame Grieve (Oct 20 2016 at 20:45):

but I see that I was missing the point.

view this post on Zulip Grahame Grieve (Oct 20 2016 at 20:46):

the only way to do choice between inline types (whether using BackboneElement or Element) is to use an invariant

view this post on Zulip Chris Moesel (Oct 21 2016 at 20:30):

Thanks, Grahame. Yes, actually Element would be more appropriate. I think that because I always saw resources using BackboneElement, I didn't think to use the more appropriate plain Element. I'll switch over to that. And thanks for confirming that invariant is the only way to allow choice between inline types.

view this post on Zulip Grahame Grieve (Oct 21 2016 at 20:56):

np


Last updated: Apr 12 2022 at 19:14 UTC