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
262 stars 121 forks source link

Default context is not unfiltered as indicated in the spec #1293

Closed EvanMachusak closed 9 months ago

EvanMachusak commented 10 months ago

Per the Author's guide:

When no context is specified in the library, and the model has not declared a default context, the default context is Unfiltered.

However cql-to-elm appears to be defaulting to Patient context for all statements without defining a contexts element in the ELM.

Consider this CQL:

library CqlArithmeticFunctionsTest

define "AbsNull Input":
    Abs(null as Integer)
define "AbsNull Output":
    null

We are neither using any model other than System nor are we declaring contexts. Nevertheless, the translator produces this ELM:


{
  "library": {
    "type": "Library",
    "identifier": {
      "type": "VersionedIdentifier",
      "id": "CqlArithmeticFunctionsTest"
    },
    "schemaIdentifier": {
      "type": "VersionedIdentifier",
      "id": "urn:hl7-org:elm",
      "version": "r1"
    },
    "usings": {
      "type": "Library$Usings",
      "def": [
        {
          "type": "UsingDef",
          "localIdentifier": "System",
          "uri": "urn:hl7-org:elm-types:r1"
        }
      ]
    },
    "statements": {
      "type": "Library$Statements",
      "def": [
        {
          "type": "ExpressionDef",
          "expression": {
            "type": "Abs",
            "operand": {
              "type": "As",
              "asTypeSpecifier": {
                "type": "NamedTypeSpecifier",
                "locator": "5:14-5:20",
                "resultTypeName": "{urn:hl7-org:elm-types:r1}Integer",
                "name": "{urn:hl7-org:elm-types:r1}Integer"
              },
              "operand": {
                "type": "Null",
                "locator": "5:6-5:9",
                "resultTypeName": "{urn:hl7-org:elm-types:r1}Any"
              },
              "locator": "5:6-5:20",
              "resultTypeName": "{urn:hl7-org:elm-types:r1}Integer",
              "strict": false
            },
            "locator": "5:2-5:21",
            "resultTypeName": "{urn:hl7-org:elm-types:r1}Integer"
          },
          "locator": "4:1-5:21",
          "resultTypeName": "{urn:hl7-org:elm-types:r1}Integer",
          "name": "AbsNull Input",
          "context": "Patient",
          "accessLevel": "Public"
        },
        {
          "type": "ExpressionDef",
          "expression": {
            "type": "Null",
            "locator": "7:2-7:5",
            "resultTypeName": "{urn:hl7-org:elm-types:r1}Any"
          },
          "locator": "6:1-7:5",
          "resultTypeName": "{urn:hl7-org:elm-types:r1}Any",
          "name": "AbsNull Output",
          "context": "Patient",
          "accessLevel": "Public"
        }
      ]
    },
    "annotation": [
      {
        "type": "CqlToElmInfo",
        "translatorOptions": "EnableLocators,EnableResultTypes,EnableDetailedErrors"
      }
    ]
  }
}
JPercival commented 9 months ago

Is this still a problem for you on master? I'm unable to reproduce: https://github.com/cqframework/clinical_quality_language/pull/1312