# How to Load Eligibility Files Into Snowflake or Postgres With Coverage History

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

## Summary

How to model and load health plan eligibility files in Snowflake or Postgres with coverage history, including merge SQL, full-file terminations and as-of queries.


![How to Load Eligibility Files Into Snowflake or Postgres With Coverage History](https://cdn.buttercms.com/MqS0tosdRfGG3Hywn0Ff)


## Content

To load health plan eligibility files into Snowflake or Postgres with coverage history, keep one row per member per coverage period with effective start and end dates, merge each new file into that table instead of overwriting it, end coverage for members missing from full files, keep retroactive changes and reinstatements as their own periods, and publish a current view for applications. This guide is for data engineers who already parse and validate eligibility files and need a reliable data model and load logic in the warehouse or database. By the end, you will have a table design, merge SQL for Snowflake and Postgres, and queries that answer "who was eligible on this date?"

Getting a file into a database is the easy part. Keeping eligibility correct over time is harder: members terminate, come back, change plans and receive retroactive coverage, and each plan sends either full snapshots or changes. A table that is simply overwritten on every load cannot answer when a member was covered, which is the question billing, reconciliation and audits ask most.

## Where This Fits

This guide covers the data model and load logic. The steps before it are covered elsewhere:

* Mapping each plan's file to one member schema: how to onboard a new health plan's eligibility file
* Checking files before they load: how to validate health plan eligibility files before they load
* Clinical formats such as HL7 and FHIR: how to ingest HL7 or FHIR files from health plans into a database
* General security and migration practices: best practices for transferring healthcare data to your database

## What You'll Need Before Starting

* A Snowflake account or Postgres database with raw, staging and production schemas
* Parsed, mapped and validated eligibility rows in a staging table
* For each plan, whether it sends full files or change files, and each file's effective date
* A role design that limits who can see protected health information (PHI)

## How to Load Eligibility Files With Coverage History: Step by Step

### Step 1: Separate Raw, Staging, History and Current Layers

Each layer has one job, which keeps bad data out of production and makes every change traceable.

**What to do:**
- **Raw**: each file exactly as received, plus a row of metadata (plan, file name, received time, row count)
- **Staging**: the latest file's rows after mapping and validation, replaced on every load
- **History**: one row per member per coverage period, never overwritten
- **Current view**: members covered today, built on the history table

**Output of this step:** Four layers with clear responsibilities.

### Step 2: Land Every File Unchanged

Raw files are your evidence when a plan disputes what it sent.

**What to do:**
- Store each file in object storage or a Snowflake stage, in a path by plan and date
- Record its metadata in a raw files table
- Keep raw files for your audit and dispute window, for example 24 months

**Output of this step:** Every delivery stored as received, with metadata.

### Step 3: Prepare Staging Before the Load

The merge assumes staging is already clean.

**What to do:**
- Map every plan to the same staging columns, with member IDs stored as text
- Validate rows and route failures to review, so only passing rows remain in staging
- Add plan, source file, file type (full or change) and file effective date to every staging row

**Output of this step:** Clean staging rows labeled with their file type and effective date.

**Where Integrate.io helps:** Integrate.io pipelines parse 834, CSV and Excel files, map each plan to one schema, validate rows and write clean staging tables in Snowflake or Postgres, as described on the eligibility file ingestion page for point solutions.

### Step 4: Design the Coverage History Table

The key decision is what makes a row unique.

**What to do:**
- Use plan, member ID and coverage start date as the key, so a member can have several periods with the same plan
- Store coverage end date as empty for open coverage
- Record the source file and load time on every row
- In Postgres, add a unique constraint on the key; in Snowflake, enforce the key in your merge logic

**Output of this step:** A history table where each row is one coverage period.

| Column | Purpose |
| --- | --- |
| plan_id | Health plan or employer that sent the record |
| member_id | The plan's member ID, stored as text |
| coverage_start_date | First day of this coverage period (part of the key) |
| coverage_end_date | Last day of this period, empty while coverage is open |
| product | Plan, product line or eligible benefit |
| status | Active or terminated |
| source_file | File that created or last changed the row |
| loaded_at | When the row was inserted or updated |

### Step 5: Merge Each File Into the History Table

The merge inserts new coverage periods and updates changed ones, without deleting anything.

**What to do:**
- Match staging rows to history rows on plan, member ID and coverage start date
- Update a matched row only when its end date, product or status changed
- Insert rows that do not match, which covers new members, retroactive adds and reinstatements

**In Snowflake:**

```sql
MERGE INTO eligibility t
USING stg_eligibility s
  ON  t.plan_id = s.plan_id
  AND t.member_id = s.member_id
  AND t.coverage_start_date = s.coverage_start_date
WHEN MATCHED AND (
       t.coverage_end_date IS DISTINCT FROM s.coverage_end_date
    OR t.product IS DISTINCT FROM s.product
    OR t.status IS DISTINCT FROM s.status)
THEN UPDATE SET
  coverage_end_date = s.coverage_end_date,
  product = s.product,
  status = s.status,
  source_file = s.source_file,
  loaded_at = CURRENT_TIMESTAMP()
WHEN NOT MATCHED THEN INSERT
  (plan_id, member_id, coverage_start_date, coverage_end_date,
   product, status, source_file, loaded_at)
VALUES
  (s.plan_id, s.member_id, s.coverage_start_date, s.coverage_end_date,
   s.product, s.status, s.source_file, CURRENT_TIMESTAMP());

```

**In Postgres** (requires a unique constraint on plan_id, member_id, coverage_start_date):

```sql
INSERT INTO eligibility
  (plan_id, member_id, coverage_start_date, coverage_end_date,
   product, status, source_file, loaded_at)
SELECT plan_id, member_id, coverage_start_date, coverage_end_date,
       product, status, source_file, now()
FROM stg_eligibility
ON CONFLICT (plan_id, member_id, coverage_start_date)
DO UPDATE SET
  coverage_end_date = EXCLUDED.coverage_end_date,
  product = EXCLUDED.product,
  status = EXCLUDED.status,
  source_file = EXCLUDED.source_file,
  loaded_at = now()
WHERE (eligibility.coverage_end_date, eligibility.product, eligibility.status)
      IS DISTINCT FROM
      (EXCLUDED.coverage_end_date, EXCLUDED.product, EXCLUDED.status);

```

**Output of this step:** New and changed coverage periods applied, with unchanged rows left alone.

### Step 6: End Coverage for Members Missing From Full Files

Full files and change files mean different things when a member is absent.

**What to do:**
- For a **change file**, do nothing for absent members: they are unchanged
- For a **full file**, end open coverage for members of that plan who are absent, using the day before the file's effective date
- Hold the termination step if the file's member count drops sharply, since a partial file would otherwise terminate real members
- Keep retroactive terminations as end-date updates on the existing period, so history shows when coverage actually ended

**For full files only** (Postgres shown; in Snowflake use `DATEADD(day, -1, :file_effective_date)`):

```sql
UPDATE eligibility e
SET coverage_end_date = :file_effective_date - INTERVAL '1 day',
    status = 'terminated',
    source_file = :source_file,
    loaded_at = now()
WHERE e.plan_id = :plan_id
  AND e.coverage_end_date IS NULL
  AND NOT EXISTS (
    SELECT 1 FROM stg_eligibility s
    WHERE s.plan_id = e.plan_id
      AND s.member_id = e.member_id);

```

**Output of this step:** Terminations applied correctly for full files, and never for change files.

**Where Integrate.io helps:** Integrate.io's Snowflake and Postgres destinations support insert and merge operations, and SQL steps can run after each load, so the merge and full-file termination logic run in the same scheduled pipeline. The Integrate.io and Snowflake post describes how loads use COPY INTO and MERGE.

### Step 7: Publish a Current View, Secure PHI and Reconcile

Most consumers need today's eligibility, not the full history.

**What to do:**
- Create a current view and point applications at it, not at raw, staging or history tables
- Restrict PHI with roles and views; in Snowflake, masking policies where your edition supports them; in Postgres, row-level security
- After each load, reconcile counts: rows in the file, rows inserted, rows updated, members terminated and rows held
- Alert on failed loads and unusual counts, as covered in best practices for monitoring eligibility file delivery

```sql
CREATE VIEW current_eligibility AS
SELECT plan_id, member_id, product
FROM eligibility
WHERE CURRENT_DATE BETWEEN coverage_start_date
      AND COALESCE(coverage_end_date, DATE '9999-12-31');

```

**Output of this step:** A secure current view and a reconciled load every cycle.

## Answering "Who Was Eligible On…?"

With coverage periods stored, as-of questions become a date filter. This works in both Snowflake and Postgres:

```sql
SELECT plan_id, member_id, product
FROM eligibility
WHERE DATE '2027-03-01' BETWEEN coverage_start_date
      AND COALESCE(coverage_end_date, DATE '9999-12-31');

```

The same pattern supports billing checks for a service date, member-month counts for capitation, and roster reconciliation, as described in member roster reconciliation in value-based care. Retroactive changes matter most for Medicaid, covered in how to process Medicaid eligibility files from managed care plans.

## Snowflake vs. Postgres for Eligibility Data

|  | Snowflake | Postgres |
| --- | --- | --- |
| Best for | Analytics across many plans and long histories | Eligibility lookups inside applications |
| Loading | COPY INTO from stages, MERGE | COPY, INSERT with ON CONFLICT, MERGE in recent versions |
| Key enforcement | In merge logic | Unique constraint |
| History | Your coverage periods, plus Time Travel for recent table changes | Your coverage periods |
| PHI controls | Roles and masking policies (edition-dependent) | Roles, views and row-level security |

Many teams use both: Postgres for application lookups and Snowflake for analytics and reconciliation, loaded from the same pipeline.

## Common Mistakes to Avoid

* Overwriting the table on every load: history disappears and as-of questions cannot be answered. Merge into coverage periods, as in Step 5.
* Using member ID alone as the key: a member who leaves and returns overwrites their earlier period. Include coverage start date, as in Step 4.
* Terminating absent members from change files: everyone not in this week's changes loses coverage. Apply terminations to full files only, as in Step 6.
* Running full-file terminations on a partial file: thousands of members are terminated by mistake. Hold the step when counts drop sharply.
* Pointing applications at history or raw tables: PHI is exposed and queries get complicated. Publish a current view, as in Step 7.
* Writing load logic per plan: each plan drifts. One pipeline template with plan settings, which Integrate.io supports, keeps merge logic consistent.

## Conclusion

Loading eligibility files into Snowflake or Postgres with coverage history comes down to the data model: one row per member per coverage period, merges instead of overwrites, terminations for full files only, and a current view on top. With that design, every question about past and present eligibility becomes a simple query, and every change traces back to the file that made it. Integrate.io runs the repeated parts, from parsing and validation to merge loads and post-load SQL, in one pipeline. Teams still mapping their first plans can start with the onboarding checklist and template.


## Tags

data engineering, eligibility files, en, healthcare data, Postgres, snowflake

## Categories

Eligibility file