Implicit Use of FHIRHelpers Functions
See original GitHub issueI’m noticing there seems to be a change in how the CQL-to-ELM project handles use of FHIRHelpers functions between versions 1.2.x and 1.3.x for FHIR 3.0.0.
The FHIR enumerated fields have their own types, but underneath are often represented as simple Strings nested in a “value”. In CQL-to-ELM for 1.2.x, a FHIRHelper function was inferred and would then wrap any property call to such a field. However, the CQL-to-ELM compiler for version 1.3.x no longer seems to apply this implicit FHIRHelper function call. Taking fhir:AdministrativeGender
as an example:
CQL
library Query version '1'
using FHIR version '3.0.0'
include FHIRHelpers version '3.0.0' called FHIRHelpers
context Patient
define GetGender: Patient.gender = 'female'
CQL-to-ELM v1.2.16 yields
<def resultTypeName="t:Boolean" name="GetGender" context="Patient" accessLevel="Public">
<expression resultTypeName="t:Boolean" xsi:type="Equal">
<operand name="ToString" libraryName="FHIRHelpers" xsi:type="FunctionRef">
<operand resultTypeName="fhir:AdministrativeGender" path="gender" xsi:type="Property">
<source resultTypeName="fhir:Patient" name="Patient" xsi:type="ExpressionRef"/>
</operand>
</operand>
<operand resultTypeName="t:String" valueType="t:String" value="female" xsi:type="Literal"/>
</expression>
</def>
but CQL-to-ELM v1.3.10 yields
<def resultTypeName="t:Boolean" name="GetGender" context="Patient" accessLevel="Public">
<expression resultTypeName="t:Boolean" xsi:type="Equal">
<operand resultTypeName="fhir:AdministrativeGender" path="gender" xsi:type="Property">
<source resultTypeName="fhir:Patient" name="Patient" xsi:type="ExpressionRef"/>
</operand>
<operand resultTypeName="t:String" valueType="t:String" value="female" xsi:type="Literal"/>
</expression>
</def>
where the difference is the lack of a wrapping function call to FHIRHelpers.ToString
.
I wondered if the definition of Equal
was meant to capture the type-unwrapping here, but the definition doesn’t seem to say anything about that.
My questions here are
- what change eliminated the implicit wrapping of certain FHIRHelpers functions over these special FHIR types?
- what was the thinking behind the change?
I ask because the definition of functions like ToString
when dispatched over an enumerated value type like AdministrativeGender “unwrapped” the value nesting in the FHIR structure. Without the implicit call as realized in the ELM, I’m not sure it’s clear anymore how a runtime implementation will have to unwrap the FHIR structure.
Also: Given that ReferralRequest.status
is also an example of an enumerated field like Patient.AdministrativeGender
, I think this question is related to #371.
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (11 by maintainers)
Top GitHub Comments
@bdrillard, just pushed a commit that adds the expected behavior for
AgeInYearsAt(Patient.deceased)
. It will now implicitly convert the Patient.deceased to a DateTime and then use the DateTime overload ofCalculateAgeInYearsAt
.Thank you for the report, I’m looking into this, it certainly seems like the wrong behavior.