Marks the beginning of a file that may contain one or more batches of HL7 messages, carrying file encoding characters, sending and receiving application and facility, file creation date and time, and file control identifier. It is the outermost wrapper in HL7's file-batch-message hierarchy, used for large batch file transmissions such as nightly lab result dumps or claims files. FHS is always paired with a closing FTS segment.
from zato.hl7v2.v2_9 import FHS
from zato.hl7v2.v2_9 import CWE, HD
fhs = FHS()
fhs.file_field_separator = '|'
fhs.file_encoding_characters = '^~\\&'
fhs.file_sending_application = HD(
namespace_id='WELLAPP',
universal_id='Wellness Hub',
universal_id_type='DNS',
)
fhs.file_sending_facility = HD(
namespace_id='CLIN01',
universal_id='Main Clinic',
universal_id_type='DNS',
)
fhs.security_classification_tag = CWE(
identifier='WELL',
text='Wellness data',
name_of_coding_system='HL70952',
)How to construct and work with real-world FHS segments.
Full file header with HD routing, file label, control identifiers, security CWE tags, and restriction text
from zato.hl7v2.v2_9 import FHS
from zato.hl7v2.v2_9 import CWE, HD
fhs = FHS()
fhs.file_field_separator = '|'
fhs.file_encoding_characters = '^~\\&'
fhs.file_sending_application = HD(
namespace_id='WELLAPP',
universal_id='Wellness Hub',
universal_id_type='DNS',
)
fhs.file_sending_facility = HD(
namespace_id='CLIN01',
universal_id='Main Clinic',
universal_id_type='DNS',
)
fhs.file_receiving_application = HD(
namespace_id='HISAPP',
universal_id='HIS',
universal_id_type='DNS',
)
fhs.file_receiving_facility = HD(
namespace_id='HUB02',
universal_id='Wellness Hub',
universal_id_type='DNS',
)
fhs.file_creation_date_time = '20260404120000'
fhs.file_security = 'TLS'
fhs.file_name_id = 'WELLFILE'
fhs.file_header_comment = 'Wellness screening file export'
fhs.file_control_id = 'FILE-2026-001'
fhs.reference_file_control_id = 'REF-FILE-999'
fhs.file_sending_network_address = HD(
namespace_id='NETSEND',
universal_id='dns',
universal_id_type='DNS',
)
fhs.file_receiving_network_address = HD(
namespace_id='NETRECV',
universal_id='dns',
universal_id_type='DNS',
)
fhs.security_classification_tag = CWE(
identifier='WELL',
text='Wellness data',
name_of_coding_system='HL70952',
)
fhs.security_handling_instructions = [
CWE(
identifier='HANDLE',
text='Standard handling',
name_of_coding_system='HL70953',
),
CWE(
identifier='LOCK',
text='Secure channel',
name_of_coding_system='HL70953',
),
]
fhs.special_access_restriction_instructions = [
'INTERNAL',
'EXTERNAL',
]Compact header with routing HD rows and trailing empty fields
from zato.hl7v2.v2_9 import FHS
from zato.hl7v2.v2_9 import HD
fhs = FHS()
fhs.file_field_separator = '|'
fhs.file_encoding_characters = '^~\\&'
fhs.file_sending_application = HD(
namespace_id='FITAPP',
universal_id='Fitness',
universal_id_type='DNS',
)
fhs.file_sending_facility = HD(
namespace_id='GYM01',
universal_id='Studio',
universal_id_type='DNS',
)Receiving partners, file label, and control identifiers filled in
from zato.hl7v2.v2_9 import FHS
from zato.hl7v2.v2_9 import HD
fhs = FHS()
fhs.file_field_separator = '|'
fhs.file_encoding_characters = '^~\\&'
fhs.file_sending_application = HD(
namespace_id='NUTRI',
universal_id='Coach App',
universal_id_type='DNS',
)
fhs.file_sending_facility = HD(
namespace_id='KITCHEN',
universal_id='Demo Kitchen',
universal_id_type='DNS',
)
fhs.file_receiving_application = HD(
namespace_id='HUB',
universal_id='Data Hub',
universal_id_type='DNS',
)
fhs.file_receiving_facility = HD(
namespace_id='LAB',
universal_id='Assessment Lab',
universal_id_type='DNS',
)
fhs.file_creation_date_time = '20260405120000'
fhs.file_name_id = 'NUTRI'
fhs.file_header_comment = 'Coaching intake file'
fhs.file_control_id = 'NUT-FILE-88'
fhs.reference_file_control_id = 'PREV-REF-01'Step-by-step guides for working with HL7 v2 in Zato.
FHS opens a file and FTS closes it with an optional batch count and comment. BHS and BTS segments typically wrap messages between the file header and trailer for wellness or fitness feeds.
file_field_separator and file_encoding_characters describe how to read the rest of the file payload, similar in purpose to MSH-1 and MSH-2 on a message.
Use HD for file sending and receiving application and facility, plus optional network addresses when partners exchange DNS-style endpoints:
from zato.hl7v2.v2_9 import FHS, HD
fhs = FHS()
fhs.file_field_separator = '|'
fhs.file_encoding_characters = '^~\\&'
fhs.file_sending_application = HD(
namespace_id='WELLAPP',
universal_id='Wellness Hub',
universal_id_type='DNS',
)Field 16 repeats as CWE values from HL70953 so receivers know how to handle the file contents. Assign a list of CWE rows in Python when more than one applies.
Yes. Field 17 is ST with repetition, so ER7 uses ~ between tokens and Python accepts a list of short restriction strings.
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.
Complete list of fields in the FHS segment, HL7 v2.9.
| # | Python name | Datatype | Usage | Repeatable | Table |
|---|---|---|---|---|---|
| 1 | file_field_separator | ST | Required | No | - |
| 2 | file_encoding_characters | ST | Required | No | - |
| 3 | file_sending_application | HD | Optional | No | - |
| 4 | file_sending_facility | HD | Optional | No | - |
| 5 | file_receiving_application | HD | Optional | No | - |
| 6 | file_receiving_facility | HD | Optional | No | - |
| 7 | file_creation_date_time | DTM | Optional | No | - |
| 8 | file_security | ST | Optional | No | - |
| 9 | file_name_id | ST | Optional | No | - |
| 10 | file_header_comment | ST | Optional | No | - |
| 11 | file_control_id | ST | Optional | No | - |
| 12 | reference_file_control_id | ST | Optional | No | - |
| 13 | file_sending_network_address | HD | Optional | No | - |
| 14 | file_receiving_network_address | HD | Optional | No | - |
| 15 | security_classification_tag | CWE | Optional | No | HL70952 |
| 16 | security_handling_instructions | CWE | Optional | Yes | HL70953 |
| 17 | special_access_restriction_instructions | ST | Optional | Yes | - |
Get started with Zato and connect your systems in minutes.