CLI assistant that extracts text from clinical documents and links diagnoses, medications, and treatments to standardized codes: ICD-10, RxNorm, and SNOMED CT — with confidence scores.
Built by Boyina Gowtham · AI Engineer × DevRel
Built with Strands Agents + Amazon Bedrock (Claude) + NLM terminology APIs.
- Customer sends medical charts (PDF/image/text) to the Medical document processing Agent.
- Agent calls tools:
file_read/process_documentfor intake,get_*for single-term lookup,link_*for bulk extraction with codes + confidence. - Lookups hit NLM Clinical Tables (ICD-10), NLM RxNav (RxNorm), Snowstorm (SNOMED CT-US); Bedrock is the fallback.
- Amazon Bedrock LLM (
us.anthropic.claude-sonnet-4-6) handles document extraction and structured linking; text PDFs fall back to PyPDF.
Input clinical PDF / image / free text → extract content → output structured coded entities with confidence scores:
- Diagnoses → ICD-10
- Medications (+ dosage/frequency) → RxNorm
- Treatments/procedures → SNOMED CT
- Document intake: PDF, JPG, JPEG, PNG, TIFF, BMP via
process_documenttool.- PDFs/images sent to Bedrock for OCR-style extraction; text PDFs fall back to PyPDF if Bedrock fails.
- Single-term lookup:
get_icd,get_rx,get_snomed.- ICD-10: NLM Clinical Tables API (no auth).
- RxNorm: NLM RxNav API (no auth).
- SNOMED CT: Snowstorm terminology server (US Edition). Bedrock fallback if API fails.
- Bulk linking:
link_icd,link_rx,link_snomed— extract all entities from clinical text and return JSON arrays with codes +confidence_score.
rack/
├── main.py # CLI loop + Strands Agent setup
├── document_processor.py # process_document tool (Bedrock + PyPDF fallback)
├── medical_coding_tools.py # get_*/link_* tools (NLM/Snowstorm + Bedrock fallback)
├── requirements.txt
├── .env.example
└── images/architecture.png
- Python 3.10+
- AWS account with Bedrock access in your region
- Bedrock model access for
us.anthropic.claude-sonnet-4-6(default, configurable)
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .envFill in .env:
| Variable | Required | Default / Notes |
|---|---|---|
AWS_ACCESS_KEY_ID |
yes | — |
AWS_SECRET_ACCESS_KEY |
yes | — |
AWS_REGION |
yes | us-east-1 |
BEDROCK_MODEL_ID |
no | us.anthropic.claude-sonnet-4-6 |
SNOMED_API_KEY |
no | Only if Snowstorm requires auth |
Dependencies: strands-agents, strands-agents-tools, boto3, pypdf, requests, python-dotenv, pillow, pandas.
python main.pyOptions:
- Process a document — provide path to PDF or image.
- Process a clinical note — paste multi-line text (blank line to submit).
- Process a sample note — runs built-in example:
Carlie had a seizure 2 weeks ago. She is complaining of frequent headaches Nausea is also present. She also complains of eye trouble with blurry vision Meds : Topamax 50 mgs at breakfast daily, Send referral order to neurologist Follow-up as scheduled - Exit — prints accumulated usage metrics on exit.
Diagnosis:
[{"diagnosis": "Atrial fibrillation", "ICD10_code": "I48.0", "description": "Paroxysmal atrial fibrillation", "confidence_score": "95%"}]Medication:
[{"medication": "Topamax", "RxNorm_code": "36926", "description": "Topiramate 50 MG Oral Tablet", "dosage": "50 mg", "frequency": "daily", "confidence_score": "95%"}]Procedure:
[{"procedure": "Referral to neurologist", "SNOMED_code": "306206005", "description": "Referral to neurology service", "confidence_score": "95%"}]| Input | Handling |
|---|---|
| Text PDF | PyPDF fast path if Bedrock unavailable and text layer > 50 chars |
| Scanned/image PDF | Bedrock only; errors if Bedrock unreachable |
| JPG/JPEG/PNG/TIFF/BMP | Bedrock only |
| Other extensions | Returns {"error": "Unsupported file format"} |
| Missing file | Returns {"error": "File not found: ..."} |
NLM APIs need internet; all coding tools fall back to Bedrock on API failure and return confidence_score: "0%" with an error field on total failure.
Assistive tooling only — not medical advice. Always verify codes with qualified clinical/coding staff before use in care, billing, or records. You are responsible for PHI handling and HIPAA/GDPR compliance when sending documents to AWS Bedrock or terminology APIs.
File not found— check path passed to option 1; CLI also validates withos.path.existsbefore calling the agent.- Bedrock
AccessDenied— enable model access in Bedrock console and checkAWS_REGION/BEDROCK_MODEL_ID. - Empty SNOMED/RxNorm results — API returned no match (
"Not found",0%); retry with generic term or rely on Bedrock fallback.
Boyina Gowtham — AI Engineer × DevRel · GitHub · LinkedIn · Medium
