Skip to content

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 serviceDICOM7_HL72HL7
Program folderC:\Program Files\Flux Inc\DICOM7 HL72HL7 Broker
Data folderC:\ProgramData\Flux Inc\DICOM7\HL72HL7
Configuration<data folder>\config.yaml
Cache<data folder>\cache (default)
Log<data folder>\logs\dicom7-hl72hl7.log
Default listen port7777

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:

  1. Reads one complete MLLP frame.
  2. Checks the MSH header and segment structure (see Inbound validation).
  3. Checks that the message type (MSH-9 components 1 and 2, for example ORU^R01) is listed in AcceptedMessageTypes.
  4. Writes the exact received bytes (message.hl7) and a manifest.json to a staging folder, then moves the folder into cache\active in one step.
  5. Only then returns AA to 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 ​

SituationMSA-1Connection
Message storedAAKept open
Exact duplicate of a stored message (see Duplicates)AAKept open
Message type not in AcceptedMessageTypesARKept open
Invalid MSH or segment structureARKept open
Invalid MLLP frame, or frame larger than HL7.MaxMessageBytesARClosed
Same MSH-10 reused with different content and ControlIdReuse: RejectAEKept open
Message could not be written to diskAEKept 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-2 has fewer than four encoding characters, or the field, component, repetition and escape characters are not all different.
  • MSH-9 does not contain both a message type and a trigger event.
  • MSH-10 is empty.
  • MSH-3, MSH-4, MSH-5, MSH-6, MSH-9, MSH-10, MSH-12 or MSH-18 contain 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-1 field 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 messageAccept (default)Reject
Same bytes as a stored messageDuplicate: AA, not delivered againDuplicate: AA, not delivered again
Same type, MSH-3, MSH-4 and MSH-10, different bytesNew message: stored and deliveredAE; 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 ​

ModeBehavior
CaptureOnly (default)Receives, stores and acknowledges messages. Nothing is delivered. Records stay in cache\active indefinitely.
RouteAndDeliverAlso 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:

  1. Lists cache\active and sorts the records by the time they were received (oldest first).
  2. In RouteAndDeliver mode, 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.
  3. Moves a record to cache\completed once every matching destination has accepted it, or to cache\rejected once every matching destination has either accepted or finally rejected it.
  4. 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 waiting in 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.AckTimeoutSeconds and is no larger than Retry.MaxAckBytes;
  • the reply is printable ASCII, starts with MSH, and contains an MSA segment;
  • MSA-1 is exactly AA;
  • MSA-2 exactly equals the MSH-10 of the message sent.

Every other outcome is a failure:

OutcomeResult
MSA-1 is in Retry.TerminalAckCodes (default AR, CR) and MSA-2 matches the sent MSH-10Final 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-2Retried
AA with a non-matching MSA-2, missing MSA, malformed or oversized replyRetried
Connect timeout, connection refused or closed, no reply within the timeoutRetried

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-config

A 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 65535

The installer runs the same check before it installs or restarts the service.

OptionDescription
--path <folder>Data folder containing config.yaml, used for the log and a relative cache folder. The folder must exist.
--validate-configValidate the configuration, print the result and exit.

Top-level keys ​

KeyTypeDefaultDescription
ModeCaptureOnly | RouteAndDeliverCaptureOnlySee Modes
HL7objectsee HL7Inbound listener
Cacheobjectsee CacheRecord storage and retention
Retryobjectsee RetryOutbound timing and acknowledgement handling
AcceptedMessageTypeslistORM^O01, ORU^R01Message types accepted from senders
DestinationslistemptyDelivery targets. See Destinations

Mode ​

  • Type: CaptureOnly or RouteAndDeliver
  • 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.

KeyTypeDefaultAllowedDescription
ListenIPstring0.0.0.00.0.0.0 or a literal IPv4/IPv6 addressAddress to listen on. 0.0.0.0 listens on all interfaces. Host names are not accepted.
ListenPortnumber77771–65535TCP port to listen on
DefaultCharacterSetstringWindows-1252see belowCharacter set used to read a message whose MSH-18 is empty
MaxMessageBytesnumber67108864 (64 MB)1024–67108864Largest accepted message. A larger frame is answered AR and the connection is closed.
ClientTimeoutSecondsnumber301–3600How long a partly received frame may stall before the connection is closed. Also the timeout for writing an acknowledgement.
IdleConnectionTimeoutSecondsnumber3001–86400How long a connection may stay open with no data before it is closed
MaxConnectionsnumber321–1024Concurrent inbound connections. Further connections are accepted and closed immediately, with a warning in the log.
ControlIdReuseAccept | RejectAcceptUnreleased. 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):

EncodingNames
US-ASCIIASCII, ISO IR6
UTF-8UTF-8, UNICODE UTF-8
ISO-8859-18859/1, ISO-8859-1, ISO IR100
Windows-1252Windows-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 ​

KeyTypeDefaultAllowedDescription
Folderstringcachenot a drive rootCache root. A relative path is resolved against the data folder.
RetentionDaysnumber30≥ 1Days a completed record is kept. Applies to completed only.
KeepSentItemsbooleantruemust be truePresent for compatibility with other DICOM7 services. RetentionDays controls cleanup of completed records.
AutoCleanupbooleantrueRun the periodic cleanup. When false, nothing is ever deleted.
CleanupIntervalMinutesnumber601–10080Time between cleanup runs. The first run is one interval after start.
AgeWarningHoursnumber481–87600Log a warning the first time an active record is older than this
ReceiptRetentionDaysnumber3650, or ≥ RetentionDaysUnreleased. 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.

KeyTypeDefaultAllowedDescription
IntervalSecondsnumber301–86400Delivery cycle interval, and first retry delay
MaxIntervalSecondsnumber900IntervalSeconds–604800Upper limit of the retry delay
ConnectTimeoutSecondsnumber51–300Time allowed to open the TCP connection
AckTimeoutSecondsnumber101–300Time allowed to write the message and to receive the reply
MaxAckBytesnumber65536128–1048576Largest reply accepted. A larger reply is a failed attempt.
TerminalAckCodeslistAR, CRtwo-letter codes; not AA or CAMSA-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.

KeyTypeDefaultDescription
Namestring— (required)Stable delivery identity. Unique (case-insensitive) among enabled destinations, with no leading or trailing spaces.
Hoststring— (required)Host name or IP address of the receiver
Portnumber— (required)TCP port, 1–65535
EnabledbooleantrueA disabled destination receives nothing. It is still checked for errors.
MessageTypeslist— (required)TYPE^TRIGGER values this destination receives. At least one.
DeliverMessagesReceivedAfterUtcdate-timenoneOnly records received at or after this time (ISO 8601, for example 2026-07-21T00:00:00Z) go to this destination
MatchlistemptyField rules. All must pass. Empty means every message of the listed types. See Routing.
TransformslistemptyField changes applied to the copy sent to this destination. See Transforms.
CorrelateobjectnoneCopy fields from an earlier record. See Correlation.
OrderedbooleantrueUnreleased. 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:

  1. The record's message type (MSH-9 type and trigger) is in the destination's MessageTypes.
  2. If DeliverMessagesReceivedAfterUtc is set, the record was received at or after that time.
  3. Every rule in Match passes. A destination with no Match rules 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 ​

KeyTypeDescription
FieldselectorField to test, for example PV1-3.4 or MSH-4
Valueslist of stringsPasses when the field equals one of these values (case-insensitive)
Patternregular expressionPasses 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 CT

If 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:

  • SEG is the three-character segment name (case-insensitive).
  • F is the field number. In MSH, numbering follows the standard, so MSH-3 is the sending application.
  • C is an optional component number.
  • A dot may be used instead of the dash: PV1.3.4 equals PV1-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.

KeyTypeDefaultDescription
Targetselector— (required)Field or component to write
Sourceselector—Field or component to copy from
Valuestring—Literal value to write
RequiredbooleantrueIf Source is missing: true fails the attempt; false skips this transform
EncodingNone | Base64Utf8NoneBase64Utf8 writes the Base64 of the value's UTF-8 bytes
CreateSegmentIfMissingbooleanfalseIf the target segment does not exist, add it. Otherwise the attempt fails.
InsertAftersegment namenoneWhere 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 Source or Value.
  • A Source whose 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.
  • Target cannot be MSH-1, MSH-2, MSH-9, MSH-10 or MSH-12. Other MSH fields, such as MSH-5 and MSH-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: OBR

Correlation ​

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.

KeyTypeDefaultAllowedDescription
Fromlist— (required)TYPE^TRIGGER values in AcceptedMessageTypesMessage types of the records to search
Onlist— (required)at least oneKeys that must match. Each has Field (in the message being sent) and CandidateField (in the earlier record).
Copylist— (required)at least oneFields 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.
LookbackHoursnumber481–87600How far before the message's receive time to search
HoldMinutesnumber150–1440How 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\completed or cache\rejected (not quarantine);
  • were received between LookbackHours before and HoldMinutes after the message being sent;
  • have, for every On key, a CandidateField value exactly equal (case-sensitive) to the message's Field value.

Candidates that would copy the same values count as one match, so an order sent several times is not a problem. Then:

OutcomeWhat happens
Matched: one distinct set of valuesThe 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 messageSent 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:

FolderContentsCleaned up automatically
stagingRecords being written. Normally empty.Leftovers are moved to quarantine at startup
activeRecords waiting for delivery, including unrouted, held, failing, and all records in CaptureOnly modeNever
completedRecords accepted by every matching destinationAfter RetentionDays
rejectedRecords that at least one destination finally rejected, once every matching destination has accepted or rejected themNever
quarantineRecords that could not be read or verified, abandoned staging records, and conflict copiesNever
receiptsOne small <record ID>.json per completed record, used to detect resendsAfter ReceiptRetentionDays (Unreleased); kept forever in 2.5.1

A record folder contains:

FileDescription
message.hl7Exact bytes received, without MLLP framing. Never modified.
manifest.jsonCapture details, written once
delivery.jsonPer-destination delivery state. Created at the first delivery attempt.
quarantine.jsonOnly 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 ​

FieldDescription
SchemaVersionAlways 1
RecordIdRecord ID; equals the folder name
ContentSha256SHA-256 of message.hl7
ReceivedUtcTime the message was received (UTC). Used for ordering, cutoffs, correlation and age warnings.
SendingApplication, SendingFacilityMSH-3, MSH-4
MessageControlIdMSH-10
MessageType, TriggerEventMSH-9 components 1 and 2
CharacterSetMSH-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
    }
  }
}
FieldDescription
CompletedUtcSet when every matching destination has accepted the record
DeliveredThe destination returned AA with a matching MSA-2
RejectedThe destination gave a final rejection (Retry.TerminalAckCodes)
AttemptsNumber of attempts so far
LastAttemptUtc, NextAttemptUtcTime of the last attempt and of the next retry
AmbiguousThe last attempt may have reached the destination, but no valid reply was received
LastErrorReason for the last failure (up to 1000 characters)
LastRemoteEndpointIP address and port actually connected to
LastAckSummary of the last reply: its MSH-3, MSH-4, MSH-9, MSH-10, MSA-1, MSA-2, MSA-3 and ERR text
CorrelationCorrelation outcome of the last attempt
RejectedAfterUnansweredAttemptUnreleased. 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 RetentionDays ago 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 ReceiptRetentionDays ago, and whose completed record is gone, are deleted. With ReceiptRetentionDays: 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
FieldMeaning
activeRecords in cache\active at the start of the cycle
oldestHoursAge of the oldest active record
unroutedRecords matching no destination
heldRecords held for correlation
waitingUnreleased. Records waiting behind an earlier record (ordered delivery)
failedRecords with a failed attempt this cycle
rejectedRecords moved to cache\rejected this cycle
quarantinedRecords moved to cache\quarantine this cycle
indexedRecords available as correlation candidates
elapsedMsUnreleased. 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: OBR

The 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: 15

A 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 :7777

When 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.