FHIR Chat · Observation.valueCodeableConcept in ValueSet? · cql

Stream: cql

Topic: Observation.valueCodeableConcept in ValueSet?


view this post on Zulip John Silva (Apr 28 2021 at 15:09):

Trying to do the following:

define "matchingObservations": exists ([Observation: "MyValueSet1"] Obs where Obs.valueCodeableConcept in MyValueSet2 )
The idea is that first need to filter possible Observations that have Observation.code in the MyValueSet1 and then filter by only those that have the Observation.valueCodeableConcept in MyValueSet2. This syntax doesn't seem to be allowed (using Atom CQL plugin). If I use this syntax it is allowed but doesn't work (with CQL Framework)

define "matchingObservations": exists ([Observation: "MyValueSet1"] Obs where Obs.value in MyValueSet2 )
Any pointers? I saw a Github thread about this (https://github.com/cqframework/clinical_quality_language/issues/564 ); does this just not work in CQL Framework yet?

Update: I was able to get it to work by adding 'as CodeableConcept'

define "matchingObservations": exists ([Observation: "MyValueSet1"] Obs where Obs.value as CodeableConcept in MyValueSet2 )

Now I'm onto the next step -- retrieving a value (string) from this Observation. Not sure how to do this:

define "myBodySite": exists ([Observation: "MyValueSet1"] Obs where Obs.value as CodeableConcept in MyValueSet2 return Obs.bodySite.text )

view this post on Zulip Rob Reynolds (Apr 29 2021 at 22:22):

exists returns a boolean.

define "myBodySite":
  [Observation: "MyValueSet1"] Obs
    where Obs.value as CodeableConcept in MyValueSet2
    return Obs.bodySite.text

view this post on Zulip Rob Reynolds (Apr 29 2021 at 22:31):

But, that returns a list of strings. Not sure if that's what you want.

define "myBodySite":
  Last(
    [Observation: "MyValueSet1"] Obs
      where Obs.value as CodeableConcept in "MyValueSet2"
      sort by effective
  ).bodySite.text

?


Last updated: Apr 12 2022 at 19:14 UTC