cqframework / clinical_quality_language

Clinical Quality Language (CQL) is an HL7 specification for the expression of clinical knowledge that can be used within both the Clinical Decision Support (CDS) and Clinical Quality Measurement (CQM) domains. This repository contains complementary tooling in support of that specification.
https://confluence.hl7.org/display/CDS/Clinical+Quality+Language
Apache License 2.0
267 stars 123 forks source link

CQL Expand Valueset Issue #1407

Closed SeenaFa closed 2 months ago

SeenaFa commented 3 months ago

The issue/error that I'm getting is the following: Expected ExpandValueSet(ValueSet), Found ExpandValueSet(java.util.ArrayList)

What I'm trying to do is check an Observation.code against the ValueSet via a function call. The function calls/uses fluent functions to do the check but the function arguments are taking a List

`library IssueExpandValueSet

using FHIR version '4.0.1'

include FHIRHelpers version '4.0.1' called FHIRHelpers include IssueExpandValueSet_Concepts called Concepts

context Patient

define "Valueset": Concepts."Garb"

define "Garb Test Fails": "Has Garb Test Fails"([Observation])

define "Garb Test Works": "Has Garb Test Workaround"([Observation])

define function "Has Garb Test Fails" (obs List): obs."With any code"(Concepts."Garb")

define function "Has Garb Test Workaround" (obs List): obs."With any code"(Concepts."Garb" as System.ValueSet)

define fluent function "With any code"(observations List, codes List): if observations is null or codes is null then null else (observations) observation where observation.code."Has"(codes)

define fluent function "Has"(codeableConcept FHIR.CodeableConcept, codes List): if codeableConcept is null or codes is null then null else exists( (codeableConcept.coding) coding where coding in codes )`

I discovered a workaround, that isn't ideal, but is demonstrated in the define called "Has Garb Test Workaround"

I'm not sure what is happening and why the error is occurring.

I also attached a zip file containing the cql libraries, valueset, and test case to reproduce the error and also demonstrate the workaround.

IssueExpandValueSet.zip