NOTE: this page will move to an HL7 wiki when a location is found for it.
This page contains a reversed and re-arranged version of the FHIR page listing occurrences of the choice[x] construct in the FHIR DSTU4 resources. The original reversed form was created by Grahame Grieve. Here the rows are re-arranged and somewhat sorted in an attempt to find errors, patterns and opportunities for refactoring and simplification of FHIR, particularly a great reduction if not removal of the choice construct from the base resources.
The tables below group choice[x] usages by their apparent intended logical data type, such as a point or interval in time; reference or value etc. The rows in each table can be compared to each other to see if they represent the same logical data type, and if so, why are they specified differently. One assumption is that many of the differences are simply because different committees and/or individuals did the modelling, and did not manage to perform a complete analysis of the possibilities of the data type, and/or may have made errors (either would be unsurprising, with working groups no doubt focused on the larger picture of one or more whole resource(s)). Without any global review mechanism, the ad hoc lists remain as they are in the specification. Consequences of this in
The specifications here are highly detailed, and some appear speculative rather than based on existing systems (e.g. the ones to do with plan definitions). Questions to consider:
what is the design intention of the data types: to represent existing systems data or ‘model’ in some way proposed functionality not currently available in existing systems? These are quite different points of view and will lead to different modelling.
do all the data type combinations described below really occur in source systems?
are all the data types in source systems represented in the specification?
are all possible data types that might occur e.g. in a new product or product version, represented?
Recurring general patterns
A number of patterns recur independent of particular data type, as follows:
value or status boolean: either a value is supplied or a boolean, indicating that the event / entity in question exists, had occurred etc; for these, the boolean value is marked in red;
these probably should be 2 data points in all cases, because the general case is a Boolean + a data structure if the Boolean is True.
structured value(s) or string: in many cases, it is assumed that the value will be supplied in one or more structured forms, OR a string (marked in grey);
this should be dealt with in a generic way across all the data types;
reference to X versus inline X versus attachment of X versus uri: various concrete representation alternatives; these are shown in some of the tables lower down;
generally a single type should be constructed to deal with this situation
coded versus value: where a coded category (e.g. ‘normal’) and/or a quantitative point or range (e.g. ‘4.5-12’ - Thyroxine T4) is available;
in many cases, both coded and quantitative data points should be used.
General data type questions
Why is Age a data type? It is an invariant on Quantity; it would be easier to just use Duration.
Why is instant any different from dateTime? They are both ISO 8601 date times. Instant is only different in that it is no-partial; the need for partial or non-partial is use-case/instance dependent, and can be handled using invariants based on a function isPartial(): Boolean.
When an event occurred (past) - point or interval in time
The following choice patterns correspond to the requirement to represent a point or interval in past time at/during which an event occurred, allowing for:
approximate information (partial date/time or period)
Why is the boolean presence flag is use for Patient.deceased[x] but not for Immunization.occurrence[x] and potentially other occurrence[x] elements?
Why does string only apply for FamilyMemberHistory.born[x] and Immunization.occurrence[x]?
Why does instant only apply in one case, and not for example to the groups of 15 or 8?
Towards a coherent model
A better approach than the above variant and probably changing choice[x] pseudo-typing would be to create one or more types representing the notion of ‘occurrence’, that accounts for the variance between time-points and intervals and also approximation (aka accuracy). Whether narrative representation occurs is a separate matter, as is a boolean presence flag; these would need to be modelled e.g. in a wrapping class.
Concretely, there are two types of formal representation of the idea of occurrences in the past:
a list of time-points and/or intervals when the event occurred or state was true;
this corresponds to the date/dateTime and Period types
a specification of possible times, optionally within some bounding interval;
this corresponds to the Timing type
The following model allows for two ways of specifying events in the past:
as a series of concrete occurrences, each with a start time and optional duration
as a pattern description, bounded by an overall time interval.
The Occurrence_pattern class corresponds to a simplified view of FHIR’s Timing class.
This model replaces all the combinations in the table above, except for String, which needs to be dealt with in a generic way for all data types.
Age at which an event occurred (past) - absolute point / interval in time | relative duration
The following choice[x] patterns correspond to data elements that ideally express
The main challenge here is to deal with the usual problem of wanting to enter an age or a date at which something happened. This can be solved with a model like the following (note: as above, the exact HL7 data types are not used, as I don’t have a UML model of FHIR; thus for e.g. Iso8601_duration, assume Duration etc):
Age is specified either:
as a date (Age_specifier.date), which may be approximate, because Iso8601_date allows partial dates;
as an age (Age_specifier.age), which may be approximate.
In the first case, effective age can be computed given a DOB argument.
Absolute point / interval in time | relative duration
The following Resource choice[x] lists are for elements that specify logical date/time ranges or durations. Durations in FHIR are just Quantities with in invariant requiring certain time units.
Q: Are there really any systems containing Ranges (2 x SimpleQuantity) representing timing?
Q: how does Duration make sense here?
Q: Why no Period?
Why does the 3rd choice list include Reference() and not the other two?
Towards a coherent model
A better approach than the above variant and probably changing choice[x] pseudo-typing would be to create one or more types representing the notion of ‘TimingSpecification’, meaning ‘specified future timing’. This would need to account for the variance between time-points and intervals and also coded ways of specifying time.
Concretely, there are two ways of representing time in the future:
with a list of specific date-times/intervals of date-times;
with a specification, i.e. like Timing.
The following Resource choice[x] lists are for elements that specify quantity data types.
It is unclear why unsignedInt is allowed in 2 places but not the 3rd, and why SimpleQuantity applies; or if it does, why not in the other two cases.
Possibly model as ‘consumption of a resource’, that incorporates a max $ value, units of <X> consumed and a code for kind of unit.
Numeric: integer | real | Range<T>
Resource . location
Resource . location
'Any' value patterns
The following choices are for data elements that logically can have any or a broad set of data values.
It is likely that at least some of them are over-specified, and in any case, listing types corresponding only to use cases known today is not a reliable way to determine the possible types in all cases for any such data point.
A general solution is to define a parent type of data types, e.g. called DataType or DataValue. This can either be done by changing the inheritance structure of FHIR as it stands now (DSTU4) or by a retro-fitting approach as described in this post.