-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathresult_lens2.cql
More file actions
84 lines (74 loc) · 7.09 KB
/
result_lens2.cql
File metadata and controls
84 lines (74 loc) · 7.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
library Retrieve
using FHIR version '4.0.0'
include FHIRHelpers version '4.0.0'
codesystem icd10: 'http://hl7.org/fhir/sid/icd-10'
codesystem SampleMaterialType: 'https://fhir.bbmri.de/CodeSystem/SampleMaterialType'
codesystem icd10gm: 'http://fhir.de/CodeSystem/dimdi/icd-10-gm'
codesystem icd10gmnew: 'http://fhir.de/CodeSystem/bfarm/icd-10-gm'
codesystem StorageTemperature: 'https://fhir.bbmri.de/CodeSystem/StorageTemperature'
context Patient
define AgeClass:
if (Patient.birthDate is null) then 'unknown' else ToString((AgeInYears() div 10) * 10)
define Gender:
if (Patient.gender is null) then 'unknown' else Patient.gender
define Custodian:
First(from Specimen.extension E
where E.url = 'https://fhir.bbmri.de/StructureDefinition/Custodian'
return (E.value as Reference).identifier.value)
define function SampleType(specimen FHIR.Specimen):
case FHIRHelpers.ToCode(specimen.type.coding.where(system = 'https://fhir.bbmri.de/CodeSystem/SampleMaterialType').first())
when Code 'plasma-edta' from SampleMaterialType then 'blood-plasma'
when Code 'plasma-citrat' from SampleMaterialType then 'blood-plasma'
when Code 'plasma-heparin' from SampleMaterialType then 'blood-plasma'
when Code 'plasma-cell-free' from SampleMaterialType then 'blood-plasma'
when Code 'plasma-other' from SampleMaterialType then 'blood-plasma'
when Code 'plasma' from SampleMaterialType then 'blood-plasma'
when Code 'tissue-formalin' from SampleMaterialType then 'tissue-ffpe'
when Code 'tumor-tissue-ffpe' from SampleMaterialType then 'tissue-ffpe'
when Code 'normal-tissue-ffpe' from SampleMaterialType then 'tissue-ffpe'
when Code 'other-tissue-ffpe' from SampleMaterialType then 'tissue-ffpe'
when Code 'tumor-tissue-frozen' from SampleMaterialType then 'tissue-frozen'
when Code 'normal-tissue-frozen' from SampleMaterialType then 'tissue-frozen'
when Code 'other-tissue-frozen' from SampleMaterialType then 'tissue-frozen'
when Code 'tissue-paxgene-or-else' from SampleMaterialType then 'tissue-other'
when Code 'derivative' from SampleMaterialType then 'derivative-other'
when Code 'liquid' from SampleMaterialType then 'liquid-other'
when Code 'tissue' from SampleMaterialType then 'tissue-other'
when Code 'serum' from SampleMaterialType then 'blood-serum'
when Code 'cf-dna' from SampleMaterialType then 'dna'
when Code 'g-dna' from SampleMaterialType then 'dna'
when Code 'blood-plasma' from SampleMaterialType then 'blood-plasma'
when Code 'tissue-ffpe' from SampleMaterialType then 'tissue-ffpe'
when Code 'tissue-frozen' from SampleMaterialType then 'tissue-frozen'
when Code 'tissue-other' from SampleMaterialType then 'tissue-other'
when Code 'derivative-other' from SampleMaterialType then 'derivative-other'
when Code 'liquid-other' from SampleMaterialType then 'liquid-other'
when Code 'blood-serum' from SampleMaterialType then 'blood-serum'
when Code 'dna' from SampleMaterialType then 'dna'
when Code 'buffy-coat' from SampleMaterialType then 'buffy-coat'
when Code 'urine' from SampleMaterialType then 'urine'
when Code 'ascites' from SampleMaterialType then 'ascites'
when Code 'saliva' from SampleMaterialType then 'saliva'
when Code 'csf-liquor' from SampleMaterialType then 'csf-liquor'
when Code 'bone-marrow' from SampleMaterialType then 'bone-marrow'
when Code 'peripheral-blood-cells-vital' from SampleMaterialType then 'peripheral-blood-cells-vital'
when Code 'stool-faeces' from SampleMaterialType then 'stool-faeces'
when Code 'rna' from SampleMaterialType then 'rna'
when Code 'whole-blood' from SampleMaterialType then 'whole-blood'
when Code 'swab' from SampleMaterialType then 'swab'
when Code 'dried-whole-blood' from SampleMaterialType then 'dried-whole-blood'
when null then 'Unknown'
else 'Unknown'
end
define Specimen:
if InInitialPopulation then [Specimen] S where (((((( (S.type.coding.code contains 'tissue-frozen')) or ( (S.type.coding.code contains 'tumor-tissue-frozen')) or ( (S.type.coding.code contains 'normal-tissue-frozen')) or ( (S.type.coding.code contains 'other-tissue-frozen')))) or ((( (S.type.coding.code contains 'blood-serum')) or ( (S.type.coding.code contains 'serum')))))) or ((((( (S.type.coding.code contains 'liquid-other')) or ( (S.type.coding.code contains 'liquid')))) or ((( (S.type.coding.code contains 'rna')))) or ((( (S.type.coding.code contains 'urine'))))) and (((((S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/StorageTemperature').value.coding.code contains 'temperatureRoom')))) or ((((S.extension.where(url='https://fhir.bbmri.de/StructureDefinition/StorageTemperature').value.coding.code contains 'four_degrees'))))))) else {} as List<Specimen>
define Diagnosis:
if InInitialPopulation then [Condition] else {} as List<Condition>
define function DiagnosisCode(condition FHIR.Condition):
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()
)
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[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) ))))))