Stream: implementers
Topic: Choice/alternatives example over the same type
Diego Bosca (Jul 16 2019 at 11:35):
Does anybody know of a (correct) example of a choice of alternatives over the same type. In particular I'm looking for a choice over Observation.value[x], but any example would do.
I can provide some (probably wrong) examples so we can discuss over them if no correct example exists yet.
Lloyd McKenzie (Jul 16 2019 at 14:12):
I'm not sure I'm following what you're asking for. Can you explain further?
Diego Bosca (Jul 16 2019 at 14:43):
Sure. The idea is having two (or more) allowed values in a attribute with 0..1 occurrences. This is the use case of having for example two different Quantities with different units and allowed ranges (e.g. one could be [0..300] kg and the other [0..10000] g). In theory this should be no problem as they can be distinguishable from code.coding.code attribute, using that as the slicing criteria.
This could also be applied to other complex data types such as CodeableConcept (arguably the declaration of bindings implicitly declares alternatives) or SampledData with different parameters.
Eric Haas (Jul 16 2019 at 15:27):
sounds like choice of units and not multiple choice types - in your first example they are both valueQuantity? so bind the Quantity.code to possible choice of units. example here: http://build.fhir.org/bodytemp.html
Diego Bosca (Jul 16 2019 at 15:38):
Yeah, both are valueQuantity. min & max value are also different, and I don't see how put both constraints (ranges and units) in a single valueQuantity. That's why the choice
Lloyd McKenzie (Jul 16 2019 at 15:49):
So you're defining a profile and you're wanting to slice a non-repeating element to just say that one of two sets of constraints apply? No real way to do that other than defining a constraint. Slicing isn't allowed on non-repeating elements unless you're slicing by type on a polymorphic element.
Eric Haas (Jul 16 2019 at 15:54):
What is the purpose of the min max constraint? to prevent implementers from doing stupid things or entry errors? Is providing all these checks in the profiles better than say in the UI?
Lloyd McKenzie (Jul 16 2019 at 15:56):
If it's a business rule for the receiving system, it's reasonable to enforce it in a profile
Michel Rutten (Jul 16 2019 at 16:08):
@Lloyd McKenzie, does FHIR allow a type slice with multiple named slices constrained to the same (single) datatype?
Usually, when a choice type element is constrained to a single datatype, then Forge automatically generates a slice name from the selected type (e.g. valueBoolean
). However if FHIR allows multiple type slices constrained to a common single type (?), then I suppose Forge should require the author to explicitly assign custom unique slice names (e.g. someBoolean
and otherBoolean
).
Diego Bosca (Jul 16 2019 at 16:10):
If I have to chose between UI or profile for enforcing a constraint I would chose profile 100% of the time :)
regarding this, I've seen profiles where this choice is simulated with the cardinality of the parent & children (e.g. 5 optional items in a 4..5 container). The only difference is that this ""list"" only has one element.
Lloyd McKenzie (Jul 16 2019 at 16:14):
I don't think we allow multiple slices for a non-repeating polymorphic element except slicing by type. @Grahame Grieve ?
Diego Bosca (Jul 16 2019 at 16:44):
To make things worse, one of my use cases would be sliced by the value of an extension over CodeableConcept :)
Grahame Grieve (Jul 26 2019 at 20:24):
I don't know the answer to either that question or the original question
Diego Bosca (Aug 01 2019 at 11:18):
I'm moving these alternatives constraints to expressions. Seems the only way to use the same kind of "building blocks" in single occurrences and multiple occurrences attributes (Observation.value[x] and Observation.component.value[x])
Last updated: Apr 12 2022 at 19:14 UTC