Schedule a demo
Message type

Unsolicited population / location-based laboratory observation

Delivers unsolicited population or location-based laboratory observations. The OBR and OBX segments carry the observation results for public health surveillance.

40segments
13required
6groups
v2.9HL7 version
opu-r25.py
# 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.units

Build and parse OPU^R25 messages in Python

How to construct, send, receive, and extract fields from real-world OPU^R25 messages.

1

Parse an incoming OPU^R25 message

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.units

Learn by building

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

Frequently asked questions

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_identifier

Beyond 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.

OPU^R25 segment composition

Segments that make up the OPU^R25 message, in order. Groups are shown with their child segments.

#SegmentUsageRepeatsDescriptionGroup
1MSHRequiredNoMessage header-
2ARVOptionalYesAccess restriction-
3SFTOptionalYesSoftware segment-
4UACOptionalNoUser authentication credential-
5NTEOptionalNoNotes and comments-
6PV1RequiredNoPatient visit-
7PV2OptionalNoPatient visit - additional info-
8PRTOptionalYesParticipation information-
9OBXRequiredNoObservation resultPATIENT_VISIT_OBSERVATION
10NTEOptionalYesNotes and commentsPATIENT_VISIT_OBSERVATION
11PRTOptionalYesParticipation informationPATIENT_VISIT_OBSERVATION
12NK1RequiredYesNext of kin / associated partiesACCESSION_DETAIL
13PIDRequiredNoPatient identificationACCESSION_DETAIL
14PD1OptionalNoPatient additional demographicACCESSION_DETAIL
15PRTOptionalYesParticipation informationACCESSION_DETAIL
16OH1OptionalYesEmployment statusACCESSION_DETAIL
17OH2OptionalYesPast or present jobACCESSION_DETAIL
18OH3OptionalNoUsual workACCESSION_DETAIL
19OH4OptionalYesCombat zone workACCESSION_DETAIL
20ARVOptionalYesAccess restrictionACCESSION_DETAIL
21OBXRequiredNoObservation resultPATIENT_OBSERVATION
22PRTOptionalYesParticipation informationPATIENT_OBSERVATION
23NTEOptionalYesNotes and commentsPATIENT_OBSERVATION
24SPMRequiredNoSpecimenACCESSION_DETAIL
25OBXRequiredNoObservation resultSPECIMEN_OBSERVATION
26PRTOptionalYesParticipation informationSPECIMEN_OBSERVATION
27NTEOptionalYesNotes and commentsSPECIMEN_OBSERVATION
28SACRequiredNoSpecimen container detailCONTAINER
29INVOptionalNoInventory detailCONTAINER
30OBRRequiredNoObservation requestORDER
31PRTOptionalYesParticipation informationORDER
32ORCRequiredNoCommon orderORDER
33PRTOptionalYesParticipation informationORDER
34NTEOptionalYesNotes and commentsORDER
35PRTOptionalYesParticipation informationORDER
36TQ1RequiredNoTiming / quantityORDER
37TQ2OptionalYesTiming / quantity relationshipORDER
38OBXRequiredNoObservation resultORDER
39PRTOptionalYesParticipation informationORDER
40NTEOptionalYesNotes and commentsORDER

Ready to build integrations?

Get started with Zato and connect your systems in minutes.

Open source In Python