-- Hospital Internal Chat Schema
CREATE TABLE IF NOT EXISTS users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    hospital_id VARCHAR(50) NOT NULL UNIQUE,
    email VARCHAR(100) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL,
    name VARCHAR(100) NOT NULL,
    role ENUM('doctor', 'nurse', 'admin_staff', 'technician', 'pharmacist') NOT NULL,
    department VARCHAR(100),
    online_status BOOLEAN DEFAULT FALSE,
    last_seen TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Seed data for testing (password is 'password' for all)
INSERT IGNORE INTO users (hospital_id, email, password, name, role, department) VALUES
('DOC001', 'sarah.mitchell@medlink.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'Dr. Sarah Mitchell', 'doctor', 'Cardiology'),
('NUR002', 'james.wilson@medlink.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'James Wilson, RN', 'nurse', 'Emergency'),
('ADM003', 'elena.rodriguez@medlink.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'Elena Rodriguez', 'admin_staff', 'Operations'),
('LAB004', 'david.chen@medlink.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'David Chen', 'technician', 'Pathology'),
('PHM005', 'anita.gupta@medlink.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'Dr. Anita Gupta', 'pharmacist', 'Pharmacy');