DICOM Integration
OctoFHIR’s built-in DICOMweb connector imports metadata only from an external
PACS. DICOM objects, frames and pixel data stay in PACS. The server stores an
ImagingStudy and a credential-free Endpoint pointing to the WADO-RS service.
FHIR R4, R4B and R5 are supported. No connection is enabled by default.
Portable FHIR API and clients
Section titled “Portable FHIR API and clients”The interoperable data contract is ordinary FHIR REST. External tools can publish and consume Patient, ImagingStudy, Endpoint, Task, DocumentReference, DiagnosticReport and Provenance on a FHIR server supporting the required resources and interactions. Images remain in the DICOMweb archive referenced by Endpoint; a consumer uses that address with its PACS credentials.
| Action | Standard HTTP interface |
|---|---|
| Find a Patient by an assigning authority and identifier | GET [fhir-base]/Patient?identifier=system|value |
| Publish linked resources atomically | POST [fhir-base] with a transaction Bundle |
| Find a patient’s studies | GET [fhir-base]/ImagingStudy?patient=Patient/id |
| Discover the DICOMweb service | GET [fhir-base]/Endpoint/id |
| Create/read an imaging task | POST [fhir-base]/Task, GET [fhir-base]/Task/id |
| Record worker progress | PUT [fhir-base]/Task/id with If-Match |
| Publish result references and provenance | a transaction containing Task, DocumentReference/DiagnosticReport and Provenance |
| Retrieve a frame | WADO-RS GET [dicom-base]/studies/{study}/series/{series}/instances/{instance}/frames/1 |
Typical usage
Section titled “Typical usage”- Configure the FHIR base URL and obtain a FHIR access token with the required resource permissions. Configure the PACS base URL and its credential separately.
- A data publisher supplies Patient/Endpoint/ImagingStudy resources. If another integration already publishes them, start by querying those resources. Otherwise an external converter can send a standard transaction Bundle, or OctoFHIR’s configured built-in importer can populate them. The publisher maps PACS PatientID and issuer to Patient.identifier; Patient.id is not assumed to equal PatientID.
- Find the Patient through ordinary FHIR search, then retrieve its ImagingStudy. Resolve the study/series Endpoint and use its WADO-RS address to retrieve an instance or a frame. Use the raw Study/Series/SOP UIDs for DICOMweb URLs.
- For processing, create a normal Task linked to the Patient and ImagingStudy. The authorized worker records accepted/in-progress states and publishes actual result references together with Task completion and Provenance.
For example, an external worker can accept this ordinary FHIR request after the referenced resources exist. Replace the example IDs with the server’s real IDs:
POST [fhir-base]/TaskAuthorization: Bearer <FHIR token>Content-Type: application/fhir+json
{ "resourceType": "Task", "status": "requested", "intent": "order", "code": {"text": "Review imaging study"}, "for": {"reference": "Patient/patient-123"}, "focus": {"reference": "ImagingStudy/study-123"}}Task codes, ownership and processing semantics are agreed with the worker. Read
progress through GET [fhir-base]/Task/id; resolve its output references through
normal FHIR reads. DocumentReference/DiagnosticReport contain metadata and DICOM
retrieval references. Image bytes remain in PACS.
The walkthrough provides copyable client commands for capability discovery, publishing a Bundle, finding studies, reading a Task and downloading one frame. Local/private IG setup is documented in Local implementation guide packages.
FHIR Task creation records a request. An authorized processing worker performs the actual work and records its confirmed states/results. A generic FHIR server is not required to execute Tasks or submit them to UPS merely because they were created. Cancellation requests and confirmed cancellation must remain distinct in that processing contract.
The repository includes a server-neutral Python client and walkthrough
and scripts/test-dicom-standard-api.py. The same R4 scenario runs against
OctoFHIR and an independent HAPI FHIR instance with request validation enabled.
It covers standard transactions, reference resolution, search, ETags, exact
synthetic WADO-RS frame bytes, and Task/result/Provenance publication. The dedicated
docker-compose.fhir-interop.yml file provides pinned HAPI/Orthanc images for
reproduction.
These clients require no OctoFHIR operations, ownership tags, StorageProvider
resources or database access. The built-in $dicom-* operations below remain
available as additional server-side automation through the
FHIR extended operation framework.
They are implementation-defined operations, rather than universally defined
DICOM/FHIR operation names.
Configure a connection
Section titled “Configure a connection”dicom.max_concurrent_imports defaults to 2 (range 1..16). Imports reserve
separate PostgreSQL advisory-lock sessions, outside the FHIR connection pool.
Allow this many additional database connections when sizing a deployment.
Concurrent imports of the same connection/study return a retryable conflict.
[dicom.connections.hospital]wado_url = "https://pacs.example.org/dicom-web"bearer_token_env = "PACS_BEARER_TOKEN" # optional when the PACS needs no credentialtimeout_seconds = 30max_metadata_bytes = 67108864 # 64 MiB per PACS metadata response; maximum 64 MiBmax_instances = 10000
[dicom.connections.hospital.patient_identifier_systems]HOSPITAL = "https://hospital.example.org/mrn"The mapping translates DICOM Issuer of Patient ID to the FHIR identifier
system used by an existing Patient. If an archive omits the issuer, explicitly
set default_patient_issuer = "HOSPITAL" in the connection table. Unmapped or
missing authorities fail import. Patient names are never used for identity.
Use server.outbound_allowlist for a PACS on a private network. HTTPS is the
default; allow_http = true explicitly allows HTTP for a trusted deployment.
URLs cannot contain credentials, query strings or fragments. Redirects and
environment HTTP proxies are disabled. Credentials never enter FHIR resources.
Changing connections requires a server restart.
max_metadata_bytes defaults to 64 MiB and can be lowered per connection. It
bounds each PACS metadata response, including a whole study, with or without
Content-Length. Large MR studies can exceed the former 8 MiB default. This limit
is independent of server.body_limit_bytes and reverse-proxy request-body limits:
those control incoming requests, rather than metadata retrieved from PACS.
Import or refresh one study
Section titled “Import or refresh one study”POST /fhir/Patient/patient-123/$dicom-importAuthorization: Bearer <FHIR access token>Content-Type: application/fhir+json
{ "resourceType": "Parameters", "parameter": [ {"name": "connection", "valueString": "hospital"}, {"name": "study", "valueString": "1.2.840.113619.2.1"} ]}study is the raw Study Instance UID, without urn:oid:. The operation requests
only GET {wado_url}/studies/{uid}/metadata using application/dicom+json. The
response must be a bounded JSON array of consistent instance datasets.
The caller must be allowed to read the selected Patient and imported resources, and create/update the generated Endpoint and ImagingStudy. SMART interaction scopes and resource policies still apply. A PACS credential never grants FHIR privileges. This operation does not accept arbitrary destination URLs or a skip-validation flag.
Every instance’s PatientID and assigning authority must match an identifier of the selected Patient. Endpoint and ImagingStudy changes commit in one normal FHIR transaction, including validation, reference integrity and resource events. An import failure does not commit half of that transaction.
The response contains references, not images:
{ "resourceType": "Parameters", "parameter": [ {"name": "imagingStudy", "valueReference": {"reference": "ImagingStudy/dicom-..."}}, {"name": "endpoint", "valueReference": {"reference": "Endpoint/dicom-..."}}, {"name": "changed", "valueBoolean": true} ]}Identity and repeat imports
Section titled “Identity and repeat imports”Resource IDs are stable per connection and study. Identical re-imports return
changed: false without adding history versions. Changed projections use ETags
to protect against concurrent updates. Existing resources must carry the
connector’s ownership tag; an occupied ID is not silently adopted. Patient
reassignment is rejected.
The connector owns study status, subject, endpoint, counts, modality, series,
description and started date. Other clinical fields, metadata and security labels
are preserved. Series and instances are sorted by UID. Counts describe the
returned metadata snapshot; available does not mean acquisition or reporting
is complete. Study Date is imported with date precision, without inventing a
timezone for a DICOM local clock.
Separate connections produce separate archive representations, even for the same Study UID. Renaming a connection therefore changes generated identities.
Discovery and durable synchronization
Section titled “Discovery and durable synchronization”QIDO discovery is configured separately from WADO retrieval. Enable it with an explicit registered backend client; the connector never derives FHIR permissions from its PACS credential. For a fresh local deployment, bootstrap can create that client before synchronization starts:
[bootstrap.backend_client]client_id = "dicom-sync"# Supply OCTOFHIR__BOOTSTRAP__BACKEND_CLIENT__CLIENT_SECRET in the environment.scopes = ["system/Patient.rs", "system/ImagingStudy.cru", "system/Endpoint.cru"]
[dicom.connections.hospital]wado_url = "https://pacs.example.org/dicom-web"qido_url = "https://pacs.example.org/dicom-web"bearer_token_env = "PACS_BEARER_TOKEN"patient_identifier_systems = { HOSPITAL = "https://hospital.example.org/mrn" }
[dicom.connections.hospital.sync]client_id = "dicom-sync"scopes = ["system/Patient.rs", "system/ImagingStudy.cru", "system/Endpoint.cru"]discovery = "scan" # or "notifications" for an external event adapterrescan_seconds = 300page_size = 100pages_per_run = 4max_studies_per_scan = 1000000retry_seconds = 5Provision the same scopes on an existing active client in an established database. Startup checks the client and its grants. Background work rechecks registration and applies ordinary resource policies. Revoking the client stops useful work. Use a distinct connection name when changing the PACS URL, assigning authorities or synchronization identity/scopes: persisted source identity cannot silently move to another archive. Credential rotation and polling limits can change on restart.
scan performs bounded repeated QIDO pages with offset and limit, continuing
until an empty page even if PACS returns fewer records than requested. StudyDate
is never a change cursor: a prior imported today may have a decades-old date.
Offset scans converge on a stable archive; they are not a snapshot guarantee while
the archive is changing. A page limit failure remains visible for administrator
attention. Replayable vendor feeds and Repository Query cursors are not assumed;
an external source adapter can use the ordered notification interface below.
Each page and its queue entries commit together. Per-study revisions coalesce; workers re-read current WADO metadata, write through normal FHIR transactions and save their checkpoint atomically with those writes. Existing async-job leases fence competing server instances. Failed work remains queued with exponential retry, capped at one hour. No-op reconciliation does not add FHIR versions.
An unknown or ambiguous patient identifier requires manual reconciliation. The connector never creates a Patient. Its pinned patient does not change after correction, deletion/recreation of the FHIR representation, or process restart. An incomplete metadata response or a QIDO count larger than the returned manifest preserves the last complete representation and retries.
Ordered source notifications
Section titled “Ordered source notifications”Only the configured backend client, authenticated with all configured sync scopes, may submit control-plane requests. Anonymous development access does not enable them. Send a strictly increasing, nonnegative integer sequence per study (a source-wide monotonic sequence is also suitable). Keep it as a decimal string to avoid JSON number precision loss:
POST /fhir/$dicom-notifyAuthorization: Bearer <configured backend token>Content-Type: application/fhir+json
{ "resourceType": "Parameters", "parameter": [ {"name":"connection","valueString":"hospital"}, {"name":"study","valueString":"1.2.840.113619.2.1"}, {"name":"sequence","valueString":"1042"}, {"name":"change","valueString":"changed"} ]}Changes are changed, deleted, rejected or restored. The response’s
accepted boolean is false for a duplicate/stale sequence. Retransmit until an
acknowledgment is received; a response acknowledges durable enqueue, not completion
of the FHIR write. Requests for different studies can proceed independently.
Explicit deletion/rejection sets ImagingStudy status to unknown and the
connector’s dicom-availability extension to deleted/rejected, retaining its
manifest and clinical annotations. Only a newer restored notification clears
that override. Scans, timeouts, HTTP failures and disappearing query results never
infer deletion or silently restore rejected images. A successful fresh import
sets the extension to available; that is source availability, not clinical
completion.
POST /fhir/$dicom-sync-status with a single connection valueString returns
study/pending/failed counts, scan offset, last scan and a bounded error code.
POST /fhir/Patient/{id}/$dicom-discover with connection and optional issuer,
offset, limit valueStrings returns a patient-specific QIDO page. It verifies
every response identity before returning UIDs. Follow nextOffset until complete
is true. Discovery returns metadata and does not itself enqueue those studies;
use notifications or the configured scanner for reconciliation. Both operations
require the configured service identity.
Optional authorized DICOMweb gateway
Section titled “Optional authorized DICOMweb gateway”The expanded gateway surface below requires v0.0.6 or newer.
Direct PACS access remains the default. To publish a gateway Endpoint for one connection, add the following table and re-import/reconcile its studies:
[dicom]max_concurrent_streams = 16 # shared across connections; range 1..256
[dicom.connections.hospital.gateway]max_stream_bytes = 8589934592 # 8 GiB per response; enforced for chunked bodies toostream_seconds = 300 # total stream lifetime, up to 3600idle_seconds = 30 # maximum wait for the next PACS chunkmax_query_studies = 100 # bounded candidate set for a QIDO request; up to 1000max_query_bytes = 134217728 # 128 MiB transient query budget and metadata response capmax_query_studies and max_query_bytes require v0.0.6 or newer; v0.0.5
rejects these configuration keys. The query budget accounts for metadata and
projections across selected studies, so a broad query can require more than one
study’s PACS response limit. It also caps the encoded JSON/XML metadata response.
Exceeding a gateway metadata byte, instance or query budget returns HTTP 413;
refine the selection or adjust the corresponding connection/gateway setting.
The Endpoint then points to {server-base}/dicomweb/hospital. Every gateway GET
requires an authenticated FHIR identity and current, primary-backed read access
to both the ImagingStudy and its Patient. It checks an independent connector
manifest recorded in the same transaction as FHIR writes. Creating or editing
ownership tags, instance UIDs or a subject through FHIR CRUD cannot forge this
proof. Re-import repairs an altered projection; clinical notes and current
security-label policies remain effective without expanding membership.
Supported routes under that service root:
| Resource | GET path |
|---|---|
| Studies | /studies, optionally filtered by StudyInstanceUID, PatientID, date, name and other supported matching keys |
| Series | /series, /studies/{uid}/series |
| Instances | /instances, /studies/{uid}/instances, /studies/{uid}/series/{series}/instances |
| Metadata | /studies/{uid}/metadata, series or individual instance /metadata |
| DICOM objects | /studies/{uid}, /studies/{uid}/series/{series}, individual instance path |
| Frames | Instance path + /frames/1,2 |
| Renderings | Study, series, instance or frame path + /rendered |
| Thumbnails | Study, series, instance or frame path + /thumbnail |
| Pixel data | Study, series or instance path + /pixeldata |
| Other bulk data | Rewritten BulkDataURI returned in metadata |
OPTIONS [dicom-base] with Accept: application/vnd.sun.wadl+xml returns the
DICOM capabilities document. It requires authentication. A browser CORS preflight
remains a separate OPTIONS request with Origin and Access-Control-Request-Method.
QIDO searches the caller’s readable, attested FHIR studies. It obtains fresh PACS
metadata for matching and response attributes, including counts and gateway
Retrieve URLs. It supports keyword/tag keys, UID alternatives, wildcard matching,
case-insensitive person-name components, date/time ranges, supported sequence
item keys and repeated/comma-separated includefield. Use limit/offset for
pagination; additional results have a Link: rel=next and a Warning status-report
URL. Broad queries exceeding the configured candidate/metadata budget return 413;
an exact StudyInstanceUID avoids scanning unrelated studies. When qido_url is
configured, matching parameters (including fuzzymatching, non-Latin names and
PACS-specific keys) are forwarded to that origin, scoped to each authorized Study
Instance UID. The PACS decides matching semantics; fuzzy matches are not subjected
to a second exact-name comparison. Results are intersected with the admitted
manifest, and gateway pagination is applied afterwards. Origin pages and fresh
metadata share the query byte budget. Without qido_url, the gateway uses the
local matching rules above and cannot perform fuzzy matching.
Nested Series/Instance queries use the authorized Study UID in their resource path; the gateway does not duplicate it as a matching parameter on origins that reject redundant parent keys. The gateway recovers missing parent Study/Series UIDs from the authenticated resource path when an origin omits them; child UIDs remain mandatory and must match the manifest. Patient discovery recovers missing patient identity fields from a complete WADO metadata snapshot only when every instance agrees on the same Study UID and configured patient identifier system. It never guesses an assigning authority. Single-instance and single-workitem retrieval also accept a bare DICOM JSON object and normalize it to the gateway’s standard array response.
With qido_url, includefield is also forwarded, including repeated values,
arbitrary origin-supported keywords, hexadecimal/private tags, sequences and
all. The PACS resolves field names. Returned attributes retain their DICOM JSON
structure; fresh verified instance metadata takes precedence, and counts/Retrieve
URLs describe the authorized gateway collection. Bulk references are exposed only
when they can be bound to verified instance metadata and rewritten to the gateway.
Metadata and QIDO support both application/dicom+json and multipart
application/dicom+xml (Native DICOM Model). Accept is required; query accept
preferences must agree with the header. q-values and exclusions are respected.
Local metadata is UTF-8; unsupported charset names are ignored. Unavailable
representations return 406. Frame lists must be positive and strictly ascending.
Study/series responses are assembled from their admitted instance set. They never request a live whole-study export from PACS, so late arrivals cannot enter the response before reconciliation. Authorization captures the current primary-backed manifest at request admission; each subsequent PACS GET verifies the exact SOP tuple and admitted Patient identity afresh. Thumbnails use a deterministic authorized representative. Renderings and transfer-syntax conversion are supplied by PACS; OctoFHIR does not run an image codec or inference engine.
Accept, including Transfer Syntax parameters, and a single byte Range are
forwarded; supported upstream multipart bodies remain byte-for-byte streams.
Rendering accepts viewport, window, quality, iccprofile and annotation.
Single-resource Range requests are forwarded; generated collection responses
reject byte ranges. Caller credentials/cookies are never forwarded to PACS, and upstream cookies,
redirects and HTML error bodies are not forwarded to the viewer. Bulk references
are resolved from the exact instance’s fresh metadata and rewritten as tag-path
tokens with absolute gateway URLs. Opaque bulk paths and source query strings are
allowed inside the configured DICOMweb origin/service path. Cross-origin,
cross-service, credential-bearing and escaping targets are rejected. A request
cannot supply its own fetch URL. InlineBinary attributes can supply bounded native
bulk bytes; they are not interpreted as another transfer syntax.
Backpressure reaches the PACS connection. Disconnecting the downstream caller
cancels its upstream body and releases the concurrency slot. Only bounded metadata
is buffered; image bytes are never saved in PostgreSQL, job bodies, Binary or S3.
Responses use Cache-Control: no-store. A midstream timeout/limit interrupts the
body; an error OperationOutcome cannot replace a body whose headers were sent.
Collection multipart headers/parts and the complete output share bounded limits.
For example, with a bearer token and an already imported study:
curl -H "Authorization: Bearer $FHIR_TOKEN" \ -H 'Accept: application/dicom+json' \ "$DICOM_BASE/studies?StudyInstanceUID=$STUDY_UID&includefield=all"curl -H "Authorization: Bearer $FHIR_TOKEN" \ -H 'Accept: multipart/related; type="application/dicom"; transfer-syntax=*' \ "$DICOM_BASE/studies/$STUDY_UID" --output study.multipartcurl -X OPTIONS -H "Authorization: Bearer $FHIR_TOKEN" \ -H 'Accept: application/vnd.sun.wadl+xml' "$DICOM_BASE"STOW, UPS origin-server routes and arbitrary URL fetching are outside the gateway. The DICOM conformance statement records the exact role, media, query and backend boundaries; a compatible PACS supplies rendering and codec support.
UPS-RS Requestor and Watcher
Section titled “UPS-RS Requestor and Watcher”The optional UPS client submits an existing FHIR Task to an external UPS-RS Task Manager. Processing and inference run in an external Performer. OctoFHIR never claims the performer’s transaction UID, executes inference or stores its DICOM outputs. UPS events describe workitems; study arrival still uses discovery/sync.
[dicom.connections.hospital.ups]url = "https://pacs.example.org/ups"client_id = "imaging-worker"scopes = ["system/Task.ru", "system/Patient.r", "system/ImagingStudy.cru", "system/Endpoint.cru", "system/DiagnosticReport.cru", "system/DocumentReference.cru", "system/Provenance.cru"]ae_title = "OCTOFHIR"# bearer_token_env = "UPS_BEARER_TOKEN"notifications = true# Standard PS3.18 filter parameter. Use "legacy_query" for dcm4chee 5.35.2.subscription_filter_format = "standard"poll_seconds = 30retry_seconds = 5max_references = 10000# Defaults to {url}/subscribers/{ae_title}; set the declared same-origin WS endpoint if different.# notification_url = "wss://pacs.example.org/ups/subscribers/OCTOFHIR"# Optional destination advertised to the external performer, without credentials:# output_stow_url = "https://pacs.example.org/dicom-web"
[dicom.connections.hospital.ups.coding_schemes]# Use a private 99-prefixed designator for local procedure codes (for example 99OCTOFHIR)."https://hospital.example.org/procedures" = "99HOSPITAL""http://unitsofmeasure.org" = "UCUM"
[dicom.connections.hospital.ups.result_mappings."1.2.840.10008.5.1.4.1.1.88.22"]kind = "diagnostic_report"system = "https://hospital.example.org/results"code = "imaging-sr"report_status = "unknown" # explicit clinical policy; COMPLETED never implies final
[dicom.connections.hospital.ups.result_mappings."1.2.840.10008.5.1.4.1.1.66.4"]kind = "document_reference"system = "https://hospital.example.org/results"code = "segmentation"Provision and enable the configured backend Client with those scopes. Caller and worker permissions are independent and checked through the normal FHIR policies. Use a distinct AE title for each independent deployment/database sharing a Task Manager. Replicas sharing the same OctoFHIR database share its AE and source leadership; separate databases must not overwrite each other’s filtered subscription. Allow one additional PostgreSQL connection per notification-enabled source for watch leadership, in addition to the import-lock capacity. Credentials, private network allowlists and HTTPS rules follow the connection rules above. UPS can have its own credential reference. A notification URL must share the UPS origin.
Filtered subscriptions use filter=00741204=<source-prefix>* by default.
Task Managers such as dcm4chee 5.35.2 instead require top-level matching keys;
configure subscription_filter_format = "legacy_query" for those connections.
OctoFHIR never switches formats automatically after a rejected subscription:
an archive that ignores the other format could silently subscribe the AE to
every workitem. The selected format also applies during polling fallback and
WebSocket recovery. Clarus 0.3.1/0.3.2 accept the standard format, but their
wildcard-prefix notifications remain unsupported; exact-label filters work.
Create a Task with status: draft (or requested), intent: order, a local
for.reference: Patient/{id}, and focus.reference: ImagingStudy/{id} imported
from this connection. code must contain one supported Coding with a display;
map its system to a DICOM Coding Scheme Designator explicitly. Private/local
schemes should use a 99-prefixed designator such as 99OCTOFHIR; registered
schemes such as UCUM retain their registered designators
(PS3.3 8.2).
All attested input instances become UPS inputs, with Study Instance UID nested
inside Input Information Sequence (0040,4021), rather than at the workitem root.
Optional Task inputs support String, dateTime,
CodeableConcept and exact Quantity with explicitly mapped units. Unsupported
value types, routing fields, repetitions and unknown modifier extensions fail
admission. doNotPerform: true (including its standard modifier extension) cannot
be submitted as positive work. R5 requestedPeriod, or a supported restriction
period, supplies the scheduled interval; it is not an actual execution period.
POST /fhir/Task/task-123/$dicom-upsAuthorization: Bearer <FHIR access token>Content-Type: application/fhir+json
{"resourceType":"Parameters","parameter":[ {"name":"connection","valueString":"hospital"}, {"name":"action","valueString":"submit"}]}Actions are submit, cancel, refresh and status, all via POST. Status exposes
the stable workitem URI, source state, desired/applied revisions, pending job,
creation/cancellation flags and a bounded error code/message. Callers supply no
DICOM dataset, remote URL, credential, patient override or workitem UID.
Submission binds the patient’s identity and Task input projection permanently;
ordinary FHIR updates cannot reassign them. Clinical notes and security labels
remain editable under the normal resource policies. Active bindings block deletion.
Commands use the existing durable job executor and PostgreSQL leases/checkpoints.
The stable 2.25.… UID is saved before any remote create. A lost create response
is recovered by retrieving that same UID; an already confirmed item is never
recreated after disappearance. Fresh input metadata rechecks the patient and exact
instance membership before creation. Cancellation that wins before any create
attempt completes locally with cancelledBeforeSubmission; an uncertain earlier
POST remains explicitly uncertain until reconciliation. An accepted cancel request
alone never changes the Task to cancelled: only the Task Manager’s CANCELED state
can do so.
| UPS state | FHIR Task status |
|---|---|
| SCHEDULED | requested |
| IN PROGRESS | in-progress |
| COMPLETED | completed |
| CANCELED (also accepts CANCELLED from PACS) | cancelled |
The Watcher opens its WebSocket before creating a filtered global subscription
with deletion locks. Its persistent source-label namespace selects only its own
workitems. Bounded event messages only wake reconciliation: every state/result is
retrieved afresh, including comparison of the requested processing parameters.
Restart, reconnect and periodic polling recover missed events;
WebSocket transport is not treated as a replay log. notifications = false is an
explicit polling-only mode, without Watcher/deletion-lock guarantees. On permanent
source retirement, drain outstanding work, verify applied terminal checkpoints,
then remove that AE’s filtered global subscription through the Task Manager’s
administrative procedure. Simply disconnecting a WebSocket does not release locks.
Completed output references are read from the Performed Procedure Sequence, checked against newly imported PACS metadata and the pinned Patient, then published with the Task and Provenance in a normal FHIR transaction. Results may be in another Study. Configured SOP Class mappings produce DiagnosticReport or DocumentReference with retrieval URLs under the configured Endpoint. An unmapped output SOP Class blocks completion until an explicit result mapping is configured. No SR content is interpreted into measurements or conclusions. Whole-object references are supported; frame/segment subset references are rejected explicitly. Clinical annotations survive reconciliation. Patient/study security labels are inherited without removing operator labels. Only after the final FHIR checkpoint is applied does the Watcher release the workitem’s deletion lock.
Reproduce PACS interoperability locally
Section titled “Reproduce PACS interoperability locally”The repository provides pinned, loopback-only Docker profiles and a synthetic 16×16 Secondary Capture fixture. Use an isolated test archive with no clinical data. The normal metadata/gateway tests run without an external PACS. The opt-in test uploads the fixture to the explicitly selected archive and starts a disposable PostgreSQL-backed OctoFHIR instance.
export DICOM_TEST_DB_PASSWORD=local-pacs-dbexport DICOM_TEST_LDAP_PASSWORD=local-pacs-ldap# Start either profile; dcm4chee needs a few minutes for its first boot.docker compose -p octofhir-dicom-local -f docker-compose.dicom.yml --profile orthanc up -d orthanccurl --retry 30 --retry-all-errors --retry-delay 1 --fail http://127.0.0.1:8042/systemDICOM_TEST_PACS=http://127.0.0.1:8042/dicom-web \DICOM_TEST_UPLOAD=http://127.0.0.1:8042/instances \cargo test -p octofhir-server --test dicom_pacs -- --ignored
# Independent PACS, with its separate Worklist AE for UPS:docker compose -p octofhir-dicom-local -f docker-compose.dicom.yml --profile dcm4chee up -d dcm4cheecurl --retry 120 --retry-all-errors --retry-delay 2 --fail \ 'http://127.0.0.1:8090/dcm4chee-arc/aets/DCM4CHEE/rs/studies?limit=1'DICOM_TEST_PACS=http://127.0.0.1:8090/dcm4chee-arc/aets/DCM4CHEE/rs \DICOM_TEST_UPLOAD=http://127.0.0.1:8090/dcm4chee-arc/aets/DCM4CHEE/rs/studies \DICOM_TEST_UPS=http://127.0.0.1:8090/dcm4chee-arc/aets/WORKLIST/rs \DICOM_TEST_UPS_WS=ws://127.0.0.1:8090/dcm4chee-arc/aets/WORKLIST/ws/subscribers/OCTOFHIR \DICOM_TEST_UPS_FILTER_FORMAT=legacy_query \cargo test -p octofhir-server --test dicom_pacs -- --ignored
# Clarus 0.3.0-beta retrieval (DICOMweb root /dicomweb):DICOM_TEST_PACS=http://127.0.0.1:8024/dicomweb \DICOM_TEST_UPLOAD=http://127.0.0.1:8024/dicomweb/studies \cargo test -p octofhir-server --test dicom_pacs -- --ignored
# Removes only this disposable project's containers and synthetic-data volumes:docker compose -p octofhir-dicom-local -f docker-compose.dicom.yml --profile orthanc --profile dcm4chee down --volumesThe retrieval scenario covers QIDO discovery, FHIR import, rewritten metadata, multipart object/frame retrieval, bulk data and Cyrillic exact/fuzzy queries against Orthanc 1.13.0, dcm4chee 5.35.2 and Clarus 0.3.0-beta. A small test-only browser viewer additionally verifies the 256 source pixels. UPS Requestor/Watcher is checked against dcm4chee and an independent protocol test peer exercising ambiguous creates, lost notifications, immutable inputs, result publication and cancellation races. Orthanc is a retrieval peer, not a UPS Task Manager. These checks do not claim broad UPS interoperability or complete OHIF/Stone viewer compatibility beyond the explicit fixture checks below.
OHIF browser verification
Section titled “OHIF browser verification”scripts/test-dicom-viewer.mjs runs the pinned OHIF 3.13.14 Docker image in a
local Chrome browser through a same-origin, test-only nginx proxy. It verifies
successful gateway frame requests and non-uniform rendered canvas pixels for
native, multiframe and JPEG Baseline fixtures. Scrolling to the second multiframe
frame must reverse the synthetic gradient. It saves screenshots and a credential-free
ohif-results.json. The Rust test waits for a matching session completion ID, so
an old result cannot satisfy a later run.
Install playwright-core in a temporary developer directory and use the installed
Chrome. Start the PACS test with a fresh session path (add the appropriate UPS
variables above for a Task Manager), then run the browser check in another shell:
verification_dir=$(mktemp -d)npm install --prefix "$verification_dir/browser" playwright-core# Shell 1: substitute the selected local PACS/upload URLs from the examples above.DICOM_TEST_PACS=http://127.0.0.1:8042/dicom-web \DICOM_TEST_UPLOAD=http://127.0.0.1:8042/instances \DICOM_VIEWER_SESSION_FILE="$verification_dir/session.json" \cargo test -p octofhir-server --test dicom_pacs -- --ignored
# Shell 2: use the same verification_dir value.DICOM_PLAYWRIGHT_MODULE="file://$verification_dir/browser/node_modules/playwright-core/index.mjs" \node scripts/test-dicom-viewer.mjs "$verification_dir/session.json" "$verification_dir/results"The browser runner creates and removes its own OHIF container. Only synthetic
fixtures and the ephemeral test backend identity are used. Frame-list support is
measured separately from individual-frame decoding: an origin’s unsupported
/frames/1,2 response is preserved, while both individual frames must still match
the source bytes and render correctly in OHIF.
Retrieval and optional file storage
Section titled “Retrieval and optional file storage”Without the gateway, a viewer follows the Endpoint and retrieves objects directly from PACS with its own authorization. OctoFHIR does not expose its PACS service credential. STOW-RS and Task Performer execution belong to the external imaging services.
Optional S3 storage for general Binary/Attachment payloads remains a separate planned driver. It does not change PACS ownership of images. Private IG packages already support local directories, local archives, registry-offline dependency resolution and pinned S3 objects; see the configuration guide.
See the repository’s implementation plan.