FHIR Chat · CQL Language Questions · cql

Stream: cql

Topic: CQL Language Questions


view this post on Zulip Eric Whitley (Mar 16 2020 at 21:50):

Hello -

Really naive question.

I'm implementing a variant of a measure where I need to do something like this:

(
    //if we have one or more elements, then increment by 1
    if (count of elements in list A > 0)
    then 1
    else 0
)
+ (count of elements in list B)

I'm struggling with how to approach the idea of doing the "if" section. I suspect I'm probably missing something obvious.

Is there an equivalent way of saying "my list is empty, so return 0 vs. my list has values, so return 1" ?

Any ideas very much appreciated.

Thank you,
Eric

view this post on Zulip Lloyd McKenzie (Mar 16 2020 at 23:05):

@Bryn Rhodes

view this post on Zulip Bryn Rhodes (Mar 16 2020 at 23:22):

Something like this?

define List1: { 1, 2, 3 }
define List2: { }
define ListExistsCount:
  if exists(List1) then 1 else 0
    + if exists(List2) then 1 else 0

view this post on Zulip Eric Whitley (Mar 17 2020 at 14:06):

Wow, thanks @Bryn Rhodes . I totally missed that. Thanks for that - you tipped me off to the "logical specification" documentation. https://cql.hl7.org/04-logicalspecification.html#if


Last updated: Apr 12 2022 at 19:14 UTC