Schedule a demo
Segment

File header

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.

17fields
2required
v2.9HL7 version
fhs.py
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',
)

Build FHS segments in Python

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

1

Wellness screening file open

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',
]
2

Fitness evaluation file

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',
)
3

Nutrition assessment file

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'

Learn by building

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

Frequently asked questions

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.

FHS field reference

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

#Python nameDatatypeUsageRepeatableTable
1file_field_separatorSTRequiredNo-
2file_encoding_charactersSTRequiredNo-
3file_sending_applicationHDOptionalNo-
4file_sending_facilityHDOptionalNo-
5file_receiving_applicationHDOptionalNo-
6file_receiving_facilityHDOptionalNo-
7file_creation_date_timeDTMOptionalNo-
8file_securitySTOptionalNo-
9file_name_idSTOptionalNo-
10file_header_commentSTOptionalNo-
11file_control_idSTOptionalNo-
12reference_file_control_idSTOptionalNo-
13file_sending_network_addressHDOptionalNo-
14file_receiving_network_addressHDOptionalNo-
15security_classification_tagCWEOptionalNoHL70952
16security_handling_instructionsCWEOptionalYesHL70953
17special_access_restriction_instructionsSTOptionalYes-

Ready to build integrations?

Get started with Zato and connect your systems in minutes.

Open source In Python