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_duefields 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.