HomeCase studiesAutomated X12 EDI Medical Billing and Denial...

Case study · Dallas, United States

Automated X12 EDI Medical Billing and Denial Orchestration Platform

Healthcare Revenue Cycle Management

Billing teams managing multi-payer healthcare practices lose weeks chasing preventable claim rejections caused by missed modifier edits, mismatched NPI identifiers, and manual remittance posting. We built an automated medical billing and revenue cycle management platform using Python, Django, and PostgreSQL that validates encounter coding against configurable payer scrubbing rules, generates compliant X12 837 claims via Celery workers, and reconciles 835 Electronic Remittance Advice files into a double-entry financial ledger. Certified coders resolve flagged exceptions and CARC/RARC denials inside prioritized React workqueues.

Industry
Healthcare Revenue Cycle Management
Solution
A revenue cycle automation platform powered by Python, Django, and PostgreSQL handling pre-submission claim scrubbing, X12 837/835 EDI processing, double-entry ledger reconciliation, and denial routing.
Platforms
Web & API
Stack
Python · Django · PostgreSQL · Celery · Redis · React
Location
Dallas, United States · delivered remotely
Role
Engineering, with the team behind for mobile and QA

Delivered remotely for a business based in Dallas, United States. Names withheld by agreement.

Project Overview

A single missing modifier or mismatched rendering NPI inside a 500-claim batch can stall clinic reimbursements for weeks. Billing teams operating across multi-specialty medical groups in Dallas often spend more hours re-keying clearinghouse rejections and manually reconciling multi-page 835 remittance PDFs than resolving genuine coverage disputes.

We engineered an automated medical billing and revenue cycle management platform using Python, Django, and PostgreSQL. The system ingests clinical encounter charges, validates every line item against deterministic NCCI and payer-specific scrubbing rules, emits compliant X12 837P/837I claim batches via Celery workers, and reconciles incoming 277CA acknowledgments and 835 Electronic Remittance Advice (ERA) payments into an immutable double-entry ledger.

Revenue Cycle Bottlenecks

Traditional billing workflows routinely lose momentum across four handoff points:

  • Late rejection discovery: Discovering preventable coding or demographic omissions only after a clearinghouse or commercial payer bounces the claim wastes days of filing window.
  • Brittle balance tracking: Updating flat balance_due fields directly during partial payments, takebacks, and secondary crossovers creates untraceable penny discrepancies.
  • Manual ERA posting: Parsing multi-claim 835 remittance files by hand leaves contractual adjustments and CARC/RARC denial codes buried until month-end close.
  • Unprioritized denial queues: Treating every rejected claim identically lets high-value appeals expire past strict payer timely-filing cutoffs.

Architectural Strategy

The core design principle was deterministic rule evaluation paired with immutable financial accounting. Floating-point numbers never touch a dollar figure anywhere in the codebase; Python Decimal types and PostgreSQL NUMERIC(12,2) columns govern every charge, allowed amount, contractual write-off, and patient balance.

Encounters advance through an explicit state machine (Draft → Scrubbing → ReadyForBatch → Submitted → Acknowledged → Adjudicated / Denied → Closed). Every remittance posting, recoupment, or manual adjustment appends balanced debit and credit journal entries inside atomic PostgreSQL transactions, guaranteeing that reconciled ledger totals always match bank deposits.

Core Capabilities

  • Configurable Pre-Submission Scrubber: Evaluates NCCI procedure-to-procedure edits, modifier requirements (25, 59, LT/RT), ICD-10 diagnosis pointers, and payer enrollment rules before transmission.
  • Automated X12 837P/837I Generation: Builds spec-compliant EDI transaction sets with unique ISA/GS/ST control numbers, retaining exact raw payloads for dispute evidence.
  • 277CA & 835 Auto-Reconciliation: Ingests clearinghouse acknowledgments and payer ERAs automatically, matching line-level payments, deductibles, coinsurance, and contractual adjustments.
  • CARC/RARC Denial Routing: Classifies denials into actionable categories—registration errors, prior authorization gaps, medical necessity, or duplicate submissions—sorted by timely-filing urgency.
  • Secondary Crossover Billing: Automatically calculates remaining patient vs. secondary-insurer responsibility upon primary 835 adjudication and queues secondary claims with primary EOB segments.
  • Month-End Financial Close Views: Generates auditable aging buckets, payer yield summaries, and unapplied cash reports directly from immutable ledger lines.

Technical Architecture

Django REST Framework coordinates encounter intake, payer contract tables, and React coder workqueues, while Celery workers backed by Redis execute heavy batch scrubbing, X12 EDI serialization, and nightly clearinghouse SFTP polling. PostgreSQL acts as both the operational workflow store and the double-entry accounting ledger.

Flow: Encounter Charge Intake → Django Rule Scrubber (NCCI + Payer Rules) → Celery X12 837 Batch Builder → Clearinghouse SFTP → 277CA / 835 ERA Ingestion Worker → PostgreSQL Double-Entry Ledger → React Denial & Appeal Workbench

Storing raw encrypted X12 segments alongside parsed relational line items allows engineers and auditors to trace any posted adjustment straight back to the exact CLP and SVC loops delivered by a payer.

Technology Stack

Category Technology detail
Core Application Python 3.12 and Django REST Framework orchestrating claims, payer contracts, and workqueues
Financial & Claim Store PostgreSQL enforcing double-entry ledger invariants, row locks, and decimal precision
Async Pipeline Celery distributed workers executing batch scrubbing, EDI generation, and ERA ingestion
Broker & Locking Redis powering Celery queues and preventing duplicate clearinghouse batch transmissions
EDI Engine Deterministic Python X12 837P/837I builder and 277CA / 835 ERA parser with ISA/GS tracking
Billing Workbench React TypeScript dashboard for coding edits, denial appeals, and aging reconciliation
Rule Evaluation Versioned NCCI, modifier, and payer-policy scrubber rules compiled per clearinghouse
Document Archive Encrypted S3-compatible object storage retaining raw EDI envelopes and EOB attachments

Engineering Trade-offs & Solutions

Engineering Challenge Solution & Trade-off
Commercial payers enforce divergent modifier and place-of-service rules on the same CPT codes Layered base NCCI edits beneath payer-specific override rules stored as versioned JSON rule graphs in Django; increases rule-authoring discipline while avoiding hardcoded per-payer Python forks.
Large 835 ERA files containing thousands of claim lines lock database tables during posting Chunked ERA adjudication into bounded per-claim PostgreSQL transactions using SELECT ... FOR UPDATE on target claim headers rather than locking whole batch tables; preserves throughput while maintaining ledger atomicity.
Clearinghouse SFTP drops mid-upload risk duplicate claim submissions on retry Recorded deterministic batch fingerprints and control numbers prior to transmission, coupled with Redis distributed locks and idempotent re-upload checks; prevents accidental duplicate claims.
Payer recoupments (negative takebacks) break naive positive-only payment models Modeled PLB provider-level adjustments and negative CLP reversals as first-class signed ledger entries linking back to original check numbers, ensuring bank reconciliation never drifts.

Security & Financial Controls

Medical claims combine sensitive clinical diagnosis codes with patient identifiers and corporate banking flows. Access inside Django enforces strict role separation: intake specialists correct demographics, certified coders modify clinical codes and modifiers, and only finance controllers can approve manual write-off thresholds or void posted batches.

All data in transit to clearinghouses traverses SFTP with SSH key authentication and PGP payload encryption where required, while archived EDI files rest in server-side encrypted object storage. Every rule override, claim resubmission, and ledger adjustment records an immutable user and timestamp trail suitable for healthcare payer and financial audits.

Batch Processing & Reconciliation Scale

Claim generation and remittance ingestion are naturally bursty, clustering around end-of-day clinical sign-offs and overnight clearinghouse drops. Celery worker pools isolate interactive React workbench traffic from heavy batch serialization, ensuring coders experience zero sluggishness while thousands of encounters scrub in the background.

PostgreSQL partial indexes on open claim states (Submitted, Denied, Unapplied) keep daily workqueue queries instant even as multi-year adjudicated history grows. Periodic materialized summaries power aging and payer-mix analytics without scanning raw ledger rows during live operational hours.

Operational Outcomes

Moving revenue cycle workflows onto a unified Python, Django, and PostgreSQL engine brought discipline, speed, and financial clarity to billing operations:

  • Cleaner first-pass submissions: Upfront NCCI and payer-rule scrubbing catches missing modifiers and coding mismatches before claims ever leave the system.
  • Automated payment reconciliation: Nightly 835 ERA parsing matches deposits to line-level charges and contractual adjustments without tedious manual posting.
  • Focused denial recovery: Prioritized React workqueues surface high-value, appealable denials ordered by timely-filing deadlines instead of burying them in generic logs.
  • Audit-proof accounting: Double-entry PostgreSQL ledgers link every dollar billed, adjusted, recouped, and collected straight back to source EDI envelopes.

01 — Questions

asked about this kind of project

How does the claim scrubber catch payer rejections before files ever reach the clearinghouse?

Before generating an X12 837 batch, Django passes every encounter charge through a versioned Python rules engine checking NCCI bundling conflicts, ICD-10-to-CPT medical necessity pairings, missing modifiers, rendering provider NPI/taxonomy completeness, and timely-filing deadlines. Failing claims pause cleanly in a coder correction queue.

Why model billing balances as an immutable double-entry ledger in PostgreSQL instead of updating a balance column?

Healthcare adjustments constantly shift amounts across primary payers, contractual write-offs, secondary crossover claims, and patient copays. An append-only double-entry ledger preserves exact penny-level auditability, prevents concurrent ERA posting corruption, and allows controllers to reconstruct balances at any historical month-end.

How do you handle duplicate 835 Electronic Remittance Advice files or partial clearinghouse acknowledgments?

Every ingested X12 envelope hashes its ISA/GS/ST control headers and stores an idempotency fingerprint in PostgreSQL. Re-processing a duplicate 835 file is a safe no-op, while 277CA acknowledgment parsers map segment-level rejections directly back to individual claim line items.

Why choose Python and Django for X12 EDI and revenue cycle automation?

Python's `Decimal` arithmetic avoids floating-point rounding drift across thousands of claim lines, while Django's ORM, admin tooling, and Celery ecosystem make building deterministic X12 parsers, rule evaluators, and auditable financial workflows fast and maintainable.

How does the platform prioritize denials so coders focus on recoverable revenue first?

Parsed 835 Claim Adjustment Reason Codes (CARC) and Remittance Advice Remark Codes (RARC) map onto categorized denial taxonomies—such as eligibility mismatch, missing authorization, or coding bundling. Workqueues rank appealable claims by remaining timely-filing days and claim dollar value.

03 — Similar project?

describe what is different about yours

Build yours.

Tell me what exists, what you need and the deadline. Fixed price for a defined scope, or $55/day (8–9 hours work) with a written plan first.

Solitaire Corporate Park, Makarba, Ahmedabad, Gujarat 380015, India · IST (UTC+5:30) · --:-- IST · Mon–Fri 09:00–18:00 IST · US & EU overlap daily

No newsletter, no CRM. Just a reply.