Schedule a demo
Segment

Pharmacy/treatment encoded order

Represents the pharmacy-verified or pharmacy-encoded version of a medication order, containing the fully resolved give code, give amount, give units, dispense amount, and number of refills. It is typically generated by the pharmacy system and sent in RDE (Pharmacy/Treatment Encoded Order) messages to downstream systems such as nursing, MAR, or dispensing devices. RXE is the authoritative representation of how the order should be fulfilled.

43fields
3required
v2.9HL7 version
rxe.py
from zato.hl7v2 import RXE, CWE

rxe = RXE()
rxe.give_code = CWE(
    identifier='OM3', text='Omega-3')
rxe.give_amount_minimum = '1'
rxe.give_units = CWE(identifier='CAP')

Build RXE segments in Python

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

1

Vitamin D maintenance

Required give code, amount, and units for a daily supplement

from zato.hl7v2.v2_9 import RXE
from zato.hl7v2.v2_9 import CWE

rxe = RXE()
rxe.give_code = CWE(
    identifier='VITD',
    text='Vitamin D3 1000 IU',
)
rxe.give_amount_minimum = '1'
rxe.give_units = CWE(identifier='IU', text='IU')
2

Probiotic capsules with encoded dispensing

Dosage form, instructions, substitution flag, refills, and prescription id

from zato.hl7v2.v2_9 import RXE
from zato.hl7v2.v2_9 import CWE, XCN

rxe = RXE()
rxe.give_code = CWE(
    identifier='PROB', text='Daily Probiotic')
rxe.give_amount_minimum = '1'
rxe.give_amount_maximum = '2'
rxe.give_units = CWE(
    identifier='CAP', text='Capsule')
rxe.give_dosage_form = CWE(
    identifier='TAB', text='Tablet')
rxe.providers_administration_instructions = [
    CWE(identifier='MEAL', text='With meal')]
rxe.substitution_status = 'G'
rxe.dispense_amount = '90'
rxe.dispense_units = CWE(
    identifier='BOT', text='Bottle')
rxe.number_of_refills = '2'
rxe.ordering_providers_dea_number = XCN(
    person_identifier='998877',
    family_name='BLUE',
    given_name='ALEX',
    suffix='RPH'
)
rxe.prescription_number = 'RX-WELL-2024-01'
rxe.number_of_refills_remaining = '5'
rxe.number_of_refills_doses_dispensed = '2'
rxe.dt_of_most_recent_refill_or_dose_dispensed = '20240415120000'
3

Herbal tea and mineral support

Strength, indication, package size, pharmacy location, and contact

from zato.hl7v2.v2_9 import RXE
from zato.hl7v2.v2_9 import CWE, PL, XAD, XTN

rxe = RXE()
rxe.give_code = CWE(
    identifier='TEA', text='Herbal Wellness Tea')
rxe.give_amount_minimum = '1'
rxe.give_units = CWE(
    identifier='SACH', text='Sachet')
rxe.give_dosage_form = CWE(
    identifier='LIQ', text='Liquid')
rxe.providers_administration_instructions = [
    CWE(identifier='HOT', text='Steep hot')]
rxe.substitution_status = 'N'
rxe.dispense_amount = '20'
rxe.dispense_units = CWE(
    identifier='SACH', text='Sachet')
rxe.number_of_refills = '1'
rxe.give_strength = '500'
rxe.give_strength_units = CWE(
    identifier='MG', text='mg')
rxe.give_indication = [
    CWE(identifier='WELL', text='Daily wellness')]
rxe.dispense_package_size = '20'
rxe.dispense_package_size_unit = CWE(
    identifier='SACH', text='SACH')
rxe.dispense_package_method = 'U'
rxe.supplementary_code = [
    CWE(identifier='SUPP', text='Nutrition program')]
rxe.original_order_date_time = '20240401080000'
rxe.give_drug_strength_volume = '5'
rxe.give_drug_strength_volume_units = CWE(
    identifier='ML', text='mL')
rxe.dispensing_pharmacy = CWE(
    identifier='PHARM',
    text='Green Valley Pharmacy',
)
rxe.dispensing_pharmacy_address = XAD(
    street_address='100 Wellness Way',
    city='Portland',
    state_or_province='OR',
    zip_or_postal_code='97201',
    country='USA',
)
rxe.deliver_to_patient_location = PL(
    point_of_care='HOME',
    room='101',
    bed='A',
)
rxe.deliver_to_address = XAD(
    street_address='200 Courier Rd',
    city='Portland',
    state_or_province='OR',
    zip_or_postal_code='97202',
    country='USA',
)
rxe.pharmacy_order_type = 'O'
rxe.pharmacy_phone_number = XTN(
    telephone_number='5551002000',
    telecommunication_use_code='PRN',
    telecommunication_equipment_type='PH'
)

Learn by building

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

Frequently asked questions

RXE carries encoded pharmacy or treatment order details: product code, amounts, units, dosage form, instructions, dispensing and refill information, strength, indications, package sizing, and pharmacy or delivery context. It appears with ORC and often near RXO and RXR in messages that document nutrition and wellness orders.

Fields 2 (give_code), 3 (give_amount_minimum), and 5 (give_units) are required. Positions 1 and 8 are withdrawn in the standard; leave them empty in ER7 when present.

from zato.hl7v2.v2_9 import RXE, CWE

rxe = RXE()
rxe.give_code = CWE(identifier='VITD', text='Vitamin D3')
rxe.give_amount_minimum = '1'
rxe.give_units = CWE(identifier='IU')

Field 1 is withdrawn; the first data field after RXE| is therefore empty, so you often see RXE||... with the give code starting in the second slot (HL7 field 2).

Assign Python lists for fields such as providers_administration_instructions, special_dispensing_instructions, give_indication, supplementary_code, and pharmaceutical_substance_alternative.

from zato.hl7v2.v2_9 import RXE, CWE

rxe = RXE()
rxe.give_code = CWE(identifier='MV', text='Multivitamin')
rxe.give_amount_minimum = '1'
rxe.give_units = CWE(identifier='TAB')
rxe.providers_administration_instructions = [
    CWE(identifier='AM', text='Morning'),
    CWE(identifier='MEAL', text='With food'),
]

RXO often describes the requested order in placer terms, while RXE carries an encoded snapshot suitable for dispensing and administration. Your interface specification should state when each appears and how identifiers link them to ORC.

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.

RXE field reference

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

#Python nameDatatypeUsageRepeatableTable
2give_codeCWERequiredNoHL70292
3give_amount_minimumNMRequiredNo-
4give_amount_maximumNMOptionalNo-
5give_unitsCWERequiredNoHL70715
6give_dosage_formCWEOptionalNoHL70716
7providers_administration_instructionsCWEOptionalYesHL70718
9substitution_statusIDOptionalNoHL70167
10dispense_amountNMOptionalNo-
11dispense_unitsCWEOptionalNoHL70720
12number_of_refillsNMOptionalNo-
13ordering_providers_dea_numberXCNOptionalYes-
14pharmacist_treatment_suppliers_verifier_idXCNOptionalYes-
15prescription_numberSTOptionalNo-
16number_of_refills_remainingNMOptionalNo-
17number_of_refills_doses_dispensedNMOptionalNo-
18dt_of_most_recent_refill_or_dose_dispensedDTMOptionalNo-
19total_daily_doseCQOptionalNo-
20needs_human_reviewIDOptionalNoHL70136
21special_dispensing_instructionsCWEOptionalYesHL70706
22give_per_time_unitSTOptionalNo-
23give_rate_amountSTOptionalNo-
24give_rate_unitsCWEOptionalNoHL70722
25give_strengthNMOptionalNo-
26give_strength_unitsCWEOptionalNoHL70723
27give_indicationCWEOptionalYesHL70724
28dispense_package_sizeNMOptionalNo-
29dispense_package_size_unitCWEOptionalNoHL70709
30dispense_package_methodIDOptionalNoHL70321
31supplementary_codeCWEOptionalYesHL70700
32original_order_date_timeDTMOptionalNo-
33give_drug_strength_volumeNMOptionalNo-
34give_drug_strength_volume_unitsCWEOptionalNoHL70729
35controlled_substance_scheduleCWEOptionalNoHL70477
36formulary_statusIDOptionalNoHL70478
37pharmaceutical_substance_alternativeCWEOptionalYesHL70730
38pharmacy_of_most_recent_fillCWEOptionalNoHL70732
39initial_dispense_amountNMOptionalNo-
40dispensing_pharmacyCWEOptionalNoHL70733
41dispensing_pharmacy_addressXADOptionalNo-
42deliver_to_patient_locationPLOptionalNo-
43deliver_to_addressXADOptionalNo-
44pharmacy_order_typeIDOptionalNoHL70480
45pharmacy_phone_numberXTNOptionalYes-

Ready to build integrations?

Get started with Zato and connect your systems in minutes.

Open source In Python