EDIFACT integration
Exchange EDIFACT with trading partners from plain Python, in any dialect they use.
With Zato, you exchange EDIFACT with trading partners from plain Python - the standard that healthcare, logistics and customs systems have carried lab results, referrals, orders and reports in for decades. One parse_edifact call turns an incoming interchange into typed Python objects, the same way HL7 v2 parsing does. The same typed classes build and serialize the messages you send back.
Reading a referral
The interchange below is a free-text referral from the Dutch healthcare dialect that ships with the platform - parse it and read the patient's details through typed, semantic names:
# Zato
# Importing a dialect package registers its message classes.
import zato.edifact.nl
from zato.edifact import parse_edifact
raw = (
"UNB+UNOA:1+41007001+41008002+230405:0912+7431'\n"
"UNH+7431+MEDVRI:1'\n"
"GGA+Praktijk Rozenburg+Administratie+Praktijk Rozenburg+Kerkstraat:14::Utrecht:3511AB+?+31611223344'\n"
"DET+24:02:14+09:41'\n"
"PID+1975:03:18+V+Dijk:van der:Peters:de::M.++BSN999990019'\n"
"TXT:1+Beste collega'\n"
"UNT+6+7431'\n"
"UNZ+1+7431'"
)
interchange = parse_edifact(raw)
msg = interchange.message
family_name = msg.pid.patient_name.married_name # 'Dijk'
born_year = msg.pid.date_of_birth.year # '1975'
To learn everything parse_edifact handles, see Message parsing, and for the full typed access model, see Field access.
How messages arrive
Trading partners deliver interchanges through mailbox networks, file drops, HTTP endpoints and email, so there is no dedicated EDIFACT connection type. A REST channel, a file transfer channel or a scheduler job receives the text and invokes your service with it. Inside the service, parse_edifact turns the text into typed messages. To learn the pattern for each carrier, see transport patterns.
Dialects
A dialect is a set of plain Python classes - segments, composites and messages - and the engine resolves the right class for each incoming message at parse time. The Dutch healthcare profiles (MEDLAB, MEDVRI, MEDRAD, MEDSPE) ship with the platform as a complete worked example, and any dialect, from national healthcare profiles to UN/EDIFACT supply-chain messages, follows the same pattern. To define your own, see Dialects and profiles.
What the engine covers
The engine handles everything between the wire text and your typed objects:
- Wire syntax - UNA service string advice, custom separators and release-character escapes, in both the five- and six-character UNA forms.
- Interchange envelopes - UNB and UNZ as typed segments, functional groups (UNG/UNE), multi-message interchanges, and bare messages without any envelope.
- Typed messages - message classes declare their segments and groups declaratively, and every element and component is accessible by a semantic Python name.
- Unknown types - message types without a registered class parse into generic messages that keep everything navigable by position and serialize back byte for byte.
- Round-trip fidelity - serialization reproduces the parsed wire text, so a message can be received, inspected, selectively modified, and passed on without disturbing the rest of its content.
See also
| Page | What it covers |
|---|---|
| Message parsing | Envelopes, separators, unknown types and byte-faithful serialization |
| Field access | Reading and writing business data through semantic Python names |
| EDIFACT in healthcare tutorial | A lab result coming in and a letter to a GP going out, step by step |
Learn more
Schedule a meaningful demo
Book a demo with an expert who will help you build meaningful systems that match your ambitions
"We evaluated 12 integration platforms and Zato was the only one to score 100%."
Philip Zuñiga, Assistant Professor, University of the Philippines