Schedule a demo
Segment

Location relationship

Defines relationships between locations, such as which locations are nearest to a given room for specific services (nearest lab, nearest pharmacy, nearest dietary) or organizational relationships. It follows LOC in MFN location master file messages and is used by bed management, patient flow, and logistics systems to determine proximity and routing for services.

6fields
2required
v2.9HL7 version
lrl.py
from zato.hl7v2.v2_9 import LRL
from zato.hl7v2.v2_9 import CWE, PL

lrl = LRL()
lrl.primary_key_value_lrl = PL(
    point_of_care='WELL',
    room='HUB',
)
lrl.location_relationship_id = CWE(
    identifier='LAB',
    text='Nearest lab',
    name_of_coding_system='HL70325',
)

Build LRL segments in Python

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

1

Nearest wellness lab

Add action with EI key and screening lab relationship

from zato.hl7v2.v2_9 import LRL
from zato.hl7v2.v2_9 import CWE, EI, PL, XON

lrl = LRL()
lrl.primary_key_value_lrl = PL(
    point_of_care='WELL',
    room='HUB',
    facility='CAMPUS',
)
lrl.segment_action_code = 'A'
lrl.segment_unique_key = EI(
    entity_identifier='REL01',
    namespace_id='WELL',
)
lrl.location_relationship_id = CWE(
    identifier='LAB',
    text='Nearest wellness lab',
    name_of_coding_system='HL70325',
)
lrl.organizational_location_relationship_value \
= [
    XON(
        organization_name='Nutrition Partners',
        id_number='NUTRICO',
    ),
]
lrl.patient_location_relationship_value = PL(
    point_of_care='LAB',
    room='DRAW-1',
    facility='WEST',
)
2

Nutrition partner organization

Relationship row naming the coaching affiliate for the hub

from zato.hl7v2.v2_9 import LRL
from zato.hl7v2.v2_9 import CWE, PL, XON

lrl = LRL()
lrl.primary_key_value_lrl = PL(
    point_of_care='WELL',
    room='CONCIERGE',
    facility='MAIN',
)
lrl.location_relationship_id = CWE(
    identifier='COACH',
    text='Nutrition partner',
    name_of_coding_system='HL70325',
)
lrl.organizational_location_relationship_value \
= [
    XON(
        organization_name='Well Coaches Inc',
        id_number='WCINC',
    ),
]
3

Parent wellness organization

Campus site pointing to the regional wellness network PL

from zato.hl7v2.v2_9 import LRL
from zato.hl7v2.v2_9 import CWE, EI, PL

lrl = LRL()
lrl.primary_key_value_lrl = PL(
    point_of_care='WELL',
    room='SITE-9',
    facility='EAST',
)
lrl.segment_action_code = 'U'
lrl.segment_unique_key = EI(
    entity_identifier='NET88',
    namespace_id='REGION',
)
lrl.location_relationship_id = CWE(
    identifier='NET',
    text='Regional network',
    name_of_coding_system='HL70325',
)
lrl.patient_location_relationship_value = PL(
    point_of_care='ORG',
    room='NETWORK',
    facility='REGIONAL',
)

Learn by building

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

Frequently asked questions

Use repeating XON rows when the relationship names a partner org, such as a nutrition coaching group that shares the wellness campus schedule.

Field 1 is the anchor PL for this LRL row, while field 6 names the related site such as the draw station paired with the hub for screening logistics.

Optional EI gives receivers a stable key for merges; pair entity and namespace ids when your registry scopes relationships:

from zato.hl7v2.v2_9 import LRL
from zato.hl7v2.v2_9 import EI

lrl = LRL()
lrl.segment_unique_key = EI(
    entity_identifier='REL01',
    namespace_id='WELL',
)

Field 4 (HL70325) tells receivers which relationship applies, for example nearest lab draw versus nutrition partner, so routing rules stay explicit.

It is optional; omit it for static directories and populate it when master file events add, update, or retire a relationship row.

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.

LRL field reference

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

#Python nameDatatypeUsageRepeatableTable
1primary_key_value_lrlPLRequiredNo-
2segment_action_codeIDOptionalNoHL70206
3segment_unique_keyEIOptionalNo-
4location_relationship_idCWERequiredNoHL70325
5organizational_location_relationship_valueXONOptionalYes-
6patient_location_relationship_valuePLOptionalNo-

Ready to build integrations?

Get started with Zato and connect your systems in minutes.

Open source In Python