Stream: cql
Topic: List Manipulation
Adrien Prost (Jul 05 2021 at 08:35):
Hello, I was wondering if the basic CQL libraries come with functions for creating lists and appending elements into them? The use case here is to be able to assign multiple possible diagnoses to a patient into a list in which subsequently filter out excluded diagnoses ?
Adrien Prost (Jul 05 2021 at 09:34):
An important point to add, is that I am also asking whether or not we can define variables in CQL, so that we can modify lists in a function for example
JP (Jul 07 2021 at 23:49):
Like some other declarative languages there are no facilities in CQL for mutating existing Lists or other definitions. Instead you use queries, definitions, and other operators to create NEW Lists.
define "Diagnosis 1":
{ 'alive and kicking' }
define "Diagnosis 2":
{ 'doing ok' }
define "Diagnosis 3":
{ 'not doing great' }
define "All Possible Diagnoses":
"Diagnosis 1" union "Diagnosis 2" union "Diagnosis 3"
define function FilterExcludedDiagnosis(diagnoses List<System.String>):
diagnoses D where D != 'doing ok'
define "Filtered Diagnoses":
FilterExcludedDiagnosis("All Possible Diagnoses")
define "Filtered Inline Instead":
"All Possible Diagnoses" D where D != 'alive and kicking'
define "Or Use Set Operators":
"All Possible Diagnoses" except "Diagnosis 3"
I find it easiest to conceptualize the paradigm as "pipes and filters":
input data -> (transform) -> intermediate data -> (filter) -> output data
data set 1 -> (union) -> output data
data set 2 -------^
Adrien Prost (Jul 08 2021 at 09:06):
Okay, thanks. I my case our diagnoses are results of decision trees where node outputs can have multiple outgoing edges, what I did is represent nodes as functions which all return a list of possible diagnoses, the function uses conditional statements to compute the correct output and then returns either the function of the descendent node from the single outgoing edge or the union of all the descendant nodes.
Adrien Prost (Jul 08 2021 at 09:08):
The problem is that I am not sure that this method will be very efficient in practice with complex decision trees
Last updated: Apr 12 2022 at 19:14 UTC