# Healthcare in Python

Receive HL7 v2 messages over MLLP, access their fields as typed Python objects, connect to FHIR servers, and build healthcare integration workflows in Python.

[Get started ▶](https://zato.io/docs/admin/guide/install/index.html) [Read the docs](https://zato.io/docs/index.html)

194

v2.9 segments

R4

FHIR client

MLLP

in and out

35

guides and docs

Code examples

## Both standards, one platform

Receive HL7 v2 over MLLP or call FHIR servers over REST, all with the same Python services.

**Receive HL7 v2**

```python
# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class ADTListener(Service):
    name = 'demo.hl7.adt-listener'

    def handle(self) -> 'None':

        # The MLLP channel parsed the message,
        # the acknowledgment is sent for you
        msg = self.request.input

        # Read fields by their semantic names
        family_name = msg.pid.patient_name.family_name
        control_id = msg.msh.message_control_id

        self.logger.info('Received %s: %s',
            control_id, family_name)
```

**Call a FHIR server**

```python
# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class FindPatients(Service):
    name = 'demo.fhir.find-patients'

    def handle(self) -> 'None':

        # Connect to a FHIR server by the name
        # of its connection definition
        client = self.fhir['FHIR.Sample']

        # A typed search, paginated for you
        patients = client.resources('Patient')
        result = patients.search(name='Chalmers').limit(10)

        for patient in result.fetch():
            self.logger.info('Found %s', patient['name'])
```

Features

## Everything for healthcare integrations

HL7 v2 and FHIR, with the production features clinical traffic needs.

[MLLP channels](https://zato.io/docs/dev/healthcare/hl7v2/mllp/index.html)

Receive and send HL7 v2 messages over MLLP with automatic acknowledgments. Zato handles the framing protocol so you focus on business logic.

```python
# The channel parses the message for you
msg = self.request.input

# Semantic field access
mrn = msg.pid.patient_identifier_list.id_number

# Send to another system over MLLP
result = self.mllp['pas'].send(data)
```

[All v2.9 segments](https://zato.io/docs/dev/healthcare/hl7/v2/parsing/index.html)

Every v2.9 segment as a typed Python class with full autocompletion and type checking.

[Built-in validation](https://zato.io/docs/dev/healthcare/hl7/v2/validation/index.html)

Validate field lengths, cardinality, required fields, datatypes, and terminology bindings.

[FHIR client](https://zato.io/docs/dev/healthcare/hl7/fhir/index.html)

Connect to any FHIR server with self.fhir - typed searches, bundles, references and path access, with OAuth tokens managed for you.

```python
client = self.fhir['FHIR.Sample']

# Read one resource by its ID ..
patient = client.get('Patient', patient_id)

# .. or search with typed parameters
results = client.resources('Observation').search(
    subject=f'Patient/{patient_id}',
    status='final',
)
```

[HL7 v2 to FHIR](https://zato.io/docs/dev/healthcare/transformation/index.html)

Transform HL7 v2 messages into FHIR resources with regular Python services.

[FHIR security](https://zato.io/docs/dev/healthcare/hl7/fhir/security/index.html)

Basic Auth and OAuth with automatic token acquisition and refresh, plus TLS.

Tutorials

## Learn by building

Step-by-step guides for HL7 v2 and FHIR integration patterns.

[MLLP HL7 - route clinical messages Accept HL7 v2 messages over MLLP and route them to receiving systems, with or without code. Start tutorial](https://zato.io/tutorials/healthcare/hl7v2.html) [FHIR FHIR resource handling Work with FHIR resources in Python - create, read, update and search clinical data on FHIR servers. Start tutorial](https://zato.io/tutorials/healthcare/fhir.html) [EDIFACT EDIFACT - parse, build, and route EDI messages Parse EDIFACT interchanges, navigate them with typed Python classes, and route messages by type. Start tutorial](https://zato.io/tutorials/healthcare/edifact.html)

Guides

## Healthcare integration guides

Platform comparisons, regulatory scoping and national FHIR programs, each with working Python code.

[AI AI agents and clinical interfaces How agents reach clinical data through a governed gateway and which controls protect patient data](https://zato.io/integrations/healthcare/ai-agents-clinical-interfaces/) [Reference HL7 v2 to FHIR mapping reference Segment-to-resource and field-to-field tables with Python code for ADT and ORU](https://zato.io/integrations/healthcare/hl7-v2-to-fhir-mapping/) [Guide How to receive HL7 v2 messages in Python Library comparison and a production MLLP listener with acknowledgments](https://zato.io/integrations/healthcare/receive-hl7-messages-python/) [EDIFACT EDIFACT messaging in healthcare Where EDIFACT remains in use in healthcare and how to parse it from Python](https://zato.io/integrations/healthcare/edifact-healthcare-messaging/) [USA TEFCA and information blocking QHINs, penalties and what your integration layer must be able to do](https://zato.io/integrations/healthcare/tefca-information-blocking-integration/) [Europe EHDS compliance checklist The 2027-2031 deadlines, the EEHRxF format and the engineering checklist](https://zato.io/integrations/healthcare/ehds-compliance-checklist/) [Germany gematik ISiK FHIR integration Query the FHIR interface German hospitals are required to expose](https://zato.io/integrations/healthcare/gematik-isik-fhir-integration/) [USA CMS-0057-F prior authorization APIs The four payer FHIR APIs due by January 2027 and the integration pattern](https://zato.io/integrations/healthcare/cms-0057-prior-authorization-fhir/) [EHR Epic and Oracle Health FHIR APIs SMART on FHIR authorization and R4 queries from Python](https://zato.io/integrations/healthcare/connect-epic-oracle-fhir-python/) [UK NHS FHIR integration UK Core on R4, GP Connect on STU3 and how to call both from Python](https://zato.io/integrations/healthcare/nhs-fhir-integration-uk/) [Pattern FHIR facade over legacy HL7 v2 Expose a FHIR-style REST API while the legacy system stays unchanged](https://zato.io/integrations/healthcare/fhir-facade-over-hl7-v2/) [Australia My Health Record and AU Core Sparked, AUCDI and Australian FHIR endpoints from Python](https://zato.io/integrations/healthcare/my-health-record-au-core-integration/) [Canada Pan-Canadian Patient Summary and CA:FeX PS-CA document bundles and the pan-Canadian exchange from Python](https://zato.io/integrations/healthcare/ps-ca-canada-fhir-integration/) [Nordics Finland's Kanta and Nordic FHIR migration Kanta, MedCom and the Nordic legacy-to-FHIR bridges](https://zato.io/integrations/healthcare/finland-kanta-nordic-fhir-migration/) [Glossary HL7 vs FHIR vs MLLP - definitions The healthcare integration vocabulary, each term with a Python example](https://zato.io/integrations/healthcare/hl7-vs-fhir-mllp-glossary/)

Documentation

## Healthcare developer guides

In-depth documentation for HL7 v2, FHIR and EDIFACT in Python.

[MLLP Receiving HL7 v2 over MLLP Routing, acknowledgments, deduplication, and REST bridge](https://zato.io/docs/dev/healthcare/hl7v2/mllp/index.html) [MLLP Sending HL7 v2 over MLLP Outgoing connections, self.mllp, acknowledgments, and TLS](https://zato.io/docs/dev/healthcare/hl7v2/mllp/outgoing.html) [MLLP MLLP channel configuration Encoding, tolerance, batch mode, and all channel settings](https://zato.io/docs/dev/healthcare/hl7v2/mllp/config.html) [Parsing HL7 v2 message parsing Parse ER7-encoded messages into typed Python objects](https://zato.io/docs/dev/healthcare/hl7/v2/parsing/index.html) [API HL7 v2 field access Access segment fields by name using typed Python objects](https://zato.io/docs/dev/healthcare/hl7/v2/field-access/index.html) [API HL7 v2 path expressions Navigate nested fields and components with dot-path syntax](https://zato.io/docs/dev/healthcare/hl7/v2/field-access/index.html#path-expressions) [Validation HL7 v2 message validation Validate messages against schema definitions](https://zato.io/docs/dev/healthcare/hl7/v2/validation/index.html) [JSON HL7 v2 parsing and serialization Convert messages between ER7, dicts and JSON](https://zato.io/docs/dev/healthcare/hl7/v2/parsing/index.html) [Batch HL7 v2 batch processing Process multiple messages in batch mode](https://zato.io/docs/dev/healthcare/hl7/v2/batch/index.html) [FHIR FHIR connections and self.fhir Configure outgoing FHIR connections and use them from Python](https://zato.io/docs/dev/healthcare/hl7/fhir/index.html) [FHIR Working with FHIR resources Create, read, update and delete resources, follow references](https://zato.io/docs/dev/healthcare/hl7/fhir/resources/index.html) [FHIR Searches and bundles Typed search parameters, result iteration and raw bundles](https://zato.io/docs/dev/healthcare/hl7/fhir/bundles/index.html) [FHIR Path access to FHIR data Navigate nested FHIR structures with dotted paths and matchers](https://zato.io/docs/dev/healthcare/hl7/fhir/path-access/index.html) [FHIR FHIR extensions Read and write extensions, including nested ones, with matchers](https://zato.io/docs/dev/healthcare/hl7/fhir/extensions/index.html) [Security FHIR security Basic Auth and OAuth with tokens managed automatically](https://zato.io/docs/dev/healthcare/hl7/fhir/security/index.html) [Trends FHIR versions in 2026 and 2027 R4 now, R6 next - which version new projects should build on](https://zato.io/docs/dev/healthcare/hl7/fhir/versions/index.html) [Europe FHIR in European healthcare projects EHDS, MyHealth@EU and national programs in 2026-2027](https://zato.io/docs/dev/healthcare/hl7/fhir/europe/index.html) [Transform Automatic HL7 v2 to FHIR conversion msg.to\_fhir() converts whole messages into FHIR bundles](https://zato.io/docs/dev/healthcare/hl7/to-fhir/index.html) [Transform HL7 v2 to FHIR configuration Identifier systems, local code values and bundle types in one .ini file](https://zato.io/docs/dev/healthcare/hl7/to-fhir/config/index.html) [Transform Z-segments and extensions How custom segments are preserved as FHIR extensions](https://zato.io/docs/dev/healthcare/hl7/to-fhir/z-segments/index.html) [Transform HL7 v2 to FHIR transformation Receive HL7 v2 over MLLP and map it to FHIR resources](https://zato.io/docs/dev/healthcare/transformation/index.html) [EDIFACT EDIFACT integration Parse interchanges into typed Python objects, define dialects, pick a transport](https://zato.io/docs/dev/healthcare/edifact/index.html) [EDIFACT EDIFACT message parsing Interchanges, envelopes, separators, and round trips](https://zato.io/docs/dev/healthcare/edifact/parsing/index.html) [EDIFACT EDIFACT field access Typed segments, composites, repeating groups, and lists](https://zato.io/docs/dev/healthcare/edifact/field-access/index.html) [EDIFACT EDIFACT dialects and profiles Define your own message types and register them](https://zato.io/docs/dev/healthcare/edifact/dialects/index.html) [EDIFACT EDIFACT transport patterns Mailboxes, file drops, REST and SOAP carriers](https://zato.io/docs/dev/healthcare/edifact/transport/index.html)

FAQ

## Frequently asked questions

[Create an MLLP channel](https://zato.io/docs/dev/healthcare/hl7v2/mllp/index.html) pointing to your Python service. Zato handles the MLLP framing and acknowledgements, and your service receives a parsed message object.

Use [attribute-based field access](https://zato.io/docs/dev/healthcare/hl7/v2/field-access/index.html) or [path expressions](https://zato.io/docs/dev/healthcare/hl7/v2/field-access/index.html#path-expressions) to read segments, fields and components as Python data.

Configure an [outgoing FHIR connection](https://zato.io/docs/dev/healthcare/hl7/fhir/index.html) in Dashboard, then use client = self.fhir\['FHIR.Sample'\] in your service to work with resources on that server.

With [Basic Auth or OAuth](https://zato.io/docs/dev/healthcare/hl7/fhir/security/index.html) - you attach a security definition to the connection and Zato obtains and refreshes tokens for you.

Use [searches and bundles](https://zato.io/docs/dev/healthcare/hl7/fhir/bundles/index.html) - client.resources('Patient').search(...) builds FHIR search queries with typed parameters and returns matching resources.

Call [msg.to\_fhir()](https://zato.io/docs/dev/healthcare/hl7/to-fhir/index.html) - one call maps the whole message to a FHIR bundle ready to post to a server. When you need full control over every element, follow the [manual transformation](https://zato.io/docs/dev/healthcare/transformation/index.html) example instead.

Yes - [message validation](https://zato.io/docs/dev/healthcare/hl7/v2/validation/index.html) checks incoming messages against HL7 v2 rules before your service logic runs.

[Create an outgoing MLLP connection](https://zato.io/docs/dev/healthcare/hl7v2/mllp/outgoing.html) and invoke it from your service - Zato takes care of framing, delivery and acknowledgements.

R4 - it is the most widely deployed version in production and US Core does not include R5, with R6 arriving in 2027. See [FHIR versions in 2026 and 2027](https://zato.io/docs/dev/healthcare/hl7/fhir/versions/index.html) for the details and for how to keep services version-independent.

FHIR becomes the mandated exchange standard, with patient summaries and e-prescriptions mandatory by March 2029. See [FHIR in European healthcare projects](https://zato.io/docs/dev/healthcare/hl7/fhir/europe/index.html) for the deadlines and the code that implements each scenario.

Yes - [the EDIFACT engine](https://zato.io/docs/dev/healthcare/edifact/index.html) parses interchanges into typed Python objects with the same access model as HL7 v2, and [EDIFACT messaging in healthcare](https://zato.io/integrations/healthcare/edifact-healthcare-messaging/) covers where that traffic remains in use.

## Ready to build healthcare integrations?

Get started with Zato and connect your clinical systems with HL7 v2 and FHIR in minutes.

[Get started ▶](https://zato.io/docs/admin/guide/install/index.html) [Read the docs](https://zato.io/docs/index.html)

Open source In Python
