medizininformatik-initiative / sq2cql

1 stars 1 forks source link

Malformed CQL for concept with children and linked criterion #136

Closed juliangruendner closed 1 month ago

juliangruendner commented 1 month ago

The CQL that is being produced for concepts with children and linked criteria seems to be incorrect.

Example:

{
  "version": "http://to_be_decided.com/draft-1/schema#",
  "display": "",
  "inclusionCriteria": [
    [
      {
        "termCodes": [
          {
            "code": "C50",
            "system": "http://fhir.de/CodeSystem/bfarm/icd-10-gm",
            "version": "2024",
            "display": "Bösartige Neubildung der Brustdrüse [Mamma]"
          }
        ],
        "attributeFilters": [
          {
            "criteria": [
              {
                "termCodes": [
                  {
                    "code": "21902-2",
                    "display": "Stage group.pathology Cancer",
                    "system": "http://loinc.org"
                  }
                ],
                "context": {
                  "code": "TNMp",
                  "display": "TNMp",
                  "system": "bzkf.dktk.oncology"
                }
              }
            ],
            "type": "reference",
            "attributeCode": {
              "code": "assessment",
              "display": "assessment",
              "system": "http://hl7.org/fhir/StructureDefinition"
            }
          }
        ],
        "context": {
          "code": "Primaerdiagnose",
          "system": "bzkf.dktk.oncology",
          "display": "Primaerdiagnose"
        }
      }
    ]
  ]
}

leads to the following CQL

using FHIR version '4.0.0'
include FHIRHelpers version '4.0.0'

codesystem icd10: 'http://fhir.de/CodeSystem/bfarm/icd-10-gm'
codesystem loinc: 'http://loinc.org'

context Patient

define "Histologie 59847-4 1":
  [Observation: Code '59847-4' from loinc]

define "Histologie 59847-4 2":
  [Observation: Code '59847-4' from loinc]

define "Histologie 59847-4 3":
  [Observation: Code '59847-4' from loinc]

define "Histologie 59847-4 4":
  [Observation: Code '59847-4' from loinc]

define "Histologie 59847-4 5":
  [Observation: Code '59847-4' from loinc]

define "Histologie 59847-4 6":
  [Observation: Code '59847-4' from loinc]

define "Histologie 59847-4 7":
  [Observation: Code '59847-4' from loinc]

define "Histologie 59847-4 8":
  [Observation: Code '59847-4' from loinc]

define "Histologie 59847-4 9":
  [Observation: Code '59847-4' from loinc]

define "Histologie 59847-4 10":
  [Observation: Code '59847-4' from loinc]

define Criterion:
  exists (from [Condition: Code 'C50' from icd10] C
    with "Histologie 59847-4" O
      such that C.evidence.detail.reference = 'Observation/' + O.id) or
  exists (from [Condition: Code 'C50.8' from icd10] C
    with "Histologie 59847-4" O
      such that C.evidence.detail.reference = 'Observation/' + O.id) or
  exists (from [Condition: Code 'C50.9' from icd10] C
    with "Histologie 59847-4" O
      such that C.evidence.detail.reference = 'Observation/' + O.id) or
  exists (from [Condition: Code 'C50.0' from icd10] C
    with "Histologie 59847-4" O
      such that C.evidence.detail.reference = 'Observation/' + O.id) or
  exists (from [Condition: Code 'C50.2' from icd10] C
    with "Histologie 59847-4" O
      such that C.evidence.detail.reference = 'Observation/' + O.id) or
  exists (from [Condition: Code 'C50.4' from icd10] C
    with "Histologie 59847-4" O
      such that C.evidence.detail.reference = 'Observation/' + O.id) or
  exists (from [Condition: Code 'C50.6' from icd10] C
    with "Histologie 59847-4" O
      such that C.evidence.detail.reference = 'Observation/' + O.id) or
  exists (from [Condition: Code 'C50.3' from icd10] C
    with "Histologie 59847-4" O
      such that C.evidence.detail.reference = 'Observation/' + O.id) or
  exists (from [Condition: Code 'C50.5' from icd10] C
    with "Histologie 59847-4" O
      such that C.evidence.detail.reference = 'Observation/' + O.id) or
  exists (from [Condition: Code 'C50.1' from icd10] C
    with "Histologie 59847-4" O
      such that C.evidence.detail.reference = 'Observation/' + O.id)

define InInitialPopulation:
  Criterion
alexanderkiel commented 1 month ago

Should be already fixed by #122 in v0.3.0. Did you use this version?

BoehmDo commented 1 month ago

You are correct, this was produced using an older sq2cql version. I updated the dependency and the cql ist looking good now! Thank you.