diff --git a/resources/test/result_age_at_diagnosis_30_to_70.cql b/resources/test/result_age_at_diagnosis_30_to_70.cql index 8d4ce819..845d2cd0 100644 --- a/resources/test/result_age_at_diagnosis_30_to_70.cql +++ b/resources/test/result_age_at_diagnosis_30_to_70.cql @@ -71,15 +71,11 @@ define Diagnosis: if InInitialPopulation then [Condition] else {} as List define function DiagnosisCode(condition FHIR.Condition): -condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() - -define function DiagnosisCode(condition FHIR.Condition, specimen FHIR.Specimen): Coalesce( condition.code.coding.where(system = 'http://hl7.org/fhir/sid/icd-10').code.first(), condition.code.coding.where(system = 'http://fhir.de/CodeSystem/dimdi/icd-10-gm').code.first(), - condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first(), - specimen.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code.first() - ) + condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() +) define InInitialPopulation: ((((exists from [Condition] C diff --git a/resources/test/result_age_at_diagnosis_lower_than_70.cql b/resources/test/result_age_at_diagnosis_lower_than_70.cql index 9230612b..417caef4 100644 --- a/resources/test/result_age_at_diagnosis_lower_than_70.cql +++ b/resources/test/result_age_at_diagnosis_lower_than_70.cql @@ -71,15 +71,11 @@ define Diagnosis: if InInitialPopulation then [Condition] else {} as List define function DiagnosisCode(condition FHIR.Condition): -condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() - -define function DiagnosisCode(condition FHIR.Condition, specimen FHIR.Specimen): Coalesce( condition.code.coding.where(system = 'http://hl7.org/fhir/sid/icd-10').code.first(), condition.code.coding.where(system = 'http://fhir.de/CodeSystem/dimdi/icd-10-gm').code.first(), - condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first(), - specimen.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code.first() - ) + condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() +) define InInitialPopulation: ((((exists from [Condition] C diff --git a/resources/test/result_all_gbn.cql b/resources/test/result_all_gbn.cql index d167d935..84561467 100644 --- a/resources/test/result_all_gbn.cql +++ b/resources/test/result_all_gbn.cql @@ -76,18 +76,14 @@ define Diagnosis: if InInitialPopulation then [Condition] else {} as List define function DiagnosisCode(condition FHIR.Condition): -condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() - -define function DiagnosisCode(condition FHIR.Condition, specimen FHIR.Specimen): Coalesce( condition.code.coding.where(system = 'http://hl7.org/fhir/sid/icd-10').code.first(), condition.code.coding.where(system = 'http://fhir.de/CodeSystem/dimdi/icd-10-gm').code.first(), - condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first(), - specimen.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code.first() - ) + condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() +) define InInitialPopulation: -((((Patient.gender = 'male') or (Patient.gender = 'other'))) and ((((((exists[Condition: Code 'C25' from icd10]) or (exists[Condition: Code 'C25' from icd10gm]) or (exists[Condition: Code 'C25' from icd10gmnew])) or (exists from [Specimen] S where (S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code contains 'C25'))))) or (((((exists[Condition: Code 'C56' from icd10]) or (exists[Condition: Code 'C56' from icd10gm]) or (exists[Condition: Code 'C56' from icd10gmnew])) or (exists from [Specimen] S where (S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code contains 'C56')))))) and (exists from [Condition] C +((((Patient.gender = 'male') or (Patient.gender = 'other'))) and ((((((exists[Condition: Code 'C25' from icd10]) or (exists[Condition: Code 'C25' from icd10gm]) or (exists[Condition: Code 'C25' from icd10gmnew])))))) or (((((exists[Condition: Code 'C56' from icd10]) or (exists[Condition: Code 'C56' from icd10gm]) or (exists[Condition: Code 'C56' from icd10gmnew]))))))) and (exists from [Condition] C where AgeInYearsAt(FHIRHelpers.ToDateTime(C.onset)) between Ceiling(10) and Ceiling(100)) and (exists from [Condition] C where FHIRHelpers.ToDateTime(C.onset) between @2023-09-30 and @2023-10-29) and (exists from [Observation: Code '39156-5' from loinc] O where ((O.value as Quantity) < 10 'kg/m2' and (O.value as Quantity) > 100 'kg/m2')) and (exists from [Observation: Code '29463-7' from loinc] O diff --git a/resources/test/result_c61_and_male.cql b/resources/test/result_c61_and_male.cql index 3809a6fa..1c03fc1c 100644 --- a/resources/test/result_c61_and_male.cql +++ b/resources/test/result_c61_and_male.cql @@ -73,15 +73,11 @@ define Diagnosis: if InInitialPopulation then [Condition] else {} as List define function DiagnosisCode(condition FHIR.Condition): -condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() - -define function DiagnosisCode(condition FHIR.Condition, specimen FHIR.Specimen): Coalesce( condition.code.coding.where(system = 'http://hl7.org/fhir/sid/icd-10').code.first(), condition.code.coding.where(system = 'http://fhir.de/CodeSystem/dimdi/icd-10-gm').code.first(), - condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first(), - specimen.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code.first() - ) + condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() +) define InInitialPopulation: -((((((((exists[Condition: Code 'C61' from icd10]) or (exists[Condition: Code 'C61' from icd10gm]) or (exists[Condition: Code 'C61' from icd10gmnew])) or (exists from [Specimen] S where (S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code contains 'C61')))))) and ((((Patient.gender = 'male')))))) \ No newline at end of file +((((((((exists[Condition: Code 'C61' from icd10]) or (exists[Condition: Code 'C61' from icd10gm]) or (exists[Condition: Code 'C61' from icd10gmnew]))))))) and ((((Patient.gender = 'male')))))) \ No newline at end of file diff --git a/resources/test/result_current.cql b/resources/test/result_current.cql index ca99e6ae..da879ce0 100644 --- a/resources/test/result_current.cql +++ b/resources/test/result_current.cql @@ -74,16 +74,12 @@ define Diagnosis: if InInitialPopulation then [Condition] else {} as List define function DiagnosisCode(condition FHIR.Condition): -condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() - -define function DiagnosisCode(condition FHIR.Condition, specimen FHIR.Specimen): Coalesce( condition.code.coding.where(system = 'http://hl7.org/fhir/sid/icd-10').code.first(), condition.code.coding.where(system = 'http://fhir.de/CodeSystem/dimdi/icd-10-gm').code.first(), - condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first(), - specimen.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code.first() - ) + condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() +) define InInitialPopulation: -((((((Patient.gender = 'male')))) and ((((((exists[Condition: Code 'C61' from icd10]) or (exists[Condition: Code 'C61' from icd10gm]) or (exists[Condition: Code 'C61' from icd10gmnew])) or (exists from [Specimen] S where (S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code contains 'C61')))))) and (( AgeInYears() between Ceiling(10) and Ceiling(90)))) or (((exists from [Specimen] S +((((((Patient.gender = 'male')))) and ((((((exists[Condition: Code 'C61' from icd10]) or (exists[Condition: Code 'C61' from icd10gm]) or (exists[Condition: Code 'C61' from icd10gmnew]))))))) and (( AgeInYears() between Ceiling(10) and Ceiling(90)))) or (((exists from [Specimen] S where FHIRHelpers.ToDateTime(S.collection.collected) between @1900-01-01 and @2024-10-25 )) and ((((exists from [Specimen] S where (S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/StorageTemperature').value.coding contains Code 'temperature2to10' from StorageTemperature) )))))) \ No newline at end of file diff --git a/resources/test/result_empty.cql b/resources/test/result_empty.cql index 54d8c019..18443214 100644 --- a/resources/test/result_empty.cql +++ b/resources/test/result_empty.cql @@ -71,15 +71,11 @@ define Diagnosis: if InInitialPopulation then [Condition] else {} as List define function DiagnosisCode(condition FHIR.Condition): -condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() - -define function DiagnosisCode(condition FHIR.Condition, specimen FHIR.Specimen): Coalesce( condition.code.coding.where(system = 'http://hl7.org/fhir/sid/icd-10').code.first(), condition.code.coding.where(system = 'http://fhir.de/CodeSystem/dimdi/icd-10-gm').code.first(), - condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first(), - specimen.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code.first() - ) + condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() +) define InInitialPopulation: true \ No newline at end of file diff --git a/resources/test/result_lens2.cql b/resources/test/result_lens2.cql index 83ceede7..c6576755 100644 --- a/resources/test/result_lens2.cql +++ b/resources/test/result_lens2.cql @@ -74,15 +74,11 @@ define Diagnosis: if InInitialPopulation then [Condition] else {} as List define function DiagnosisCode(condition FHIR.Condition): -condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() - -define function DiagnosisCode(condition FHIR.Condition, specimen FHIR.Specimen): Coalesce( condition.code.coding.where(system = 'http://hl7.org/fhir/sid/icd-10').code.first(), condition.code.coding.where(system = 'http://fhir.de/CodeSystem/dimdi/icd-10-gm').code.first(), - condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first(), - specimen.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code.first() - ) + condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() +) define InInitialPopulation: -((((((Patient.gender = 'male'))) or (((Patient.gender = 'female')))) and ((((((exists[Condition: Code 'C41' from icd10]) or (exists[Condition: Code 'C41' from icd10gm]) or (exists[Condition: Code 'C41' from icd10gmnew])) or (exists from [Specimen] S where (S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code contains 'C41'))))) or (((((exists[Condition: Code 'C50' from icd10]) or (exists[Condition: Code 'C50' from icd10gm]) or (exists[Condition: Code 'C50' from icd10gmnew])) or (exists from [Specimen] S where (S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code contains 'C50')))))) and (((( exists [Specimen: Code 'tissue-frozen' from SampleMaterialType]) or ( exists [Specimen: Code 'tumor-tissue-frozen' from SampleMaterialType]) or ( exists [Specimen: Code 'normal-tissue-frozen' from SampleMaterialType]) or ( exists [Specimen: Code 'other-tissue-frozen' from SampleMaterialType]))) or ((( exists [Specimen: Code 'blood-serum' from SampleMaterialType]) or ( exists [Specimen: Code 'serum' from SampleMaterialType]))))) or (((((Patient.gender = 'male')))) and ((((((exists[Condition: Code 'C41' from icd10]) or (exists[Condition: Code 'C41' from icd10gm]) or (exists[Condition: Code 'C41' from icd10gmnew])) or (exists from [Specimen] S where (S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code contains 'C41'))))) or (((((exists[Condition: Code 'C50' from icd10]) or (exists[Condition: Code 'C50' from icd10gm]) or (exists[Condition: Code 'C50' from icd10gmnew])) or (exists from [Specimen] S where (S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code contains 'C50')))))) and (((( exists [Specimen: Code 'liquid-other' from SampleMaterialType]) or ( exists [Specimen: Code 'liquid' from SampleMaterialType]))) or ((( exists [Specimen: Code 'rna' from SampleMaterialType]))) or ((( exists [Specimen: Code 'urine' from SampleMaterialType])))) and ((((exists from [Specimen] S where (S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/StorageTemperature').value.coding contains Code 'temperatureRoom' from StorageTemperature) ))) or (((exists from [Specimen] S where (S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/StorageTemperature').value.coding contains Code 'four_degrees' from StorageTemperature) )))))) \ No newline at end of file +((((((Patient.gender = 'male'))) or (((Patient.gender = 'female')))) and ((((((exists[Condition: Code 'C41' from icd10]) or (exists[Condition: Code 'C41' from icd10gm]) or (exists[Condition: Code 'C41' from icd10gmnew])))))) or (((((exists[Condition: Code 'C50' from icd10]) or (exists[Condition: Code 'C50' from icd10gm]) or (exists[Condition: Code 'C50' from icd10gmnew]))))))) and (((( exists [Specimen: Code 'tissue-frozen' from SampleMaterialType]) or ( exists [Specimen: Code 'tumor-tissue-frozen' from SampleMaterialType]) or ( exists [Specimen: Code 'normal-tissue-frozen' from SampleMaterialType]) or ( exists [Specimen: Code 'other-tissue-frozen' from SampleMaterialType]))) or ((( exists [Specimen: Code 'blood-serum' from SampleMaterialType]) or ( exists [Specimen: Code 'serum' from SampleMaterialType]))))) or (((((Patient.gender = 'male')))) and ((((((exists[Condition: Code 'C41' from icd10]) or (exists[Condition: Code 'C41' from icd10gm]) or (exists[Condition: Code 'C41' from icd10gmnew])))))) or (((((exists[Condition: Code 'C50' from icd10]) or (exists[Condition: Code 'C50' from icd10gm]) or (exists[Condition: Code 'C50' from icd10gmnew]))))))) and (((( exists [Specimen: Code 'liquid-other' from SampleMaterialType]) or ( exists [Specimen: Code 'liquid' from SampleMaterialType]))) or ((( exists [Specimen: Code 'rna' from SampleMaterialType]))) or ((( exists [Specimen: Code 'urine' from SampleMaterialType])))) and ((((exists from [Specimen] S where (S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/StorageTemperature').value.coding contains Code 'temperatureRoom' from StorageTemperature) ))) or (((exists from [Specimen] S where (S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/StorageTemperature').value.coding contains Code 'four_degrees' from StorageTemperature) )))))) \ No newline at end of file diff --git a/resources/test/result_male_or_female.cql b/resources/test/result_male_or_female.cql index b823b85c..4f219686 100644 --- a/resources/test/result_male_or_female.cql +++ b/resources/test/result_male_or_female.cql @@ -71,15 +71,11 @@ define Diagnosis: if InInitialPopulation then [Condition] else {} as List define function DiagnosisCode(condition FHIR.Condition): -condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() - -define function DiagnosisCode(condition FHIR.Condition, specimen FHIR.Specimen): Coalesce( condition.code.coding.where(system = 'http://hl7.org/fhir/sid/icd-10').code.first(), condition.code.coding.where(system = 'http://fhir.de/CodeSystem/dimdi/icd-10-gm').code.first(), - condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first(), - specimen.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code.first() - ) + condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() +) define InInitialPopulation: ((((((Patient.gender = 'male'))) or (((Patient.gender = 'female')))))) \ No newline at end of file diff --git a/resources/test/result_quote.cql b/resources/test/result_quote.cql index c9bfb98f..24b8b13f 100644 --- a/resources/test/result_quote.cql +++ b/resources/test/result_quote.cql @@ -73,15 +73,11 @@ define Diagnosis: if InInitialPopulation then [Condition] else {} as List define function DiagnosisCode(condition FHIR.Condition): -condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() - -define function DiagnosisCode(condition FHIR.Condition, specimen FHIR.Specimen): Coalesce( condition.code.coding.where(system = 'http://hl7.org/fhir/sid/icd-10').code.first(), condition.code.coding.where(system = 'http://fhir.de/CodeSystem/dimdi/icd-10-gm').code.first(), - condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first(), - specimen.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code.first() - ) + condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() +) define InInitialPopulation: -((((((((exists[Condition: Code 'C61\"\'\\\n\r\t' from icd10]) or (exists[Condition: Code 'C61\"\'\\\n\r\t' from icd10gm]) or (exists[Condition: Code 'C61\"\'\\\n\r\t' from icd10gmnew])) or (exists from [Specimen] S where (S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code contains 'C61\"\'\\\n\r\t')))))) and ((((Patient.gender = 'male')))))) \ No newline at end of file +((((((((exists[Condition: Code 'C61\"\'\\\n\r\t' from icd10]) or (exists[Condition: Code 'C61\"\'\\\n\r\t' from icd10gm]) or (exists[Condition: Code 'C61\"\'\\\n\r\t' from icd10gmnew]))))))) and ((((Patient.gender = 'male')))))) \ No newline at end of file diff --git a/resources/test/result_some_gbn.cql b/resources/test/result_some_gbn.cql index 8a76a3db..da5fbe35 100644 --- a/resources/test/result_some_gbn.cql +++ b/resources/test/result_some_gbn.cql @@ -76,18 +76,14 @@ define Diagnosis: if InInitialPopulation then [Condition] else {} as List define function DiagnosisCode(condition FHIR.Condition): -condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() - -define function DiagnosisCode(condition FHIR.Condition, specimen FHIR.Specimen): Coalesce( condition.code.coding.where(system = 'http://hl7.org/fhir/sid/icd-10').code.first(), condition.code.coding.where(system = 'http://fhir.de/CodeSystem/dimdi/icd-10-gm').code.first(), - condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first(), - specimen.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code.first() - ) + condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() +) define InInitialPopulation: -((((Patient.gender = 'other') or (Patient.gender = 'male'))) and (((((exists[Condition: Code 'C24' from icd10]) or (exists[Condition: Code 'C24' from icd10gm]) or (exists[Condition: Code 'C24' from icd10gmnew])) or (exists from [Specimen] S where (S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code contains 'C24'))))) and (exists from [Condition] C +((((Patient.gender = 'other') or (Patient.gender = 'male'))) and (((((exists[Condition: Code 'C24' from icd10]) or (exists[Condition: Code 'C24' from icd10gm]) or (exists[Condition: Code 'C24' from icd10gmnew])))))) and (exists from [Condition] C where AgeInYearsAt(FHIRHelpers.ToDateTime(C.onset)) between Ceiling(1) and Ceiling(11)) and (exists from [Condition] C where FHIRHelpers.ToDateTime(C.onset) between @2023-10-29 and @2023-10-30) and (exists from [Observation: Code '39156-5' from loinc] O where ((O.value as Quantity) < 1 'kg/m2' and (O.value as Quantity) > 111 'kg/m2')) and (exists from [Observation: Code '29463-7' from loinc] O diff --git a/src/projects/bbmri/mod.rs b/src/projects/bbmri/mod.rs index 5669e6c7..0c705d52 100644 --- a/src/projects/bbmri/mod.rs +++ b/src/projects/bbmri/mod.rs @@ -57,7 +57,7 @@ pub static CQL_SNIPPETS: LazyLock define function DiagnosisCode(condition FHIR.Condition): -condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() - -define function DiagnosisCode(condition FHIR.Condition, specimen FHIR.Specimen): Coalesce( condition.code.coding.where(system = 'http://hl7.org/fhir/sid/icd-10').code.first(), condition.code.coding.where(system = 'http://fhir.de/CodeSystem/dimdi/icd-10-gm').code.first(), - condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first(), - specimen.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code.first() - ) + condition.code.coding.where(system = 'http://fhir.de/CodeSystem/bfarm/icd-10-gm').code.first() +) define InInitialPopulation: {{retrieval_criteria}} \ No newline at end of file