Skip to content

Commit

Permalink
Merge pull request #151 from samply/develop
Browse files Browse the repository at this point in the history
CQL generation and some other stuff
  • Loading branch information
enola-dkfz authored Jun 20, 2024
2 parents 072ffdd + 28ed3d3 commit 0f4dfe4
Show file tree
Hide file tree
Showing 32 changed files with 2,143 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
#architectures: '[ "amd64", "arm64" ]'
#profile: debug
test-via-script: false
#features: '[ "" ]'
features: '[ "bbmri", "dktk", "" ]'
push-to: ${{ (github.ref_protected == true || github.event_name == 'workflow_dispatch') && 'dockerhub' || 'ghcr' }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ dev/pki/*
!dev/pki/pki
Cargo.lock
.vscode/*
pkg/
16 changes: 12 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "focus"
version = "0.5.2"
version = "0.6.0"
edition = "2021"
license = "Apache-2.0"

Expand All @@ -13,9 +13,14 @@ reqwest = { version = "0.11", default_features = false, features = ["json", "def
serde = { version = "1.0.152", features = ["serde_derive"] }
serde_json = "1.0"
thiserror = "1.0.38"
chrono = "0.4.31"
indexmap = "2.1.0"
tokio = { version = "1.25.0", default_features = false, features = ["signal", "rt-multi-thread", "macros"] }
beam-lib = { git = "https://github.com/samply/beam", branch = "develop", features = ["http-util"] }
laplace_rs = {git = "https://github.com/samply/laplace-rs.git", tag = "v0.3.0" }
uuid = "1.8.0"
rand = { default-features = false, version = "0.8.5" }
futures-util = { version = "0.3", default-features = false, features = ["std"] }

# Logging
tracing = { version = "0.1.37", default_features = false }
Expand All @@ -26,12 +31,15 @@ once_cell = "1.18"

# Command Line Interface
clap = { version = "4", default_features = false, features = ["std", "env", "derive", "help", "color"] }
rand = { default-features = false, version = "0.8.5" }
futures-util = { version = "0.3", default-features = false, features = ["std"] }

[features]
default = []
bbmri = []
dktk = []

[dev-dependencies]
tokio-test = "0.4.2"
pretty_assertions = "1.4.0"
tokio-test = "0.4.2"

[build-dependencies]
build-data = "0"
Expand Down
32 changes: 26 additions & 6 deletions README.md

Large diffs are not rendered by default.

File renamed without changes.
2 changes: 1 addition & 1 deletion resources/cql/BBMRI_STRAT_DIAGNOSIS_STRATIFIER
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ define Diagnosis:
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())
specimen.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code.first())

File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion resources/test/query_bbmri.cql
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ define Diagnosis:
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())
specimen.extension.where(url='https://fhir.bbmri.de/StructureDefinition/SampleDiagnosis').value.coding.code.first())



Expand Down
86 changes: 86 additions & 0 deletions resources/test/result_age_at_diagnosis_30_to_70.cql
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
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'


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 else {} as List<Specimen>

define Diagnosis:
if InInitialPopulation then [Condition] else {} as List<Condition>

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()
)

define InInitialPopulation:
((((exists from [Condition] C
where AgeInYearsAt(FHIRHelpers.ToDateTime(C.onset)) between Ceiling(30) and Ceiling(70)))))
86 changes: 86 additions & 0 deletions resources/test/result_age_at_diagnosis_lower_than_70.cql
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
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'


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 else {} as List<Specimen>

define Diagnosis:
if InInitialPopulation then [Condition] else {} as List<Condition>

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()
)

define InInitialPopulation:
((((exists from [Condition] C
where AgeInYearsAt(FHIRHelpers.ToDateTime(C.onset)) between Ceiling(0) and Ceiling(70)))))
Loading

0 comments on commit 0f4dfe4

Please sign in to comment.