Appearance
HL72HL7 — HL7 Message Broker
HL72HL7 is a store-and-forward broker for HL7 v2 messages. It receives MLLP-framed messages from one or more senders, writes each accepted message to disk before acknowledging it, and then delivers it to one or more MLLP destinations chosen by message type and field rules. Each destination can get its own field transforms and correlation rules.
Typical uses:
- Spool orders from an HIS, RIS or EHR while the downstream systems are not ready yet, then deliver the backlog later.
- Fan out a single feed to several receivers, each getting only the messages meant for it (for example, by patient location).
- Add order identifiers from an earlier order message to a result message before forwarding it.
| Windows service | DICOM7_HL72HL7 |
| Program folder | C:\Program Files\Flux Inc\DICOM7 HL72HL7 Broker |
| Data folder | C:\ProgramData\Flux Inc\DICOM7\HL72HL7 |
| Configuration | <data folder>\config.yaml |
| Cache | <data folder>\cache (default) |
| Log | <data folder>\logs\dicom7-hl72hl7.log |
| Default listen port | 7777 |
Versions
This page describes HL72HL7 2.5.2. Items marked Unreleased are part of 2.5.2 and are not in 2.5.1. If you run 2.5.1, leave these settings out of config.yaml.
How it works
Capture first
For each message received, HL72HL7 does the following in order:
- Reads one complete MLLP frame.
- Checks the MSH header and segment structure (see Inbound validation).
- Checks that the message type (
MSH-9components 1 and 2, for exampleORU^R01) is listed inAcceptedMessageTypes. - Writes the exact received bytes (
message.hl7) and amanifest.jsonto a staging folder, then moves the folder intocache\activein one step. - Only then returns
AAto the sender.
The stored bytes are never changed. Transforms and correlation are applied to a copy at delivery time, so the original message is always on disk as it was received.
If the service stops while a message is still in staging, no AA was sent for it. At the next start, leftover staging folders are moved to cache\quarantine and the sender is expected to resend.
Acknowledgements returned to senders
| Situation | MSA-1 | Connection |
|---|---|---|
| Message stored | AA | Kept open |
| Exact duplicate of a stored message (see Duplicates) | AA | Kept open |
Message type not in AcceptedMessageTypes | AR | Kept open |
| Invalid MSH or segment structure | AR | Kept open |
Invalid MLLP frame, or frame larger than HL7.MaxMessageBytes | AR | Closed |
Same MSH-10 reused with different content and ControlIdReuse: Reject | AE | Kept open |
| Message could not be written to disk | AE | Kept open |
The acknowledgement swaps the sending and receiving application and facility from the inbound MSH, uses ACK^<trigger> as MSH-9, copies the inbound version into MSH-12 (2.3 if it is empty), and puts the inbound MSH-10 in MSA-2. For a negative answer, a short reason (up to 200 characters) is placed in MSA-3.
A connection may carry many messages. Every complete frame is acknowledged in order. A sender can keep the connection open between messages; it is closed after IdleConnectionTimeoutSeconds without traffic.
Inbound validation
A message is rejected with AR when any of the following is true:
- It is shorter than 10 bytes, or the first segment is not
MSH. MSH-2has fewer than four encoding characters, or the field, component, repetition and escape characters are not all different.MSH-9does not contain both a message type and a trigger event.MSH-10is empty.MSH-3,MSH-4,MSH-5,MSH-6,MSH-9,MSH-10,MSH-12orMSH-18contain characters outside printable ASCII.- The message contains an empty segment (two consecutive carriage returns), a segment name that is not three uppercase letters or digits, or a segment that does not use the
MSH-1field separator. - The message contains a line feed (
0x0A), NUL, or an MLLP framing byte. Segments must be separated by carriage return (0x0D) only.
See HL7 Conformance for general DICOM7 HL7 behavior.
Duplicates and record identity
Every stored message is a record named by a 64-character hexadecimal ID. The ID is a SHA-256 hash computed from:
- the message type (
TYPE^TRIGGER), MSH-3(sending application),MSH-4(sending facility),MSH-10(message control ID),- and, with
HL7.ControlIdReuse: Accept, the SHA-256 of the exact message bytes.
How a new message is treated depends on HL7.ControlIdReuse (Unreleased):
| Incoming message | Accept (default) | Reject |
|---|---|---|
| Same bytes as a stored message | Duplicate: AA, not delivered again | Duplicate: AA, not delivered again |
Same type, MSH-3, MSH-4 and MSH-10, different bytes | New message: stored and delivered | AE; a copy is kept in cache\quarantine for review |
With Accept, senders that reuse control IDs (for example, several devices using a seconds timestamp as MSH-10) never collide. The trade-off: a sender that rebuilds a message on resend (for example, with a new MSH-7 timestamp) produces a different message, and it is delivered again.
Duplicate detection looks in cache\active, cache\completed, and cache\receipts. Receipts let a resend be recognized after the completed copy has been cleaned up (see Retention). Records in cache\rejected and cache\quarantine are not checked, so an exact resend of one of those messages is stored again as a new record.
2.5.1 behavior
2.5.1 has no ControlIdReuse setting. Its record identity does not include the message bytes, and it always behaves like Reject. Records captured by 2.5.1 load unchanged in 2.5.2, and an exact resend of a 2.5.1 record is still recognized as a duplicate.
Modes
| Mode | Behavior |
|---|---|
CaptureOnly (default) | Receives, stores and acknowledges messages. Nothing is delivered. Records stay in cache\active indefinitely. |
RouteAndDeliver | Also routes every active record to its matching destinations and delivers it. Requires at least one enabled destination. |
CaptureOnly is the shipped setting. A common rollout is to capture first, then add destinations, validate the configuration, switch to RouteAndDeliver, and restart the service. The captured backlog is then delivered, oldest first.
Delivery cycle
The delivery cycle runs 5 seconds after start and then every Retry.IntervalSeconds. Each cycle:
- Lists
cache\activeand sorts the records by the time they were received (oldest first). - In
RouteAndDelivermode, works out the destinations for each record (see Routing) and attempts delivery to every destination that has not yet accepted or finally rejected it, and whose retry time has come. - Moves a record to
cache\completedonce every matching destination has accepted it, or tocache\rejectedonce every matching destination has either accepted or finally rejected it. - Logs one summary line.
Destinations are independent. A record that one destination has already accepted is never sent to that destination again because another destination is failing.
Destination routing is evaluated against the configuration in effect at the time of the cycle. Adding a destination therefore also applies to records that are still active.
Ordered delivery (Unreleased)
With Ordered: true (the default), each destination receives its messages in the order HL72HL7 received them. While an earlier record is failing or waiting for its next retry, later records for the same destination wait behind it. This prevents, for example, a cancel overtaking the order it cancels.
- Each destination is blocked independently.
- Records held for correlation never block later records.
- Records that a destination has already accepted, or finally rejected, do not block.
- Blocked records are counted as
waitingin the cycle summary.
Set Ordered: false when a stuck message must not delay the others for that receiver.
WARNING
With Ordered: true, a message that a destination keeps answering with a retryable error (for example AE), or a transform that keeps failing, holds up every later message for that destination until it is resolved.
In 2.5.1, records are processed in record-ID order rather than arrival order, and a failing record never delays other records.
Acknowledgements from destinations
For each attempt, HL72HL7 opens a new TCP connection, writes one MLLP frame, reads one MLLP-framed reply, and closes the connection. An attempt succeeds only when all of these are true:
- the reply arrives within
Retry.AckTimeoutSecondsand is no larger thanRetry.MaxAckBytes; - the reply is printable ASCII, starts with
MSH, and contains anMSAsegment; MSA-1is exactlyAA;MSA-2exactly equals theMSH-10of the message sent.
Every other outcome is a failure:
| Outcome | Result |
|---|---|
MSA-1 is in Retry.TerminalAckCodes (default AR, CR) and MSA-2 matches the sent MSH-10 | Final rejection: not retried for this destination |
Any other non-AA code (for example AE, CA, CE), or a terminal code with a non-matching MSA-2 | Retried |
AA with a non-matching MSA-2, missing MSA, malformed or oversized reply | Retried |
| Connect timeout, connection refused or closed, no reply within the timeout | Retried |
HL72HL7 delivers at least once. If the message was written but no reply arrived, the attempt is marked ambiguous and the message is sent again with the same MSH-10. Receivers should treat a repeated MSH-10 as a possible duplicate.
Rejection after an unanswered attempt (Unreleased). Some receivers reject a message they already hold. If a final rejection follows an attempt that got no reply, the record still moves to cache\rejected, but delivery.json records RejectedAfterUnansweredAttempt: true and the log entry is a warning that names it as a likely duplicate rather than an error.
Retries and backoff
There is no limit on the number of attempts and no age limit for active records. After attempt n fails, the next attempt is scheduled IntervalSeconds × 2^(n−1) seconds later, capped at MaxIntervalSeconds. With the defaults: 30 s, 60 s, 120 s, 240 s, 480 s, then every 900 s. Because retries are checked by the delivery cycle, the effective delay is rounded up to the next cycle.
Active records that are older than Cache.AgeWarningHours are logged once as a warning.
Configuration
HL72HL7 reads config.yaml from its data folder once, at startup. After any change, validate the file and restart the service. See Starting and Stopping and Configuration.
Validating configuration
The configuration is validated strictly. Any error stops the service before it opens its listener; it never falls back to defaults for a malformed file. Keys are case-sensitive and unknown keys are an error.
Check a configuration without starting the service, from an elevated command prompt:
bat
"C:\Program Files\Flux Inc\DICOM7 HL72HL7 Broker\HL72HL7.exe" ^
--path "C:\ProgramData\Flux Inc\DICOM7\HL72HL7" --validate-configA valid file prints HL72HL7 configuration is valid: <path> and exits with code 0. An invalid file exits with code 1 and logs every problem found, for example:
text
Invalid HL72HL7 configuration:
- RouteAndDeliver mode requires at least one enabled destination
- Destinations[0].Port must be between 1 and 65535The installer runs the same check before it installs or restarts the service.
| Option | Description |
|---|---|
--path <folder> | Data folder containing config.yaml, used for the log and a relative cache folder. The folder must exist. |
--validate-config | Validate the configuration, print the result and exit. |
Top-level keys
| Key | Type | Default | Description |
|---|---|---|---|
Mode | CaptureOnly | RouteAndDeliver | CaptureOnly | See Modes |
HL7 | object | see HL7 | Inbound listener |
Cache | object | see Cache | Record storage and retention |
Retry | object | see Retry | Outbound timing and acknowledgement handling |
AcceptedMessageTypes | list | ORM^O01, ORU^R01 | Message types accepted from senders |
Destinations | list | empty | Delivery targets. See Destinations |
Mode
- Type:
CaptureOnlyorRouteAndDeliver - Default:
CaptureOnly
RouteAndDeliver requires at least one destination with Enabled: true. In CaptureOnly mode, destinations may be configured; they are validated but not used.
HL7
Settings for the inbound MLLP listener.
| Key | Type | Default | Allowed | Description |
|---|---|---|---|---|
ListenIP | string | 0.0.0.0 | 0.0.0.0 or a literal IPv4/IPv6 address | Address to listen on. 0.0.0.0 listens on all interfaces. Host names are not accepted. |
ListenPort | number | 7777 | 1–65535 | TCP port to listen on |
DefaultCharacterSet | string | Windows-1252 | see below | Character set used to read a message whose MSH-18 is empty |
MaxMessageBytes | number | 67108864 (64 MB) | 1024–67108864 | Largest accepted message. A larger frame is answered AR and the connection is closed. |
ClientTimeoutSeconds | number | 30 | 1–3600 | How long a partly received frame may stall before the connection is closed. Also the timeout for writing an acknowledgement. |
IdleConnectionTimeoutSeconds | number | 300 | 1–86400 | How long a connection may stay open with no data before it is closed |
MaxConnections | number | 32 | 1–1024 | Concurrent inbound connections. Further connections are accepted and closed immediately, with a warning in the log. |
ControlIdReuse | Accept | Reject | Accept | Unreleased. What to do when a message reuses the identity of a stored message with different content. See Duplicates. |
Character set names accepted in DefaultCharacterSet and in a message's MSH-18 (case-insensitive):
| Encoding | Names |
|---|---|
| US-ASCII | ASCII, ISO IR6 |
| UTF-8 | UTF-8, UNICODE UTF-8 |
| ISO-8859-1 | 8859/1, ISO-8859-1, ISO IR100 |
| Windows-1252 | Windows-1252, CP1252 |
Messages are stored as received regardless of character set. The character set matters only when HL72HL7 has to read fields: for Match rules, transforms and correlation.
HL7 also accepts the keys SenderName, ReceiverName and ReceiverFacility, which are shared with other DICOM7 services. HL72HL7 does not use them.
Cache
| Key | Type | Default | Allowed | Description |
|---|---|---|---|---|
Folder | string | cache | not a drive root | Cache root. A relative path is resolved against the data folder. |
RetentionDays | number | 30 | ≥ 1 | Days a completed record is kept. Applies to completed only. |
KeepSentItems | boolean | true | must be true | Present for compatibility with other DICOM7 services. RetentionDays controls cleanup of completed records. |
AutoCleanup | boolean | true | Run the periodic cleanup. When false, nothing is ever deleted. | |
CleanupIntervalMinutes | number | 60 | 1–10080 | Time between cleanup runs. The first run is one interval after start. |
AgeWarningHours | number | 48 | 1–87600 | Log a warning the first time an active record is older than this |
ReceiptRetentionDays | number | 365 | 0, or ≥ RetentionDays | Unreleased. Days a receipt is kept, counted from completion. 0 keeps receipts forever. In 2.5.1 receipts are always kept. |
See also Cache folder layout and the general Cache page.
Retry
Outbound delivery settings, shared by all destinations.
| Key | Type | Default | Allowed | Description |
|---|---|---|---|---|
IntervalSeconds | number | 30 | 1–86400 | Delivery cycle interval, and first retry delay |
MaxIntervalSeconds | number | 900 | IntervalSeconds–604800 | Upper limit of the retry delay |
ConnectTimeoutSeconds | number | 5 | 1–300 | Time allowed to open the TCP connection |
AckTimeoutSeconds | number | 10 | 1–300 | Time allowed to write the message and to receive the reply |
MaxAckBytes | number | 65536 | 128–1048576 | Largest reply accepted. A larger reply is a failed attempt. |
TerminalAckCodes | list | AR, CR | two-letter codes; not AA or CA | MSA-1 codes that are a final answer. See below. |
TerminalAckCodes are trimmed and upper-cased. A reply with one of these codes and a matching MSA-2 stops retries to that destination. Once every matching destination has accepted or finally rejected the record, it moves to cache\rejected for review. AE is not in the default list, so application errors are retried. Set TerminalAckCodes: [] to retry every negative reply forever.
AcceptedMessageTypes
- Type: list of
TYPE^TRIGGER - Default:
ORM^O01,ORU^R01
The message types HL72HL7 accepts. A message whose MSH-9 type and trigger are not listed is answered AR and not stored. Each entry must have exactly two parts made of letters and digits, for example ADT^A08; a third component such as ORU^R01^ORU_R01 is not accepted. Entries are case-insensitive and duplicates are ignored. The list cannot be empty.
Every type used in a destination's MessageTypes or Correlate.From must also be listed here.
Destinations
Each entry is one MLLP receiver.
| Key | Type | Default | Description |
|---|---|---|---|
Name | string | — (required) | Stable delivery identity. Unique (case-insensitive) among enabled destinations, with no leading or trailing spaces. |
Host | string | — (required) | Host name or IP address of the receiver |
Port | number | — (required) | TCP port, 1–65535 |
Enabled | boolean | true | A disabled destination receives nothing. It is still checked for errors. |
MessageTypes | list | — (required) | TYPE^TRIGGER values this destination receives. At least one. |
DeliverMessagesReceivedAfterUtc | date-time | none | Only records received at or after this time (ISO 8601, for example 2026-07-21T00:00:00Z) go to this destination |
Match | list | empty | Field rules. All must pass. Empty means every message of the listed types. See Routing. |
Transforms | list | empty | Field changes applied to the copy sent to this destination. See Transforms. |
Correlate | object | none | Copy fields from an earlier record. See Correlation. |
Ordered | boolean | true | Unreleased. Deliver in arrival order. See Ordered delivery. |
Destination names are durable
Delivery progress is stored per destination name. If you rename a destination, HL72HL7 treats it as a new receiver: every record that is still active is sent to it, including records the old name had already delivered.
Routing
A record is sent to a destination when all of the following are true:
- The record's message type (
MSH-9type and trigger) is in the destination'sMessageTypes. - If
DeliverMessagesReceivedAfterUtcis set, the record was received at or after that time. - Every rule in
Matchpasses. A destination with noMatchrules accepts every message that meets 1 and 2.
A record can match several destinations; it is delivered to each of them.
A record that matches no destination is unrouted. It stays in cache\active, a warning is logged once for it, and it is counted as unrouted in each cycle summary. It is delivered if a later configuration change makes it match.
Match rules
| Key | Type | Description |
|---|---|---|
Field | selector | Field to test, for example PV1-3.4 or MSH-4 |
Values | list of strings | Passes when the field equals one of these values (case-insensitive) |
Pattern | regular expression | Passes when the field matches this .NET regular expression (case-insensitive) |
A rule needs Values, Pattern, or both. With both, either one passing is enough. Values entries cannot be empty. The field value is trimmed before it is compared. A missing or empty field never passes. Use ^ and $ in Pattern to match the whole value; without them, a match anywhere in the value passes.
yaml
Match:
- Field: PV1-3.4 # Facility component of the assigned location
Values:
- NORTH-CAMPUS
- Field: OBR-4.1
Pattern: "^(US|CT)" # Procedure codes starting with US or CTIf a record has to be read for Match rules or correlation but its MSH-18 names an unsupported character set, or it cannot be parsed, it is moved to cache\quarantine.
Field selectors
Match, Transforms and Correlate refer to fields with selectors of the form SEG-F or SEG-F.C:
SEGis the three-character segment name (case-insensitive).Fis the field number. InMSH, numbering follows the standard, soMSH-3is the sending application.Cis an optional component number.- A dot may be used instead of the dash:
PV1.3.4equalsPV1-3.4.
Transforms and correlation read and write only the first occurrence of a segment. Repetitions and subcomponents cannot be selected.
Transforms
Transforms change the copy of the message sent to one destination. They never change the stored message. Transforms run in the order listed, and each one sees the result of the ones before it.
| Key | Type | Default | Description |
|---|---|---|---|
Target | selector | — (required) | Field or component to write |
Source | selector | — | Field or component to copy from |
Value | string | — | Literal value to write |
Required | boolean | true | If Source is missing: true fails the attempt; false skips this transform |
Encoding | None | Base64Utf8 | None | Base64Utf8 writes the Base64 of the value's UTF-8 bytes |
CreateSegmentIfMissing | boolean | false | If the target segment does not exist, add it. Otherwise the attempt fails. |
InsertAfter | segment name | none | Where to add a missing segment: after the last segment with this name. Requires CreateSegmentIfMissing: true. Without it, the segment is added at the end. |
Rules:
- Each transform needs exactly one of
SourceorValue. - A
Sourcewhose segment does not exist, or that is beyond the end of the segment, is missing. A field that exists but is empty is not missing; it copies an empty value. Targetcannot beMSH-1,MSH-2,MSH-9,MSH-10orMSH-12. OtherMSHfields, such asMSH-5andMSH-6, can be set.- Fields and components are added as needed to reach the target position.
- The written value cannot contain the field separator, a carriage return, a line feed or an MLLP framing byte. When the target is a component, it also cannot contain the component separator. A field-level target can contain component separators, for example
Value: "A^B". - The result must still be a valid HL7 message, encoded in the message's character set.
When there are no transforms and no correlation assignments, the stored bytes are sent unchanged.
Failed transforms are retried
A transform that fails (missing required source, missing target segment, value that cannot be written) fails the delivery attempt. It is retried with backoff like any other failure, and with Ordered: true it holds up later messages for that destination. Check the log for Outbound transform failed.
yaml
Transforms:
# Set the receiving application and facility for this receiver
- Value: WORKLIST
Target: MSH-5
- Value: ROOM-1
Target: MSH-6
# Copy the ordering provider, if present, into a new NTE segment after OBR
- Source: OBR-16
Target: NTE-3
Required: false
Encoding: Base64Utf8
CreateSegmentIfMissing: true
InsertAfter: OBRCorrelation
A Correlate block copies fields from an earlier stored record into the message sent to a destination. A typical use is adding the order number from an ORM^O01 to an ORU^R01 produced by a device that does not return it.
| Key | Type | Default | Allowed | Description |
|---|---|---|---|---|
From | list | — (required) | TYPE^TRIGGER values in AcceptedMessageTypes | Message types of the records to search |
On | list | — (required) | at least one | Keys that must match. Each has Field (in the message being sent) and CandidateField (in the earlier record). |
Copy | list | — (required) | at least one | Fields to copy. Each has Source (in the earlier record) and Target (in the message being sent). Target cannot be MSH-1, -2, -9, -10 or -12. |
LookbackHours | number | 48 | 1–87600 | How far before the message's receive time to search |
HoldMinutes | number | 15 | 0–1440 | How long to hold the message waiting for a match, and how far after its receive time to search |
LookbackHours plus HoldMinutes must fit within Cache.RetentionDays, so that candidates are not cleaned up while they are still needed.
How a match is found
Candidates are stored records that:
- are of a type listed in
From; - are in
cache\active,cache\completedorcache\rejected(not quarantine); - were received between
LookbackHoursbefore andHoldMinutesafter the message being sent; - have, for every
Onkey, aCandidateFieldvalue exactly equal (case-sensitive) to the message'sFieldvalue.
Candidates that would copy the same values count as one match, so an order sent several times is not a problem. Then:
| Outcome | What happens |
|---|---|
| Matched: one distinct set of values | The values are written, then the destination's transforms run |
| NoCandidates or Ambiguous (candidates disagree on the values) | The message is held for this destination until HoldMinutes after it was received, then sent without the copied values. HL72HL7 never chooses between disagreeing candidates. |
MissingKey: an On field is empty in the message | Sent at once without the copied values |
If a Copy target already has a value in the message, the message keeps its own value. When the two differ, a warning is logged. The outcome is recorded in delivery.json (Correlation) and in the log, with the shortened IDs of the candidate records.
Held records are counted as held in the cycle summary and do not block ordered delivery.
Target segment must exist
Copied values are written without creating segments. If the message being sent does not contain the segment named in a Copy target, the attempt fails and is retried. Copy only into segments the message always contains.
Cache folder layout
Each record is a folder named by its record ID, inside one of these folders under the cache root:
| Folder | Contents | Cleaned up automatically |
|---|---|---|
staging | Records being written. Normally empty. | Leftovers are moved to quarantine at startup |
active | Records waiting for delivery, including unrouted, held, failing, and all records in CaptureOnly mode | Never |
completed | Records accepted by every matching destination | After RetentionDays |
rejected | Records that at least one destination finally rejected, once every matching destination has accepted or rejected them | Never |
quarantine | Records that could not be read or verified, abandoned staging records, and conflict copies | Never |
receipts | One small <record ID>.json per completed record, used to detect resends | After ReceiptRetentionDays (Unreleased); kept forever in 2.5.1 |
A record folder contains:
| File | Description |
|---|---|
message.hl7 | Exact bytes received, without MLLP framing. Never modified. |
manifest.json | Capture details, written once |
delivery.json | Per-destination delivery state. Created at the first delivery attempt. |
quarantine.json | Only in quarantine: time and reason |
Protected health information
message.hl7 contains the full HL7 message. The installer limits the data folder to the SYSTEM account and Administrators. Do not copy cache contents into email or chat; use a secure channel when sending them for support.
manifest.json
| Field | Description |
|---|---|
SchemaVersion | Always 1 |
RecordId | Record ID; equals the folder name |
ContentSha256 | SHA-256 of message.hl7 |
ReceivedUtc | Time the message was received (UTC). Used for ordering, cutoffs, correlation and age warnings. |
SendingApplication, SendingFacility | MSH-3, MSH-4 |
MessageControlId | MSH-10 |
MessageType, TriggerEvent | MSH-9 components 1 and 2 |
CharacterSet | MSH-18 (may be empty) |
On every cycle, each active record is checked: both files must exist, the manifest must be complete, the folder name must match RecordId, the message hash must match ContentSha256, and the MSH must match the manifest. A record that fails any check is moved to quarantine with the reason.
delivery.json
json
{
"SchemaVersion": 1,
"CompletedUtc": null,
"Destinations": {
"EXAMPLE-WORKLIST": {
"Delivered": false,
"Attempts": 3,
"LastAttemptUtc": "2026-01-15T12:00:00Z",
"NextAttemptUtc": "2026-01-15T12:02:00Z",
"Ambiguous": false,
"LastError": "Destination returned MSA-1=AE (Unknown location)",
"Rejected": false,
"LastRemoteEndpoint": "192.0.2.50:7777",
"LastAck": "MSH-3=EXAMPLE_MWL MSH-4=EXAMPLE_SITE MSH-9=ACK^O01 MSH-10=ACK-001 MSA-1=AE MSA-2=EXAMPLE-001 MSA-3=Unknown location",
"Correlation": null,
"RejectedAfterUnansweredAttempt": false
}
}
}| Field | Description |
|---|---|
CompletedUtc | Set when every matching destination has accepted the record |
Delivered | The destination returned AA with a matching MSA-2 |
Rejected | The destination gave a final rejection (Retry.TerminalAckCodes) |
Attempts | Number of attempts so far |
LastAttemptUtc, NextAttemptUtc | Time of the last attempt and of the next retry |
Ambiguous | The last attempt may have reached the destination, but no valid reply was received |
LastError | Reason for the last failure (up to 1000 characters) |
LastRemoteEndpoint | IP address and port actually connected to |
LastAck | Summary of the last reply: its MSH-3, MSH-4, MSH-9, MSH-10, MSA-1, MSA-2, MSA-3 and ERR text |
Correlation | Correlation outcome of the last attempt |
RejectedAfterUnansweredAttempt | Unreleased. The final rejection followed an attempt with no reply, so the destination probably already holds the message |
Destinations are keyed by Name. Entries for destinations that have since been removed from the configuration are kept but no longer considered.
Before each attempt, HL72HL7 saves the attempt as ambiguous; after the reply it saves the outcome. If the service stops between the two, the attempt is retried.
Do not edit delivery.json
A delivery.json with inconsistent values (for example Delivered: true with a NextAttemptUtc) causes the record to be moved to quarantine.
Retention and cleanup
When Cache.AutoCleanup is true, the cleanup runs every CleanupIntervalMinutes:
- Completed records whose receipt shows completion more than
RetentionDaysago are deleted. Before deleting, HL72HL7 checks that the receipt exists, names the same record, and has the same content hash as the record. If any check fails, the record is kept and an error is logged. - Receipts (Unreleased) whose completion is more than
ReceiptRetentionDaysago, and whose completed record is gone, are deleted. WithReceiptRetentionDays: 0, receipts are kept forever.
Records in active, rejected and quarantine are never deleted automatically, whatever their age. Plan disk space for the backlog that can build up while destinations are unavailable or while running in CaptureOnly mode.
Logging
The log is written to <data folder>\logs\dicom7-hl72hl7.log. Files roll at 10 MB and the last 7 files are kept. Message contents are not logged; records are identified by record ID and MSH-10. See Logs.
Each delivery cycle logs a summary:
text
Broker cycle: mode=RouteAndDeliver, active=12, oldestHours=0.4, unrouted=1, held=2, waiting=3, failed=1, rejected=0, quarantined=0, indexed=40, elapsedMs=85| Field | Meaning |
|---|---|
active | Records in cache\active at the start of the cycle |
oldestHours | Age of the oldest active record |
unrouted | Records matching no destination |
held | Records held for correlation |
waiting | Unreleased. Records waiting behind an earlier record (ordered delivery) |
failed | Records with a failed attempt this cycle |
rejected | Records moved to cache\rejected this cycle |
quarantined | Records moved to cache\quarantine this cycle |
indexed | Records available as correlation candidates |
elapsedMs | Unreleased. Duration of the cycle |
Each cleanup run logs the number of records and receipts deleted. In 2.5.2 (Unreleased) it also logs the number of entries in each cache folder and the elapsed time.
Accepted deliveries are logged with the destination, record ID, MSH-10, remote and local endpoint, elapsed time, and the reply summary. Failures add the attempt number, whether the attempt was ambiguous, the next retry time and the error.
Examples
Settings for 2.5.2
The examples include settings marked # Unreleased; omit on 2.5.1. Remove those lines before using an example with HL72HL7 2.5.1, which refuses to start with settings it does not recognise.
Capture only
The shipped configuration. Messages are stored and acknowledged; nothing is delivered.
yaml
Mode: CaptureOnly
HL7:
ListenIP: 0.0.0.0
ListenPort: 7777
DefaultCharacterSet: Windows-1252
MaxMessageBytes: 67108864
ClientTimeoutSeconds: 30
IdleConnectionTimeoutSeconds: 300
MaxConnections: 32
ControlIdReuse: Accept # Unreleased; omit on 2.5.1
Cache:
Folder: cache
RetentionDays: 30
KeepSentItems: true
AutoCleanup: true
CleanupIntervalMinutes: 60
AgeWarningHours: 48
ReceiptRetentionDays: 365 # Unreleased; omit on 2.5.1
Retry:
IntervalSeconds: 30
MaxIntervalSeconds: 900
ConnectTimeoutSeconds: 5
AckTimeoutSeconds: 10
MaxAckBytes: 65536
TerminalAckCodes:
- AR
- CR
AcceptedMessageTypes:
- ORM^O01
- ORU^R01
Destinations: []Route orders by location, with transforms
Orders for one location go to a worklist receiver. Only orders received on or after the cutover time are sent; earlier orders and orders for other locations stay in cache\active as unrouted.
yaml
Mode: RouteAndDeliver
AcceptedMessageTypes:
- ORM^O01
Destinations:
- Name: WORKLIST-ROOM-1
Host: 10.0.0.50
Port: 7777
MessageTypes:
- ORM^O01
DeliverMessagesReceivedAfterUtc: 2026-07-21T00:00:00Z
Ordered: true # Unreleased; omit on 2.5.1
Match:
- Field: PV1-3.4
Values:
- NORTH-CAMPUS
- Field: PV1-3.1
Pattern: "^ROOM-?1$"
Transforms:
- Value: WORKLIST
Target: MSH-5
- Source: OBR-16
Target: NTE-3
Required: false
Encoding: Base64Utf8
CreateSegmentIfMissing: true
InsertAfter: OBRThe HL7, Cache and Retry sections are omitted here for brevity; omitted keys take their defaults.
Add the order number to results
A device returns ORU^R01 results without the order number. HL72HL7 finds the ORM^O01 with the same visit number (PV1-19) and copies its placer order number into the result before sending it to the EHR's interface engine.
yaml
Mode: RouteAndDeliver
Cache:
RetentionDays: 30 # must cover LookbackHours + HoldMinutes
AcceptedMessageTypes:
- ORM^O01
- ORU^R01
Destinations:
- Name: DEVICE-ORDERS
Host: 10.0.0.60
Port: 7777
MessageTypes:
- ORM^O01
- Name: RESULTS-EHR
Host: hl7.example.org
Port: 6661
MessageTypes:
- ORU^R01
Correlate:
From:
- ORM^O01
On:
- Field: PV1-19
CandidateField: PV1-19
Copy:
- Source: OBR-2
Target: OBR-2
LookbackHours: 48
HoldMinutes: 15A result whose PV1-19 matches one order (or several copies of the same order) is sent with that order's OBR-2, unless the result already has its own OBR-2. A result with no matching order, or with orders that disagree, is held for up to 15 minutes after it arrived and then sent unchanged. A result with an empty PV1-19 is sent unchanged at once.
Installation and upgrades
The HL72HL7 installer creates config.yaml only if it does not already exist. Upgrades and uninstalls keep the configuration and the whole cache. The installer validates the configuration before installing or restarting the service. See Installation.
To check the service and listener:
bat
sc.exe query DICOM7_HL72HL7
netstat -ano | findstr :7777When testing a new installation, send only test messages. For each AA returned, one record folder containing message.hl7 and manifest.json should appear under cache\active.