Stream: implementers
Topic: Implementation of Choice Data Types
Joe Paquette (May 23 2019 at 13:57):
Example: Patient properties deceased[x]
and multipleBirth[x]
My reading of http://build.fhir.org/formats.html#choice [ref: "Elements that have a choice of data type cannot repeat - they must have a maximum cardinality of 1. When constructing an instance of an element with a choice of types, the authoring system must create a single element with a data type chosen from among the list of permitted data types."] implies to me that the implementation of choice data types should result in only one choice property (e.g., single polymorphic deceased
property as opposed to the multiple deceasedBoolean
and deceasedDataTime
properties). Am I reading this correctly? Should the implementation be:
- a single
deceased
property that can support either a boolean data type or a dateTime data type - two properties of
deceasedBoolean
anddeceasedDataTime
where only one of these fields can be used at a time - something else that I'm missing...
Looking at the generated fhir.schema.json
from the downloads (JSON SCHEMA), the schema definition for "Patient" specifically defines the following (ignoring the "underscored prperties"): deceasedBoolean
, deceasedDateTime
. If the requirement is for a single polymorphic property, the "Patient" JSON Schema should have a single deceased
property having a oneOf
for type definitions for boolean
and dataTime
(string).
If the intent is to implement choice fields as one per data type (e.g., deceasedBoolean
, deceasedDateTime
), then based on the requirement to allow only one of these, the JSON Schema should have a "oneOf" for deceasedBoolean
or deceasedDateTime
.
I'd appreciate any insight on the underlying intent and how other folks are handling this in real implementations.
Thanks!
Jean Duteau (May 23 2019 at 13:58):
Example: Patient properties
deceased[x]
andmultipleBirth[x]
- two properties of
deceasedBoolean
anddeceasedDataTime
where only one of these fields can be used at a time
This.
Joe Paquette (May 23 2019 at 14:12):
OK, thanks...
So, shouldn't the JSON Schema enforce this by using "oneOf" for deceasedBoolean
and deceasedDateTime
? Or is the intent that an implementer must add appropriate logic on how to handle the specific uses?
Lloyd McKenzie (May 23 2019 at 14:49):
@Grahame Grieve
nicola (RIO/SS) (May 28 2019 at 18:14):
and again ;) choice types in fhir json are represented in a wrong way - you will have combinatorial problems with more than one union in resource, you could not have collection of union attributes, search problems etc. I will bomb until we fix it!
Grahame Grieve (May 28 2019 at 20:38):
the intent that an implementer must add appropriate logic on how to handle the specific uses
Json schema can't represent all the rules. So we add the ones to schema that people find useful, based on feedback. There's a tradeoff for different uses of the schema . for XML, we publish 2 different schema, for different purposes.
Last updated: Apr 12 2022 at 19:14 UTC