A FastAPI application that processes medical documents using Large Language Models (LLMs), extracts structured data, implements Retrieval-Augmented Generation (RAG), and converts data to FHIR format.
- Document Management: Store and retrieve medical documents with SQLAlchemy
- LLM Integration: Summarize medical notes and extract patient information using OpenAI
- RAG Pipeline: Question answering system using vector embeddings and ChromaDB
- Structured Data Extraction: Extract patient data, diagnoses, medications with ICD/RxNorm codes
- FHIR Conversion: Convert structured data to FHIR-compatible format
- Containerized Deployment: Full Docker support for easy deployment
This application demonstrates a complete medical document processing pipeline:
- FastAPI Backend - RESTful API with automatic documentation
- LLM Integration - OpenAI GPT models for text processing
- RAG System - Vector-based document retrieval and question answering
- Medical Code Lookup - Integration with public health APIs (ICD-10, RxNorm)
- FHIR Compliance - Healthcare data format standardization
- Docker Containerization - Easy setup for testing
- Docker and Docker Compose
- OpenAI API key
git clone https://github.com/mjv57/medical-doc-processor.git
cd medical-doc-processorCreate a .env file in the project root:
Option 1: Using command line
cat > .env << EOF
OPENAI_API_KEY=your-openai-api-key-here
APP_ENV=production
LOG_LEVEL=info
EOF**Option 2: Manually create with below:
OPENAI_API_KEY=your-openai-api-key-here APP_ENV=production LOG_LEVEL=info
docker build -t medical-document-processor .docker-compose up -ddocker-compose logs -fOnce running, the API will be available at:
- Interactive Documentation: http://localhost:8000/docs
- Health Check: http://localhost:8000/health
curl http://localhost:8000/healthcurl -X POST "http://localhost:8000/documents/1/summarize" \
-H "Content-Type: application/json" \
-d '{"document_id": 1, "use_cache": true}'curl -X POST "http://localhost:8000/answer_question" \
-H "Content-Type: application/json" \
-d '{"text": "What was the patient blood pressure?"}'curl -X POST "http://localhost:8000/documents/1/extract_structured"curl -X POST "http://localhost:8000/documents/1/to_fhir"python test_agent.pypython test_fhir.pypython test_llm_api.pypython test_rag.pydocker-compose down -vdocker image rm medical-document-processor# View application logs
docker-compose logs -fdocker-compose logs appThe requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested.services:
app:
platform: linux/arm64 # Fix here
build: .
container_name: medical-document-processordocker-compose down -v
docker build --no-cache -t medical-document-processor .
docker-compose up -d