๐ Try it live: https://rxaccess-ai.streamlit.app
RxAccess AI is a production-grade healthcare AI prototype that demonstrates end-to-end capabilities for prescription management, patient access, prior authorization, affordability insights, and adherence intelligence. This platform closely mirrors real-world challenges solved by health-tech companies like PHIL.
This platform addresses key healthcare challenges:
- Prescription Access: Intelligent OCR and extraction from images/PDFs
- Prior Authorization: Automated PA form generation, status tracking, and approval prediction
- Affordability: Insurance coverage estimation and patient assistance program recommendations
- Adherence Intelligence: ML-powered risk prediction and personalized interventions
- Multi-Stakeholder Support: Dashboards for patients, providers, pharmacies, and pharma companies
graph TB
A[User Upload] --> B[OCR Engine]
B --> C[LLM Extraction & Structuring]
C --> D[Structured Prescription Data]
D --> E[RAG Medical Assistant]
D --> F[PA Assistant]
D --> G[Affordability Engine]
D --> H[Adherence Predictor]
E --> I[ChromaDB Vector Store]
F --> J[PA Form Generator]
G --> K[Coverage Estimator]
H --> L[ML Model XGBoost]
I --> M[Patient Dashboard]
J --> M
K --> M
L --> M
M --> N[Provider View]
M --> O[Pharma Insights]
style A fill:#e1f5ff
style M fill:#fff4e1
style L fill:#ffe1f5
- Upload prescription images (JPG, PNG) or PDFs
- OCR using Tesseract with LLM-powered correction
- Extract: medicine name, dosage, frequency, duration, doctor info, patient details
- Structured JSON output with confidence scores
- Ask questions about uploaded prescriptions
- Knowledge base with drug information, interactions, side effects
- ChromaDB vector store for semantic search
- Context-aware responses using LangChain
- Automated PA form generation
- Required documentation checklist
- Approval likelihood prediction
- Status tracking (Pending โ Under Review โ Approved/Denied)
- Missing information alerts
- Insurance coverage estimation
- Copay calculator
- Patient assistance program recommendations
- Cash-pay vs insurance comparison
- Generic alternatives suggestions
- XGBoost ML model for adherence risk scoring
- Features: age, medication class, regimen complexity, past adherence
- Personalized intervention generation
- Reminder scheduling with motivational messaging
- Patient View: Prescription details, Q&A, adherence score, reminders
- Provider/Pharmacy View: Extracted data, PA status, patient insights
- Pharma Insights: Aggregated metrics, adherence rates, PA success rates
| Component | Technology |
|---|---|
| Backend | Python 3.10+, FastAPI |
| Frontend | Streamlit |
| LLM Framework | LangChain |
| LLM Provider | Ollama (local) / Groq / OpenAI |
| Vector Store | ChromaDB |
| OCR | Tesseract + LLM correction |
| ML | scikit-learn, XGBoost |
| Deployment | Docker, AWS-ready |
- Python 3.10+
- Docker (optional)
- Tesseract OCR
- Clone the repository
git clone <repository-url>
cd rxaccess-ai- Install Tesseract OCR
Windows:
# Download from: https://github.com/UB-Mannheim/tesseract/wiki
# Add to PATHmacOS:
brew install tesseractLinux:
sudo apt-get install tesseract-ocr- Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Set up environment variables
cp .env.example .env
# Edit .env with your API keys- Initialize the system
python scripts/init_system.pydocker build -t rxaccess-ai .
docker run -p 8501:8501 -p 8000:8000 rxaccess-aistreamlit run streamlit_app/app.pyAccess at: http://localhost:8501
-
Upload Prescription
- Navigate to "๐ Upload Prescription" tab
- Upload image or PDF
- View extracted structured data
-
Ask Questions
- Go to "๐ฌ Medical Assistant" tab
- Ask about side effects, interactions, dosage instructions
- Get AI-powered responses with sources
-
Check Prior Authorization
- Visit "๐ Prior Authorization" tab
- Review PA form summary
- Check approval likelihood
- Track submission status
-
Explore Affordability
- Open "๐ฐ Affordability" tab
- View insurance coverage estimate
- Compare cash-pay options
- Find patient assistance programs
-
View Adherence Insights
- Check "๐ Adherence Intelligence" tab
- See risk score prediction
- Review personalized interventions
- Set up reminders
-
Multi-Stakeholder Views
- Switch between Patient, Provider, and Pharma dashboards
- Explore role-specific insights
rxaccess-ai/
โโโ streamlit_app/
โ โโโ app.py # Main Streamlit application
โ โโโ pages/
โ โ โโโ 1_upload.py # Prescription upload
โ โ โโโ 2_assistant.py # RAG medical assistant
โ โ โโโ 3_prior_auth.py # PA assistant
โ โ โโโ 4_affordability.py # Affordability engine
โ โ โโโ 5_adherence.py # Adherence intelligence
โ โ โโโ 6_dashboards.py # Multi-stakeholder views
โ โโโ components/
โ โโโ sidebar.py # Shared sidebar
โ โโโ utils.py # UI utilities
โโโ src/
โ โโโ extraction/
โ โ โโโ ocr_engine.py # Tesseract OCR
โ โ โโโ llm_extractor.py # LLM-based extraction
โ โโโ rag/
โ โ โโโ vector_store.py # ChromaDB setup
โ โ โโโ retriever.py # RAG retriever
โ โ โโโ qa_chain.py # Q&A chain
โ โโโ prior_auth/
โ โ โโโ pa_generator.py # PA form generation
โ โ โโโ approval_predictor.py # Approval likelihood
โ โ โโโ status_tracker.py # Status management
โ โโโ affordability/
โ โ โโโ coverage_estimator.py # Insurance coverage
โ โ โโโ assistance_finder.py # Patient assistance
โ โโโ adherence/
โ โ โโโ risk_predictor.py # ML risk model
โ โ โโโ intervention_gen.py # Personalized interventions
โ โ โโโ model_trainer.py # Model training
โ โโโ utils/
โ โ โโโ pii_redaction.py # PII handling
โ โ โโโ disclaimer.py # Legal disclaimers
โ โ โโโ logger.py # Logging setup
โ โโโ config.py # Configuration
โโโ backend/
โ โโโ main.py # FastAPI application
โ โโโ routes/
โ โ โโโ extraction.py # Extraction endpoints
โ โ โโโ rag.py # RAG endpoints
โ โ โโโ prior_auth.py # PA endpoints
โ โ โโโ adherence.py # Adherence endpoints
โ โโโ models/
โ โโโ schemas.py # Pydantic models
โโโ models/
โ โโโ adherence_model.pkl # Trained XGBoost model
โ โโโ scaler.pkl # Feature scaler
โโโ data/
โ โโโ knowledge_base/
โ โ โโโ drug_info.json # Drug information
โ โ โโโ interactions.json # Drug interactions
โ โ โโโ side_effects.json # Side effects database
โ โโโ synthetic/
โ โ โโโ prescriptions/ # Sample prescriptions
โ โ โโโ patient_data.csv # Synthetic patient data
โ โ โโโ adherence_data.csv # Training data
โ โโโ uploads/ # User uploads
โโโ evaluation/
โ โโโ extraction_eval.py # OCR accuracy metrics
โ โโโ rag_eval.py # RAG faithfulness
โ โโโ model_eval.py # ML model performance
โ โโโ results/ # Evaluation results
โโโ scripts/
โ โโโ init_system.py # System initialization
โ โโโ generate_synthetic_data.py # Data generation
โ โโโ train_adherence_model.py # Model training
โโโ docs/
โ โโโ ARCHITECTURE.md # Detailed architecture
โ โโโ API.md # API documentation
โ โโโ DEPLOYMENT.md # Deployment guide
โ โโโ SECURITY.md # Security considerations
โโโ tests/
โ โโโ test_extraction.py
โ โโโ test_rag.py
โ โโโ test_prior_auth.py
โ โโโ test_adherence.py
โโโ .env.example # Environment template
โโโ .gitignore
โโโ requirements.txt
โโโ Dockerfile
โโโ docker-compose.yml
โโโ README.md
Edit .env file:
# LLM Configuration
LLM_PROVIDER=ollama # ollama, groq, openai
OLLAMA_MODEL=llama3.1
GROQ_API_KEY=your_groq_key
OPENAI_API_KEY=your_openai_key
# Vector Store
CHROMA_PERSIST_DIR=./data/chroma_db
# OCR
TESSERACT_PATH=/usr/bin/tesseract
# AWS (Optional)
AWS_ACCESS_KEY_ID=your_key
AWS_SECRET_ACCESS_KEY=your_secret
AWS_REGION=us-east-1
# Application
DEBUG=True
LOG_LEVEL=INFO- Character Error Rate (CER)
- Word Error Rate (WER)
- Field-level accuracy (medicine name, dosage, etc.)
- Faithfulness score
- Answer relevancy
- Context precision/recall
- Adherence prediction: AUC-ROC, F1-score, precision, recall
- Feature importance analysis
Run evaluation:
python evaluation/run_all_evals.py- PII redaction for sensitive data
- Encrypted data storage (implement in production)
- Audit logging for all access
- Role-based access control
- Secure API endpoints with authentication
- "Not medical advice" disclaimer on all outputs
- "For demonstration purposes only" notice
- Recommendation to consult healthcare professionals
- S3 for file storage
aws s3 mb s3://rxaccess-ai-uploads- ECR for Docker images
aws ecr create-repository --repository-name rxaccess-ai
docker tag rxaccess-ai:latest <account>.dkr.ecr.us-east-1.amazonaws.com/rxaccess-ai
docker push <account>.dkr.ecr.us-east-1.amazonaws.com/rxaccess-ai- ECS/Fargate for containers
# Use provided CloudFormation template
aws cloudformation create-stack --stack-name rxaccess-ai --template-body file://deploy/cloudformation.ymlSee docs/DEPLOYMENT.md for detailed instructions.
# Run all tests
pytest tests/
# Run specific test suite
pytest tests/test_extraction.py -v
# Run with coverage
pytest --cov=src tests/- Real-time prescription verification with pharmacy databases
- Multi-language support for prescriptions
- Mobile app integration
- SMS/Email reminder system
- Integration with EHR systems (HL7 FHIR)
- Advanced PA automation with payer API integration
- Real-time insurance eligibility verification
- Predictive analytics for medication shortages
- Blockchain for prescription authenticity
- Telemedicine integration
- Clinical trial matching based on prescriptions
- Pharmacogenomics integration
- Real-world evidence generation
- Population health analytics
- AI-powered formulary optimization
Contributions are welcome! Please read our contributing guidelines and submit pull requests.
MIT License - see LICENSE file for details.
- Inspired by PHIL's mission to improve prescription access and adherence
- Built with open-source AI/ML tools
- Synthetic data generated for demonstration purposes
For questions or support, please open an issue or contact the development team.