Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Β 
Β 

Latest commit

Β 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MedConnect - AI-Powered Healthcare Platform

MedConnect is an AI-powered digital healthcare platform that streamlines appointment scheduling, centralizes patient records, and enhances doctor-patient communication. The platform integrates Machine Learning models to assist doctors in early diagnosis, achieving 99.73% accuracy in kidney disease detection.

πŸš€ Features

  • AI-Driven Scheduling: Intelligent appointment booking system that reduces wait times by up to 40%
  • ML-Assisted Diagnostics: 99.73% accuracy in kidney disease detection using advanced AI models
  • Centralized Records: All medical history in one place, accessible anytime, anywhere
  • AI Health Assistant: 24/7 AI-powered chatbot for instant health-related queries
  • Early Disease Detection: Advanced ML models for early detection of critical diseases
  • Modern UI/UX: Beautiful, responsive design with professional healthcare aesthetics
  • Secure Data: Bank-level encryption and compliance standards for patient data

πŸ› οΈ Technology Stack

  • Backend: Django 4.2+
  • AI/ML: TensorFlow, Keras for image analysis
  • Database: SQLite3 (development)
  • Frontend: Bootstrap 5, HTML5, CSS3, JavaScript
  • Icons: Font Awesome 6.4
  • Fonts: Inter, Poppins

πŸ“‹ Prerequisites

  1. Python 3.8+ - Download from python.org
  2. pip - Usually comes with Python
  3. Virtual Environment (Recommended)

πŸ”§ Installation & Setup

1. Clone the Repository

git clone <repository-url>
cd medconnect

2. Install Python

  • Download Python 3.8 or higher from python.org
  • During installation, check "Add Python to PATH" (very important!)
  • Verify installation: Open Command Prompt and run python --version

3. Create Virtual Environment (Recommended)

# Navigate to project directory
cd medconnect

# Create virtual environment
python -m venv venv

# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On Mac/Linux:
source venv/bin/activate

4. Install Dependencies

# Install required packages
pip install -r requirements.txt

Note: llama-cpp-python requires C++ build tools on Windows. For GPU support (recommended), you'll also need CUDA Toolkit. See the Installing llama-cpp-python section below for detailed instructions.

Or install individually:

pip install django tensorflow pillow numpy cryptography
# For llama-cpp-python, see Installing llama-cpp-python section below

5. Run Database Migrations

python manage.py migrate

6. Create Superuser (Optional - for admin access)

python manage.py createsuperuser

7. Start Development Server

python manage.py runserver

The server will start at: http://127.0.0.1:8000

πŸš€ Quick Start Scripts

Windows (Batch)

Double-click run_server.bat or run:

run_server.bat

Windows (PowerShell)

.\run_server.ps1

πŸ“ Project Structure

medconnect/
β”œβ”€β”€ main/              # Main application (auth, appointments, dashboards)
β”œβ”€β”€ chat/              # Chat/AI assistant app
β”œβ”€β”€ scans/             # Medical scan analysis app
β”œβ”€β”€ medconnect/        # Project settings
β”œβ”€β”€ manage.py          # Django management script
β”œβ”€β”€ requirements.txt   # Python dependencies
β”œβ”€β”€ db.sqlite3         # Database file (created after migrations)
└── media/             # User-uploaded files (created automatically)

🌐 Access Points

πŸ‘₯ User Roles

Patients

  • Register and create profile
  • Book appointments with doctors
  • Upload medical reports
  • Access AI health assistant
  • Upload scans for analysis
  • View appointment history

Doctors

  • Register and create professional profile
  • Manage appointments
  • View patient records
  • Access AI diagnostic assistance
  • Set consultation fees
  • Manage schedule

πŸ› Troubleshooting

Python Not Found

Problem: Windows shows "Python was not found" or opens Microsoft Store.

Solution 1: Disable Windows Store Python Aliases (Recommended)

  1. Open Windows Settings (Win + I)
  2. Go to: Apps β†’ Advanced app settings β†’ App execution aliases
  3. Turn OFF python.exe, python3.exe, and pythonw.exe
  4. Restart your terminal/command prompt
  5. Test: python --version

Solution 2: Use Python Launcher

py manage.py runserver

Solution 3: Add Python to PATH Manually

  1. Find your Python installation folder (e.g., C:\Python39)
  2. Find the Scripts folder (e.g., C:\Python39\Scripts)
  3. Add both to System Environment Variables β†’ Path
  4. Restart terminal

Module Not Found Errors

  • Activate your virtual environment: venv\Scripts\activate
  • Install missing packages: pip install <package-name>
  • Reinstall all dependencies: pip install -r requirements.txt

Database Errors

  • Run migrations: python manage.py migrate
  • If issues persist, delete db.sqlite3 and run migrations again:
    del db.sqlite3
    python manage.py migrate

Port Already in Use

  • Change port: python manage.py runserver 8001
  • Or kill the process using port 8000

Static Files Not Loading

  • Collect static files: python manage.py collectstatic
  • Ensure DEBUG = True in settings.py for development

πŸ“¦ Installing llama-cpp-python

The llama-cpp-python package requires C++ compilation on Windows. Here are the installation options:

Option 1: Install with GPU Support (NVIDIA CUDA) - Recommended for Performance

Prerequisites:

  1. NVIDIA GPU with CUDA support
  2. CUDA Toolkit installed (download from https://developer.nvidia.com/cuda-downloads)
  3. cuDNN (download from https://developer.nvidia.com/cudnn)

Installation Steps:

  1. Install Visual Studio Build Tools:

  2. Install CUDA Toolkit:

  3. Install llama-cpp-python with CUDA:

    Option A: Using pre-built wheels (Easiest - Recommended):

    # For CUDA 12.1
    pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu121
    
    # For CUDA 11.8
    pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu118
    
    # Check your CUDA version with: nvidia-smi

    Option B: Build from source (if pre-built wheels don't work):

    # Set environment variable for CUDA (use GGML_CUDA, not LLAMA_CUBLAS)
    set CMAKE_ARGS=-DGGML_CUDA=on
    
    # Install with CUDA support
    pip install llama-cpp-python --force-reinstall --no-cache-dir

    Important: Make sure CUDA Toolkit is installed and nvcc is in your PATH before building.

Option 2: Install Visual Studio Build Tools (CPU Only)

  1. Download Visual Studio Build Tools:

  2. Install Build Tools:

    • Run the installer
    • Select "Desktop development with C++" workload
    • Click "Install"
  3. Install llama-cpp-python (CPU):

    pip install llama-cpp-python

Option 3: Use Pre-built Wheels (If Available)

Try installing from a pre-built wheel:

pip install llama-cpp-python --only-binary :all:

Note: Pre-built wheels may not be available for all Python versions.

Option 4: Use Conda (Alternative)

If you have Anaconda/Miniconda installed:

conda install -c conda-forge llama-cpp-python

Verification

After installation, verify it works:

from llama_cpp import Llama
print("llama-cpp-python installed successfully!")

# Test GPU support (if installed with CUDA)
try:
    # Try loading a small model to test GPU
    model = Llama(model_path="path/to/model.gguf", n_gpu_layers=-1)
    print("GPU support: Enabled")
except Exception as e:
    print(f"GPU support: {e}")
    print("Falling back to CPU mode")

GPU Configuration

The code is configured to use GPU by default:

  • n_gpu_layers=-1 means use all available GPU layers
  • If GPU is not available, it will automatically fall back to CPU
  • You can adjust GPU layers in chat/modules/ai.py if needed

Performance Tips:

  • More GPU layers = Faster inference but requires more VRAM
  • Fewer GPU layers = Slower but uses less VRAM
  • Set n_gpu_layers=0 in the code to force CPU-only mode

Troubleshooting llama-cpp-python

  • CMake errors: Install CMake from https://cmake.org/download/
  • Compiler errors: Ensure Visual Studio Build Tools are installed
  • Python version: Ensure you're using Python 3.8-3.12
  • CUDA not found:
  • GPU not detected:
    • Check GPU: nvidia-smi
    • Verify CUDA version matches the wheel version
    • The code will automatically fall back to CPU if GPU is unavailable

🎯 Key Features Explained

AI-Powered Diagnostics

  • Uses TensorFlow/Keras models for medical image analysis
  • Achieves 99.73% accuracy in kidney disease detection
  • Supports early disease detection

Appointment System

  • AI-driven scheduling reduces wait times by 40%
  • Real-time availability checking
  • Automated reminders and notifications

AI Health Assistant

  • 24/7 availability
  • Powered by advanced language models
  • Provides instant health-related information

πŸ“ Development Notes

  • The project uses SQLite database by default (development)
  • Static files are served automatically in development
  • Media files are stored in the media/ directory
  • For production, configure proper database (PostgreSQL recommended) and static file serving
  • Ensure proper security settings before deploying to production

πŸ“„ License

All rights reserved Β© 2024 MedConnect

πŸ”’ Security

Data Encryption

  • Patient data encryption: All sensitive PHI (Protected Health Information) is encrypted using Fernet (AES-128) encryption
    • Medical history, contact numbers, appointment notes, and chat conversations are automatically encrypted
    • Encryption keys are stored securely via environment variables
    • Default encryption password: "medconnect" (can be changed via MEDCONNECT_ENCRYPTION_KEY environment variable)

Encryption Key Setup

The system uses "medconnect" as the default encryption password. This password is automatically derived into a secure Fernet key using PBKDF2 (100,000 iterations).

Set Environment Variable (Optional):

Windows (PowerShell):

$env:MEDCONNECT_ENCRYPTION_KEY="medconnect"

Windows (Command Prompt):

set MEDCONNECT_ENCRYPTION_KEY=medconnect

Linux/Mac:

export MEDCONNECT_ENCRYPTION_KEY="medconnect"

Note: The environment variable is already set to "medconnect" by default in settings.py. You only need to set it manually if you want to change it.

For Production:

  • Use a strong, unique password (not "medconnect")
  • Store the password in a secure environment variable or secrets manager
  • Never commit the password to version control
  • Use different passwords for development and production

HIPAA Compliance

  • HIPAA-compliant audit logging: Comprehensive audit trail of all PHI access
    • Tracks user actions, IP addresses, timestamps, and resource access
    • Viewable in Django admin panel
    • Required for HIPAA compliance
    • Automatic logging via middleware for all PHI access

Security Features

  • Encrypted Fields:

    • Patient medical history
    • Patient contact numbers
    • Doctor phone numbers
    • Appointment notes and medical history
    • Contact form messages
    • Chat conversations (prompts and responses)
  • Encryption Method: Fernet symmetric encryption (AES-128 in CBC mode)

  • Storage: Base64 encoded encrypted strings in database

  • Audit Logging:

    • Automatic logging of all PHI (Protected Health Information) access
    • Tracks: user accessing data, action performed (view, create, update, delete), resource type and ID, IP address and user agent, timestamp, additional details
    • Access via Admin: View audit logs in Django admin panel at /admin/
  • Security Settings:

    • Session Security: HTTP-only cookies, secure cookies (enable in production with HTTPS), session expiration, SameSite protection
    • Password Security: Minimum 8 characters, complexity requirements, Django's built-in validators
    • XSS Protection: Content Security Policy headers, XSS filter enabled
    • Clickjacking Protection: X-Frame-Options: DENY
  • Access Control:

    • Authentication required for all PHI access
    • Role-based access (Patient/Doctor)
    • Automatic audit logging via middleware

Testing Security

Test encryption using the provided test script:

python test_encryption.py

Or test manually in Python shell:

from main.utils.encryption import encrypt_data, decrypt_data

# Test encryption
encrypted = encrypt_data("Test medical history")
decrypted = decrypt_data(encrypted)
assert decrypted == "Test medical history"
print("Encryption working correctly!")

Production Security Checklist

Before deploying to production:

  • Set ENCRYPTION_KEY environment variable with a strong password
  • Set DEBUG = False in settings.py
  • Set SECURE_SSL_REDIRECT = True
  • Set SESSION_COOKIE_SECURE = True
  • Set CSRF_COOKIE_SECURE = True
  • Configure proper database (PostgreSQL recommended)
  • Set up SSL/HTTPS certificate
  • Configure secure file storage for media files
  • Set up regular backups
  • Configure log rotation for audit logs
  • Review and test all security settings
  • Conduct security audit
  • Set up monitoring and alerting

Important Security Notes

  1. Encryption Key: Never lose your encryption key! Data encrypted with a lost key cannot be recovered.

  2. Backup Strategy: Ensure encrypted backups include the encryption key (stored separately and securely).

  3. Performance: Encryption/decryption adds minimal overhead. Monitor performance in production.

  4. Legacy Data: Existing unencrypted data will be automatically encrypted on next save.

  5. File Encryption: Currently, file uploads are stored as-is. For production, implement file-level encryption or use encrypted storage services.

  • Regular security audits recommended for production deployment

Note: This is a development version. For production deployment, ensure proper configuration of:

  • Database (PostgreSQL recommended)
  • Static file serving
  • Security settings
  • Environment variables
  • SSL/HTTPS
  • Backup systems

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages