Delivers unsolicited population or location-based laboratory observations. The OBR and OBX segments carry the observation results for public health surveillance.
# Zato
from zato.hl7v2 import HL7Message
# An incoming message ..
raw = 'MSH|^~\&|SENDER|FAC|RCV|DEST|20260701||' \
'OPU^R25^OPU_R25|MSG001|P|2.9\r' \
'OBR|1||ORD001\r' \
'OBX|1|NM|2345-7^Glucose^LN||95|mg/dL|70-100'
# .. parsed into a Python object ..
msg = HL7Message.parse(raw)
# .. whose fields we can now access.
order_id = msg.obr.placer_order_number
test = msg.obr.universal_service_identifier
value = msg.obx.observation_value
units = msg.obx.unitsHow to construct, send, receive, and extract fields from real-world OPU^R25 messages.
Demonstrates receiving and extracting key fields from a unsolicited population / location-based laboratory observation transaction
# Zato
from zato.hl7v2 import HL7Message
# An incoming message ..
raw = 'MSH|^~\&|SENDER|FAC|RCV|DEST|20260701||' \
'OPU^R25^OPU_R25|MSG001|P|2.9\r' \
'OBR|1||ORD001\r' \
'OBX|1|NM|2345-7^Glucose^LN||95|mg/dL|70-100'
# .. parsed into a Python object ..
msg = HL7Message.parse(raw)
# .. whose fields we can now access.
order_id = msg.obr.placer_order_number
test = msg.obr.universal_service_identifier
value = msg.obx.observation_value
units = msg.obx.unitsStep-by-step guides for working with HL7 v2 in Zato.
Use the HL7v2 message parser to extract the typed structure. The parsed message gives you direct access to every segment and field by name.
from zato.hl7v2 import HL7Message
raw = 'MSH|^~\&|SENDER|FACILITY|RECEIVER|DEST|20260401120000||OPU^R25^OPU_R25|MSG00001|P|2.9\rPV1|1|I|MED^201^A^^^MAIN||||1234^CHEN^DAVID^L^^^MD|5678^PATEL^NINA^R^^^MD|||MED|||||||VN-90001|||||||||||||||||||||20260401\rPV2|||^Routine checkup\rPRT|1||AT^Attending||1234^CHEN^DAVID^L^^^MD'
msg = HL7Message.parse(raw)
order_id = msg.obr.placer_order_number
test = msg.obr.universal_service_identifierBeyond the mandatory MSH header, the required segments are: PV1, OBX, NK1, PID, OBX, SPM, OBX, SAC. Optional segments provide additional detail when available.
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.
Segments that make up the OPU^R25 message, in order. Groups are shown with their child segments.
| # | Segment | Usage | Repeats | Description | Group |
|---|---|---|---|---|---|
| 1 | MSH | Required | No | Message header | - |
| 2 | ARV | Optional | Yes | Access restriction | - |
| 3 | SFT | Optional | Yes | Software segment | - |
| 4 | UAC | Optional | No | User authentication credential | - |
| 5 | NTE | Optional | No | Notes and comments | - |
| 6 | PV1 | Required | No | Patient visit | - |
| 7 | PV2 | Optional | No | Patient visit - additional info | - |
| 8 | PRT | Optional | Yes | Participation information | - |
| 9 | OBX | Required | No | Observation result | PATIENT_VISIT_OBSERVATION |
| 10 | NTE | Optional | Yes | Notes and comments | PATIENT_VISIT_OBSERVATION |
| 11 | PRT | Optional | Yes | Participation information | PATIENT_VISIT_OBSERVATION |
| 12 | NK1 | Required | Yes | Next of kin / associated parties | ACCESSION_DETAIL |
| 13 | PID | Required | No | Patient identification | ACCESSION_DETAIL |
| 14 | PD1 | Optional | No | Patient additional demographic | ACCESSION_DETAIL |
| 15 | PRT | Optional | Yes | Participation information | ACCESSION_DETAIL |
| 16 | OH1 | Optional | Yes | Employment status | ACCESSION_DETAIL |
| 17 | OH2 | Optional | Yes | Past or present job | ACCESSION_DETAIL |
| 18 | OH3 | Optional | No | Usual work | ACCESSION_DETAIL |
| 19 | OH4 | Optional | Yes | Combat zone work | ACCESSION_DETAIL |
| 20 | ARV | Optional | Yes | Access restriction | ACCESSION_DETAIL |
| 21 | OBX | Required | No | Observation result | PATIENT_OBSERVATION |
| 22 | PRT | Optional | Yes | Participation information | PATIENT_OBSERVATION |
| 23 | NTE | Optional | Yes | Notes and comments | PATIENT_OBSERVATION |
| 24 | SPM | Required | No | Specimen | ACCESSION_DETAIL |
| 25 | OBX | Required | No | Observation result | SPECIMEN_OBSERVATION |
| 26 | PRT | Optional | Yes | Participation information | SPECIMEN_OBSERVATION |
| 27 | NTE | Optional | Yes | Notes and comments | SPECIMEN_OBSERVATION |
| 28 | SAC | Required | No | Specimen container detail | CONTAINER |
| 29 | INV | Optional | No | Inventory detail | CONTAINER |
| 30 | OBR | Required | No | Observation request | ORDER |
| 31 | PRT | Optional | Yes | Participation information | ORDER |
| 32 | ORC | Required | No | Common order | ORDER |
| 33 | PRT | Optional | Yes | Participation information | ORDER |
| 34 | NTE | Optional | Yes | Notes and comments | ORDER |
| 35 | PRT | Optional | Yes | Participation information | ORDER |
| 36 | TQ1 | Required | No | Timing / quantity | ORDER |
| 37 | TQ2 | Optional | Yes | Timing / quantity relationship | ORDER |
| 38 | OBX | Required | No | Observation result | ORDER |
| 39 | PRT | Optional | Yes | Participation information | ORDER |
| 40 | NTE | Optional | Yes | Notes and comments | ORDER |
Get started with Zato and connect your systems in minutes.