Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

RxAccess AI โ€” Intelligent Prescription Access & Adherence Platform

Live Demo

๐Ÿš€ Try it live: https://rxaccess-ai.streamlit.app


๐ŸŽฏ Project Overview

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.

๐Ÿฅ Alignment with PHIL's Mission

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

๐Ÿ—๏ธ Architecture

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
Loading

๐Ÿš€ Features

1. Prescription Ingestion & Extraction

  • 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

2. RAG-Powered Medical Assistant

  • Ask questions about uploaded prescriptions
  • Knowledge base with drug information, interactions, side effects
  • ChromaDB vector store for semantic search
  • Context-aware responses using LangChain

3. Prior Authorization Assistant

  • Automated PA form generation
  • Required documentation checklist
  • Approval likelihood prediction
  • Status tracking (Pending โ†’ Under Review โ†’ Approved/Denied)
  • Missing information alerts

4. Affordability & Access Intelligence

  • Insurance coverage estimation
  • Copay calculator
  • Patient assistance program recommendations
  • Cash-pay vs insurance comparison
  • Generic alternatives suggestions

5. Adherence Prediction & Personalization

  • XGBoost ML model for adherence risk scoring
  • Features: age, medication class, regimen complexity, past adherence
  • Personalized intervention generation
  • Reminder scheduling with motivational messaging

6. Multi-Stakeholder Dashboards

  • 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

๐Ÿ› ๏ธ Tech Stack

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

๐Ÿ“ฆ Installation

Prerequisites

  • Python 3.10+
  • Docker (optional)
  • Tesseract OCR

Local Setup

  1. Clone the repository
git clone <repository-url>
cd rxaccess-ai
  1. Install Tesseract OCR

Windows:

# Download from: https://github.com/UB-Mannheim/tesseract/wiki
# Add to PATH

macOS:

brew install tesseract

Linux:

sudo apt-get install tesseract-ocr
  1. Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Set up environment variables
cp .env.example .env
# Edit .env with your API keys
  1. Initialize the system
python scripts/init_system.py

Docker Setup

docker build -t rxaccess-ai .
docker run -p 8501:8501 -p 8000:8000 rxaccess-ai

๐ŸŽฎ Usage

Start the Application

streamlit run streamlit_app/app.py

Access at: http://localhost:8501

Demo Flow

  1. Upload Prescription

    • Navigate to "๐Ÿ“„ Upload Prescription" tab
    • Upload image or PDF
    • View extracted structured data
  2. Ask Questions

    • Go to "๐Ÿ’ฌ Medical Assistant" tab
    • Ask about side effects, interactions, dosage instructions
    • Get AI-powered responses with sources
  3. Check Prior Authorization

    • Visit "๐Ÿ“‹ Prior Authorization" tab
    • Review PA form summary
    • Check approval likelihood
    • Track submission status
  4. Explore Affordability

    • Open "๐Ÿ’ฐ Affordability" tab
    • View insurance coverage estimate
    • Compare cash-pay options
    • Find patient assistance programs
  5. View Adherence Insights

    • Check "๐Ÿ“Š Adherence Intelligence" tab
    • See risk score prediction
    • Review personalized interventions
    • Set up reminders
  6. Multi-Stakeholder Views

    • Switch between Patient, Provider, and Pharma dashboards
    • Explore role-specific insights

๐Ÿ“ Project Structure

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

๐Ÿ”ง Configuration

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

๐Ÿ“Š Evaluation Metrics

Extraction Accuracy

  • Character Error Rate (CER)
  • Word Error Rate (WER)
  • Field-level accuracy (medicine name, dosage, etc.)

RAG Performance

  • Faithfulness score
  • Answer relevancy
  • Context precision/recall

ML Model Performance

  • Adherence prediction: AUC-ROC, F1-score, precision, recall
  • Feature importance analysis

Run evaluation:

python evaluation/run_all_evals.py

๐Ÿ”’ Security & Compliance

HIPAA Considerations

  • 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

Disclaimers

  • "Not medical advice" disclaimer on all outputs
  • "For demonstration purposes only" notice
  • Recommendation to consult healthcare professionals

๐Ÿš€ Deployment

AWS Deployment

  1. S3 for file storage
aws s3 mb s3://rxaccess-ai-uploads
  1. 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
  1. ECS/Fargate for containers
# Use provided CloudFormation template
aws cloudformation create-stack --stack-name rxaccess-ai --template-body file://deploy/cloudformation.yml

See docs/DEPLOYMENT.md for detailed instructions.

๐Ÿงช Testing

# Run all tests
pytest tests/

# Run specific test suite
pytest tests/test_extraction.py -v

# Run with coverage
pytest --cov=src tests/

๐Ÿ“ˆ Future Improvements

Short-term

  • 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)

Medium-term

  • Advanced PA automation with payer API integration
  • Real-time insurance eligibility verification
  • Predictive analytics for medication shortages
  • Blockchain for prescription authenticity
  • Telemedicine integration

Long-term

  • Clinical trial matching based on prescriptions
  • Pharmacogenomics integration
  • Real-world evidence generation
  • Population health analytics
  • AI-powered formulary optimization

๐Ÿค Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests.

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Inspired by PHIL's mission to improve prescription access and adherence
  • Built with open-source AI/ML tools
  • Synthetic data generated for demonstration purposes

๐Ÿ“ž Contact

For questions or support, please open an issue or contact the development team.


โš ๏ธ IMPORTANT DISCLAIMER: This is a prototype for demonstration purposes only. Not intended for actual medical use. Always consult healthcare professionals for medical advice.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages