Clinical Risk Modeling Engine for Medication Diversion Detection | AI-Powered Opioid Diversion Prevention Tool
THIS IS A PROTOTYPE DEMONSTRATION ONLY. This software is NOT intended for clinical use, is not designed to treat or diagnose any medical condition, and should not be used for actual clinical decision making. This prototype is for demonstration and research purposes only. Any use for actual patient care is strictly prohibited until proper validation, regulatory approval, and clinical trials have been completed.
INTELLECTUAL PROPERTY RIGHTS: This Clinical Risk Modeling Engine is the intellectual property of Raphael Tomas Malikian. Any use of this tool must provide proper attribution to the creator. Commercial use is strictly prohibited without explicit written permission and licensing. For permission inquiries, please contact the author directly.
The Clinical Risk Modeling Engine is an AI-powered clinical decision support tool (CDST) designed to proactively identify and flag high-risk polypharmacy and potential medication safety/diversion scenarios. Built with machine learning and evidence-based guidelines from DEA, CDC, and SAMHSA, this system addresses the critical challenge of prescription drug diversion, particularly opioids and controlled substances.
- Full Enterprise System: Backend API with EHR integration capabilities (Under Development)
- Standalone Web Tool: Browser-based assessment tool (Prototype Ready)
- Evidence-based evaluation framework using DEA, CDC, and SAMHSA guidelines
- XAI (Explainable AI) with SHAP/LIME analysis for clinical transparency
- FastAPI-based REST API for enterprise deployment (Planned)
- Standalone web-based assessment tool for immediate use
- Machine learning model for medication diversion detection using Gradient Boosting
- Professional verification system for enhanced security
- Substance abuse history - History of drug or alcohol abuse
- Mental health history - Depression, anxiety, PTSD, or other mental health conditions
- Chronic pain history - Long-term pain conditions requiring medication
- Pain out of proportion to physical exam - Pain levels inconsistent with physical findings
- Opioid prescriptions - Number and frequency of opioid medications
- Benzodiazepine prescriptions - Count and duration of benzodiazepine use
- High-dose prescriptions - Medications exceeding recommended dosages
- Concurrent prescriptions - Multiple high-risk medications simultaneously
- Early refill requests - Requesting refills before scheduled time (Red Flag)
- Unusual requests - Early refills, large quantities, specific formulations
- Prescription frequency - Number of prescriptions per month
- Emergency department visits - Frequent ED visits in pattern recognition
- Hospitalization history - Hospital admissions and inpatient stays
- Primary care visits - Regular healthcare engagement patterns
- Emergency requests - Unscheduled or urgent care visits
- Lost/stolen reports - Number of reported lost/stolen prescriptions
- Number of prescribers - Multiple healthcare providers prescribing controlled substances
- Number of pharmacies - Using multiple pharmacies (pharmacy hopping)
- Geographic dispersion - Distance between prescribers and pharmacies
- Travel distance to provider - Long distances traveled for prescriptions
- Travel distance to pharmacy - Extended travel for medication pickup
- Prescriber pressure tactics - Aggressive demands or threats toward providers
- Prescription shopping patterns - Visiting multiple providers for same medications
- Insurance status - Uninsured or cash-paying patients
- Payment method - Cash payments as a red flag for avoiding tracking
- Doctor shopping admissions - Patient self-reported shopping behavior
- Diversion admissions - Patient acknowledgment of medication diversion
- Provider clinical intuition - Gut feeling assessment by healthcare provider
- Inconsistent complaints - Changing reasons for medication requests
- Time since last prescription - Short intervals between similar prescriptions
- History of diversion - Previous documented medication diversion incidents
- Backend: Python, FastAPI, scikit-learn, pandas
- Database: SQLAlchemy ORM with PostgreSQL/MySQL support
- Machine Learning: Gradient Boosting, XAI with SHAP/LIME
- API: RESTful endpoints with authentication
- Integration: EHR connectivity (EPIC, Cerner, Allscripts)
- PDMP Integration: Prescription drug monitoring program connections
- Frontend: HTML, CSS, JavaScript (No server required)
- Security: Professional verification with license validation
- Assessment: Dual-level (Basic/Detailed) patient risk evaluation
- Offline Capability: Functions without internet connection
- Backend: Python 3.8+, FastAPI, Uvicorn
- Machine Learning: scikit-learn, XGBoost, SHAP, LIME
- Data Processing: pandas, NumPy
- Database: SQLAlchemy, PostgreSQL
- Authentication: OAuth2, JWT tokens
- Containerization: Docker, Docker Compose
- Frontend: Vanilla JavaScript, HTML5, CSS3
- No External Dependencies: Pure browser-based operation
For the full enterprise system (currently under development):
- Clone the repository:
git clone <repository-url>- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtpython run_system.py apiOr directly:
uvicorn main:app --reload --host 0.0.0.0 --port 8000- Download
ui_demo.htmlfrom the repository - Open in any modern web browser
- Complete professional verification with medical license
- Begin patient risk assessments
python run_system.py demo- Complete risk factor integration
- Professional verification system
- Evidence-based risk scoring
- XAI feature importance visualization
- Dual assessment levels (Basic/Detailed)
- Comprehensive risk factor coverage
- Mandatory disclaimer popup
- Research citations and accountability
- Backend API integration
- EHR connectivity (EPIC, Cerner, Allscripts)
- PDMP (Prescription Drug Monitoring Program) integration
- Database connectivity and management
- Production-level security implementation
- Clinical validation and testing
- Regulatory compliance preparation
diversion/
βββ api/ # API endpoints (Enterprise system)
βββ data/ # Data processing modules
βββ models/ # ML models and training algorithms
βββ services/ # Business logic and service layers
βββ utils/ # Utility functions and helpers
βββ tests/ # Unit and integration tests
βββ ui_demo.html # Standalone web assessment tool (Prototype Ready)
βββ requirements.txt # Python dependencies
βββ requirements-dev.txt # Development dependencies
βββ LICENSE # MIT License
βββ README.md # Project documentation
βββ CHANGELOG.md # Version history
βββ CONTRIBUTING.md # Contribution guidelines
βββ EHR_INTEGRATION.md # EHR integration planning
βββ PUBLIC_DATA_SOURCES.md # Testing data resources
βββ main.py # Main application entry point
After deploying the full system, API documentation will be available at http://localhost:8000/docs
- Medical license number verification
- Provider name and specialty validation
- Prevents unauthorized access by non-medical professionals
- Basic Assessment: Quick screening with core risk factors
- Detailed Assessment: Comprehensive evaluation with all risk indicators
- Evidence-based risk calculation
- Weighted risk factors based on research
- Feature importance visualization
- Red flag identification and reporting
- Mandatory professional verification
- Protection against cherry-picking of potential patients
- Clinical decision support for legitimate healthcare providers only
Run the test suite:
python -m pytest tests/For testing and validation, this project can utilize various publicly available healthcare datasets. See PUBLIC_DATA_SOURCES.md for a comprehensive list of resources including:
- Government health datasets (HCUP, CDC, SAMHSA)
- Synthetic patient data generators (Synthea)
- Clinical research datasets (MIMIC, PhysioNet)
- Substance abuse and opioid-related statistics
This tool incorporates evidence-based risk factors from peer-reviewed research including:
- CDC Guidelines for Prescribing Opioids for Chronic Pain
- DEA guidelines on controlled substance diversion
- SAMHSA substance use indicators
- Studies on prescription drug monitoring programs
- Research on "doctor shopping" behavior
- Pain management and addiction studies
All risk factors are weighted based on clinical evidence and research findings.
Here are some screenshots of the Clinical Risk Modeling Engine:
Raphael Tomas Malikian Email: rtmalikian@gmail.com
Raphael has experience working in the Family Medicine field as a provider and has lived experience of how damaging drug diversion is on providers, patients, pharmacies, and the greater community in the context of the opioid epidemic and other controlled substance diversion. This personal and professional experience has informed the development of this Clinical Risk Modeling Engine to help identify potential medication diversion risks.
We welcome contributions to enhance the Clinical Risk Modeling Engine. Please see CONTRIBUTING.md for guidelines on how to participate.
This project was created with the assistance of Qwen Code in Visual Studio Code using the coder model. The AI coding assistant helped with code generation, debugging, documentation, and project structure development.
MIT License (see LICENSE file)
- medication diversion detection
- opioid abuse prevention
- prescription drug monitoring
- clinical decision support
- AI healthcare tool
- drug diversion prevention
- controlled substance monitoring
- physician safety
- patient safety
- prescription safety
- healthcare AI
- machine learning healthcare
- opioid crisis solution
- drug abuse detection
- medical informatics
- clinical risk assessment



