Schedule a demo
Segment

Timing/quantity relationship

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.

10fields
0required
v2.9HL7 version
tq2.py
from zato.hl7v2 import TQ2, EI

tq2 = TQ2()
placer = EI(entity_identifier='ORD1')
tq2.related_placer_number = placer

Build TQ2 segments in Python

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

1

Linked wellness orders

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'
2

Multi-step nutrition plan

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'
3

Fitness program sequencing

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'

Learn by building

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

Frequently asked questions

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_number

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

TQ2 field reference

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

#Python nameDatatypeUsageRepeatableTable
1set_id_tq2SIOptionalNo-
2sequence_results_flagIDOptionalNoHL70503
3related_placer_numberEIOptionalYes-
4related_filler_numberEIOptionalYes-
5related_placer_group_numberEIOptionalYes-
6sequence_condition_codeIDOptionalNoHL70504
7cyclic_entry_exit_indicatorIDOptionalNoHL70505
8sequence_condition_time_intervalCQOptionalNo-
9cyclic_group_maximum_number_of_repeatsNMOptionalNo-
10special_service_request_relationshipIDOptionalNoHL70506

Ready to build integrations?

Get started with Zato and connect your systems in minutes.

Open source In Python