medizininformatik-initiative / sq2cql

1 stars 1 forks source link

Filter Qualitative Values without Version #117

Open juliangruendner opened 3 months ago

juliangruendner commented 3 months ago

IS:

Qualitative values are currently filtered for with the version, as the generated cql query uses "contains", which compares using equal.

SHOULD:

Qualitative values should be filtered for without the version. The generated cql query should then use "equivalent" instead of "contains.

Examples

CQL with contains (IS)

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

codesystem loinc: 'http://loinc.org/'
codesystem uiccstadiumcs: 'http://dktk.dkfz.de/fhir/onco/core/CodeSystem/UiccstadiumCS'

context Patient

define Criterion:
exists (from [Observation: Code '21908-9' from loinc] O
where O.value.as(CodeableConcept).coding contains Code 'IIA' from uiccstadiumcs)

define InInitialPopulation:
Criterion

CQL with equivalent (SHOULD)

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

codesystem loinc: 'http://loinc.org'
codesystem uiccstadiumcs: 'http://dktk.dkfz.de/fhir/onco/core/CodeSystem/UiccstadiumCS'

context Patient

define Criterion:
exists (from [Observation: Code '21908-9' from loinc] O
where exists (from O.value.coding C where C ~ Code 'IIA' from uiccstadiumcs))

define InInitialPopulation:
Criterion

Example FHIR resource as json which contains value code

{
    "resourceType": "Observation",
    "component": [
        {
            "extension": [
                {
                    "url": "http://dktk.dkfz.de/fhir/StructureDefinition/onco-core-Extension-TNMcpuPraefix",
                    "valueCodeableConcept": {
                        "coding": [
                            {
                                "system": "http://dktk.dkfz.de/fhir/onco/core/CodeSystem/TNMcpuPraefixTCS",
                                "code": "c",
                                "display": "Kategorie wurde durch klinische Angaben festgestellt, bzw. erfüllt die Kriterien für p nicht"
                            }
                        ]
                    }
                }
            ],
            "code": {
                "coding": [
                    {
                        "system": "http://loinc.org",
                        "code": "21905-5",
                        "display": "Primary tumor.clinical Cancer"
                    }
                ]
            },
            "valueCodeableConcept": {
                "coding": [
                    {
                        "system": "http://dktk.dkfz.de/fhir/onco/core/CodeSystem/TNMTCS",
                        "code": "0",
                        "display": "0"
                    }
                ]
            }
        },
        {
            "extension": [
                {
                    "url": "http://dktk.dkfz.de/fhir/StructureDefinition/onco-core-Extension-TNMcpuPraefix",
                    "valueCodeableConcept": {
                        "coding": [
                            {
                                "system": "http://dktk.dkfz.de/fhir/onco/core/CodeSystem/TNMcpuPraefixTCS",
                                "code": "c",
                                "display": "Kategorie wurde durch klinische Angaben festgestellt, bzw. erfüllt die Kriterien für p nicht"
                            }
                        ]
                    }
                }
            ],
            "code": {
                "coding": [
                    {
                        "system": "http://loinc.org",
                        "code": "21906-3",
                        "display": "Regional lymph nodes.clinical"
                    }
                ]
            },
            "valueCodeableConcept": {
                "coding": [
                    {
                        "system": "http://dktk.dkfz.de/fhir/onco/core/CodeSystem/TNMNCS",
                        "code": "1",
                        "display": "1"
                    }
                ]
            }
        },
        {
            "extension": [
                {
                    "url": "http://dktk.dkfz.de/fhir/StructureDefinition/onco-core-Extension-TNMcpuPraefix",
                    "valueCodeableConcept": {
                        "coding": [
                            {
                                "system": "http://dktk.dkfz.de/fhir/onco/core/CodeSystem/TNMcpuPraefixTCS",
                                "code": "c",
                                "display": "Kategorie wurde durch klinische Angaben festgestellt, bzw. erfüllt die Kriterien für p nicht"
                            }
                        ]
                    }
                }
            ],
            "code": {
                "coding": [
                    {
                        "system": "http://loinc.org",
                        "code": "21907-1",
                        "display": "Distant metastases.clinical [Class] Cancer"
                    }
                ]
            },
            "valueCodeableConcept": {
                "coding": [
                    {
                        "system": "http://dktk.dkfz.de/fhir/onco/core/CodeSystem/TNMMCS",
                        "code": "0",
                        "display": "0"
                    }
                ]
            }
        }
    ],
    "effectiveDateTime": "2021-10-21T00:00:00+02:00",
    "status": "final",
    "id": "9f9de0ce0f243936181f4a13362af10d2d3c1431b3dcbf204ce417974bfe8a5f",
    "code": {
        "coding": [
            {
                "system": "http://loinc.org",
                "code": "21908-9",
                "display": "Stage group.clinical Cancer"
            }
        ]
    },
    "valueCodeableConcept": {
        "coding": [
            {
                "system": "http://dktk.dkfz.de/fhir/onco/core/CodeSystem/UiccstadiumCS",
                "version": "2",
                "code": "IIA"
            }
        ]
    },
    "subject": {
        "reference": "Patient/40066cb1cce93d76636b482b3eddbad2d711fa90c709cf209879572113c26aea",
        "identifier": {
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "MR"
                    }
                ]
            },
            "system": "https://fhir.diz.uk-erlangen.de/identifiers/patient-id",
            "value": "105555588"
        }
    }
}
alexanderkiel commented 1 week ago

I found a simpler way to test via equivalence:

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

codesystem loinc: 'http://loinc.org/'
codesystem uiccstadiumcs: 'http://dktk.dkfz.de/fhir/onco/core/CodeSystem/UiccstadiumCS'

context Patient

define Criterion:
  exists (from [Observation: Code '21908-9' from loinc] O
    where O.value ~ Code 'IIA' from uiccstadiumcs)

define InInitialPopulation:
  Criterion

It's just possible to apply the equivalence operator to a FHIR CodeableConcept and a CQL Code.

alexanderkiel commented 1 week ago

We have to wait until all sites have at least the v0.29 of Blaze deployed.