Skip to main content

AI Workflows README

Overview

This project implements AI-powered workflows for the EasyManage healthcare management system, focusing on three high-priority use cases:

  1. Drug Demand Forecasting - Predict future drug demand using time series analysis
  2. Medication Adherence Prediction - Identify patients at risk of non-adherence
  3. Revenue Prediction - Forecast revenue trends and optimize financial planning

Project Structure

easymanage_ai/
├── README.md # This file
├── easymanage_ai_workflows_analysis.md # Comprehensive analysis of available AI workflows
├── easymanage_ai_implementation_guide.md # Technical implementation details
├── src/ # Source code directory
│ ├── data/ # Data processing modules
│ │ ├── __init__.py
│ │ ├── extractor.py # EasyManage API data extraction
│ │ └── features.py # Feature engineering
│ ├── models/ # Machine learning models
│ │ ├── __init__.py
│ │ ├── demand_forecaster.py # Drug demand forecasting
│ │ ├── adherence_predictor.py # Medication adherence prediction
│ │ └── revenue_predictor.py # Revenue prediction
│ ├── api/ # FastAPI services
│ │ ├── __init__.py
│ │ ├── main.py # Main API application
│ │ └── routes/ # API route definitions
│ ├── monitoring/ # Monitoring and logging
│ │ ├── __init__.py
│ │ └── monitor.py # AI service monitoring
│ └── utils/ # Utility functions
│ ├── __init__.py
│ └── helpers.py # Helper functions
├── tests/ # Test files
├── requirements.txt # Python dependencies
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker compose for services
└── config/ # Configuration files
└── settings.py # Application settings

Quick Start

Prerequisites

Installation

  1. Clone the repository

    git clone <repository-url>
    cd easymanage_ai
  2. Install Python dependencies

    pip install -r requirements.txt
  3. Set up environment variables

    export EASYMANAGE_BASE_URL="http://127.0.0.1:9080"
    export API_KEY="your-api-key-if-required"
  4. Run the services

    # Option 1: Run directly with Python
    python -m uvicorn src.api.main:app --host 0.0.0.0 --port 8000

    # Option 2: Run with Docker
    docker-compose up -d

API Endpoints

Once running, the following endpoints will be available:

Drug Demand Forecasting

  • POST /forecast/demand - Get drug demand forecast
  • GET /drugs/active - List active drugs for forecasting

Medication Adherence

  • POST /predict/adherence - Predict patient adherence risk
  • GET /patients/at-risk - Get list of high-risk patients

Revenue Prediction

  • POST /forecast/revenue - Get revenue forecast
  • GET /revenue/metrics - Get current revenue metrics

Usage Examples

1. Drug Demand Forecasting

import requests

# Forecast demand for drug ID 123 for next 30 days
response = requests.post("http://localhost:8000/forecast/demand", json={
"drug_id": 123,
"periods": 30,
"confidence_level": 0.95
})

forecast = response.json()
print(f"Predicted demand: {forecast['predictions']}")

2. Medication Adherence Prediction

# Predict adherence risk for a patient
response = requests.post("http://localhost:8000/predict/adherence", json={
"patient_id": 456,
"drug_id": 123
})

prediction = response.json()
print(f"Adherence risk: {prediction['adherence_risk']}")

3. Revenue Prediction

# Get revenue forecast for next quarter
response = requests.post("http://localhost:8000/forecast/revenue", json={
"periods": 90,
"confidence_level": 0.95
})

revenue_forecast = response.json()
print(f"Revenue forecast: {revenue_forecast}")

Configuration

EasyManage Connection

Update the base URL in config/settings.py:

EASYMANAGE_BASE_URL = "http://your-easymanage-server:9080"

Model Parameters

Adjust model parameters in the respective model classes:

# In src/models/demand_forecaster.py
class DrugDemandForecaster:
def __init__(self):
self.forecast_horizon = 30 # Days to forecast
self.confidence_level = 0.95 # Prediction confidence
self.min_data_points = 100 # Minimum data for training

Monitoring & Logging

The system includes comprehensive monitoring:

  • Model Performance Tracking - Accuracy, execution time, confidence scores
  • API Usage Metrics - Request counts, response times, error rates
  • Data Quality Monitoring - Missing data, data freshness, validation errors

Access monitoring data via:

# Get model performance metrics
curl http://localhost:8000/monitoring/performance

# Get system health status
curl http://localhost:8000/health

Testing

Run the test suite:

# Run all tests
pytest tests/

# Run specific test file
pytest tests/test_demand_forecaster.py

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

Deployment

Production Deployment

  1. Update configuration for production

    # config/settings.py
    DEBUG = False
    LOG_LEVEL = "INFO"
    EASYMANAGE_BASE_URL = "https://server01.production.easymanage.com"
  2. Set up monitoring and alerting

    • Configure log aggregation (ELK stack, Splunk)
    • Set up metrics collection (Prometheus, Grafana)
    • Configure alerting rules
  3. Deploy with Docker

    docker-compose -f docker-compose.prod.yml up -d

Kubernetes Deployment

# k8s/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: easymanage-ai
spec:
replicas: 3
selector:
matchLabels:
app: easymanage-ai
template:
metadata:
labels:
app: easymanage-ai
spec:
containers:
- name: easymanage-ai
image: easymanage-ai:latest
ports:
- containerPort: 8000
env:
- name: EASYMANAGE_BASE_URL
value: "https://server01.production.easymanage.com"

Roadmap

Phase 1 (Current)

  • ✅ Drug demand forecasting
  • ✅ Medication adherence prediction
  • ✅ Revenue prediction

Phase 2 (Next)

  • 🔄 Drug interaction detection
  • 🔄 Patient risk scoring
  • 🔄 Insurance claim optimization

Phase 3 (Future)

  • 📋 Staff scheduling optimization
  • 📋 Patient segmentation
  • 📋 Performance analytics

Changelog

v1.0.0 (Current)

  • Initial implementation of three core AI workflows
  • FastAPI-based REST API
  • Docker containerization
  • Basic monitoring and logging

Note: This implementation requires access to the EasyManage system and appropriate data permissions. Ensure compliance with healthcare data regulations (HIPAA, etc.) before deployment in production environments.