Architecture Note · Security & Compliance
Clinical Documentation & Deterministic RCM Coding: Quote Grounding, Attestation Locks, and Rule-Backed Scrubbing
How verbatim quote-grounded SOAP synthesis, mandatory clinician attestation locks, SQLite NCCI/CDT rule tables, and zero-raw-PHI exports prevent claim denials without autonomous submission.
The Operational Problem: Unverified Charts and Preventable Payer Denials
Multi-site outpatient medical groups and dental service organizations lose margin on two connected fronts: clinician charting backlog and avoidable first-pass claim rejections. Across US Medicare and commercial PPOs, UK private medical insurers (AXA Health, Bupa), and Australian or Canadian dental plans, revenue teams routinely rework CO-97 bundling edits, CO-16 missing radiograph or pre-authorization attachments, CO-50 medical-necessity denials, and unlinked GP referral identifiers. Simultaneously, clinicians under-code moderate medical decision making (99213 instead of 99214) or omit restorative core buildups (D2950) and quadrant specifiers (D4341), leaving earned reimbursement unbilled.
Why Naive AI Wrappers Fail in Clinical Revenue Cycles
Dropping an encounter transcript into a generic prompt wrapper introduces three structural failures that compliance and revenue-cycle leaders cannot absorb:
- Unanchored clinical assertions: Fluent summaries routinely smooth over missing vitals, laterality, or failed conservative-therapy timelines. Without byte-exact source grounding, an auditing clinician cannot verify whether an assessment came from the patient encounter or model interpolation.
- Nondeterministic coding and modifier guesses: Language models lack reliable state over NCCI edits, CDT bundling constraints, and payer-specific referral rules. Letting a generative layer emit CPT or CDT pairs without deterministic validation misses Modifier
-25on same-day joint injections (20610), Modifier-XS/-59on diagnostic ultrasound alongside needle guidance (76881+76942), or same-day radiograph bundling (D0210+D0220). - Missing sign-off gates and raw PHI leakage: Auto-releasing unreviewed drafts or storing raw transcripts indefinitely creates regulatory exposure under HIPAA, UK GDPR / Caldicott, and Australian Privacy Principles.
The Deterministic Architecture That Fixes It
Our clinical documentation and RCM architecture pairs constrained FastAPI + SQLite (WAL mode) microservices with strict deterministic invariants and mandatory human gates:
- Source-quote-grounded SOAP synthesis (
POST /api/notes/structure): Encounter text or temporary uploads across medical and dental specialties are structured into Subjective, Objective, Assessment, and Plan bullets where every item carries a verbatimsource_quote,start_offset, andend_offsetchecked againsttranscript[start_offset:end_offset] == source_quote. Notes persist withstatus="pending_attestation",attested=False, andattestation_required=True. - SQLite rule-table validation (
POST /api/rcm/validate): Proposed ICD-10-CM, CPT, CDT, and MBS/OPCS codes are evaluated deterministically against five seeded SQLite tables:rcm_bundling_rules,rcm_modifier_rules,rcm_undercoding_rules,rcm_medical_necessity_rules, andrcm_preauth_rules. The engine flags undercoding (99213vs99214,D7210vsD7240, omittedD2950), missing modifiers (-25,-XS), missing dental quadrant specifiers, and unlinked pre-auths or radiographs before claim packet assembly. - Mandatory clinician attestation and zero auto-submission (
POST /api/claims/{id}/attest): The API hard-rejectsauto_submit=truewithHTTP 422and blocks unattested exports withHTTP 409 Conflict. Unlocking a claim packet requires a licensed clinician or certified coder’sattester_name, registrylicense_id(NPI, GMC, AHPRA, or RCDSO),reviewed_quotes=True, and a SHA-256 attestation digest written to hash-chainedaudit_logs. Any edit to SOAP text automatically invalidates prior locks. - PHI de-identification, denial QA, and 1-hour upload wipe: Before audit export (
GET /api/claims/{id}/export?format=csv), jurisdiction profiles (US HIPAA Safe Harbor, UK GDPR/Caldicott, AU APP) redact names, DOBs, MRNs, addresses, phones, emails, and member IDs while preserving clinical metrics and codes, verified for zero raw PHI and OWASP formula-safe RFC 4180 CSV formatting.GET /api/rcm/denialstracks clean-claim rate and coder QA metrics, while scoped HMAC invite tokens enforce sliding-window rate limits (HTTP 429) andwipe_expired_uploads()purges0600temporary uploads after3600seconds.
Operational Takeaway
Clinical documentation automation holds up under payer scrutiny only when every SOAP claim points to an exact transcript span, deterministic SQLite rules catch modifier and pre-authorization gaps, PHI is stripped prior to export, and no claim moves forward without an attested human signature.