cqf-tooling icon indicating copy to clipboard operation
cqf-tooling copied to clipboard

Additional implicit conversions in FHIRHelpers

Open brynrhodes opened this issue 2 years ago • 2 comments

Consider the following expression:

Patient.birthDate < Now()

There are two implicit conversions happening here, one from the birthDate to a System.Date and one from a System.Date to a System.DateTime. CQL intentionally does not support transitive implicit conversion, and so this expression fails. However, the FHIRPath engines already do this because they are handling the conversions at run-time.

Define additional implicit conversions in FHIR helpers to account for implicit conversions defined in CQL types as well:

define function ToDateTime(value date): ToDateTime(value.value)
define function ToDecimal(value integer): ToDecimal(value.value)

These need to be reflected in the ModelInfo as ConversionInfo as well:

   <conversionInfo functionName="FHIRHelpers.ToDateTime" fromType="FHIR.date" toType="System.DateTime"/>
   <conversionInfo functionName="FHIRHelpers.ToDecimal" fromType="FHIR.integer" toType="System.Decimal"/>

brynrhodes avatar Jun 17 '22 19:06 brynrhodes