Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CQL Has Code in ValueSet issue #1412

Open
SeenaFa opened this issue Sep 11, 2024 · 1 comment
Open

CQL Has Code in ValueSet issue #1412

SeenaFa opened this issue Sep 11, 2024 · 1 comment
Assignees

Comments

@SeenaFa
Copy link

SeenaFa commented Sep 11, 2024

The issue I'm encountering is that I'm getting a false value but should be getting true when checking if a code is in a ValueSet or not.

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. I tried breaking down each step of the function calls to see if I can isolate the problem but was unable to.
I found that when I call the fluent function(s) directly, I get a "null" value and not sure why that is. Below is a snippet of the CQL but have also attached a zip file containing the CQL library and test case.

`library IssueObservationCode

using FHIR version '4.0.1'

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

context Patient

define "ObservationsList": [Observation]

define "Observations Garb": [Observation: Concepts."Garb"]

define "test function": "Has garb"("ObservationsList")

define "test fluent": "ObservationsList"."Obs garb during"()

define "test fluent has": "ObservationsList"[0].code."Has"(Concepts."Garb" as System.ValueSet)

define function "Has garb"(obs List):
exists(obs."Obs garb during"())

define fluent function "Obs garb during"(observations List<FHIR.Observation>):
observations
."With any code"(Concepts."Garb" as System.ValueSet)

define fluent function "With any code"(observations List<FHIR.Observation>, codes List<System.Code>):
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<System.Code>):
if codeableConcept is null or codes is null then null
else
exists(
(codeableConcept.coding) coding
where coding in codes
)`

IssueObservationCode.zip

@antvaset antvaset self-assigned this Sep 11, 2024
@antvaset
Copy link
Contributor

antvaset commented Oct 2, 2024

Hi @SeenaFa, I can replicate this issue using the latest version of the extension, and it's related to #1407 (which we fixed in #1409).

The issue had to do with the imported valueset being expanded prematurely during execution. Only external valuesets were affected and not the ones defined in the library. So if I bring valueset "Garb": 'garb' into the IssueObservationCode library and re-run the CQL, I get

Patient=Patient(id=Patient1)
ObservationsList=[Observation(id=lead-observation-1)]
Observations Garb=[Observation(id=lead-observation-1)]
test function=true
test fluent=[Observation(id=lead-observation-1)]
test fluent has=true

as expected.

Once the extension is updated, external valuesets should work as intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants