CareLedger

Every charge deserves an explanation.

Inspiration

A hospital bill often arrives when a family is already exhausted. Instead of a clear account of what happened, patients receive pages of codes, unfamiliar descriptions, insurance adjustments, and a final amount due with little context.

We built CareLedger around a simple question: What if a patient could upload a medical bill and receive a clear, evidence-backed explanation of what deserves attention?

What it does

CareLedger is a patient-side medical bill auditing application.

A patient uploads a hospital billing PDF containing an itemized statement and insurance processing information. CareLedger then:

  1. Extracts the patient, facility, dates, charges, and insurance amounts.
  2. Lets the patient review and correct the extracted information.
  3. Reconciles every hospital charge against its matching Explanation of Benefits line.
  4. Runs deterministic audit rules for duplicate charges, coverage discrepancies, overlapping services, and care-specific concerns.
  5. Asks an AI Advocate and AI Defender to examine each finding from opposing perspectives.
  6. Uses an adjudicator to decide whether each finding survives, is downgraded, or is rejected.
  7. Produces prioritized next steps, an editable dispute letter, a phone script, and an evidence checklist.

The final screen highlights only confirmed savings opportunities. Items that still require clarification are shown separately rather than being presented as savings.

How we built it

CareLedger uses Next.js 14 with the App Router, TypeScript, Tailwind CSS, and Zod.

Uploaded PDFs are processed in memory using pdf-parse. No authentication, database, user account, or file persistence is required. After extraction, every value is normalized into a strict case schema.

Every monetary value is stored as integer cents, which keeps the arithmetic exact and avoids floating-point rounding errors.

The unexplained statement gap is the difference between what the hospital requests and what the Explanation of Benefits (EOB) says the patient owes. It can never be less than zero:

Unexplained statement gap = max(0, hospital amount due - EOB patient responsibility)

For example:

max(0, $4,392 - $2,698) = $1,694 unexplained statement gap

The reconciliation engine matches bill and insurance lines using service codes, dates, and billed amounts. Audit rules then examine the normalized case and create findings with patient impact, evidence, and source references.

Aggregate findings are excluded from summary arithmetic so an account-level gap is not counted again alongside the individual charges that explain it.

The displayed savings opportunity includes only confirmed line-item mismatches and can never exceed the amount currently due:

Savings opportunity = min(confirmed non-aggregate mismatches, current amount due)

Items that still need clarification are kept separate and are not presented as savings.

For model-assisted review, CareLedger uses a provider fallback chain. If every provider is unavailable, the application returns a complete cached analysis instead of leaving the patient with an incomplete screen.

Challenges we faced

Keeping every number connected to the uploaded document

An early version could display fixture totals when an uploaded case failed validation. That made the interface look complete, but the numbers could belong to a different case.

We fixed this by carrying a case identifier through extraction, analysis, and rendering. The UI refuses to display a plan unless its case identifier matches the uploaded document.

Avoiding double-counted findings

An account-level statement gap can be explained by multiple individual charges. Adding the aggregate finding to those charges would exaggerate the financial impact.

We created explicit aggregate findings and exclude them from the summary totals.

Describing savings responsibly

A charge that needs clarification is not automatically a savings opportunity. We changed the closing figure to include only confirmed mismatches that survive adjudication, capped by the current balance.

Making PDF extraction work on Vercel

Local PDF processing behaved differently after serverless deployment. We had to package the parser’s worker and native canvas dependencies correctly, align the upload limit with Vercel’s request-size ceiling, and give extraction its own bounded timeout.

Designing for failure

Provider keys may be missing, responses may contain malformed JSON, networks may be unavailable, and a model may omit a finding. We tested each failure mode and ensured CareLedger still produces a complete, usable result.

What we learned

We learned that trust in a financial or healthcare interface comes from provenance, not decoration. Every amount needs a visible path back to the uploaded document.

We also learned that AI is more useful when it is given structured roles. Having an Advocate make the strongest patient case and a Defender provide the strongest reasonable counterargument creates a more balanced result than asking one model for a single opinion.

Most importantly, failure handling is part of the product experience. A patient should never lose the entire review because one provider or network request failed.

What we are proud of

CareLedger transforms a dense medical billing packet into a clear account position, evidence-backed findings, and practical actions a patient can take next.

The application works without API keys, processes documents without storing them, keeps all arithmetic deterministic, and remains transparent about what is confirmed versus what still needs clarification.

What is next

Future versions could add OCR for scanned documents, support separate bill and EOB uploads, expand the audit packs for emergency care, surgery, and oncology, and incorporate regional billing protections.

All current demonstration data is synthetic. CareLedger is an informational prototype and does not make a HIPAA compliance claim.

Built With

Share this project:

Updates