FHIR Chat · Required primitive without a value · implementers

Stream: implementers

Topic: Required primitive without a value


view this post on Zulip Ivan Dubrov (Dec 12 2018 at 07:56):

It is possible for FHIR primitive element to not have any value (but only extensions). One example would ElementDefinition.type.code, which is required, but in StructureDefinitions for primitive types themselves their ".value" field doesn't have any code.

I find this feature a bit confusing because it means that "type" of primitive value could be something completely different (value is empty and extension gives value of some other type) and "required value" is not really required (because value could be empty).

What was a rationale of that decision and in particular, why ".value" part of primitive is optional? How often this is expected to happen?

view this post on Zulip Michel Rutten (Dec 12 2018 at 09:27):

Note that this behavior is formally defined by fundamental invariant "ele-1", which applies to all elements:
http://hl7.org/fhir/element.html#definition

view this post on Zulip Michel Rutten (Dec 12 2018 at 09:32):

In general, almost all elements in core FHIR resources and datatypes are optional (Min = 0), to cover widely varying use cases. For a specific implementation, you can create profiles that define additional constraints and remove some of the default optionality.

view this post on Zulip Grahame Grieve (Dec 12 2018 at 09:41):

it doesn't happen much. But it can happen on any type

view this post on Zulip Lloyd McKenzie (Dec 12 2018 at 15:06):

As an example, someone might extend Patient.birthDate to have a string that says "summer of either 1931 or 1932". If you want to check for the existence of a value, you always need to check for the presence of the value, not just the element

view this post on Zulip Ivan Dubrov (Dec 12 2018 at 17:26):

Right. It basically creates three possible cases:
1. There is a primitive "element" and the value, too (happy case)
2. There are no primitive "element" (nothing case)
3. There are a primitive "element", but no value, only extensions (exciting case)

In my current internal API, #3 have to be explicitly handled, which is kind of painful (because it's a very uncommon case). I guess, I can interpret it as #2, although it is not the same (the value IS there, you just don't know how to interpret it...)

view this post on Zulip Grahame Grieve (Dec 12 2018 at 20:04):

yes

view this post on Zulip Ewout Kramer (Dec 18 2018 at 09:48):

I think it's useful in this context to add that if the element is of a coded type and the cardinality is 1.. and the type of binding is "required", there must be a code.


Last updated: Apr 12 2022 at 19:14 UTC