
DICOMweb, HL7 FHIR, DuckDB Cohort Indexing, and OMOP MI-CDM
Source:vignettes/interop_fhir_and_omop.Rmd
interop_fhir_and_omop.RmdOverview
dicomtk 0.5.0 introduces standards-compliant medical
imaging interoperability:
-
DICOMweb (PS3.18):
as_dicom_json(),from_dicom_json(),pack_multipart_dicom(),unpack_multipart_dicom(),dicomweb_qido(),dicomweb_wado(),dicomweb_stow(), anddicomweb_metadata()with OAuth2/Bearer/Basic authentication. -
HL7 FHIR R4/R5:
as_fhir_imaging_study(),from_fhir_imaging_study(),as_fhir_imaging_selection(),as_fhir_diagnostic_report(),as_fhir_provenance(),as_w3c_prov(), andlink_synthea_cohort(). -
DuckDB / Parquet Archive Index & Guardrailed
NL-to-SQL:
dicom_index_build(),dicom_index_query(),validate_readonly_sql(),dicom_cohort_nl(),export_cohort_spec(), andrun_cohort_spec(). -
OHDSI OMOP MI-CDM:
to_omop_image_occurrence(),to_omop_image_feature(), andwrite_omop_micdm()backed byomop_imaging_concepts.
1. Archive Index & Guardrailed NL-to-SQL Cohort Builder
library(dicomtk)
synth <- dicom_synthesize(modality = "CT", dims = c(16L, 16L, 3L), phi_profile = "basic")
idx <- dicom_index_build(synth[["out_dir"]])
cohort <- dicom_cohort_nl(idx, "CT series with at least 2 instances")
cohort$sql
#> [1] "SELECT SeriesInstanceUID, StudyInstanceUID, Modality, SeriesDescription, BodyPartExamined, SliceThickness, n_instances FROM series WHERE Modality = 'CT' AND n_instances >= 2"
cohort$results
#> # A tibble: 1 × 7
#> SeriesInstanceUID StudyInstanceUID Modality SeriesDescription BodyPartExamined
#> <chr> <chr> <chr> <chr> <chr>
#> 1 2.25.17946692018… 2.25.1794669201… CT "" ""
#> # ℹ 2 more variables: SliceThickness <dbl>, n_instances <int>2. HL7 FHIR ImagingStudy & OHDSI OMOP
MI-CDM
vol <- read_dicom_volume(synth[["out_dir"]])
fhir_study <- as_fhir_imaging_study(vol, patient_ref = "Patient/p-001")
fhir_study$resourceType
#> [1] "ImagingStudy"
occ <- to_omop_image_occurrence(idx)
occ[, c("image_occurrence_id", "modality_concept_id", "image_study_uid")]
#> # A tibble: 1 × 3
#> image_occurrence_id modality_concept_id image_study_uid
#> <int> <int> <chr>
#> 1 1 4300757 2.25.179466920183402667200000010001
dicom_index_close(idx)
unlink(synth[["out_dir"]], recursive = TRUE)