Carries patient diagnosis information including the diagnosis code (ICD-10 or ICD-9), description, type (admitting, working, or final), diagnosing clinician, and priority. It repeats for multiple diagnoses and appears in ADT, BAR, DFT, ORM, and referral messages. EHRs and registration systems send DG1 to billing, coding, and clinical decision support systems.
from zato.hl7v2 import DG1
dg1 = DG1()
dg1.set_id_dg1 = '1'
dg1.diagnosis_code_dg1 = 'Z00.00'
dg1.diagnosis_type = 'A'
dg1.diagnosis_priority = '1'How to construct and work with real-world DG1 segments.
Routine general examination recorded as an admitting diagnosis
from zato.hl7v2.v2_9 import DG1
from zato.hl7v2.v2_9 import CWE, XCN, EI
dg1 = DG1()
dg1.set_id_dg1 = '1'
dg1.diagnosis_code_dg1 = CWE(
identifier='Z00.00',
text='General exam',
name_of_coding_system='I10'
)
dg1.diagnosis_date_time = '20240315'
dg1.diagnosis_type = CWE(identifier='A')
dg1.diagnosis_priority = '1'
dg1.diagnosing_clinician = XCN(
person_identifier='0001',
family_name='SMITH',
given_name='ANNA',
suffix='MD'
)
dg1.diagnosis_classification = CWE(identifier='F')
dg1.attestation_date_time = '20240315'
dg1.diagnosis_identifier = EI(entity_identifier='DX001')Immunization encounter recorded as a working diagnosis with clinician
from zato.hl7v2.v2_9 import DG1
from zato.hl7v2.v2_9 import CWE, XCN
dg1 = DG1()
dg1.set_id_dg1 = '1'
dg1.diagnosis_code_dg1 = CWE(
identifier='Z23',
text='Immunization encounter',
name_of_coding_system='I10'
)
dg1.diagnosis_date_time = '20240610'
dg1.diagnosis_type = CWE(identifier='W')
dg1.diagnosis_priority = '2'
dg1.diagnosing_clinician = XCN(
person_identifier='5678',
family_name='JONES',
given_name='ROBERT',
suffix='MD'
)
dg1.diagnosis_classification = CWE(identifier='I')Routine eye exam recorded as a final diagnosis with attestation date
from zato.hl7v2.v2_9 import DG1
from zato.hl7v2.v2_9 import CWE, XCN, EI
dg1 = DG1()
dg1.set_id_dg1 = '1'
dg1.diagnosis_code_dg1 = CWE(
identifier='Z01.1',
text='Eye examination',
name_of_coding_system='I10'
)
dg1.diagnosis_date_time = '20240820'
dg1.diagnosis_type = CWE(identifier='A')
dg1.diagnosis_priority = '1'
dg1.diagnosing_clinician = XCN(
person_identifier='9999',
family_name='LEE',
given_name='SARAH',
suffix='OD'
)
dg1.diagnosis_classification = CWE(identifier='F')
dg1.confidential_indicator = 'Y'
dg1.attestation_date_time = '20240820'
dg1.diagnosis_identifier = EI(entity_identifier='DX042')
dg1.diagnosis_action_code = 'A'Step-by-step guides for working with HL7 v2 in Zato.
DG1 carries diagnosis information for a patient encounter - the diagnosis code, type (admitting, working, final), priority, diagnosing clinician, classification, and attestation date. It appears in ADT, DFT, and BAR messages to support billing, clinical documentation, and care coordination.
Create the segment and access its fields directly:
from zato.hl7v2.v2_9 import DG1, CWE
dg1 = DG1()
dg1.diagnosis_code_dg1 = CWE(
identifier='Z00.00',
text='General exam',
name_of_coding_system='I10'
)
dg1.diagnosis_type = CWE(identifier='A')
dg1.diagnosis_priority = '1'
code = dg1.diagnosis_code_dg1
dx_type = dg1.diagnosis_type
priority = dg1.diagnosis_priorityA message can contain multiple DG1 segments, each with a different set_id_dg1. Create multiple segments to represent them:
from zato.hl7v2.v2_9 import DG1, CWE
dg1_primary = DG1()
dg1_primary.set_id_dg1 = '1'
dg1_primary.diagnosis_code_dg1 = CWE(
identifier='Z00.00',
text='General exam',
name_of_coding_system='I10'
)
dg1_secondary = DG1()
dg1_secondary.set_id_dg1 = '2'
dg1_secondary.diagnosis_code_dg1 = CWE(
identifier='Z23',
text='Immunization encounter',
name_of_coding_system='I10'
)The diagnosis_type field uses HL7 table 0052. Common values include:
from zato.hl7v2.v2_9 import DG1, CWE
dg1 = DG1()
# A = Admitting
dg1.diagnosis_type = CWE(identifier='A')
# W = Working
dg1.diagnosis_type = CWE(identifier='W')
# F = Final
dg1.diagnosis_type = CWE(identifier='F')The diagnosing_clinician field uses the XCN (extended composite name) datatype:
from zato.hl7v2.v2_9 import DG1, XCN
dg1 = DG1()
dg1.diagnosing_clinician = XCN(
person_identifier='12345',
family_name='Smith',
given_name='John',
suffix='MD'
)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 DG1 segment, HL7 v2.9.
| # | Python name | Datatype | Usage | Repeatable | Table |
|---|---|---|---|---|---|
| 1 | set_id_dg1 | SI | Required | No | - |
| 3 | diagnosis_code_dg1 | CWE | Required | No | HL70051 |
| 5 | diagnosis_date_time | DTM | Optional | No | - |
| 6 | diagnosis_type | CWE | Required | No | HL70052 |
| 15 | diagnosis_priority | NM | Optional | No | HL70359 |
| 16 | diagnosing_clinician | XCN | Optional | Yes | - |
| 17 | diagnosis_classification | CWE | Optional | No | HL70228 |
| 18 | confidential_indicator | ID | Optional | No | HL70136 |
| 19 | attestation_date_time | DTM | Optional | No | - |
| 20 | diagnosis_identifier | EI | Optional | No | - |
| 21 | diagnosis_action_code | ID | Optional | No | HL70206 |
| 22 | parent_diagnosis | EI | Optional | No | - |
| 23 | drg_ccl_value_code | CWE | Optional | No | HL70728 |
| 24 | drg_grouping_usage | ID | Optional | No | HL70136 |
| 25 | drg_diagnosis_determination_status | CWE | Optional | No | HL70731 |
| 26 | present_on_admission_poa_indicator | CWE | Optional | No | HL70895 |
Get started with Zato and connect your systems in minutes.