A Gradio web application that extracts medical named entities from 1,000 clinical notes, maps them to standard medical codes, renders an interactive dashboard, and provides a chatbot to query the results — all running locally with no external API keys required.
Dataset: ncbi/Open-Patients
Select number of records to Analyze

| Step | Description |
|---|---|
| 1 | Loads 1,000 records from ncbi/Open-Patients (HuggingFace) |
| 2 | Extracts conditions, symptoms, medications, and procedures via keyword NER |
| 3 | Looks up the top 10 of each category against free NLM APIs: ICD-10-CM, RxNorm, CPT, and SNOMED-CT |
| 4 | Renders an interactive Plotly dashboard (bar charts + code tables, dark theme) |
| 5 | Provides a chatbot (Ollama) to ask questions about the extracted data |
- Python 3.10+
- Ollama running locally
| Display name | Ollama ID | Pull command |
|---|---|---|
| Llama 3.2 | llama3.2 |
ollama pull llama3.2 |
| GPT OSS 20B | gpt-oss:20b |
ollama pull gpt-oss:20b |
| Gemma 3 1B | gemma3:1b |
ollama pull gemma3:1b |
Pull at least one model before starting:
ollama pull llama3.2 # recommended default (~2 GB)gradio>=4.0.0
ollama>=0.1.7
pandas>=2.0.0
plotly>=5.18.0
datasets>=2.14.0
requests
tqdm
Install all at once:
pip install -r requirements.txt# 1. Clone and enter the repo
git clone <repo-url>
cd chatbot_healthcare
# 2. Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Make sure Ollama is running with llama3.2
ollama serve # or open the Ollama desktop app
ollama pull llama3.2
# 5. Launch the app
./launch.sh # or: python gradio_simple.pyOpen http://localhost:7860 in your browser.
| Tab | What to do |
|---|---|
| Data Analysis | Click "Load & Analyze Data" to run NER and see a text summary |
| Chat with Bot | Ask questions about the data (e.g. "What are the most common conditions?") |
| Dataset | Check available records; clear the NER cache to force a re-run |
| NER Dashboard | Adjust the record slider, click "Run NER Dashboard" for the Plotly chart |
| Export | Download results as CSV files |
OLLAMA_MODEL=mistral ./launch.sh
lsof -ti:7860 | xargs kill -9 2>/dev/null python gradio_simple.py
python Medicalnerdashboard.py
Results are cached at cache/ner_hf_biomedical.pkl after the first run (~1 min for 1,000 records). Subsequent runs load instantly. Use the Dataset tab or delete the file to force a fresh run.
gradio_simple.py <- Gradio UI (all tabs, event wiring)
medical_ner_dashboard.py <- Core pipeline library
load_texts() <- HuggingFace datasets loader
run_ner() <- d4data/biomedical-ner-all transformer NER
lookup_all_codes() <- NLM ICD-10-CM / RxNorm / CPT / SNOMED APIs
build_dataframes() <- pandas DataFrames per category
build_figure() <- Plotly 4x2 subplot dashboard
_build_context() <- text summary fed to chatbot
launch.sh <- startup script (checks Ollama, kills port 7860)
requirements.txt <- all Python dependencies
| Code system | Used for | API |
|---|---|---|
| ICD-10-CM | Conditions, symptoms | NLM Clinical Tables |
| RxNorm | Medications | NIH RxNav |
| CPT | Procedures (curated map) | Built-in lookup table |
| SNOMED-CT | Procedures (fallback) | NLM Clinical Tables |
| File | Purpose |
|---|---|
medical_ner_dashboard.py |
Core NER + code-lookup pipeline |
gradio_simple.py |
Full Gradio web UI |
launch.sh |
One-command launcher |
requirements.txt |
Reproducible environment |
- Loads 1,000 records from
ncbi/Open-Patients - Extracts conditions, symptoms, medications, procedures
- Top 10 per category with ICD-10-CM / RxNorm / CPT / SNOMED-CT codes
- Interactive dashboard (Plotly bar charts + code tables)
- Chatbot grounded on extracted data (Ollama, no API key needed)
- Fully local — no external API keys required



