Course Project - Digital Healthcare Informatics Illinois Institute of Technology | Mar 2025 - Apr 2025
A clinical NLP web application that translates complex hospital discharge instructions into patient-friendly summaries at a 6th-grade reading level, with FHIR Composition output for EHR integration and a multilingual translation layer supporting the full language catalog via pycountry.
This was a team project. My scope covered:
-
Prompt Engineering: Engineered the 8-category structured prompt in
prompt_engineer.pyenforcing deterministic GPT-4o output at temperature=0.0 into a strict JSON schema with keys: Summary, Instructions, Importance, FollowUpTasks, Medications (ToTake/ToAvoid), Precautions, References, Disclaimer. All JSON keys enforced in English regardless of output language. Every section required non-empty content with explicit constraints on bullet length and deduplication logic. -
FAISS-Backed RAG Validation Layer: Built
validation_layer.pyusing SentenceTransformer (all-MiniLM-L6-v2) embeddings and IndexFlatL2 similarity search to retrieve top-3 relevant source chunks per bullet, with a strict per-bullet LLM validation pass that accepts or rejects each simplified statement against the original discharge text without rephrasing it. -
FHIR Composition Conversion: Built
fhirconvertion.pyusingfhir.resourcesto convert simplified JSON output into a LOINC-coded (11502-2) FHIR Composition resource with structured sections for Summary, Instructions, Importance, FollowUpTasks, Medications, Precautions, References, and Disclaimer - triggered automatically post-simplification for EHR integration. -
Hybrid Translation System: Engineered two dedicated translation functions in
language.py:t()for static UI elements with (text, language) session-state cache keys, andat()for bidirectional chatbot translation with (text, source, target) cache keys - both calling GPT-4o with a literal translation prompt. Language enumeration handled via pycountry across the full language selector. -
Chatbot Translation Layer: Engineered the bilingual translation integration within the assistant chat flow using
at()inlanguage.py- a bidirectional GPT-4o translation function with (text, source, target) session-state cache keys that translates both user queries and assistant responses while preserving the original simplified content integrity.
| Method | Endpoint | Purpose |
|---|---|---|
| POST | /simplify |
Simplify discharge instructions into 8-category JSON |
| POST | /validate |
LLM-based validation of simplified output against original |
| POST | /to_fhir |
Convert simplified JSON to FHIR Composition resource |
| POST | /assistant/chat |
Source-grounded chatbot from simplified instructions |
| POST | /upload |
Upload discharge document and extract raw text |
| GET | /health |
Health check |
├── backend/
│ ├── app.py # FastAPI app - all endpoints
│ ├── prompt_engineer.py # GPT-4o prompt + simplify/validate logic
│ ├── validation_layer.py # FAISS RAG validation layer
│ ├── fhirconvertion.py # FHIR Composition builder
│ ├── language.py # t() and at() translation functions
│ ├── models.py # Pydantic + SQLAlchemy data models
│ ├── db.py # Database session management
│ ├── utils.py # File extraction and JSON parsing utilities
│ ├── create_assistant.py # OpenAI Assistant configuration
│ └── requirements.txt
├── frontend/
│ ├── app.py # Streamlit frontend
│ ├── language.py # Translation and language selector
│ └── requirements.txt
└── README.md
- Backend: FastAPI, Uvicorn, SQLAlchemy
- AI: GPT-4o (OpenAI), OpenAI Assistants API
- NLP: SentenceTransformers (all-MiniLM-L6-v2), FAISS IndexFlatL2
- Healthcare: fhir.resources, LOINC 11502-2
- Frontend: Streamlit
- Other: pycountry, pdfminer.six, ratelimit, python-dotenv
git clone https://github.com/Hamju1999/DischargeSimplify.git
cd DischargeSimplify
pip install -r backend/requirements.txtCreate .env:
OPENAI_API_KEY=your-api-key
ASSISTANT_ID=your-assistant-id
Run:
uvicorn backend.app:app --reloadMohammad Hamza Piracha | Data Scientist & Applied AI Engineer | LinkedIn | hamzapiracha@live.com