Carries data elements specific to UB-92 and later UB-04 institutional billing claims in the United States, including condition codes, value codes, occurrence codes, and occurrence span codes. It appears in BAR and DFT messages sent by patient accounting systems to claims processing and clearinghouse systems for inpatient and outpatient institutional billing.
from zato.hl7v2 import UB2
ub2 = UB2()
ub2.set_id_ub2 = '1'
ub2.co_insurance_days_9 = '5'
ub2.covered_days_7 = '3'
ub2.document_control_number = 'DOC001'How to construct and work with real-world UB2 segments.
Basic billing record for a routine wellness visit with covered days and document control
from zato.hl7v2.v2_9 import UB2
ub2 = UB2()
ub2.set_id_ub2 = '1'
ub2.co_insurance_days_9 = '5'
ub2.covered_days_7 = '3'
ub2.non_covered_days_8 = '0'
ub2.document_control_number = 'DOC001'Uniform billing locator fields populated for a routine preventive care claim
from zato.hl7v2.v2_9 import UB2
ub2 = UB2()
ub2.set_id_ub2 = '1'
ub2.uniform_billing_locator_11_state = 'CA-7890'
ub2.uniform_billing_locator_31_national = 'LOC31-NAT'
ub2.uniform_billing_locator_49_national = 'NAT49-001'
ub2.uniform_billing_locator_56_state = 'ST56-002'Special visit count with condition code for an annual check-up billing record
from zato.hl7v2.v2_9 import UB2
from zato.hl7v2.v2_9 import CWE
ub2 = UB2()
ub2.set_id_ub2 = '1'
ub2.condition_code_24_30 = CWE(
identifier='30',
text='Annual checkup'
)
ub2.covered_days_7 = '7'
ub2.non_covered_days_8 = '0'
ub2.document_control_number = 'DOC500'
ub2.special_visit_count = '2'Step-by-step guides for working with HL7 v2 in Zato.
UB2 carries uniform billing data for institutional claims - co-insurance days, covered and non-covered days, condition codes, value amounts, billing locator fields, and document control numbers. It appears in financial messages to provide the claim-level detail needed for payer adjudication.
Create the segment and access its fields directly:
from zato.hl7v2.v2_9 import UB2
ub2 = UB2()
ub2.covered_days_7 = '3'
ub2.document_control_number = 'DOC001'
ub2.special_visit_count = '2'
covered = ub2.covered_days_7
doc_num = ub2.document_control_number
visit_count = ub2.special_visit_countThe condition_code_24_30 field uses the CWE datatype with HL7 table 0043:
from zato.hl7v2.v2_9 import UB2, CWE
ub2 = UB2()
ub2.condition_code_24_30 = CWE(
identifier='30',
text='Annual checkup'
)UB2 contains several uniform billing locator fields (positions 9-11, 13-16) that carry state and national-level billing identifiers. These are free-text ST fields whose content is defined by the billing jurisdiction. They map to specific form locators on the UB-04 institutional claim form.
Set the covered_days_7 and non_covered_days_8 fields directly as string values:
from zato.hl7v2.v2_9 import UB2
ub2 = UB2()
ub2.set_id_ub2 = '1'
ub2.covered_days_7 = '5'
ub2.non_covered_days_8 = '0'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.
Complete list of fields in the UB2 segment, HL7 v2.9.
| # | Python name | Datatype | Usage | Repeatable | Table |
|---|---|---|---|---|---|
| 1 | set_id_ub2 | SI | Optional | No | - |
| 2 | co_insurance_days_9 | ST | Optional | No | - |
| 3 | condition_code_24_30 | CWE | Optional | No | HL70043 |
| 4 | covered_days_7 | ST | Optional | No | - |
| 5 | non_covered_days_8 | ST | Optional | No | - |
| 6 | value_amount_code_39_41 | UVC | Optional | No | - |
| 7 | occurrence_code_date_32_35 | OCD | Optional | No | - |
| 8 | occurrence_span_code_dates_36 | OSP | Optional | No | - |
| 9 | uniform_billing_locator_2_state | ST | Optional | No | - |
| 10 | uniform_billing_locator_11_state | ST | Optional | No | - |
| 11 | uniform_billing_locator_31_national | ST | Optional | No | - |
| 12 | document_control_number | ST | Optional | No | - |
| 13 | uniform_billing_locator_49_national | ST | Optional | No | - |
| 14 | uniform_billing_locator_56_state | ST | Optional | No | - |
| 15 | uniform_billing_locator_57_sational | ST | Optional | No | - |
| 16 | uniform_billing_locator_78_state | ST | Optional | No | - |
| 17 | special_visit_count | NM | Optional | No | - |
Get started with Zato and connect your systems in minutes.