Modeling a Simple List: The (ID, LINE) Pattern
Purpose: To master Epic’s most fundamental pattern for representing one-to-many relationships.
The Pattern That Rules Them All
Section titled “The Pattern That Rules Them All”Open any Epic database and you’ll find one pattern repeated more than any other. It appears in 275 tables—exactly half of the entire database. It’s the foundation for storing everything from multiple diagnoses per encounter to multiple addresses per patient. This is the (ID, LINE)
pattern.
Understanding the Pattern
Section titled “Understanding the Pattern”The (ID, LINE)
pattern solves a universal problem: how do you store multiple related items for a single entity? In a hierarchical database like Chronicles, you simply add multiple values to the same field. But in a relational database, you need rows. The LINE
column creates those rows while maintaining order.
Let’s see it in action with patient encounter diagnoses:
Here’s what each part means:
- ID (PAT_ENC_CSN_ID): Links all diagnoses to one encounter
- LINE: Orders the diagnoses (1, 2, 3…)
- Together they form a composite key that uniquely identifies each diagnosis
The Critical Insight: LINE ≠ Priority
Section titled “The Critical Insight: LINE ≠ Priority”Here’s a common misconception: “LINE 1 must be the primary diagnosis.” Let’s prove this wrong:
As you can see, primary diagnoses can appear in any LINE position. LINE indicates entry order, not clinical importance. This is crucial for correct data interpretation.
LINE Numbering Rules
Section titled “LINE Numbering Rules”Through empirical testing, we can establish Epic’s LINE numbering rules:
The rules are consistent:
- LINE always starts at 1 (never 0)
- LINE increments by 1 (no gaps in sequences)
- LINE is always an INTEGER data type
Real-World Applications
Section titled “Real-World Applications”The (ID, LINE)
pattern appears everywhere in healthcare data:
Each use case follows the same pattern:
- Patient Addresses: Multiple addresses per patient (home, work, billing)
- Allergy Reactions: Multiple reactions per allergy
- Coverage Members: Multiple family members per insurance plan
- Order Diagnoses: Multiple diagnoses justifying a single order
Working with (ID, LINE) Data
Section titled “Working with (ID, LINE) Data”When querying these tables, remember:
1. Always include LINE in your ORDER BY
-- Correct: Preserves the intended sequenceSELECT * FROM PAT_ENC_DXWHERE PAT_ENC_CSN_ID = 12345ORDER BY LINE;
2. Use both columns for joins
-- When the child table also uses (ID, LINE)SELECT * FROM parent pJOIN child c ON p.ID = c.ID AND p.LINE = c.LINE;
3. Aggregate carefully
The Chronicles Connection
Section titled “The Chronicles Connection”Why does Epic use this pattern so extensively? It’s a direct translation of Chronicles’ “related multiple” concept. In Chronicles, a single field can hold multiple values. When this hierarchical data moves to relational Clarity, each value becomes a row, with LINE preserving the original sequence.
This is why you’ll never see:
- LINE numbers starting at 0
- Gaps in LINE sequences (like 1, 2, 4)
- Non-integer LINE values
These would violate Chronicles’ data model.
Key Takeaways
Section titled “Key Takeaways”- The
(ID, LINE)
pattern appears in 275 tables—half of Epic’s database - LINE always starts at 1 and increments sequentially without gaps
- Critical: LINE indicates entry order, NOT priority or importance
- The pattern directly translates Chronicles’ “related multiple” concept to relational tables
- Always include LINE in ORDER BY clauses to preserve intended sequences
- Primary diagnoses, preferred addresses, etc. can appear at any LINE position