Reference·DG1 Segment·DG1-1
HL7 v2 Reference

HL7 v2 DG1-1 (Set ID): Format, Values, and Testing Notes

Jul 27, 2026 · 4 min read
DG1-3 →

DG1-1 is a single number, which is exactly why it gets overlooked — until a message with five diagnoses lands and three of them share the value "1" because a source system never bothered to increment it.

Quick answer

DG1-1 is a sequence number that identifies which repetition of the DG1 segment you're looking at within a message. The first DG1 in the message is 1, the second is 2, and so on — it exists so downstream systems can keep repeating diagnosis segments in order and reference a specific one without ambiguity.

What this field contains

Type
Sequence Number (SI) — a plain positive integer, no components or sub-fields
Starts at
1 — the first DG1 in the message, incrementing by one for each additional repetition
Scope
per-message — the count resets with each new message rather than persisting across a patient's history

Example

Synthetic example Generated by Synthibase
DG1|1||E11.9^Type 2 diabetes mellitus without complications^I10|Type 2 diabetes mellitus without complications|202607250830|F||||||||1

Set ID value of 1 marking this as the first (and in this example, only) DG1 repetition in the message.

Where this trips people up

The most common failure isn't a malformed value, it's a system that generates every DG1-1 as "1" regardless of how many diagnosis segments are actually in the message, because whoever built the interface assumed there'd only ever be one diagnosis. That works fine until a multi-diagnosis encounter comes through and the receiving application either overwrites earlier diagnoses or throws a duplicate-key error depending on how it keys off this field. Test with messages carrying at least three DG1 repetitions with properly incrementing values, and separately test what happens when a sending system violates that assumption.

HL7 v2 DG1 Explained: Structure, Fields, and Common Mistakes
HL7 ADT Messages: A01 through A08 Explained
Regression Testing for EHR Upgrades: A Complete Guide
Generate multi-repetition DG1 test messages in seconds
Synthibase builds HL7 v2 test data with correctly sequenced, multi-diagnosis DG1 segments so you can catch set-ID handling bugs before they reach production.
Start free trial →
This page is written independently by Synthibase for testing and informational purposes. It is not an official publication of HL7 International or X12/Washington Publishing Company, and is not a substitute for reviewing the official standard or your trading partner's companion guide. See our Terms of Service for full legal terms.