Schedule a demo
Segment

Batch trailer

Marks the end of a batch of HL7 messages, carrying a count of the messages in the batch and optionally a batch comment and totals field. It is always paired with a preceding BH S and is used by receiving systems to validate that the correct number of messages were received in the batch transmission.

3fields
0required
v2.9HL7 version
bts.py
from zato.hl7v2.v2_9 import BTS

bts = BTS()
bts.batch_message_count = '42'
bts.batch_comment = 'Wellness batch complete'
bts.batch_totals = ['150', '200', '50']

Build BTS segments in Python

How to construct and work with real-world BTS segments.

1

Wellness screening totals

Message count, friendly comment, and repeating NM totals

from zato.hl7v2.v2_9 import BTS

bts = BTS()
bts.batch_message_count = '42'
bts.batch_comment = 'Wellness screening batch complete'
bts.batch_totals = ['150', '200', '50']
2

Fitness message run closed

Count and short comment without totals

from zato.hl7v2.v2_9 import BTS

bts = BTS()
bts.batch_message_count = '18'
bts.batch_comment = 'Fitness registrations closed'
3

Nutrition assessments only

Totals repeat for macro summaries without a comment

from zato.hl7v2.v2_9 import BTS

bts = BTS()
bts.batch_message_count = '9'
bts.batch_totals = ['12.5', '10.0', '8.5']

Learn by building

Step-by-step guides for working with HL7 v2 in Zato.

Frequently asked questions

It is a string token (ST) partners use to report how many logical messages appeared between BHS and BTS. Align the meaning with your batch profile for wellness or fitness feeds.

Field 3 repeats in ER7 with ~ between NM values. In Python, assign a list of numeric strings:

from zato.hl7v2.v2_9 import BTS

bts = BTS()
bts.batch_totals = ['150', '200', '50']

No. It is optional; send an empty field between pipes when you only need counts and totals.

Use batch_comment and control identifiers from BHS together in operations logs so support teams can match an opened batch header with its trailer row.

Yes. Omit the list or leave the field empty when totals are computed elsewhere or not part of the agreement.

Zato connects to any system that speaks HL7v2 over MLLP or FHIR over REST. This includes Epic, Cerner, Meditech, Allscripts, and other EHR platforms.

Yes, Zato has built-in MLLP support for sending and receiving HL7v2 messages. MLLP channels handle the framing protocol automatically.

Zato supports HL7 v2.9, which is backward compatible with earlier versions including v2.3, v2.5, and v2.7. Standard segments and datatypes are available as typed Python classes.

Yes. Zato handles both HL7v2 and FHIR natively, so you can parse v2 messages and build FHIR resources with IG-specific extensions in the same service. Typed Python classes are available for both protocols, including extensions from US Core, UK Core, Da Vinci, and other Implementation Guides.

BTS field reference

Complete list of fields in the BTS segment, HL7 v2.9.

#Python nameDatatypeUsageRepeatableTable
1batch_message_countSTOptionalNo-
2batch_commentSTOptionalNo-
3batch_totalsNMOptionalYes-

Ready to build integrations?

Get started with Zato and connect your systems in minutes.

Open source In Python