A grounded agent pipeline with a trained coding model and a transparent evaluation of what is and is not measured.
Aravind Kannappan · Synthure · aravinds.kannappan@gmail.com
↓ Download PDFThe note generator is trained on real open license notes (MTSamples: 1,952 usable notes, MedSecId sections (optional), PMC Open Access); labels come from a source independent of the generator, so a model must learn text to label rather than memorize a template. Every headline number is reported on the frozen real-note test split, never trained on.
Real test accuracy populates here after the Colab data engine run writes it to data/model_evals.json. It is reported separately from the synthetic val split on purpose: a number well below the old 1.00 is the honest signal that the model learned clinical language, not a template grammar.
Only measured results are shown as numbers. Components that are not yet benchmarked are marked Heuristic or Planned and detailed in the evaluation plan.
Synthure is a multi agent clinical AI demonstrator that turns one clinical note into four interconnected stakeholder portals, one each for the patient, the physician, the hospital revenue cycle team, and the employer benefits team. The four portals share a single mutable encounter, so an action in one portal (approving a prior authorization, toggling a code, applying for financial assistance, submitting a claim) ripples through the others in real time and recomputes the shared risk, cost, and reimbursement figures.
A note is processed by a pipeline with no fallback path. De identification and biomedical NER run as OpenMed models (Apache 2.0) exported to int8 ONNX and executed in the browser, so the raw note never leaves the device and every entity carries a real model confidence. Diagnosis entities are linked to ICD 10 CM through the official CDC/NCHS alphabetic index: candidates are retrieved from the index and a Claude call may only choose among them or abstain, so a code outside the official index cannot be produced. Literal codes written in the note are validated against the CMS tabular and fee schedules. Four grounded writer agents, a verifier, a constitution critic, and a revision pass then produce and audit the reports.
This version removes the previous risk heuristics entirely and replaces every number with something traceable. Three claims are backed by data. (1) NER: Claude based NER recovers the correct ICD 10 category in 60.4% of cases and the exact code in 23.5% (N = 149), against 0.0% for the deterministic regex extractor on the same prose. (2) Readmission: the readmission figure is the real CMS HRRP published 30 day rate for the encounter's dominant condition, not an invented score. (3) Coding: a trained bi encoder retriever plus cross encoder reranker links a diagnosis mention to its ICD 10 CM code, ranking the exact code first 41 percent of the time on CodiEsp gold mentions (top five 49 percent, MRR 0.44, N = 3,615). For denial we deliberately make no prediction: there is no public claim adjudication dataset, and the one labeled proxy we tested (DataFog complexity_score) turned out to be an inverse length artifact, so we removed the fabricated denial probability and show only sourced prior authorization and claim validity facts. Generation is grounded in the extracted facts, every code is format validated, and a code enforced three tier autonomy model keeps clinical decisions with the physician.
The United States healthcare system allocates a large fraction of clinical capacity to administrative rather than patient facing work. Physicians spend a substantial share of their time on prior authorization, claims submission, denial management, and documentation, a pattern associated with high rates of clinician burnout and with hundreds of billions of dollars in estimated annual administrative waste [1, 2].
The root cause is structural fragmentation. Each of the four principal stakeholders in a patient's care trajectory, the patient, their physician, the hospital, and the employer or insurer, operates within a separate software ecosystem with no shared intelligence layer. A single clinical note simultaneously generates downstream work across all four: the patient needs plain language explanations and cost estimates; the physician needs authorizations filed and claims submitted; the hospital revenue cycle team needs claim tracking and denial management; the employer needs aggregated, anonymized utilization against benefit plans.
Synthure explores a different shape for this problem: a single grounded pipeline that produces four role specific portals from one note, connected by one shared encounter, so that the same facts and the same actions are reflected everywhere at once. The contribution of this report is the architecture and a reproducible evaluation of the parts that are currently testable, together with a plan to evaluate the rest.
Synthure is organized as a pipeline of specialized agents that feed four interconnected portals.
The novel element is the shared encounter. In the shipped demo this is a single mutable state object that every portal reads from and writes to. Approving a prior authorization in the clinician console clears the largest review item, advances the claim, and flips the patient view to covered; toggling a code or removing a procedure recomputes the patient cost, the expected reimbursement, and the employer cohort. Every action emits a cross portal event, and the portals carry an inbox so any one can message any other. We verified this propagation with a headless reducer test covering the prior authorization, code edit, financial assistance, claim submission, and messaging flows.
The shipped demo runs entirely in Next.js route handlers with the shared encounter held client side. The production design, where the encounter becomes a server authoritative, event sourced aggregate broadcast over web sockets for multi user, cross device synchronization, is described as future work in the evaluation plan.
Every clinical note traverses the pipeline below. Each stage appends a trace step with its name, model, and duration.
Stage 1, Quality gate: all extracted ICD 10 and CPT codes are validated against compiled patterns. A bare five digit number is accepted as a CPT code only when it is a known code or the surrounding text marks it as one, which prevents stray numbers from being billed.
Stage 2, De identification and biomedical NER, on device: OpenMed PII ClinicalE5 Small 33M scrubs identifiers in the browser before anything is transmitted, then OpenMed DiseaseDetect and PharmaDetect TinyMed 65M extract diagnosis and drug entities with per entity softmax confidences. Symptom and lab spans are tagged by a Claude call whose outputs are accepted only if they appear verbatim in the note. Medication entities are accepted only if they match the RxNorm prescribable vocabulary.
Stage 3, Code linking: for each diagnosis entity, a trained bi encoder retriever embeds the mention and every code in the FY2026 ICD 10 CM index (98,186 codes) into one space and returns the nearest candidates, then a cross encoder reranker fine tuned on CodiEsp scores them and the top codes are kept. Candidates are constrained to the index, so a code outside it cannot be produced, and every accepted code is validated against the CMS tabular with its billable flag. The retriever and reranker run as a small service (a Hugging Face Space); the lexical index lookup remains as an in process fallback. Official descriptions come from the order file; consumer language comes from MedlinePlus Connect where available, with its source labeled.
Stage 4, Risk and readiness: there are no hand tuned risk heuristics in this version. Readmission is a lookup of the real CMS HRRP published 30 day rate for the encounter's dominant condition. Claim readiness is a deterministic scrub whose every input is a sourced fact: prior authorization required under a published payer list, a claim validity issue (for example a procedure billed with no supporting diagnosis), or an administrative flag stated in the note. We show no denial probability, because no public claim outcome data exists to train one, and we say so in the product.
Stage 5, Generation, verification, orchestration: four writer agents (Claude Haiku) produce role specific reports using forced tool_use schemas, grounded strictly in the extracted facts. A verifier and an orchestrator (Claude Sonnet) audit each statement against the facts and connect the four reports. All product copy is sanitized to contain no hyphens or dashes.
We report only results we actually ran and can reproduce. Note: the NER and retrieval numbers below were measured on the previous pipeline (Claude tool_use extraction versus a regex baseline). The shipped pipeline now extracts with OpenMed models on device and links codes through the official ICD 10 CM index with constrained choice; re running this benchmark against the new pipeline is the first item of ongoing work.
NER, diagnosis to ICD 10. We evaluate the NER stage on the public dataset Inje/SYMPTOMS-COT-ICD10-2024, where each item has a gold ICD 10 code. For each item we construct a short note from its symptom list and stated diagnosis, run the extractor, and check whether it recovers the gold code. On N = 149 English items:
The headline finding is the gap: the deterministic extractor recovers no diagnoses from prose, because prose contains no literal codes, while the Claude NER path recovers the correct ICD 10 chapter most of the time. This is the measured justification for the NER stage.
Retrieval, symptom text to ICD 10 category. We train a TF IDF retriever on real symptom text and test it against a BM25 baseline on the same data. The data is split deterministically into a fit set, a validation slice, and a disjoint held out test set (N = 781). The trained model is a hybrid of a word TF IDF centroid, a character 3 to 4 gram TF IDF centroid, and BM25, with the three blend weights chosen only on the validation slice. On the held out test set the hybrid edges the BM25 baseline: MRR 0.340 versus 0.330, recall at 1 25.1% versus 24.2%, recall at 5 44.2% versus 43.5%. The gain is real but small, which quantifies that lexical methods plateau here. The dense retriever that replaced this path (Section 5) is the improvement, now built and deployed. The lexical trainer is pure standard library Python and runs offline; the artifact lives at eval/models/icd_model.json.
Readmission, calibration to CMS HRRP. The readmission figure is the published national 30 day risk standardized readmission rate for the encounter's dominant condition (for example heart failure 21.7%, COPD 19.6%, AMI 15.6%, pneumonia 16.9%), with the national all cause rate of 15.3% as the baseline for conditions outside the HRRP cohorts. To test whether these rates are recoverable from code level features rather than memorized, we ran a leave one condition out chapter regression: it scored a mean absolute error of 5.27 percentage points against a 4.29 point mean baseline (N = 10 conditions). Because chapter features do not beat the mean, we do not extrapolate; we calibrate to the published rates directly and label them as such.
Denial, not modeled. There is no public dataset of real claim adjudication outcomes (paid versus denied); that data is PHI protected. The one labeled proxy we could obtain, the DataFog complexity_score, correlates about -0.62 with note length, so it is essentially an inverse length artifact and a model trained on it learns nothing about denials (a logistic regression reached a meaningless AUC of 1.0 by reconstructing length). We therefore removed the denial heuristic and display no denial probability at all.
Caveats. The NER N is 149 and the dataset is idealized; the CodiEsp coder numbers are on Spanish origin cases translated to English; the readmission benchmark has only 10 conditions. Per stage latency profiling on the deployed pipeline is future work.
What changed in this version. The hand tuned denial and readmission heuristics were removed. Readmission is now calibrated to real CMS HRRP rates; claim readiness is a sourced, auditable scrub; a trained retriever now has a measured number against BM25; and the fabricated denial probability is gone.
What is still honestly open, with the concrete method for each.
Synthure is not just a chain of agents. After the writers run, an alignment layer applies inference time safety mechanisms drawn from the safety literature. We are precise about what this is: we do not train a reward model (that needs preference data and compute we do not have). The writer agents run on Claude, which Anthropic aligned with RLHF, and on top of that we add the inference time techniques below, each cited to the work that introduced it.
A clinical constitution (Constitutional AI, Bai et al. 2022). Every report is checked against six explicit principles: no fabricated codes, no agent issued prescribing or diagnosing, cost figures labeled as estimates, no identifying information in aggregate views, abstention under low confidence, and risk numbers that come from data or are not shown. A Constitution Critic agent (Claude Sonnet when a key is present, deterministic rule checks otherwise) audits each report and a revise step removes violations.
An autonomy gate. Each action is routed to one of three tiers: fully automated (draft a prior authorization, prepare an appeal, generate patient education), single human approval (file the authorization, submit the claim, message the patient), or prohibited (prescribe, diagnose, change treatment). The third tier is a design prohibition, not a setting; those actions are never generated. This is the corrigibility and scalable oversight idea made concrete.
Selective prediction (Geifman and El-Yaniv 2017). When extraction confidence falls below 0.60, or no codes are confidently extracted, the system abstains and escalates to a human coder rather than auto routing.
Red team result. We applied the red teaming method of Ganguli et al. 2022 to these safeguards: adversarial cases that try to make the agent bill a fabricated code, prescribe, diagnose, quote an unqualified cost, or leak identifying information into an aggregate view. The deterministic checks catch 7 of 7 injected violations with 0 false positives on the clean cases (eval/safety_eval.py). The set is small and handcrafted, so this is evidence the safeguards fire as intended, not a guarantee of completeness.
Every measured number above comes from public data and a committed, pure standard library script, so it can be re run offline.
Reproduce it: python3 eval/train_risk.py retrains the retriever and the readmission calibration and rewrites eval/results.json; python3 eval/retrieval_bm25.py runs the lexical baseline; python3 eval/safety_eval.py red teams the alignment layer; the NER benchmark constructs a note from each item, runs the extractor, and compares returned codes to the gold code at the category and exact levels.
Synthure shows that a single grounded agent pipeline can drive four interconnected stakeholder portals from one clinical note, with actions in any portal rippling through the others in real time, on openly available model APIs and serverless infrastructure.
The evaluation is narrow but real, and every shipped number is traceable: a trained bi encoder plus cross encoder coder ranks the exact ICD 10 CM code first 41 percent of the time on CodiEsp gold mentions; the readmission figure is the real CMS HRRP published rate; the denial heuristic was removed rather than dressed up; and an inference time alignment layer (a clinical constitution, an autonomy gate, and selective prediction) sits between the agents and the portals, catching every injected violation in a small red team set. Every number here is tied to public data and a reproducible script.
Bai et al. 2022, Constitutional AI: Harmlessness from AI Feedback. Ouyang et al. 2022, Training language models to follow instructions with human feedback (InstructGPT, RLHF). Christiano et al. 2017, Deep reinforcement learning from human preferences. Irving et al. 2018, AI Safety via Debate. Ganguli et al. 2022, Red Teaming Language Models to Reduce Harms. Lightman et al. 2023, Let's Verify Step by Step. Glaese et al. 2022, Improving alignment of dialogue agents via targeted human judgements (Sparrow). Geifman and El-Yaniv 2017, Selective Classification for Deep Neural Networks. Dhuliawala et al. 2023, Chain of Verification Reduces Hallucination in Large Language Models.