Model a dental PPO deductible and annual maximum in TypeScript
The fixture records the crown's $1,200 submitted office charge as billedCents. The in-network allowed amount is $1,000. After a $50 deductible, the plan's 50% share would be $475. The annual maximum has $400 left, so the plan pays $400 and the patient owes $600.
Carry the balances across visits
Start with $50 of deductible remaining and $500 of remaining annual plan benefits. Under the sample PPO terms, a cleaning is deductible-exempt and its $100 plan payment counts toward the maximum. The full $50 deductible is still available when the crown is processed. The crown uses the remaining $400 of plan benefits, leaving the following filling with a $0 plan payment. The allowed amount, deductible, and covered percentage are separate fields on a dental explanation of benefits. American Dental Association explanation of benefits
| Visit | Billed | Allowed | Write-off | Deductible applied | Uncapped plan share | Plan paid | Patient pays | Deductible / annual max left |
|---|---|---|---|---|---|---|---|---|
| Cleaning | $150 | $100 | $50 | $0 | $100 | $100 | $0 | $50 / $400 |
| Crown | $1,200 | $1,000 | $200 | $50 | $475 | $400 | $600 | $0 / $0 |
| Filling | $200 | $160 | $40 | $0 | $128 | $0 | $160 | $0 / $0 |
| Total | $1,550 | $1,260 | $290 | $50 | $500 | $760 |
Apply the waterfall in adjudication order
For each covered in-network visit, the write-off is billed minus allowed. Apply the lesser of the remaining deductible and the allowed amount unless the visit is exempt. Multiply the remaining eligible amount by the plan percentage and round half up to cents. Cap that result at the remaining annual maximum, then subtract the actual plan payment from the allowance to get the patient portion. On the crown, that $600 consists of the $50 deductible, $475 in coinsurance, and $75 above the remaining benefit.
The annual maximum is the plan's payment budget. Reduce it by what the plan actually paid and carry it to the next row alongside the deductible balance. The example uses the supplied adjudication order for one member in one benefit year. When applying the waterfall to a real plan, use its benefit schedule and starting balances. American Dental Association guide to benefits and limitations
Run the benchmark
Save the block as dentalplan-benchmark.ts and run node --experimental-strip-types dentalplan-benchmark.ts with Node.js 24. The script needs no packages. Node.js TypeScript documentation
import assert from "node:assert/strict"; type Benefits = { deductibleRemainingCents: bigint; annualMaxRemainingCents: bigint }; type Visit = { id: string; billedCents: bigint; allowedCents: bigint; deductibleExempt: boolean; planBps: bigint; }; const BASIS_POINTS = 10_000n; const min = (a: bigint, b: bigint) => a < b ? a : b; function adjudicate(opening: Benefits, visits: readonly Visit[]) { let { deductibleRemainingCents, annualMaxRemainingCents } = opening; assert(deductibleRemainingCents >= 0n && annualMaxRemainingCents >= 0n, "Opening benefit balances must be nonnegative"); const seen = new Set<string>(); const rows = visits.map(({ id, billedCents, allowedCents, deductibleExempt, planBps }) => { assert(id.trim() === id && id && !seen.has(id), `Missing or repeated visit ID: ${id}`); assert(allowedCents >= 0n && allowedCents <= billedCents, `Invalid allowed amount: ${id}`); assert(planBps >= 0n && planBps <= BASIS_POINTS, `Invalid plan rate: ${id}`); seen.add(id); const writeOffCents = billedCents - allowedCents; const deductibleCents = deductibleExempt ? 0n : min(allowedCents, deductibleRemainingCents); const eligibleCents = allowedCents - deductibleCents; const uncappedPlanCents = (eligibleCents * planBps + BASIS_POINTS / 2n) / BASIS_POINTS; const planPaidCents = min(uncappedPlanCents, annualMaxRemainingCents); const patientCents = allowedCents - planPaidCents; deductibleRemainingCents -= deductibleCents; annualMaxRemainingCents -= planPaidCents; return { id, billedCents, allowedCents, writeOffCents, deductibleCents, uncappedPlanCents, planPaidCents, patientCents, deductibleRemainingCents, annualMaxRemainingCents, }; }); const totals = rows.reduce((total, row) => ({ billedCents: total.billedCents + row.billedCents, writeOffCents: total.writeOffCents + row.writeOffCents, planPaidCents: total.planPaidCents + row.planPaidCents, patientCents: total.patientCents + row.patientCents, }), { billedCents: 0n, writeOffCents: 0n, planPaidCents: 0n, patientCents: 0n }); return { rows, totals, closing: { deductibleRemainingCents, annualMaxRemainingCents } }; } const opening: Benefits = { deductibleRemainingCents: 5_000n, annualMaxRemainingCents: 50_000n }; const visits: Visit[] = [ { id: "cleaning", billedCents: 15_000n, allowedCents: 10_000n, deductibleExempt: true, planBps: 10_000n }, { id: "crown", billedCents: 120_000n, allowedCents: 100_000n, deductibleExempt: false, planBps: 5_000n }, { id: "filling", billedCents: 20_000n, allowedCents: 16_000n, deductibleExempt: false, planBps: 8_000n }, ]; const report = adjudicate(opening, visits); assert.deepEqual(report.rows, [ { id: "cleaning", billedCents: 15_000n, allowedCents: 10_000n, writeOffCents: 5_000n, deductibleCents: 0n, uncappedPlanCents: 10_000n, planPaidCents: 10_000n, patientCents: 0n, deductibleRemainingCents: 5_000n, annualMaxRemainingCents: 40_000n }, { id: "crown", billedCents: 120_000n, allowedCents: 100_000n, writeOffCents: 20_000n, deductibleCents: 5_000n, uncappedPlanCents: 47_500n, planPaidCents: 40_000n, patientCents: 60_000n, deductibleRemainingCents: 0n, annualMaxRemainingCents: 0n }, { id: "filling", billedCents: 20_000n, allowedCents: 16_000n, writeOffCents: 4_000n, deductibleCents: 0n, uncappedPlanCents: 12_800n, planPaidCents: 0n, patientCents: 16_000n, deductibleRemainingCents: 0n, annualMaxRemainingCents: 0n }, ]); assert.deepEqual(report.closing, { deductibleRemainingCents: 0n, annualMaxRemainingCents: 0n }); assert.deepEqual(opening, { deductibleRemainingCents: 5_000n, annualMaxRemainingCents: 50_000n }); assert.deepEqual(report.totals, { billedCents: 155_000n, writeOffCents: 29_000n, planPaidCents: 50_000n, patientCents: 76_000n }); for (const row of report.rows) { assert.equal(row.billedCents, row.writeOffCents + row.planPaidCents + row.patientCents); } const lowFee = adjudicate(opening, [{ ...visits[1], allowedCents: 2_000n }]).rows[0]; assert.equal(lowFee.deductibleCents, 2_000n); assert.equal(lowFee.deductibleRemainingCents, 3_000n); assert.equal(lowFee.planPaidCents, 0n); const halfCent = adjudicate({ ...opening, deductibleRemainingCents: 0n }, [{ ...visits[1], billedCents: 1n, allowedCents: 1n }]).rows[0]; assert.equal(halfCent.planPaidCents, 1n); assert.throws(() => adjudicate(opening, [visits[0], visits[0]]), /repeated visit ID/); assert.throws(() => adjudicate(opening, [{ ...visits[0], allowedCents: 15_001n }]), /Invalid allowed amount/); console.log("Visit | billed / allowed / write-off | deductible | uncapped plan / paid plan / patient | deductible left / max left (cents)"); for (const row of report.rows) { console.log(`${row.id} | ${row.billedCents} / ${row.allowedCents} / ${row.writeOffCents} | ${row.deductibleCents} | ${row.uncappedPlanCents} / ${row.planPaidCents} / ${row.patientCents} | ${row.deductibleRemainingCents} / ${row.annualMaxRemainingCents}`); } const { billedCents, writeOffCents, planPaidCents, patientCents } = report.totals; console.log(`Billed = write-off + plan + patient (cents): ${billedCents} = ${writeOffCents} + ${planPaidCents} + ${patientCents}`); Verified Node output
Visit | billed / allowed / write-off | deductible | uncapped plan / paid plan / patient | deductible left / max left (cents) cleaning | 15000 / 10000 / 5000 | 0 | 10000 / 10000 / 0 | 5000 / 40000 crown | 120000 / 100000 / 20000 | 5000 | 47500 / 40000 / 60000 | 0 / 0 filling | 20000 / 16000 / 4000 | 0 | 12800 / 0 / 16000 | 0 / 0 Billed = write-off + plan + patient (cents): 155000 = 29000 + 50000 + 76000 Reconcile each submitted charge as write-off + plan payment + patient portion. Keep the opening balances and processed visit order alongside the estimate so the same inputs reproduce the line items.
DentalPlan PPO cost estimator · B2B Ops and FinOps Benchmarks