Expresses relationships between multiple timing and quantity specifications defined in TQ1 segments, such as sequential, cyclic, or concurrent execution of orders. It is used in complex multi-step order workflows - for example, indicating that one medication must be given before another, or that infusion steps must occur in sequence. TQ2 is paired with TQ1 in pharmacy and other order messages when orders have interdependent scheduling requirements.
from zato.hl7v2 import TQ2, EI
tq2 = TQ2()
placer = EI(entity_identifier='ORD1')
tq2.related_placer_number = placerHow to construct and work with real-world TQ2 segments.
Placer, filler, and group identifiers tying a screening order to lab work
from zato.hl7v2.v2_9 import TQ2
from zato.hl7v2.v2_9 import CQ, CWE, EI
tq2 = TQ2()
tq2.set_id_tq2 = '1'
tq2.sequence_results_flag = 'C'
tq2.related_placer_number = [
EI(entity_identifier='ORD100', universal_id_type='WELL')]
tq2.related_filler_number = [
EI(entity_identifier='LAB50', universal_id_type='GV')]
tq2.related_placer_group_number = [
EI(entity_identifier='GRP01', universal_id_type='WELL')]
tq2.sequence_condition_code = 'S'
tq2.cyclic_entry_exit_indicator = 'Y'
tq2.sequence_condition_time_interval = CQ(
quantity='30', units=CWE(identifier='D'))
tq2.cyclic_group_maximum_number_of_repeats = '6'
tq2.special_service_request_relationship = 'S'Sequenced meal-prep orders with interval and repeat limits
from zato.hl7v2.v2_9 import TQ2
from zato.hl7v2.v2_9 import CQ, CWE, EI
tq2 = TQ2()
tq2.set_id_tq2 = '1'
tq2.sequence_results_flag = 'N'
tq2.related_placer_number = [
EI(entity_identifier='MEAL1', universal_id_type='NUTR')]
tq2.related_filler_number = [
EI(entity_identifier='MEAL2', universal_id_type='NUTR')]
tq2.sequence_condition_code = 'E'
tq2.cyclic_entry_exit_indicator = 'N'
tq2.sequence_condition_time_interval = CQ(
quantity='7', units=CWE(identifier='D'))
tq2.cyclic_group_maximum_number_of_repeats = '4'
tq2.special_service_request_relationship = 'C'Group program identifier with spacing between structured activity blocks
from zato.hl7v2.v2_9 import TQ2
from zato.hl7v2.v2_9 import CQ, CWE, EI
tq2 = TQ2()
tq2.set_id_tq2 = '1'
tq2.sequence_results_flag = 'P'
tq2.related_placer_number = [
EI(entity_identifier='FIT01', universal_id_type='GV')]
tq2.related_filler_number = [
EI(entity_identifier='COACH01', universal_id_type='GV')]
tq2.related_placer_group_number = [
EI(entity_identifier='PG2024', universal_id_type='GV')]
tq2.sequence_condition_time_interval = CQ(
quantity='14', units=CWE(identifier='D'))
tq2.cyclic_group_maximum_number_of_repeats = '8'
tq2.special_service_request_relationship = 'P'Step-by-step guides for working with HL7 v2 in Zato.
TQ2 links timing and quantity segments (TQ1) to related placer, filler, and group identifiers and describes sequencing, cyclic behavior, and relationships between service requests. It supports structured wellness, fitness, and nutrition programs where multiple orders must run in a defined order or cadence.
Create a TQ2 segment and read its attributes directly:
from zato.hl7v2.v2_9 import TQ2, EI
tq2 = TQ2()
tq2.set_id_tq2 = '1'
tq2.related_placer_number = [
EI(entity_identifier='ORD100', universal_id_type='WELL')]
placers = tq2.related_placer_numberFields 3 and 4 use EI (entity identifier). They may repeat; assign a list of EI values in Python:
from zato.hl7v2.v2_9 import TQ2, EI
tq2 = TQ2()
tq2.related_placer_number = [
EI(entity_identifier='ORD100', universal_id_type='WELL')]
tq2.related_filler_number = [
EI(entity_identifier='LAB50', universal_id_type='GV')]TQ1 describes when and how often something happens; TQ2 describes how separate TQ1 blocks or related orders connect (sequence flags, cyclic entry and exit, intervals, and relationship codes). Messages often carry TQ1 rows for each timing block and TQ2 rows to express dependencies between them.
Field 8 is a composite quantity with units, typically using CWE for coded units:
from zato.hl7v2.v2_9 import TQ2, CQ, CWE
tq2 = TQ2()
tq2.sequence_condition_time_interval = CQ(
quantity='30', units=CWE(identifier='D'))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 TQ2 segment, HL7 v2.9.
| # | Python name | Datatype | Usage | Repeatable | Table |
|---|---|---|---|---|---|
| 1 | set_id_tq2 | SI | Optional | No | - |
| 2 | sequence_results_flag | ID | Optional | No | HL70503 |
| 3 | related_placer_number | EI | Optional | Yes | - |
| 4 | related_filler_number | EI | Optional | Yes | - |
| 5 | related_placer_group_number | EI | Optional | Yes | - |
| 6 | sequence_condition_code | ID | Optional | No | HL70504 |
| 7 | cyclic_entry_exit_indicator | ID | Optional | No | HL70505 |
| 8 | sequence_condition_time_interval | CQ | Optional | No | - |
| 9 | cyclic_group_maximum_number_of_repeats | NM | Optional | No | - |
| 10 | special_service_request_relationship | ID | Optional | No | HL70506 |
Get started with Zato and connect your systems in minutes.