Skip to content

FHIR & HL7 bridges

The imaging ↔ EHR seam: turn a DICOM instance into a FHIR ImagingStudy, and read or build HL7 v2 messages — so an app or agent can move a study between the imaging world and a clinical system without a separate mapping layer.

DICOM → FHIR ImagingStudy

from pydcm import fhir

study = fhir.imaging_study("CT0001.dcm")   # dict — a FHIR R4 ImagingStudy resource
study["resourceType"]                       # "ImagingStudy"
study["series"][0]["instance"]

The study / series / instance hierarchy and a contained Patient are mapped from the DICOM headers. Serialize the dict with json.dumps to hand it to any FHIR consumer.

HL7 v2 — parse

from pydcm import hl7

segments = hl7.parse(message_text)         # list of segment dicts

HL7 v2 — build an ORU^R01 result

oru = hl7.build_oru(
    config={...},          # sending/receiving application + facility
    context={...},         # patient + order identifiers
    observations=[...],    # OBX result rows
)                          # → ER7 string ready to send back to the HIS

These bridges are pydcm's own API over the native FHIR / HL7 engines — there is no third-party Python FHIR or HL7 library in the loop.