Marks the end of a logical segment group within an HL7 v2 message. It carries a set identifier and an optional group name that must match the corresponding SGH (Segment Group Header). Together, the SGH /SGT pair brackets repeating or nested groups of segments, letting parsers determine exactly where each group ends without relying on segment order heuristics.
from zato.hl7v2 import SGT
sgt = SGT()
sgt.set_id_sgt = '1'
sgt.segment_group_name = 'ORDER'How to construct and work with real-world SGT segments.
Closes the named order group opened by the matching SGH
from zato.hl7v2.v2_9 import SGT
sgt = SGT()
sgt.set_id_sgt = '1'
sgt.segment_group_name = 'ORDER'Closes an observation group after result segments
from zato.hl7v2.v2_9 import SGT
sgt = SGT()
sgt.set_id_sgt = '2'
sgt.segment_group_name = 'OBSERVATION'Closes a segment group using only the sequence number
from zato.hl7v2.v2_9 import SGT
sgt = SGT()
sgt.set_id_sgt = '3'Step-by-step guides for working with HL7 v2 in Zato.
SGT marks the end of a logical segment group in an HL7 v2 message. It is always paired with an SGH that opens the same group, and the segments between them form the group content.
Yes, the set_id_sgt value must match the set_id_sgh of the corresponding header so parsers can pair them correctly:
from zato.hl7v2.v2_9 import SGH, SGT
sgh = SGH()
sgh.set_id_sgh = '1'
sgh.segment_group_name = 'ORDER'
sgt = SGT()
sgt.set_id_sgt = '1'
sgt.segment_group_name = 'ORDER'No, it is optional. When present, it should match the name in the corresponding SGH for clarity:
from zato.hl7v2.v2_9 import SGT
sgt = SGT()
sgt.set_id_sgt = '1'
sgt.segment_group_name = 'PATIENT'Yes. Close inner groups before outer groups, using set identifiers to match each SGT to its SGH. This maintains a proper nesting hierarchy within the message.
Instantiate SGT and set its fields:
from zato.hl7v2.v2_9 import SGT
sgt = SGT()
sgt.set_id_sgt = '1'
sgt.segment_group_name = 'RESULT'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 SGT segment, HL7 v2.9.
| # | Python name | Datatype | Usage | Repeatable | Table |
|---|---|---|---|---|---|
| 1 | set_id_sgt | SI | Required | No | - |
| 2 | segment_group_name | ST | Optional | No | - |
Get started with Zato and connect your systems in minutes.