question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implicit Use of FHIRHelpers Functions

See original GitHub issue

I’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

  1. what change eliminated the implicit wrapping of certain FHIRHelpers functions over these special FHIR types?
  2. 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:closed
  • Created 5 years ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
brynrhodescommented, Mar 8, 2019

@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 of CalculateAgeInYearsAt.

1reaction
brynrhodescommented, Jan 29, 2019

Thank you for the report, I’m looking into this, it certainly seems like the wrong behavior.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FHIR.CQF.COMMON\Home - FHIR v4.0.1
This implementation guide contains common HL7® Fast Healthcare Interoperability Resources (FHIR®) assets for use in content IGs built using ...
Read more >
fhir-helpers - npm
FHIR-helpers. This library is intended to deliver helper methods for forming FHIR resources that follow the hl7 FHIR standard.
Read more >
Well Known CQL Documentation Tags - cqframework ...
This tag is used in the FHIRHelpers library to provide support for externally implemented ... where fluent invocation of FHIRPath functions was implicit....
Read more >
Implicit Implications (part 3): The Future is Functional (implicitly)
Another common and painful mistake is to use implicit conversions to ... You can't abstract over implicit functions in the same way that...
Read more >
xmlschema no implicit conversion of datetime into string
... Architecture and,XQuery Type Conversion Functions Reference,Implicit Use of FHIRHelpers Functions Issue #382 cqframework,Solved: NiFi: Converting a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found