# Showcases 1: Claims on a Synthea Population

Source: https://obsvra.com/learn/showcases/synthea-claims

**Requires Pro** (`FlatFile`) — a Free-tier version of the same idea is [Showcases 3](https://obsvra.com/learn/showcases/pool-without-pro/)

### Problem statement

You're testing a claims pipeline — adjudication, pricing, an 837 ingest, a reserving model. It needs two things that pull in opposite directions: members who look like a real population, and far more claims than any real population would hand you.

Real member data solves the first and fails the second, because it's PHI and it isn't leaving its controlled environment to sit in your CI. Synthea solves the first beautifully — it's MITRE's open-source patient generator, with disease modules built by clinicians and calibrated against CDC and NIH statistics — but it can't effectively solve the second.

Synthea *does* export claims. What it can't do is separate claim volume from population size. Every claim exists because Synthea simulated the encounter that produced it, so the only way to get more claims is to simulate more patient lifetimes. We measured 45 patients producing 4,687 claims; a million claims means simulating on the order of ten thousand-plus people, which took about three hours at the rate we measured.

That's not a criticism — Synthea is modeling decades of medical history per person, which is a far harder computation than emitting a single patient row. It's just a different job from the one you need here.

So use Synthea for the half it's extraordinary at, and SpiceGrinder for the half it isn't built for.

### The model

Generate a population with Synthea once, then project `patients.csv` down to the handful of columns a claim line actually needs — member id, birthdate, gender, state — and commit that file. It's now an ordinary repo artifact: reviewable, diffable, and fixed, so nothing downstream depends on re-running Synthea.

`FlatFile` samples a row from that pool. The important property is that it draws a **whole row atomically**: the member id, birthdate, gender, and state on any given claim line always belong to the same person. There's no join to get wrong and no consistency pass to remember afterward.

The claim economics are the same `Poisson` and `Lognormal` pairing from [Claims 1](https://obsvra.com/learn/modeling-101/modeling-lesson-claims-1/) — count and amount — and an `Append` joins the member to the claim, exactly as [Claims 2](https://obsvra.com/learn/modeling-101/modeling-lesson-claims-2/) did with the bundled person model. The only thing that changes here is where the member comes from.

```xml
<?xml version="1.0" encoding="UTF-8"?>
<dataset columns="memberId, birthdate, gender, state, serviceUnits, billedAmount" seed="42">
	<root node="ClaimLine"/>
	<nodes>
		<Append name="ClaimLine">
			<input name="Member"/>
			<input name="ServiceUnits"/>
			<input name="BilledAmount"/>
		</Append>

		<FlatFile name="Member" file="member-pool.csv" mode="unweighted" skipHeader="true"/>

		<Poisson name="ServiceUnits" lambda="2.5"/>
		<Lognormal name="BilledAmount" mu="6.4" sigma="0.9"/>
	</nodes>
</dataset>
```

Run it (`samples/pro/health/claims-from-synthea.xml`, from that directory so the relative pool path resolves) and each row is a real Synthea member with claim economics you chose:

```
62f60bdb-cc5c-8305-b98b-f2b229a55eca,1975-10-03,F,Massachusetts,3,1848.9720300223617
76b20010-c318-5754-8c85-983aa538522f,2018-02-27,M,Massachusetts,0,237.50512954998106
0dd6cb0d-0e17-ab7a-8054-7f89c4259da7,1960-09-04,F,Massachusetts,2,359.76872222763626
7512bbb4-b22b-0979-6edc-389e16607ac7,2025-02-03,F,Massachusetts,1,199.3029938671857
6f45f2e9-a617-570a-8867-dec1260088bb,2013-06-07,M,Massachusetts,1,642.8437122811947
```

Members recur across claim lines the way they do in a real book of business, because the pool is sampled randomly.

### Why this shape works

**Generate at build time, read at generate time.** Synthea runs once and produces a file you commit. It's tempting to wire a generator directly to a live data source instead, but that costs you reproducibility — `ServiceCall` against a live endpoint isn't deterministic unless the service is. A committed pool is a fixed input, so the same model and seed produce the same bytes forever. If you don't need that determinism, then the "live" source would work just fine.

**Project the pool before you use it.** `patients.csv` has 28 columns; a claim line needs four. Carrying 24 unused dimensions is needlessly inefficient, and several of Synthea's columns need care anyway — `ZIP` and `FIPS` are numeric-looking strings with leading zeros, and `01109` arrives as `1109.0` unless you list the column in `FlatFile`'s `textColumns`. Filter out what you don't need, and mark as text any identifier column you keep.

**Volume and population are now separate knobs.** The same 40-member pool produced a million claim lines in 1.6 seconds. Want a heavier book? Change `lambda`. Want a catastrophe year? Change `mu`. Want more distinct members? Regenerate the pool. None of those three decisions forces the other two, which is the whole point of splitting the problem this way.

As always, `lambda="2.5"` and `mu="6.4" sigma="0.9"` are examples. They're yours to set — that's the lever that SpiceGrinder gives you and that Synthea can't.
