FHIR
FHIR copied to clipboard
Introduce `ofTypeEqual` and use in generated constraints
I'm wondering if we should also introduce ofTypeEqual and use that in our generated expressions instead of asTypeEqual.
The background on this one is pretty interesting:
many of the fhirpath expressions in the base spec (and a few of the constraints) use the fhirpath as function to convert a list of input items to a filtered list of output items of a given type (or subtypes).
However, the official as documentation says this about it:
If there is more than one item in the input collection, the evaluator will throw an error.
Furthermore, the spec lists the as function as deprecated, although I think its more to favor the as operator instead (which is not retired).
Anyway, I think most of those expressions and FHIRPath constraints should probably be using the ofType function instead of as.
I think its too much of a breaking change to make our as function spec compliant at this point, however I do think that we could introduce ofTypeEqual and use that instead of asTypeEqual in our generated constraints.
Originally posted by @lmsurpre in https://github.com/LinuxForHealth/FHIR/issues/3974#issuecomment-1276971570
Here is a JIRA issue I opened for the dicrepency between the FHIRPath as definition and its usage in FHIR: https://jira.hl7.org/browse/FHIR-25188
Although you can see that they are also starting to fix some of the expressions to favor ofType over as:
https://github.com/HL7/fhir/pull/2395/files
https://github.com/HL7/fhir/pull/2549/files