# How to Flatten an 834 File Into Tables: Choosing the Grain and Mapping Loops

**Published:** Dec 01, 2026
**Author:** Donal Tobin
**Category:** Eligibility file

## Summary

The design decisions behind turning an 834 enrollment file into correct CSV or database tables, with a worked example of members and coverages.


![How to Flatten an 834 File Into Tables: Choosing the Grain and Mapping Loops](https://cdn.buttercms.com/ubIWygADQU24IhWH5L7g)


## Content

To flatten an 834 file into tables, decide the grain first, either one row per member or one row per coverage, then pull member fields from each INS loop, link every dependent to its subscriber, pull coverage fields from each HD loop, decode maintenance and relationship codes, convert CCYYMMDD dates, and check that row counts match the segments in the file. This guide is for data engineers and analysts who need 834 enrollment data in CSV files or database tables that are correct, not just readable. By the end, you will know which design choices to make, how each 834 loop maps to columns, and how to check the result.

Most 834 to CSV conversions fail quietly. The file converts, the columns look sensible, and only later does someone notice that dependents are not linked to subscribers, that benefit dates were used as eligibility dates, or that members with two coverages became two members.

## Where This Fits

This guide covers the design decisions when turning an 834 into tables. Related topics are covered elsewhere:

* What an 834 contains, segment by segment: the 834 file layout guide
* Tools for converting 834, 835 and 837 files to CSV or Excel, including a free converter: the best EDI to CSV and Excel converters
* Loading flattened data with coverage history: how to load eligibility files into Snowflake or Postgres

## Why Flattening an 834 Is Harder Than It Looks

An 834 is hierarchical. A transaction is a sequence of member loops, each opened by an INS segment, and each member can carry several coverage loops, each opened by an HD segment. Dependents do not point to their subscriber with a parent ID; they simply follow the subscriber in the file, usually carrying the subscriber's identifier in a REF segment.

A table is flat. Turning one into the other means choosing what a row represents, carrying context from earlier segments into later rows, and deciding which of several dates and codes belongs in each column. Each plan's companion guide adds its own variations on top of the X12 standard.

## What You'll Need Before Starting

* Sample 834 files from the plan, with PHI removed or in a secure environment
* The plan's 834 companion guide, which says which segments and codes it uses
* A target layout: a single CSV, or separate member and coverage tables
* A parser or tool that reads X12 and exposes segments by loop

## How to Flatten an 834 Into Tables: Step by Step

### Step 1: Choose the Grain

The grain decides what one row means, and every later choice depends on it.

**What to do:** - **One row per member**: simplest for rosters and eligibility lookups; coverages must be summarized or limited to one per member - **One row per coverage**: each HD loop becomes a row, with member fields repeated; right when members hold several benefits, such as medical, dental and vision - **Two tables**: a members table and a coverages table linked by member key; best for databases and analytics - Write the choice down, because changing it later means reprocessing history

**Output of this step:** A documented grain and target layout.

**Where Integrate.io helps:** Integrate.io's EDI (X12) source flattens 834 files at the grain you choose, one row per member or one row per coverage, with named columns such as member_id and eligibility_begin.

### Step 2: Map Member Fields From the INS Loop

Everything from one INS segment until the next belongs to one member.

**What to do:** - **INS**: subscriber indicator (INS01), relationship code (INS02), maintenance type (INS03), maintenance reason (INS04) and benefit status (INS05) - **REF**: subscriber identifier (REF*0F) and group or policy number (REF*1L), plus any other qualifiers the companion guide lists - **NM1*IL**: member name and member identifier (NM109) - **DMG**: date of birth and gender; **N3/N4**: address; **PER**: phone or email where present - **DTP at member level**: eligibility begin (356) and eligibility end (357), and maintenance effective date (303) where used

**Output of this step:** A field map from member-level segments to member columns.

### Step 3: Link Dependents to Their Subscriber

This is the most common gap in 834 conversions.

**What to do:** - Use INS01 to tell subscribers (Y) from dependents (N) - Carry the subscriber identifier (REF*0F) onto every dependent row, or carry it forward from the preceding subscriber if the plan omits it on dependents - Create a household or subscriber key so all members of a family can be grouped - Flag any dependent that cannot be linked, rather than guessing

**Output of this step:** Every dependent row linked to a subscriber, with unlinked dependents flagged.

### Step 4: Map Coverage Fields From the HD Loop

Coverage details sit under HD segments, and a member can have several.

**What to do:** - **HD**: maintenance type (HD01), insurance line such as HLT, DEN or VIS (HD03), plan or coverage description (HD04) and coverage level such as EMP or FAM (HD05) - **DTP at coverage level**: benefit begin (348) and benefit end (349) - Keep benefit dates separate from member eligibility dates; they can differ - If your grain is one row per member, decide explicitly which coverage to keep or how to summarize several

**Output of this step:** A field map from coverage-level segments to coverage columns.

### Step 5: Decode Codes, but Keep the Originals

Codes are compact in the file and confusing in a table.

**What to do:** - Translate INS02 relationship codes, for example 18 for self, 01 for spouse and 19 for child - Translate INS03 maintenance types: 021 addition, 001 change, 024 cancellation or termination, 030 audit or compare - Translate HD05 coverage levels and INS05 benefit status using the plan's companion guide - Store both the raw code and the decoded value, so you can always trace back to the file

**Output of this step:** Readable code columns alongside the original codes.

### Step 6: Convert Dates and Handle Empty Values

834 dates arrive as text and need care.

**What to do:** - Convert CCYYMMDD strings to real dates, and reject values that do not parse - Treat an empty end date as open coverage, not as a missing value to fill - Keep date qualifiers in mind: 356 and 357 describe eligibility, 348 and 349 describe the benefit - Keep the original string in a raw column if downstream teams may need to audit it

**Output of this step:** Typed date columns with clear meanings.

**Where Integrate.io helps:** The EDI (X12) source keeps 834 dates as CCYYMMDD strings so values are never silently reinterpreted, and Integrate.io's low-code expressions convert them to date types in the same pipeline.

### Step 7: Check the Flattened Output Against the File

A conversion is only correct if the counts match.

**What to do:** - Count INS segments in the file and compare with member rows - Count HD segments and compare with coverage rows - Check every dependent has a subscriber and every subscriber appears once per transaction - Compare totals with the file's trailer counts and with the previous delivery

**Output of this step:** A flattened file or table set whose counts reconcile with the 834.

Broader checks are covered in how to validate health plan eligibility files before they load.

## A Worked Example

The fictional 834 fragment below holds one subscriber with medical coverage and one dependent child.

```text
INS*Y*18*021*28*A***FT~
REF*0F*100200300~
REF*1L*GRP001~
DTP*356*D8*20270101~
NM1*IL*1*DOE*JANE****34*100200300~
DMG*D8*19800515*F~
HD*021**HLT*PPO*FAM~
DTP*348*D8*20270101~
INS*N*19*021*28*A~
REF*0F*100200300~
NM1*IL*1*DOE*SAM****34*100200301~
DMG*D8*20120310*M~
HD*021**HLT*PPO*FAM~
DTP*348*D8*20270101~

```

Flattened into two tables, it becomes:

**Members**

| member_id | subscriber_id | relationship | maintenance | last_name | first_name | dob | eligibility_begin |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 100200300 | 100200300 | Self (18) | Addition (021) | DOE | JANE | 1980-05-15 | 2027-01-01 |
| 100200301 | 100200300 | Child (19) | Addition (021) | DOE | SAM | 2012-03-10 |  |

**Coverages**

| member_id | insurance_line | plan | coverage_level | benefit_begin |
| --- | --- | --- | --- | --- |
| 100200300 | HLT | PPO | FAM | 2027-01-01 |
| 100200301 | HLT | PPO | FAM | 2027-01-01 |

The dependent has no member-level eligibility date in this fragment, which is why benefit dates and eligibility dates need separate columns, and why the companion guide decides which one your contracts rely on.

## Common Mistakes to Avoid

* Picking the grain after building the conversion: rows double or coverages disappear. Choose first, as in Step 1.
* Leaving dependents unlinked: family-level services and billing break. Link every dependent, as in Step 3.
* Mixing eligibility and benefit dates: coverage appears to start on the wrong day. Keep 356/357 and 348/349 separate, as in Steps 2 and 4.
* Dropping the raw codes: decoded labels cannot be traced back to the file. Keep both, as in Step 5.
* Treating empty end dates as errors: open coverage gets rejected. Empty usually means ongoing.
* Hand-converting each plan's 834 differently: results drift between plans. One parser with plan-specific settings, which Integrate.io supports, keeps every 834 flattened the same way.

## Conclusion

Flattening an 834 file into tables is mostly a set of design decisions: choose the grain, map member fields from INS loops and coverage fields from HD loops, link dependents to subscribers, decode codes while keeping originals, convert dates with their qualifiers in mind, and reconcile counts with the file. Made once and written down, those decisions turn every plan's 834 into consistent rows. Integrate.io's EDI (X12) source applies them in a pipeline, flattening at the grain you choose and loading the result alongside CSV and Excel files from other plans. Problems that show up after flattening are covered in common eligibility file errors and how to fix them.


## Tags

data engineering, EDI 834, eligibility files, en, healthcare data

## Categories

Eligibility file