The EHI Playground: Your Interactive Toolkit
Purpose: To transform you from a passive reader into an active explorer of Epic’s healthcare data.
Welcome to Your Interactive Database
Section titled “Welcome to Your Interactive Database”This book isn’t just about reading—it’s about doing. Every SQL query you see can be executed directly in your browser against a real Epic EHI export. No setup required. No installation needed. Just click and explore.
Let’s start with your very first query. Click the play button to see it in action:
Congratulations! You just queried an Epic EHI database. Those numbers you see? PAT_ENC_CSN_ID is the Contact Serial Number—Epic’s unique identifier for each encounter. ENC_CLOSED_YN tells you whether the encounter documentation is complete (‘Y’ for yes).
How This Interactive Environment Works
Section titled “How This Interactive Environment Works”Our playground runs on a complete Epic EHI export loaded into SQLite, accessible directly in your browser. Here’s what makes it special:
- Real Data Structure: All 551 tables from an actual Epic export
- Complete Documentation: The
_metadata
table contains Epic’s official documentation - Instant Feedback: See results immediately, no waiting
- Safe Exploration: Read-only access means you can’t break anything
Your First Data Exploration
Section titled “Your First Data Exploration”Let’s dig deeper. Epic stores timestamps in a specific format. Run this query to see how dates work:
Notice the date format: M/D/YYYY 12:00:00 AM
. This is Epic’s standard—all dates include a midnight timestamp, even when only the date matters.
Editing and Experimenting
Section titled “Editing and Experimenting”Every query box is fully editable. Try modifying the previous query:
- Change
LIMIT 5
toLIMIT 10
to see more results - Add
WHERE YEAR(CONTACT_DATE) = 2023
to filter by year - Remove the
GROUP BY
to see individual encounters
Don’t worry about making mistakes—you can always reset to the original query.
Understanding Query Results
Section titled “Understanding Query Results”When you run a query, you’ll see:
- Column Headers: The field names from your SELECT statement
- Data Rows: The actual values from the database
- Row Count: How many records your query returned
- Execution Time: How long the query took (usually milliseconds)
Power User Tips
Section titled “Power User Tips”1. Use Comments for Learning
-- Comments help explain what's happeningSELECT PAT_ID, -- Patient identifier COUNT(*) as visits -- Total encountersFROM pat_encGROUP BY PAT_ID;
2. Explore Schema While Querying
-- See all columns in a tablePRAGMA table_info(pat_enc);
3. Check Data Quality
-- Find NULL valuesSELECT COUNT(*) as total, COUNT(CONTACT_DATE) as with_date, COUNT(*) - COUNT(CONTACT_DATE) as missing_dateFROM pat_enc;
Common Patterns You’ll Use
Section titled “Common Patterns You’ll Use”Throughout this book, you’ll see these query patterns repeatedly:
When Things Go Wrong
Section titled “When Things Go Wrong”Errors are part of learning. Here are common issues and fixes:
- “No such column” error: Check spelling and use
PRAGMA table_info()
to see available columns - Empty results: Your WHERE clause might be too restrictive
- Too many results: Add a LIMIT clause to manage output
- Syntax errors: SQLite uses standard SQL—check for missing commas or quotes
Your Learning Path
Section titled “Your Learning Path”As you progress through this book:
- Try every query: Don’t just read—execute and observe
- Modify examples: Change filters, add columns, experiment
- Build intuition: Notice patterns in table names and relationships
- Ask questions: Use the
_metadata
table (next chapter) to answer them
The beauty of this approach? You’re not learning about a theoretical database—you’re actively querying the same Epic EHI structure used by thousands of healthcare organizations worldwide.
Key Takeaways
Section titled “Key Takeaways”- Every SQL example in this book is executable in your browser against real Epic EHI data
- The interactive environment provides immediate feedback with no setup required
- Epic’s date format includes timestamps even for date-only fields:
M/D/YYYY 12:00:00 AM
- Experimentation is encouraged—you can’t break anything in this read-only environment
- Common patterns include joining patient data, searching metadata, and handling Epic’s specific data formats