Agentic Medical Coding AI

A portfolio-ready, human-in-the-loop AI workflow that converts synthetic clinical documentation into evidence-linked ICD-10-CM coding suggestions. Specialized agents extract documentation, retrieve candidates, validate specificity, enforce safety policy, create a tamper-evident audit trail, and produce an HL7 FHIR R4 Task for coder review.
Educational decision-support prototype only. It is not a production encoder, does not replace a qualified coding professional, and must not be used to submit claims.
Why this project belongs in this portfolio
This is Project 8 in the healthcare data and AI roadmap. It combines capabilities demonstrated across earlier projects:
| Prior project |
Capability reused here |
| FHIR Healthcare Analytics |
FHIR R4 ingestion and clinical resource parsing |
| ICD-10 Medical Coding Analytics |
ICD-10-CM terminology and mapping logic |
| HL7 v2 ADT Pipeline |
Healthcare interoperability workflow thinking |
| X12 EDI Claims Pipeline |
Revenue-cycle context and downstream claim awareness |
| HIPAA Compliance Pipeline |
Auditability, least privilege, and privacy-aware design |
| Clinical LLM RAG Pipeline |
Grounded retrieval and evidence-linked output |
| Sepsis Early Warning LLM |
Safety gating, clinical workflow integration, and escalation |
System architecture
flowchart TD
A["Synthetic note or FHIR R4 Bundle"] --> B["Evidence Agent"]
B --> C["Candidate Retrieval Agent"]
C --> D["Validation and Specificity Agent"]
D --> E{"Evidence sufficient?"}
E -- Yes --> F["Compliance Agent"]
E -- No --> G["Abstain or ask clarification"]
F --> H["Human coder review"]
H --> I["FHIR R4 Task and audit event"]
Agent responsibilities
| Agent |
Responsibility |
Safety control |
| Evidence Agent |
Finds diagnosis concepts and assertion status |
Excludes negated and historical findings |
| Candidate Agent |
Retrieves ICD-10-CM candidates from a terminology catalog |
Returns candidates, never final codes |
| Validation Agent |
Checks evidence and missing specificity |
Reduces confidence and asks focused questions |
| Compliance Agent |
Applies workflow policy |
Requires human review or abstains |
| Orchestrator |
Preserves state and trace across agents |
Produces a reviewable decision trail |
Key features
- Deterministic baseline that runs locally without an API key
- Present, negated, and historical condition handling
- Evidence spans attached to every coding suggestion
- Confidence and documentation-specificity checks
- Explicit abstention for unsupported or low-evidence cases
- Mandatory human review before any downstream use
- FHIR R4 Bundle input and
Task proposal output
- Hash-chained JSONL audit events
- FastAPI endpoints, CLI, evaluation harness, and unit tests
- Replaceable terminology and LLM interfaces for future experiments
Repository structure
agentic-medical-coding-ai/
├── data/
│ ├── demo_cases.json
│ └── icd10_demo_catalog.json
├── docs/
│ ├── architecture.md
│ ├── evaluation.md
│ └── model_card.md
├── output/
├── src/medical_coding_ai/
│ ├── agents.py
│ ├── api.py
│ ├── audit.py
│ ├── cli.py
│ ├── evaluation.py
│ ├── fhir.py
│ ├── models.py
│ ├── orchestrator.py
│ └── terminology.py
├── tests/
├── pyproject.toml
└── requirements.txt
Quick start
git clone https://github.com/nipa-analytics/agentic-medical-coding-ai.git
cd agentic-medical-coding-ai
python -m venv .venv
# Windows: .venv\Scripts\activate
# macOS/Linux: source .venv/bin/activate
pip install -e ".[dev]"
pytest -q
Run one note:
medical-coding-ai --note "Assessment: essential hypertension. No diabetes."
Run the evaluation set:
medical-coding-ai --evaluate data/demo_cases.json
Start the API:
uvicorn medical_coding_ai.api:app --reload
Then open http://127.0.0.1:8000/docs.
API example
curl -X POST http://127.0.0.1:8000/v1/suggest \
-H "Content-Type: application/json" \
-d '{"case_id":"demo-1","note":"Essential hypertension. No diabetes."}'
The response includes the suggested code, supporting evidence offsets, confidence, disposition, clarification questions, and the full agent trace.
FHIR workflow
POST /v1/fhir/suggest accepts a small FHIR R4 Bundle containing Patient, Condition, or DocumentReference resources. The endpoint returns a FHIR R4 Task with:
intent = proposal
status = requested
businessStatus = Human review required
- ICD-10-CM suggestions in
Task.output
This deliberately keeps an AI suggestion separate from an adjudication-ready claim.
Evaluation strategy
The included synthetic set is a smoke test, not clinical validation. It measures exact-match precision, recall, F1, review rate, negation behavior, abstention, and FHIR serialization. A credible next phase should use dual-coded synthetic or appropriately governed de-identified notes, adjudicated disagreements, subgroup analysis, calibration, code-set version checks, and prospective silent-mode validation.
Terminology limitation
data/icd10_demo_catalog.json contains only a tiny illustrative subset. A production design must use the applicable official ICD-10-CM release, official guidelines, payer policy, and a governed terminology service. Never infer that the demo catalog represents complete or current billable-code coverage.
Responsible AI safeguards
- Synthetic data only in the repository
- No autonomous claim submission
- Human review required on supported suggestions
- Abstention when evidence is insufficient
- Negation/history awareness
- Evidence provenance and audit events
- No upcoding or reimbursement optimization objective
- Version, drift, security, and bias checks required before real-world use
Standards and authoritative references
Suggested roadmap
- Connect the official release-specific ICD-10-CM files.
- Add embeddings or BM25 for candidate retrieval.
- Add an optional structured-output clinical LLM behind the deterministic baseline.
- Expand negation, temporality, laterality, acuity, and encounter logic.
- Add CPT/HCPCS only after licensing and scope review.
- Build a Streamlit coder workbench with accept, reject, edit, and reason capture.
- Run blinded evaluation against an adjudicated synthetic benchmark.
- Add role-based access, prompt-injection tests, monitoring, and CI.
Author
Nipa Shah
Healthcare AI | Clinical NLP | Responsible AI | Interoperability
GitHub Portfolio
评论