Imaging study arrival to FHIR ImagingStudy
Take DICOM objects a modality sends by C-STORE, record each new study as a FHIR ImagingStudy, and optionally forward every object to a PACS.
On this page
When a CT, MR or ultrasound modality finishes a study, it sends each image to a storage SCP by DICOM C-STORE. This recipe makes MedHook that SCP. The DICOM listener stores each object, the workflow writes an ImagingStudy for the study to a FHIR server so other systems learn that images exist, and an optional second destination forwards the object to a PACS. It replaces a Mirth channel with a DICOM Listener source and a DICOM Sender destination.
Source and destination
The modality sends to the MedHook DICOM listener. Each object becomes one run with the object's metadata and a signed reference to it; the image itself never enters the run.
flowchart LR
A[Modality] -->|C-STORE| B[DICOM listener]
B -->|metadata + signed object ref| C[dicom trigger]
C --> D[JavaScript, Data Map]
D -->|ImagingStudy, If-None-Exist| E[FHIR R4 server]
C -->|object ref| F[DICOM send]
F -->|C-STORE| G[PACS]- Source: DICOM objects from a modality (or a router or another PACS), sent by C-STORE.
- Destination: any FHIR R4 server a FHIR REST profile can reach, and optionally a PACS or other storage SCP.
- Result: one ImagingStudy per study, and each object forwarded to the PACS.
What it uses
- The DICOM listener, turned on by your operator with Helm
dicom.enabled(or thedicomCompose profile), and thedicomtrigger. - A JavaScript step and a field mapping step (the destination's Data Map).
- Adapter
fhir-rest, actioncreatewithifNoneExist. - Optional: adapter
dicom, actionsend.
The listener
Your operator sets the listener's AE title and the AE titles allowed to call it, for example in Helm:
dicom:
enabled: true
aeTitle: MEDHOOK
allowedCallingAeTitles: ["DEMO-CT1"]
networkPolicy:
allowedCidrs: ["10.20.30.0/24"] # the modality networkAn AE title is not authentication: any host that reaches the port can claim DEMO-CT1. Keep the port reachable only from the modality network (allowedCidrs, loadBalancerSourceRanges, or a VPN), and on a shared network turn on TLS with client certificates. See Who may send.
On the modality, add a storage destination with the listener's address, port (11112 by default) and AE title (MEDHOOK), and its own AE title DEMO-CT1. Most modalities have a Verify button that sends a C-ECHO: it should succeed before you send a study.
The trigger
The trigger takes objects that DEMO-CT1 sends to MEDHOOK:
{
"type": "dicom",
"calledAeTitle": "MEDHOOK",
"callingAeTitles": ["DEMO-CT1"]
}Each run's input is the object's metadata and its reference:
{
"triggerType": "dicom",
"triggerId": "trg_demo_ct",
"callingAeTitle": "DEMO-CT1",
"calledAeTitle": "MEDHOOK",
"sopClassUid": "1.2.840.10008.5.1.4.1.1.2",
"sopInstanceUid": "2.25.1001",
"transferSyntaxUid": "1.2.840.10008.1.2.1",
"studyInstanceUid": "2.25.1000",
"seriesInstanceUid": "2.25.1000.1",
"modality": "CT",
"accessionNumber": "DEMO-ACC-0001",
"patientId": "DEMO-MRN-0001",
"studyDate": "20261001",
"object": { "store": "local", "key": "2026/10/01/…", "sig": "…" }
}The FHIR destination
Add a destination named FHIR server with two output steps. A Data Map has no operation that adds a prefix, so a JavaScript step first writes the two values FHIR wants as URNs:
return {
...input,
studyUrn: `urn:oid:${input.studyInstanceUid}`,
sopClassUrn: `urn:oid:${input.sopClassUid}`,
};Then a Data map → JSON step builds the ImagingStudy. Rows whose source the input does not have ($.fixed) write their default, which is how a Data Map sets a fixed value:
| Source | Target | Rule |
|---|---|---|
$.fixed | status | default available |
$.fixed | identifier[0].system | default urn:dicom:uid |
$.studyUrn | identifier[0].value | |
$.fixed | identifier[1].type.coding[0].system | default http://terminology.hl7.org/CodeSystem/v2-0203 |
$.fixed | identifier[1].type.coding[0].code | default ACSN |
$.accessionNumber | identifier[1].value | |
$.fixed | subject.identifier.system | default urn:demohealth:mrn (your MRN system) |
$.patientId | subject.identifier.value | |
$.studyDate | started | op date-format from YYYYMMDD to YYYY-MM-DD |
$.fixed | modality[0].system | default http://dicom.nema.org/resources/ontology/DCM |
$.modality | modality[0].code | |
$.seriesInstanceUid | series[0].uid | |
$.fixed | series[0].modality.system | default http://dicom.nema.org/resources/ontology/DCM |
$.modality | series[0].modality.code | |
$.sopInstanceUid | series[0].instance[0].uid | |
$.fixed | series[0].instance[0].sopClass.system | default urn:ietf:rfc:3986 |
$.sopClassUrn | series[0].instance[0].sopClass.code |
The subject is a logical reference by MRN. If your FHIR server needs a literal Patient/{id} reference, look the patient up first (a search step) and map its id instead. An object without a Study Date leaves started out.
The send step's config names the resource type and turns on the duplicate check:
{ "resourceType": "ImagingStudy", "ifNoneExist": "identifier" }With ifNoneExist set to identifier, the create sends the study's first identifier (urn:dicom:uid|urn:oid:<Study Instance UID>) as If-None-Exist. A study arrives as many objects, one run each: the first creates the ImagingStudy and the rest find it and create nothing new.
Forward to a PACS (optional)
Add a second destination named PACS with no output step, so it sends the run's input as it arrived, and a Send on a DICOM profile with action send:
{
"name": "Demo PACS",
"adapterType": "dicom",
"config": {
"host": "pacs.demohealth.example.test",
"port": 11112,
"calledAeTitle": "DEMO-PACS",
"callingAeTitle": "MEDHOOK",
"tlsEnabled": true
}
}The step reads the object back by the object reference and sends it by C-STORE. The reference only works for runs of the trigger that received the object, until DICOM_STORE_RETENTION_DAYS (30 days by default) passes, so replay a failed forward within that time. The PACS must know MedHook's AE title (MEDHOOK), and Test connection sends a C-ECHO.
Test it with a synthetic object
Write a test object with no real patient in it, for example with dcmtk's dump2dcm from this dump:
(0008,0016) UI =CTImageStorage
(0008,0018) UI [2.25.1001]
(0008,0020) DA [20261001]
(0008,0050) SH [DEMO-ACC-0001]
(0008,0060) CS [CT]
(0010,0010) PN [TESTPATIENT^ALEX]
(0010,0020) LO [DEMO-MRN-0001]
(0020,000d) UI [2.25.1000]
(0020,000e) UI [2.25.1000.1]dump2dcm demo-ct.dump demo-ct.dcm
echoscu -aet DEMO-CT1 -aec MEDHOOK dicom.demohealth.example.test 11112
storescu -aet DEMO-CT1 -aec MEDHOOK dicom.demohealth.example.test 11112 demo-ct.dcmstorescu reports Success once the run is recorded. The execution shows the metadata above and the ImagingStudy the FHIR destination created. Send the same file again: the run is not repeated, because the trigger drops a resend of the same SOP Instance UID from the same sender.
Status
Available on this release for the study, its first series and its first instance.
The ImagingStudy is created from the first object of a study. Later series and instances of the same study do not update it, and numberOfSeries and numberOfInstances are not counted; keeping a full instance list needs a read and an update per object, which is not part of this recipe. MedHook does not serve the images (no WADO-RS or endpoint): point viewers at the PACS. The run's input holds the patient id and accession number, so treat executions as PHI.