Using Orthanc as a DICOM gateway to fix tags and transfer syntaxes: when the pattern fits
Orthanc can sit between a modality and a PACS as a middleman that receives instances, modifies them and forwards the result. You use this pattern when a sending device or archive produces data the receiving side rejects or misreads, and the fix belongs in transit because the source cannot be changed quickly or at all. Typical cases include a scanner that sends a transfer syntax the PACS refuses, or tags with values the archive expects in a different form. The orthanc-setup-samples repository on GitHub includes a Lua transcode middleman that changes the transfer syntax between a modality and a PACS, and a Python sanitizer middleman that modifies tags and transfer syntax. Treat both as starting points to adapt, test and review against your own data, not as drop-in production code.
The gateway pattern is usually the right choice when the fix is needed across many sources, when the device vendor cannot patch firmware or configuration in your timeframe, or when the PACS team needs one controlled place to apply rules. Fixing the modality or PACS directly is usually better when the correction is a simple configuration setting on that device, because every extra hop adds a component to monitor, back up and patch. A middleman also changes what the receiving system sees, so audit trails, accession and patient identifiers, and any changes to data that downstream clinicians rely on need an explicit owner. Confirm with your radiology informatics and compliance teams which modifications are permitted before any rule goes live.
Before you build, list every rule the gateway will apply and test each one with sample studies from each source, including the C-FIND filtering sample if queries are also affected. Check the Orthanc version you deploy against the Orthanc NEWS file, because scripting behavior and transcoding internals have changed across releases, and confirm the scripting API calls in your version's documentation. Plan for failure as well: decide what happens to an instance that cannot be modified, whether it is forwarded unchanged, held or rejected, and who is alerted.
Which gateway approach fits which problem
This table compares the three sample patterns in the orthanc-setup-samples repository with a fix at the modality or PACS itself. Read each row as a question: what is broken, which approach addresses it, what it changes in the data flow, and what to confirm before you commit.
| Problem | Approach | What it changes | Main risk |
|---|---|---|---|
| Modality sends a transfer syntax the PACS cannot accept | Lua transcode middleman | Changes the transfer syntax of instances passing between the modality and the PACS, leaving tags as they are | Confirm which transfer syntaxes each side accepts and whether lossy compression is acceptable for your clinical use |
| Tags are wrong, missing or non-conformant in received data | Python sanitizer middleman | Modifies DICOM tags and transfer syntax of instances in flight before they reach the PACS | Confirm the exact tag rules and test that edited studies still match on identifiers the PACS uses for patient matching |
| Modality or workstation queries return data the PACS should not expose | C-FIND request filter | Filters or rewrites incoming C-FIND requests so that only permitted query attributes or results pass through | Confirm the filter fails closed on unexpected requests and that query logic is tested against every modality that uses it |
| Source device can be corrected at its own configuration | Fix at the modality or PACS | Changes the output of the device or the receiving system directly, with no intermediate server | Confirm the vendor supports the change and whether firmware or configuration updates are available for each device |
| Several sites or devices need different rules | Gateway with per-source logic | Applies rules by source AE title or IP, so one gateway serves many senders | Confirm that source identification is reliable, since AE titles and addresses can be misconfigured or spoofed on a network |
| Changes must be auditable for compliance review | Gateway with logging and tests | Records each modification so an assessor can trace what was altered and when | Confirm the log content and retention meet your policy, and that original data is kept or recoverable where required |
Setting up a gateway between a modality and a PACS
This sequence takes a modality-to-PACS path from observed problems to a tested Orthanc gateway that corrects tags and transfer syntaxes in flight. Each step ends with a check, so the team can confirm the gateway works before any traffic is routed through it.
Inventory failing instances and tags
Collect sample instances from the modality that the PACS rejects or displays incorrectly, and record the transfer syntax, SOP class and the specific tags that need changing. Work with the modality owner and the PACS administrator to agree the list of required fixes, and keep copies of the untouched files for later comparison. Done when every failure has a written entry naming the tag or syntax involved and the sample file that shows it.
Clone and read the chosen sample
Clone the orthanc-setup-samples repository and open the middleman sample that matches your need, either the Lua transcode middleman, the Python sanitizer middleman or the C-FIND filtering sample. Read the script line by line, note which Orthanc configuration keys it depends on, and identify any routes or actions it would trigger on your server. Done when you can explain what the script changes, which events it hooks into and what it leaves untouched.
Define DicomModalities entries for each hop
In the gateway's configuration, add a DicomModalities entry for the originating modality and another for the downstream PACS, using the AET, IP address and port each device expects. Confirm the values with the device administrators, since a mismatch in any one of them is a common cause of rejected associations. Done when the gateway is able to list both entries and the configuration file has been validated on a non-production instance.
Add the script and test connectivity
Place the chosen script in the gateway's Lua or Python plugin path, restart Orthanc, and check the logs for load errors. Run C-ECHO from the modality to the gateway and from the gateway to the PACS, then send one test study through the path. Done when both C-ECHO requests succeed, the test study appears on the gateway, and the log shows the script ran without errors.
Compare tags and syntax before and after
Retrieve the test study from the PACS and compare it with the original sample using a DICOM dump tool, checking the transfer syntax UID and each tag you intended to change. Confirm that unrelated tags, pixel data and study identifiers were not altered by accident. Done when a written comparison shows every intended change applied and no unexpected differences, and the result has been reviewed by the PACS team.
Disable unneeded routes and actions
Review the gateway's configuration for any route, script or REST action that the sample enabled but your path does not need, and disable it. Confirm that the /tools/execute-script route and the export route stay disabled, as the Orthanc security FAQ recommends. Done when a configuration review lists each active route with its purpose, and an unauthenticated request to the disabled routes is refused.
Security risks of a modifying gateway
A gateway that rewrites tags and transfer syntaxes sits in the path of every study, so it holds patient images in transit and sometimes on disk. The risks below come from that position, from the scripts it runs with server privileges, and from the REST and DICOM interfaces it exposes. Each card names a control to set and a check to run before go-live.
Patient images held in transit
A middleman Orthanc receives full studies from the modality, changes them, and forwards them on. Until the forward completes, identifiable images may sit in the storage area and the index, so the gateway needs the same access controls, encryption and deletion rules as the archive. Ask who can read the storage directory and whether failed forwards leave copies behind, and confirm the retention behavior with your storage configuration.
Orthanc security FAQScripts run with server privileges
Lua and Python middleman scripts execute inside the Orthanc process, so a bug or a malicious input in a script acts with the same file and network access as the server. Keep scripts under version control, restrict who can change them on the host, and review any parsing of tag values that come from modalities. Treat every script change as a release that needs a test pass.
Disable the execute-script route
The REST route /tools/execute-script can let a malicious user run any system command on the host. Keep it disabled in every gateway configuration, including test and staging copies that were cloned from a working setup. Check the running configuration rather than the template, because the route is easy to leave enabled while debugging.
Restrict the export route
The export route can overwrite files on the server, which matters on a gateway that writes modified copies to disk. Keep it disabled unless you have a documented need, and if it must stay on, limit who can call it and where it can write. Confirm that no routing script creates files at paths that an external user could influence.
Authenticate REST access
By default Orthanc only accepts HTTP connections from localhost. If you enable RemoteAccessAllowed, set AuthenticationEnabled to true, define users in RegisteredUsers, and place the REST API behind HTTPS and a reverse proxy. Test an unauthenticated request from another host and confirm it is refused before the gateway joins the hospital network.
Encrypt inter-site DICOM links
DICOM TLS is supported in Orthanc from version 1.9.0, which lets a gateway protect classic DICOM exchanges with other sites. Plan certificates for each modality and peer, configure both ends, and confirm that clear-text associations are refused on links that carry patient data. Check the exact TLS settings against the version you run, since certificate handling differs between the DICOM and REST paths.
Orthanc security FAQTrade-offs of changing data in the middle
Changing data in flight is a decision about what the PACS is allowed to store, and it should be made before any Lua or Python script is written. When Orthanc sits between a modality and a PACS and rewrites tags or transfer syntaxes, the PACS receives instances the modality never produced. The study may still look correct on a viewer, but the bytes, the attribute values and the transfer syntax no longer match what the device recorded. Each change needs an owner who can say whether that difference is acceptable for diagnostic use, for research, for billing and for legal retention. Confirm with the clinical lead, the radiology informatics owner and the compliance or privacy officer which fields may change, which may never change, and who signs off on a modified dataset.
The risks are concentrated in four places. First, audit trails: a gateway that rewrites PatientID, AccessionNumber or StudyInstanceUID breaks the link between what the modality acquired and what clinicians later see, so the gateway's own logs must record the original and modified values for every instance. Second, de-identification claims: a sanitizer that removes some tags does not make a dataset de-identified, because private tags, burned-in pixel text and free-text fields can still carry identifiers. Any statement that data is de-identified should rest on a documented method reviewed by privacy staff, not on the existence of a script. Third, integrity and referencing: changing a UID or a series attribute can orphan structured reports, presentation states, segmentations or AI results that point to the original identifiers. Fourth, transfer syntax changes can alter pixel data through lossy compression, which the reader must treat as a clinical question, not a storage detail.
Document the decision in a short data handling record that lists each script, its version, the tags and syntaxes it changes, the reason, the approving owners and the review date. Keep the original instance archived or otherwise recoverable where policy allows, and state in that record whether the PACS copy is the modified version. Test the record against a sample study from each modality, including one with private tags and one with compressed pixel data, and confirm with the PACS vendor how it treats modified instances and duplicate UIDs. The Orthanc configuration and scripts should be reviewed whenever the Orthanc core is upgraded, because the transfer syntax and DICOM parsing behavior can change between releases. Confirm the current release notes for the version in use before relying on earlier test results.
Limits to confirm in your environment
A gateway that rewrites tags and transfer syntaxes sits in the middle of clinical data flow, so its behavior depends on details the samples cannot guarantee. The cards below list the items to verify against your own modalities, Orthanc version and study volumes before anything is promoted to production.
Supported transfer syntaxes and codecs
Confirm which transfer syntaxes and codecs your chosen Orthanc build can decode and encode, and which ones your modalities and PACS actually send and accept. Compressed formats such as JPEG variants depend on the codecs in the package you install, so test each pair you plan to convert with real sample files from every device. Record any syntax that fails or is silently refused, because a gateway that cannot convert it will either block the study or pass it through unchanged.
Orthanc pluginsPrivate tags from your modalities
Modality vendors often write private tags that the sanitizer sample does not expect. Before you remove, rewrite or keep any tag, list the private groups each scanner produces and decide which ones carry clinical meaning, such as reconstruction or dose data. A script that edits tags by name may miss private elements entirely, so check the output of a full study against the original on each modality model.
Sample license and maintenance status
The orthanc-setup-samples repository is a collection of examples, not a supported product. Confirm the license terms printed in the repository, the date of its most recent commits, and whether the Lua and Python scripts still match the Orthanc API you run. Your organization owns any changes you make to these scripts, so decide who will maintain them after the first release.
Setup samples repositoryPerformance at your study volume
A gateway that decodes and re-encodes every instance adds CPU and memory load on each association. Measure throughput with a representative mix of study sizes, including large multi-frame images, at the peak hour you expect. Watch queue depth, retry behavior and disk use on the staging node, since a slow transcode can back up the modality and delay the workflow behind it.
Effect of release 1.13.0 on transcoding
Release 1.13.0 rewrote storage-area access and DICOM parsing and transcoding to improve caching and reduce memory use. Read the release notes for every transcoding or parsing change that affects the syntaxes you convert, and rerun your test set on that exact version before upgrading. Keep the previous image available so you can roll back if output changes for a modality you depend on.
Orthanc release notesQuestions teams ask before building an Orthanc gateway
What drives the cost of an Orthanc DICOM gateway project?
The main drivers are how many tags and transfer syntaxes must change, how many modalities and PACS endpoints the gateway serves, and how much validation the work needs against real studies. A gateway that rewrites a few patient-identity tags for one scanner is a small job. A gateway that normalizes tags differently for each modality, handles several compressed formats and must prove each rule against many series costs more in design, scripting and testing time. Costs are mostly one-time build effort, plus later changes whenever a new modality or PACS rule is added. Ask any provider for a quote that lists the tag rules, the modalities, the transfer syntaxes and the test cases as separate line items.
How long does it take to build a tag-fixing gateway?
Duration depends on the same drivers as cost: the number of rules, the number of modalities, and how many sample datasets must be checked before the PACS owner accepts the output. Teams with a small, well-defined rule set usually finish faster than teams that discover new vendor quirks during testing. No fixed duration is stated here. Ask for a written schedule with milestones for the rule inventory, the first working middleman, the validation run on real data, and the PACS acceptance test, and check that the schedule includes time for the PACS owner to review results.
What does the client need to provide for the gateway work?
You need sample data from each modality, including the exact tags and transfer syntaxes it sends, because the vendor's sample scripts will not match your devices. You also need a named owner of the PACS who signs off on what the PACS should accept, the AE titles, IP addresses and ports for every endpoint, and firewall rules that allow the gateway to reach both sides. Confirm early whether de-identified or synthetic test data is allowed in your environment, and who approves the use of real patient studies in a test system.
Can our own team build an Orthanc gateway without a partner?
Yes, if your team has DICOM networking experience, can write Lua or Python against the Orthanc REST API and plugin hooks, and has access to test modalities and a non-production PACS. The official orthanc-setup-samples repository includes a Lua transcode middleman, a Python sanitizer middleman and a C-FIND request filtering sample, which give a working starting point. The harder work is usually the validation: finding which tags each device sends wrong, confirming the PACS accepts the output, and keeping the rules maintained after firmware updates. Assess those skills honestly before committing internal time.
What should we check before changing tags in transit?
Check whether the change alters data the clinic or PACS relies on for matching, such as patient identifiers, study UIDs, or accession numbers, because a rewritten identifier can split one patient into two records. Confirm which tags the downstream system uses to file and display studies, and whether a rule that is correct for one modality breaks another. Also confirm that transfer syntax changes do not remove information the reading workstation needs, and that the original file is kept or can be recovered if a rule was wrong. Document each rule with the reason it exists.
How do we test the gateway against the PACS before go-live?
Test with a representative set of studies from every modality, send them through the gateway to a non-production PACS, and compare what arrives with what was sent, tag by tag. Include C-FIND queries from the workstations you use, because a filtering rule that hides results can look like missing data. Run failure cases too: unreachable PACS, rejected associations and malformed files. Ask the PACS owner to sign off on the test report before any production traffic is routed. Keep the test evidence, since compliance and clinical reviewers may ask for it later.
When would Orthanc Team SRL services fit this kind of project?
Orthanc Team SRL, the company that maintains Orthanc, sells deployment, configuration and development services and pre-paid dedicated support hours valid for 12 months, quoted on request. Their services may fit if you want the core developers to review a gateway design, to add a custom plugin, or to provide dedicated support during rollout. Orthanc has no paid edition, so the cost is for services rather than the software. Ask them to quote a defined scope and confirm what the support hours cover. DeployOpen is a separate company, and it can plan and build the gateway in your infrastructure, but it does not act as a reseller or partner of Orthanc Team SRL.
Who maintains the gateway rules after go-live?
Someone on your side must own the rules, because scanner firmware updates, new protocols and PACS upgrades can change which tags arrive and which ones the PACS expects. Plan for a change process that re-runs the validation set after each change, and for version control on the Lua or Python scripts. Ongoing support can be handled internally or through a retainer, which covers scheduled reviews, upgrades and continuous testing. Confirm who receives alerts when a rule rejects a study, and how quickly a fix can be deployed without interrupting image flow.
Where the script hook sits between modality, PACS and index
The flow starts when a modality sends instances to Orthanc over DICOM store. Orthanc's script hook, running Lua or Python from the setup samples, edits tags or transfer syntax on each instance before it is indexed and forwarded to the PACS. A C-FIND query from the PACS passes through the filter before it reaches Orthanc's index, so the filter decides what the PACS can see. Check that the hook runs on every path, and that both directions use the same rules.
Instances are cleaned on ingest and C-FIND queries are filtered before reaching the index.
How DeployOpen scopes and delivers an Orthanc gateway
DeployOpen treats an Orthanc gateway between a modality and a PACS as a bounded piece of work: the tag rules, transfer syntax decisions and C-FIND filters are agreed in writing before any script is written. The gateway is then built and tested inside your own network, and handed over with the configuration, scripts and runbooks your team needs to operate it.
How we scope
- We list every modality and PACS pair the gateway will sit between, with AE titles, ports and direction of traffic.
- We record which tags are changed, removed or validated, and which must pass through untouched.
- We agree the target transfer syntaxes per destination and the policy for refused or unexpected formats, in the written scope.
How we build
- We start from a Lua or Python sample, adapt it to your rules, and keep each rule in its own reviewable file.
- We test with sample studies from each modality, checking pixel data, tag values and transfer syntax before and after the gateway.
- We configure C-FIND filtering and disable risky REST routes such as script execution and export overwrite, as the Orthanc security guidance advises.
How we hand over
- Your team receives the source of each script, its configuration keys, and a test set with expected outputs for regression checks.
- We document the processing order, what happens on failure, and how to add a rule without changing the gateway core.
- Deliverables are agreed in the written scope, and handover covers a walkthrough with the engineers who will run the gateway.
How we support
- Engagements are fixed-scope, so changes to rules after handover are priced as a new written scope or added to a retainer.
- Ongoing support, upgrades when new Orthanc releases arrive, and continuous testing of the gateway are available as retainers.
- Ask us to confirm which Orthanc version, plugin set and Lua or Python runtime your gateway depends on before any upgrade is planned.

