How nenncy/dischargesimplify works
Project Type and Purpose
• Full-stack AI-powered service:
– A FastAPI backend exposing three main endpoints (simplify, validate, assistant chat)
– A (future) Streamlit or similar frontend for clinician/patient interaction
• Purpose: Simplify complex medical discharge instructions via LLMs, validate them, and provide an interactive assistant chat.
File Structure
• Top-level:
– backend/
· main.py (FastAPI app entry)
· LLM_simplify.py (LLM invocation logic)
· patient_chat.py (assistant-chat logic)
– frontend/
· app.py (Streamlit or lightweight UI)
– requirements.txt, README.md
• No dedicated database directory yet (SQL planned), but FAISS indexing is part of the retrieval layer.
README for Insights
• Three API endpoints: /simplify, /validate, /assistant/chat
• LLM interface via Huggingface Transformers or OpenAI API
• Validation layer uses FAISS for semantic chunking/search
• Outputs structured JSON for EHR systems
Main Components
A. User Interface (Frontend)
– Clinician/Patient UI (Streamlit/app.py)
– Sends requests to backend endpoints
B. API Gateway / Backend (FastAPI)
– Endpoint: POST /simplify
· Orchestrates LLM_simplify module
– Endpoint: POST /validate
· Triggers validation pipeline (chunking → FAISS index → rule checks)
– Endpoint: POST /assistant/chat
· Routes to patient_chat module for interactive Q&A
C. LLM Layer
– Huggingface Transformers or OpenAI API (external service)
– Local or cloud model
D. Validation & Retrieval Layer
– Text chunker → FAISS semantic index
– Verification rules (medications, follow-ups, safety filters)
E. Data Store (future)
– SQL database for logs, audit, user/session data
F. External Integrations
– EHR systems (JSON output)
– Clinical oversight dashboards (future)
Relationships & Interactions
• Frontend → FastAPI:
– Simplify request → /simplify
– Validate request → /validate
– Chat interactions → /assistant/chat
• FastAPI → LLM:
– HTTP or SDK calls to model service
• FastAPI → FAISS:
– Build/query index in-memory or persistent store
• FastAPI → (future) SQL DB:
– Persist requests, logs, user data
• FastAPI → EHR:
– Push structured JSON output
• Patient ↔ Assistant Chat:
– Stateful session managed by patient_chat.py
Architectural Patterns & Principles
• Separation of concerns
– API layer vs. AI/validation logic vs. UI
• Modular services
– LLM_simplify.py & patient_chat.py as independent modules
• Extensibility points
– Swap in/out different LLM providers (configurable in code)
– Plug in FHIR-compliant output module in future