Skip to content
The Path

Module 4 · Transport and acknowledgements·10 min

Batch files

FHS, BHS, BTS, FTS: sending hundreds of messages at once, and acknowledging them.

Every evening at 11 pm, the sleep lab tells billing about every night recorded that day. It could send one DFT per patient over MLLP and wait for each acknowledgement. Instead, it puts everything into a single file, which billing processes in one go. That is the HL7 v2 batch protocol, and it is the very example the standard uses.

One file, one batch, two DFT^P03 messages: two polysomnographies recorded on the night of 26 to 27 June.

DFT^P03^DFT_P03· Post financial transaction
|||||||||
|||||||||
||||||||||
||
||||||||
||||||||||
||||||||||
||
||||||||
||||||||||
|||
|

In the middle, two ordinary messages, each with its own MSH. Around them, a four-segment envelope. Click BTS-1: the batch announces two messages. Count the MSH lines: it adds up.

The envelope: four segments

Segment Name Role
FHS File Header opens the file
BHS Batch Header opens a batch
BTS Batch Trailer closes the batch, with the message count
FTS File Trailer closes the file, with the batch count

A file holds one or more batches, a batch holds messages. These segments are written like any other HL7 segment: same delimiters, same rules. A batch usually carries a single message type, but the standard does not forbid mixing them: the spec decides.

The standard marks all four segments as optional. So some partners exchange plain files of back-to-back messages, with no envelope. That is allowed, but you lose the control counts. The specification must say which one you get.

The fields to know

FHS and BHS follow the shape of MSH. FHS-1 and FHS-2 carry the delimiters, just like MSH-1 and MSH-2. Then come sender, receiver and date. After that, the batch-specific fields:

Field Content
FHS-9 file name or ID
FHS-11 unique file control ID
FHS-12 control ID of the original file, on a resend
BHS-9 batch name or type
BHS-11 unique batch control ID
BHS-12 control ID of the original batch, on a resend
BTS-1 number of messages in the batch
BTS-3 one or more control totals (repeating)
FTS-1 number of batches in the file

The counts: a check, not decoration

BTS-1 and FTS-1 let the receiver check it got everything. A file cut during transfer, or read while it was still being written, gives itself away here: two MSH lines under a BTS|3.

BTS-3 goes further: a total computed from the messages themselves. The standard leaves the formula to each site. Here, 2 is the sum of the FT1-10 quantities. If billing gets a different total, a message was altered on the way.

The standard adds that the sequence number protocol (MSH-13) has a natural application in batches: messages numbered one after another, so the receiver spots a gap or a duplicate.

When are batches used?

  • Overnight billing: every charge of the day to the financial system, the standard’s own example.
  • Bulk loads: historical results, an initial import when a new system goes live.
  • Catch-up: after an outage, the backlog goes out as one file rather than one message at a time.

A query can also ask for its response as a batch, with RCP-3 set to B (see the “Queries: QBP and RSP” lesson).

The standard even allows an empty batch. If the agreement requires a file every evening, the lab sends one with no messages on days with nothing to bill.

Acknowledging a batch

There is no single ACK for a file. The standard offers three options, to be chosen in the specification:

  1. a response batch that acknowledges every message;
  2. no automatic acknowledgement: the receiver prints a control report that people handle by hand;
  3. a response batch that only contains the errors. If it is empty, everything was accepted.

The response batch holds the usual responses for the message type: for a DFT, ACKs. Here is billing’s reply in “errors only” mode: the charge code in the second message is unknown.

Billing sends back a batch holding a single acknowledgement: the error on message MSG00082.

ACK^P03^ACK· Acknowledgement
||||||||||
||||||||||
||||||||||
||
||||
|
|

BHS-12 carries the BHS-11 of the 27 June batch: billing states which batch it is answering. Same logic on a resend: once the code is fixed, the lab sends a new batch, with a new BHS-11, and the original ID in BHS-12.

A billing batch, from 11 pm to 6 am

Sleep lab

sender

SFTP folder

drop zone

Billing

receiver

  1. FAC20260627.hl7
  2. folder pickup
  3. ACK batch · MSA|AE
  4. acknowledgement pickup
  5. fixed batch · BHS-12

File or MLLP?

The standard has file transfer in mind for batches. MLLP is built for one message at a time, with an acknowledgement after each. Nothing forbids sending a batch over MLLP, but many receivers will not take it: one that expects an MSH and gets an FHS may well reject the block. Agree on it up front. In practice, batches travel as dropped files, often over SFTP. On arrival, the interface engine checks the counts, splits the batch into messages, then handles each one as if it had arrived alone.

And in FHIR?

The closest thing is a Bundle of type batch: a set of independent requests, processed one by one by the server. Its reply, of type batch-response, gives one result per entry, much like an acknowledgement batch.

Check your understanding

1 of 5

Tonight’s file ends with BTS|3, but you only count two MSH segments in the batch. What happened?

+50 XPPass the quiz (4 correct answers) to complete the lesson.

Reviewed and checked on 28 September 2026