# HealthLink - Complete Healthcare Management & Telemedicine Platform

## 🏥 Project Overview
HealthLink is a comprehensive healthcare management and telemedicine platform that enables:
- Patient registration and health record management
- Doctor verification and consultation system  
- Online appointment booking and management
- Medical records storage and retrieval
- Admin panel for system oversight
- Secure file uploads and data management

## 📋 Setup Instructions

### 1. Database Setup
1. Open phpMyAdmin or MySQL command line
2. Import the `database.sql` file to create all tables with sample data
3. Database name: `healthlink_db`

### 2. Configuration
1. Update `config.php` with your database credentials:
   ```php
   define('DB_HOST', 'localhost');
   define('DB_USER', 'root');
   define('DB_PASS', '');
   define('SITE_URL', 'http://localhost/Health_link');
   ```
2. Ensure XAMPP/Apache and MySQL are running
3. Create `uploads` folder with write permissions

### 3. Directory Structure
```
Health_link/
├── index.php                    # Public homepage
├── config.php                   # Database configuration
├── database.sql                 # Database structure
├── README.md                   # This file
├── patient-register.php        # Patient registration
├── patient-login.php           # Patient login
├── doctor-login.php            # Doctor login  
├── register-doctor.php         # Doctor registration
├── patient/
│   ├── dashboard.php           # Patient dashboard
│   ├── doctors.php             # Browse doctors
│   ├── book-appointment.php    # Book appointment
│   ├── appointments.php        # View appointments
│   ├── health-records.php     # Medical records
│   └── logout.php              # Patient logout
├── doctor/
│   ├── dashboard.php           # Doctor dashboard
│   └── logout.php              # Doctor logout
├── admin/
│   ├── login.php               # Admin login
│   ├── dashboard.php           # Admin dashboard
│   ├── doctor-verification.php # Verify doctors
│   └── logout.php              # Admin logout
└── uploads/                    # File storage
    ├── doctors/               # Doctor documents
    └── patients/              # Patient files
```

### 4. Default Login Credentials

#### 🔐 Admin Access:
- **Username:** `admin`
- **Password:** `password`
- **URL:** `http://localhost/Health_link/admin/login.php`

#### 👨‍⚕️ Doctor Access:
1. Register through `register-doctor.php`
2. Wait for admin verification via admin panel
3. Login through `doctor-login.php` after approval

#### 👤 Patient Access:
1. Register through `patient-register.php`
2. Automatic login after registration
3. Access dashboard immediately

## ✅ Implemented Features

### 🏠 Public Website
- Professional homepage with services overview
- Navigation to patient/doctor/admin portals
- Responsive Bootstrap design
- Service information and contact details

### 👥 Patient Portal
- **Registration & Login:**
  - Auto Health ID generation (HL-2025-00001)
  - Email validation and secure passwords
  - Auto-login after registration
  
- **Dashboard & Navigation:**
  - Patient dashboard with quick actions
  - Profile management with emergency contacts
  - Session management and logout
  
- **Doctor & Appointments:**
  - Browse and filter doctors by specialization
  - View doctor profiles, ratings, and fees
  - Book appointments (online/physical)
  - View appointment history and status
  - Appointment management system
  
- **Health Records:**
  - Personal health information management
  - Medical history storage and retrieval
  - Health metrics tracking (height, weight, blood group)
  - Allergy and medication tracking

### 👨‍⚕️ Doctor Portal
- **Registration & Verification:**
  - Comprehensive registration with document upload
  - PMC license verification system
  - Admin approval workflow
  - Document storage (license, qualification, CNIC)
  
- **Dashboard:**
  - Doctor statistics and analytics
  - Today's appointment schedule
  - Patient consultation history
  - Profile management system

### 🔧 Admin Panel
- **System Overview:**
  - Admin dashboard with key metrics
  - User registration statistics
  - System activity monitoring
  
- **Doctor Management:**
  - Doctor verification system
  - Review uploaded documents
  - Approve/reject applications
  - Notification system for status updates
  
- **User Management:**
  - Patient and doctor oversight
  - System settings and configuration

### 🔒 Security & Data Management
- **Authentication:**
  - Bcrypt password hashing
  - Session-based authentication
  - Role-based access control (Patient/Doctor/Admin)
  
- **Data Security:**
  - SQL injection prevention with prepared statements
  - XSS protection with input sanitization
  - Secure file upload validation
  - Proper session management
  
- **File Management:**
  - Secure file storage system
  - File type and size validation
  - Organized directory structure

### 📊 Database Features
- **Core Tables:**
  - `patients` - Patient profiles with Health IDs
  - `doctors` - Doctor profiles with verification status
  - `appointments` - Appointment management system
  - `medical_records` - Centralized health records
  - `specializations` - Medical specialties
  - `admin_users` - System administrators
  
- **Advanced Features:**
  - `patient_health_info` - Detailed health metrics
  - `notifications` - Multi-channel messaging
  - `reviews` - Doctor rating system
  - `audit_logs` - System activity tracking
  - `system_settings` - Configurable parameters

## 🚀 Technologies Used
- **Backend:** PHP 7.4+
- **Database:** MySQL 5.7+ with prepared statements
- **Frontend:** Bootstrap 5, Font Awesome icons
- **Security:** Bcrypt hashing, input sanitization
- **File Handling:** Secure uploads with validation

## 🧪 Testing the System

### Step-by-Step Testing:
1. **Start XAMPP** and import `database.sql`
2. **Register as Patient:**
   - Visit `patient-register.php`
   - Fill form and auto-login to dashboard
   - Browse doctors and book appointment
3. **Register as Doctor:**
   - Visit `register-doctor.php`  
   - Upload required documents
   - Wait for admin verification
4. **Admin Verification:**
   - Login to admin panel
   - Review doctor application
   - Approve/reject with notifications
5. **Doctor Login:**
   - Login with verified account
   - Access doctor dashboard
   - View appointments and patients
6. **Complete Workflow:**
   - Test appointment booking flow
   - Verify medical records storage
   - Check notification system

## 📈 Ready for Enhancement

The system provides a solid foundation for:
- **Payment Gateway Integration** (Stripe, PayPal)
- **Video Consultation Module** (Google Meet, Zoom APIs)
- **SMS/WhatsApp Notifications** (Twilio integration)
- **Email System** (SMTP configuration)
- **Advanced Reporting** (Charts and analytics)
- **Mobile App API** (REST API endpoints)
- **Prescription Module** (Digital prescriptions)
- **Lab Reports Integration** (Third-party lab APIs)

## 🔧 System Requirements
- **PHP:** 7.4 or higher
- **MySQL:** 5.7 or higher
- **Apache:** 2.4 or higher
- **Extensions:** mysqli, gd, fileinfo
- **Storage:** 100MB+ for file uploads

## 🎯 Production Deployment
1. Update `config.php` with production database
2. Set proper file permissions (755 for directories, 644 for files)
3. Configure SSL certificate
4. Set up automated backups
5. Configure email SMTP settings
6. Implement proper logging system

---

**HealthLink - Your Complete Healthcare Management Solution**
*Powered by CarePoint AI*

For support and queries: admin@healthlink.com