When auto-routing DICOM studies with Orthanc fits your workflow
Orthanc can route studies automatically using Lua and Python hooks, so a study that lands from a modality can be forwarded to a PACS, an AI tool or a research archive without an operator pushing it by hand. This fits a hospital or imaging group that receives studies from several scanners and must get each one to the right destination, for example a clinical PACS for reading, an AI inference service for triage, and a research archive for de-identified copies. In practice, routing means Orthanc watches for newly stored instances or completed studies, evaluates conditions on DICOM tags or on the source that sent the data, and then sends the study onward. Each rule is a decision about where patient images go, so the rules need a named owner, usually the imaging informatics lead, with sign-off from the radiology or compliance team for any destination outside the clinical record.
Auto-routing fits best when the destinations are stable, the routing conditions can be expressed in DICOM tags or source AE titles, and someone is accountable for what happens when a forward fails. It fits poorly when every study needs a human decision. Before you commit, confirm which Orthanc version your environment will run, since the release notes for each version describe changes to storage access and transcoding that can affect hook behavior, and check the Orthanc Book for the current form of the Lua and Python callbacks you plan to use. Ask whether your sites need retries, how long a study may wait in a queue, and whether deleting a study after forwarding is allowed under your retention policy. DeployOpen implements and tests the routing rules inside your own infrastructure, covering the rule set, failure handling and the test evidence your reviewers will ask for, so the design is settled before it reaches production.
Routing by tag, by source or by Python rule
Tag-based routing inspects DICOM attributes of each received instance, such as Modality, StudyDescription or BodyPartExamined, and forwards the study when a value matches. In Orthanc this is usually written as a Lua OnStoredInstance handler that calls the REST API to send the instance to a destination. It fits sites with a small, stable set of rules, such as sending CT chest studies to an AI tool and everything else to the PACS. The rules are easy to read and test, and they run inside the server without extra services.
- Low maintenance for simple rules: a handful of tag comparisons stays readable for a long time.
- Tag quality dependency: modalities that send inconsistent
StudyDescriptionorBodyPartExaminedvalues will route inconsistently. - Per-instance evaluation: the handler runs for each instance, so rules must be idempotent to avoid duplicate sends.
- Hard-coded destinations: new AETs or AI tools usually mean editing the script and reloading.
- Lua version dependency: confirm the Lua hook names and behavior against your Orthanc version before you rely on them.
Before you adopt this style, check how consistently your modalities populate the tags you plan to route on.
Source-based routing decides where a study goes according to where it came from: the calling AET, the sending IP address or the modality entry defined in Orthanc. It is often the simplest rule set because every received study already carries its origin. A typical use is forwarding everything from a mammography unit to a dedicated review archive, while CT studies from another site go to a different PACS. Source rules rarely require parsing image content, so they keep the logic small.
- Clear ownership: each source maps to a named department or device, which helps audits and change reviews.
- Stable identifiers: AETs are configured once per device, so rules change less often than tag logic.
- Breaks on re-badging: a modality with a reconfigured AET or a new IP address silently falls out of its rule.
- Poor fit for mixed sources: a shared workstation or a relay that sends studies from many devices hides the true origin.
- Coupling to network configuration: source rules depend on the
DicomModalitiesentries, so network changes need coordinated updates.
Ask your team for an inventory of every AET and IP that sends to Orthanc, and confirm which ones forward through intermediaries.
Python scripts suit conditions that are awkward in Lua: combining several tags with conditional logic, looking up a patient or order in an external system, keeping state across instances, or calling a service before deciding where a study goes. Lookups add latency and a dependency, so the script should define what happens when the external service is unavailable. Python rules also need their own tests, because logic that grows over time is harder to review than a short Lua handler. Confirm that the Python plugin and its hooks are available and documented for your Orthanc version before design work starts.
- Multi-tag and lookup logic: combines attribute checks with external data where a flat tag match cannot.
- Ongoing code maintenance: rules become software with versioning, code review and regression tests.
- Failure handling is your responsibility: timeouts, retries and fallback destinations must be designed explicitly.
- Performance under volume: heavy logic on every instance can slow ingestion, so keep per-instance work minimal.
- Security review: scripts that call external systems need reviewed credentials and restricted network paths.
Before you commit, ask for a written list of the lookups, their timeouts and the fallback behavior for each.
Configuration options and when each fits
This table compares the routing decisions a team makes before writing any Lua or Python rule: what triggers the route, how studies are matched, where they go, and what happens after forwarding. Read each row as a choice to settle with clinical, PACS and AI owners before build starts. The main takeaway is that deletion after forwarding and retry behavior carry the most risk, so they deserve the earliest sign-off.
| Decision | When it fits | Main trade-off |
|---|---|---|
| Trigger: stored instance event | Routing each instance as it arrives, for example when a modality sends images one at a time | Rules can fire on partial studies, so downstream steps may act before a series or study is complete |
| Trigger: stable study event | Sending a whole study once it stops changing, for example before an AI tool reads it | Delivery waits for the study to settle, which adds latency and depends on how the stability timer is set |
| Match by DICOM tags | Modality, body part, series description or manufacturer decides the destination | Tag values vary between scanners and sites, so rules need testing against real sample data |
| Match by source or origin | Studies from a given modality or peer AET go to a specific PACS or AI tool | Source identity is only as reliable as the AET and network configuration behind it |
| Destination: DICOM C-STORE to a modality or PACS | The receiving system only accepts classic DICOM and is already registered in Orthanc | Association setup, AET and port mismatches and transfer syntax acceptance can all cause silent failures |
| Destination: DICOM peer or REST | The target is another Orthanc or a service reached over HTTPS, or an AI tool expects a web API | Needs its own authentication and certificate handling, and the receiving side must accept the payload format |
| Deletion after forwarding | Storage is limited and a verified copy exists at the destination | Deleting before the receiver confirms storage can lose the only copy, so confirmation logic must be designed first |
| Retry behavior | Destinations are sometimes offline, for example overnight maintenance or a restarted AI service | Aggressive retries can flood a recovering system, while too few leave studies stranded without alerting anyone |
| Logging and alerting | Audit teams need a record of what was routed, to where and when, and failures need an owner | Detailed logs help investigations but may hold patient identifiers that require the same access controls as images |
Setting up routing rules with checks at each step
This sequence moves a routing design from an inventory of modalities and destinations to a monitored production router, with a verification check before each change goes live. Each check is designed to catch a problem while it is still cheap to fix, especially anything that could delete or misroute clinical images.
Inventory modalities and destinations
Your PACS, imaging and network teams list every modality, PACS, AI tool and downstream archive that will send or receive studies through Orthanc. For each one, record the AE title, IP address, DICOM port, supported transfer syntaxes and who owns the configuration. The step is done when the list is signed off by both the imaging and network owners and every entry has a matching firewall rule request. Missing or mismatched AE titles are the most common cause of failed routing later, so this list is the reference for every following step.
Define routing rules on a test instance
Write the OnStoredInstance Lua rules that select studies by tag or by source AE title, and set the destination for each rule on a separate test Orthanc instance, not the production server. Keep the REST API and any script execution endpoints restricted while you work: the Orthanc security FAQ warns that the /tools/execute-script route can run system commands and that the export route can overwrite files, so both should stay disabled. The step is done when the rules are stored in version control and reviewed by someone other than the author.
Verify matching with non-clinical sample studies
Send non-clinical or anonymized sample studies to the test instance from each source, including edge cases such as missing tags, unexpected modalities and compressed transfer syntaxes. Confirm that each study is routed to the intended destination and that studies matching no rule are left alone. The step is done when every sample produces the expected routing result in the Orthanc logs and in the destination, and the results are recorded so that a later rule change can be re-tested against the same set.
Register destinations and confirm C-ECHO connectivity
Add each destination to the DicomModalities configuration on the test instance, then run a C-ECHO from Orthanc to every destination. Repeat the check from each destination back to Orthanc where that direction is used. Confirm the AE title, IP address and port in both directions, and confirm that any TLS settings match on both ends. The step is done when every C-ECHO succeeds and the results are logged. A failed echo at this stage is usually a configuration or firewall issue, and it is far easier to isolate before forwarding is enabled.
Enable forwarding on production in stages
Move the verified configuration to production, enabling forwarding for one source and one rule first. Watch the first real studies arrive at the destination and check that the instance counts match what was sent. Widen the scope one rule or source at a time. Do not enable deletion of local copies in this step. The step is done when forwarding has run through a full working period without unexpected rejections, duplicates or missing instances, and the change is recorded with the person who approved it.
Test deletion with a non-clinical study before enabling it
Only after forwarding is stable, configure deletion after successful forwarding, and test it first with a non-clinical study that you control. Confirm that the study is removed from Orthanc only after the destination confirms receipt, and that a deliberately unreachable destination causes the study to be kept. The step is done when both tests behave as expected and the rollback procedure has been rehearsed. Deletion is the step most likely to cause irreversible loss, so it should not be enabled for clinical data until these tests pass.
Add monitoring and review retry behavior
Set up alerts for failed forwards, growing queues and destinations that stop responding, and review how Orthanc retries failed transfers in your version and configuration. Confirm with your own testing how long failed items remain queued and what happens after repeated failures. The step is done when an alert has been triggered and cleared on purpose during a test, and the on-call team has a written runbook for failed or stuck routes. Review the retry settings after each Orthanc upgrade, because behavior may change between releases.
Deleting studies after forwarding without losing data
A successful send is not proof that the destination stored the study safely. When a router deletes its local copy after forwarding, the only remaining copy may be the one that was never confirmed. In an Orthanc auto-routing workflow, the forward step typically ends when the destination accepts the transfer or returns a success status, and neither event tells you that the images were written to durable storage, that every instance arrived, or that the receiving system will still hold them after its own retention or cleanup jobs run. Deletion should therefore be a separate, gated decision in the routing design, not a side effect of the forward rule.
Put three checks in front of any delete action. First, confirm the transfer was complete, using the study's instance counts and status on the destination rather than the router's log line alone. Second, where the receiving system supports it, use storage commitment to get an explicit answer that the images were stored; that mechanism is covered in its own topic, so here it is enough to know it is a separate control with its own configuration and testing. Third, check your retention policy and obtain clinical or operational sign-off for the categories of study you intend to remove. Also confirm which Orthanc settings govern automatic deletion and whether they run on a schedule, after a forward, or only on explicit API calls, because that behavior varies between releases and configurations. Check it against the exact Orthanc version you run, using the Orthanc NEWS file, and test it on a non-clinical copy before enabling it in production.
Security and operational risks in routing workflows
A router sits between modalities, PACS and AI tools, so it holds copies of patient studies and the credentials to send them onward. The risks below cluster around exposed administration routes, open REST access, stored destination credentials, missing audit trails and unapproved recipients, and each one needs a control before the routing rules go live.
Script execution and export routes
The Orthanc security FAQ warns that the /tools/execute-script route can let a malicious user run any system command, and that the export route can overwrite files. Routing rules rarely need either route, so confirm both stay disabled in the configuration used by the router. Check this on every node, including test and rebuilt containers, because a copied configuration file can re-enable them.
Unrestricted REST access
By default Orthanc only accepts HTTP connections from localhost. When RemoteAccessAllowed is enabled, set AuthenticationEnabled to true, define named accounts in RegisteredUsers, and place the server behind HTTPS and a reverse proxy. An unauthenticated REST endpoint lets anyone on the network list, export or delete studies that the routing rules are moving.
Credentials for destinations
Each forwarding target, whether a PACS, a cloud bucket or an AI service, needs credentials or an AET and address entry in the router. Keep these out of Lua and Python scripts that are committed to source control, and restrict who can read the configuration file. Ask who owns each destination credential, how it is rotated, and how a revoked credential stops forwarding without losing queued studies.
Audit logging of forwarded studies
Once a rule forwards a study and then deletes the local copy, the router may be the only record of where that patient data went. Log each forwarding decision with the study identifier, the rule that matched, the destination and the outcome, and keep those logs outside the Orthanc instance they describe. Test that a retried or failed send still leaves a traceable entry.
Routing to unapproved AI tools
A rule that matches on modality or study description can send patient images to an AI tool that the privacy office never reviewed. Maintain an allowlist of approved destinations, require that each new destination passes a data handling review, and make adding a destination a change that goes through version control. Confirm where the AI service stores and logs the images it receives.
How a received study flows through routing rules
The flow starts when a modality sends instances to Orthanc over DICOM. Each instance is stored and then passed to a Lua or Python rule that checks tags or the source modality and chooses a destination such as a PACS, an AI tool or a research archive. A failed forward goes to a retry queue rather than being dropped. Deletion from Orthanc happens only after the receiving system confirms delivery, so check that confirmation step before enabling any delete action.
Routing from a modality through rules to destinations, with retries and a gated deletion.
Questions teams ask about routing DICOM studies with Orthanc
Does Orthanc charge a license fee for routing studies?
No. Orthanc has no paid edition, and the core is licensed GPLv3 or later, so routing rules you write in Lua or Python do not carry a license fee from the project. Costs come from the work around it: someone must design the rules, build them, test them against real traffic and run them afterward. Orthanc Team SRL sells deployment, configuration and development services, including pre-paid dedicated support hours valid for 12 months, and quotes them on request. Ask any vendor, including DeployOpen, to price routing as a fixed scope tied to a written list of rules, endpoints and test cases. Confirm the license of any plugin you add, because the scalability and cloud plugins are licensed AGPLv3 or later.
How long does an Orthanc auto-routing build take?
The sources do not give a fixed duration, and the honest answer depends mainly on rule count and testing. A build with a few routes keyed on modality AET and one destination is much smaller than a build with conditional rules on tags, deletion after forwarding, retry logic and AI tool hand-offs. Testing usually takes longer than the first draft of the Lua script, because each route must be checked against real studies from each modality, including unusual series and incomplete transfers. Ask for a timeline in the written scope that lists the rule inventory, the test matrix and the sign-off steps, so you can see which items drive the schedule.
What does our team need to provide for a routing project?
Plan to supply three things before work starts. First, an inventory of every modality, PACS and AI tool that will send or receive studies, with its AE title, IP address, port and whether it is a source or a destination. Second, a set of sample studies from each source, including edge cases such as multi-frame images, compressed transfer syntaxes and studies with missing or inconsistent tags. Third, named sign-off owners who can approve routing rules, deletion behavior and retry limits. Without the AE inventory, rules often fail silently because an unknown caller is rejected or mapped to the wrong destination. Without sample data, testing reflects what the developer imagines rather than what the scanners actually send.
Can our own team build Orthanc routing without a partner?
Yes, if your team has DICOM knowledge, can read the Orthanc Book and can run a test environment with representative studies. The routing logic is ordinary Lua or Python running inside Orthanc, and the project documentation covers the REST API and scripting hooks. The risks lie in less visible areas: understanding association settings, handling the same study arriving twice, preventing deletion before a destination confirms receipt, and keeping rules maintainable after the original author leaves. Confirm that someone on your team will own the scripts, the test cases and the change process after go-live, not only the first build.
When is it worth hiring a partner for DICOM routing?
A partner is worth considering when the rules touch patient care or cross several systems at once, or when your team lacks time to test them properly. Typical triggers include routing that depends on tags in the study, forwarding to AI tools that need specific series, deleting originals only after confirmed delivery, and sites with different security requirements such as DICOM TLS. A partner can also help when the build must be reviewed by your security or compliance team. Ask for a fixed-scope proposal with written deliverables, a test plan and a retest step, because most DeployOpen engagements are fixed-scope and agreed in writing before work starts.
What goes wrong most often when Orthanc forwards studies automatically?
The most common problems are silent: a route that fires before a study is complete, a destination that rejects the association because the calling AE title is not registered, or a deletion rule that removes instances the receiving system never stored. Retries can also duplicate studies if the destination accepted the first transfer but the acknowledgement was lost. Check each route for completeness conditions, confirm AE and port settings on both ends, log each forward with its outcome, and test deletion only on copies. The Orthanc security FAQ also warns that the script execution and export routes can run commands or overwrite files, so keep those disabled.
Do we need to secure the routing setup itself?
Yes. Routing stores and moves patient images, so treat the Orthanc server and its REST interface as sensitive. By default Orthanc accepts HTTP connections only from localhost. If remote access is enabled, the security FAQ recommends turning on authentication with users in RegisteredUsers, using HTTPS and placing a reverse proxy in front for any Internet exposure. Keep routing scripts under version control, restrict who can edit them, and review which destinations each source can reach. For DICOM exchanges between sites, the project supports DICOM TLS from version 1.9.0, which should be confirmed for your deployment before you rely on it.
Which Orthanc version should a new routing build target?
Target the newest stable release that your validation process allows, then pin it. The most recent release listed in the project's NEWS file is 1.13.0, released on 2026-08-15, and it rewrote storage-area access and DICOM parsing and transcoding to improve caching and reduce memory use. Because that change touches the code paths that routing relies on, test your scripts on the exact version you plan to run. Record the version, the plugin versions and the Docker image tag in your change records so future upgrades can be compared against the routing test set.
How DeployOpen scopes and delivers Orthanc routing
DeployOpen treats auto-routing as a written, fixed-scope piece of work: the routing rules, source and destination systems, and the failure behavior are agreed before anything is built. The routing logic is then built and tested inside the client's own Orthanc deployment, in their infrastructure, and handed over with documentation the client's team can operate.
How we scope
- We list every modality, PACS and AI tool that sends or receives studies, with AE titles, network paths and the direction of each flow.
- We write down the routing conditions in plain terms, such as tags, source AE title or study description, and agree them in writing.
- We agree what happens to a study that matches no rule, fails to forward, or arrives partially, before the build starts.
How we build
- We implement routing in Orthanc Lua scripts or Python plugins, depending on the rule complexity agreed during scoping.
- We configure forwarding retries and deletion-after-forwarding only after the agreed success condition is verified in a test environment.
- We test each rule with sample studies from each source, including malformed, partial and duplicate cases, and record the results.
How we hand over
- We deliver the routing scripts, configuration files and a runbook describing each rule, its owner and how to change it.
- We document the test cases used, the expected outcome of each, and how to rerun them after an Orthanc upgrade.
- We walk your operations team through monitoring the routing logs and responding when a forward fails.
How we support
- Ongoing support, upgrades and continuous testing are available as a retainer, scoped separately from the original build.
- Retainer work can cover routing changes when new modalities, PACS or AI tools are added to the network.
- Any change to routing rules is retested against the agreed cases before it goes into production.

