based on this info database (-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Oct 05, 2024 at 06:29 PM
-- Server version: 10.11.9-MariaDB
-- PHP Version: 7.2.34

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `u406552082_info`
--

-- --------------------------------------------------------

--
-- Table structure for table `admins`
--

CREATE TABLE `admins` (
  `id` int(11) NOT NULL,
  `username` varchar(50) NOT NULL,
  `password` varchar(255) NOT NULL,
  `email` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `budgets`
--

CREATE TABLE `budgets` (
  `id` int(11) NOT NULL,
  `month` varchar(7) DEFAULT NULL,
  `budgeted_revenue` decimal(10,2) DEFAULT NULL,
  `budgeted_expenses` decimal(10,2) DEFAULT NULL,
  `notes` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `comments`
--

CREATE TABLE `comments` (
  `id` int(11) NOT NULL,
  `patient_id` int(11) NOT NULL,
  `sender` enum('patient','doctor','admin') NOT NULL,
  `message` text NOT NULL,
  `timestamp` datetime DEFAULT current_timestamp(),
  `parent_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `doctors`
--

CREATE TABLE `doctors` (
  `id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `username` varchar(100) NOT NULL,
  `password` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `specialization` varchar(255) DEFAULT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `registration_date` date DEFAULT curdate(),
  `profile_picture` varchar(255) DEFAULT NULL,
  `department` varchar(100) DEFAULT NULL,
  `date_of_joining` date DEFAULT NULL,
  `status` enum('active','inactive') DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `doctor_patient`
--

CREATE TABLE `doctor_patient` (
  `id` int(11) NOT NULL,
  `doctor_id` int(11) NOT NULL,
  `patient_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `employees`
--

CREATE TABLE `employees` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `role` enum('admin','doctor','staff','accountant') NOT NULL,
  `email` varchar(255) NOT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `department` varchar(100) DEFAULT NULL,
  `date_of_joining` date DEFAULT NULL,
  `status` enum('active','inactive') DEFAULT 'active',
  `username` varchar(100) NOT NULL,
  `password` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `profile_picture` varchar(255) DEFAULT NULL,
  `specialization` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `health_records`
--

CREATE TABLE `health_records` (
  `id` int(11) NOT NULL,
  `patient_id` int(11) NOT NULL,
  `blood_pressure` varchar(20) DEFAULT NULL,
  `weight` decimal(5,2) DEFAULT NULL,
  `bmi` decimal(4,2) DEFAULT NULL,
  `cholesterol` decimal(5,2) DEFAULT NULL,
  `prescription` text DEFAULT NULL,
  `treatment_progress` text DEFAULT NULL,
  `record_date` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `insurance_claims`
--

CREATE TABLE `insurance_claims` (
  `id` int(11) NOT NULL,
  `patient_id` int(11) DEFAULT NULL,
  `invoice_id` int(11) DEFAULT NULL,
  `claim_amount` decimal(10,2) DEFAULT NULL,
  `status` enum('Pending','Approved','Rejected') DEFAULT NULL,
  `submission_date` date DEFAULT NULL,
  `processing_date` date DEFAULT NULL,
  `notes` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `invoices`
--

CREATE TABLE `invoices` (
  `id` int(11) NOT NULL,
  `patient_id` int(11) NOT NULL,
  `service_name` varchar(255) NOT NULL,
  `service_description` text DEFAULT NULL,
  `cost` decimal(10,2) NOT NULL,
  `tax_rate` decimal(5,2) DEFAULT 0.00,
  `discount` decimal(5,2) DEFAULT 0.00,
  `total_amount` decimal(10,2) NOT NULL,
  `invoice_date` date DEFAULT curdate(),
  `notes` text DEFAULT NULL,
  `tax` decimal(5,2) DEFAULT 0.00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `invoice_services`
--

CREATE TABLE `invoice_services` (
  `id` int(11) NOT NULL,
  `invoice_id` int(11) NOT NULL,
  `service_id` int(11) NOT NULL,
  `service_name` varchar(255) NOT NULL,
  `cost` decimal(10,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `messages`
--

CREATE TABLE `messages` (
  `id` int(11) NOT NULL,
  `sender_id` int(11) NOT NULL,
  `receiver_id` int(11) NOT NULL,
  `message` text NOT NULL,
  `timestamp` datetime DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `patients`
--

CREATE TABLE `patients` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `age` int(11) NOT NULL,
  `gender` enum('Male','Female','Other') NOT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `email` varchar(100) DEFAULT NULL,
  `medical_history` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `date_of_birth` date DEFAULT NULL,
  `registration_datetime` datetime DEFAULT current_timestamp(),
  `registration_date` date DEFAULT NULL,
  `status` enum('Initial Consultation','Diagnostic Phase','Treatment in Progress','Improving','Monitoring','Maintenance Phase','Awaiting Test Results','Follow-up Needed','Paused','Completed Program','Relapsed','Discontinued','Inactive') DEFAULT 'Initial Consultation',
  `doctor_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `patient_logins`
--

CREATE TABLE `patient_logins` (
  `id` int(11) NOT NULL,
  `patient_id` int(11) NOT NULL,
  `username` varchar(50) NOT NULL,
  `password` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `payments`
--

CREATE TABLE `payments` (
  `id` int(11) NOT NULL,
  `patient_id` int(11) NOT NULL,
  `invoice_id` int(11) NOT NULL,
  `amount_paid` decimal(10,2) NOT NULL,
  `payment_date` date NOT NULL,
  `payment_method` varchar(50) DEFAULT NULL,
  `notes` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `salaries`
--

CREATE TABLE `salaries` (
  `id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `basic_salary` decimal(10,2) NOT NULL,
  `bonuses` decimal(10,2) DEFAULT 0.00,
  `deductions` decimal(10,2) DEFAULT 0.00,
  `overtime_hours` int(11) DEFAULT 0,
  `overtime_rate` decimal(10,2) DEFAULT 0.00,
  `tax` decimal(10,2) DEFAULT 0.00,
  `payment_date` date NOT NULL,
  `net_salary` decimal(10,2) NOT NULL,
  `status` enum('Pending','Paid') DEFAULT 'Pending',
  `notes` text DEFAULT NULL,
  `payslip_path` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `services`
--

CREATE TABLE `services` (
  `service_id` int(11) NOT NULL,
  `service_name` varchar(255) NOT NULL,
  `service_price` decimal(10,2) NOT NULL,
  `service_description` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `admins`
--
ALTER TABLE `admins`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`);

--
-- Indexes for table `budgets`
--
ALTER TABLE `budgets`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `comments`
--
ALTER TABLE `comments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `patient_id` (`patient_id`);

--
-- Indexes for table `doctors`
--
ALTER TABLE `doctors`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`),
  ADD UNIQUE KEY `email` (`email`),
  ADD KEY `employee_id` (`employee_id`);

--
-- Indexes for table `doctor_patient`
--
ALTER TABLE `doctor_patient`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `doctor_id` (`doctor_id`,`patient_id`),
  ADD KEY `fk_doctor_patient_patient_id` (`patient_id`);

--
-- Indexes for table `employees`
--
ALTER TABLE `employees`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `email` (`email`),
  ADD UNIQUE KEY `username` (`username`);

--
-- Indexes for table `health_records`
--
ALTER TABLE `health_records`
  ADD PRIMARY KEY (`id`),
  ADD KEY `patient_id` (`patient_id`);

--
-- Indexes for table `insurance_claims`
--
ALTER TABLE `insurance_claims`
  ADD PRIMARY KEY (`id`),
  ADD KEY `patient_id` (`patient_id`),
  ADD KEY `invoice_id` (`invoice_id`);

--
-- Indexes for table `invoices`
--
ALTER TABLE `invoices`
  ADD PRIMARY KEY (`id`),
  ADD KEY `patient_id` (`patient_id`);

--
-- Indexes for table `invoice_services`
--
ALTER TABLE `invoice_services`
  ADD PRIMARY KEY (`id`),
  ADD KEY `invoice_id` (`invoice_id`),
  ADD KEY `service_id` (`service_id`);

--
-- Indexes for table `messages`
--
ALTER TABLE `messages`
  ADD PRIMARY KEY (`id`),
  ADD KEY `sender_id` (`sender_id`),
  ADD KEY `receiver_id` (`receiver_id`);

--
-- Indexes for table `patients`
--
ALTER TABLE `patients`
  ADD PRIMARY KEY (`id`),
  ADD KEY `doctor_id` (`doctor_id`);

--
-- Indexes for table `patient_logins`
--
ALTER TABLE `patient_logins`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `patient_id` (`patient_id`),
  ADD UNIQUE KEY `username` (`username`);

--
-- Indexes for table `payments`
--
ALTER TABLE `payments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `patient_id` (`patient_id`),
  ADD KEY `invoice_id` (`invoice_id`);

--
-- Indexes for table `salaries`
--
ALTER TABLE `salaries`
  ADD PRIMARY KEY (`id`),
  ADD KEY `employee_id` (`employee_id`);

--
-- Indexes for table `services`
--
ALTER TABLE `services`
  ADD PRIMARY KEY (`service_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `admins`
--
ALTER TABLE `admins`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `budgets`
--
ALTER TABLE `budgets`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `comments`
--
ALTER TABLE `comments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `doctors`
--
ALTER TABLE `doctors`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `doctor_patient`
--
ALTER TABLE `doctor_patient`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `employees`
--
ALTER TABLE `employees`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `health_records`
--
ALTER TABLE `health_records`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `insurance_claims`
--
ALTER TABLE `insurance_claims`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `invoices`
--
ALTER TABLE `invoices`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `invoice_services`
--
ALTER TABLE `invoice_services`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `messages`
--
ALTER TABLE `messages`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `patients`
--
ALTER TABLE `patients`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `patient_logins`
--
ALTER TABLE `patient_logins`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `payments`
--
ALTER TABLE `payments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `salaries`
--
ALTER TABLE `salaries`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `services`
--
ALTER TABLE `services`
  MODIFY `service_id` int(11) NOT NULL AUTO_INCREMENT;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `comments`
--
ALTER TABLE `comments`
  ADD CONSTRAINT `comments_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`);

--
-- Constraints for table `doctors`
--
ALTER TABLE `doctors`
  ADD CONSTRAINT `doctors_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`);

--
-- Constraints for table `doctor_patient`
--
ALTER TABLE `doctor_patient`
  ADD CONSTRAINT `doctor_patient_fk_doctor_id` FOREIGN KEY (`doctor_id`) REFERENCES `doctors` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `doctor_patient_ibfk_2` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_doctor` FOREIGN KEY (`doctor_id`) REFERENCES `doctors` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_doctor_patient_doctor_id` FOREIGN KEY (`doctor_id`) REFERENCES `doctors` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_doctor_patient_patient_id` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `health_records`
--
ALTER TABLE `health_records`
  ADD CONSTRAINT `health_records_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `insurance_claims`
--
ALTER TABLE `insurance_claims`
  ADD CONSTRAINT `insurance_claims_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `insurance_claims_ibfk_2` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `invoices`
--
ALTER TABLE `invoices`
  ADD CONSTRAINT `invoices_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`);

--
-- Constraints for table `invoice_services`
--
ALTER TABLE `invoice_services`
  ADD CONSTRAINT `invoice_services_ibfk_1` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `invoice_services_ibfk_2` FOREIGN KEY (`service_id`) REFERENCES `services` (`service_id`) ON DELETE CASCADE;

--
-- Constraints for table `messages`
--
ALTER TABLE `messages`
  ADD CONSTRAINT `messages_ibfk_1` FOREIGN KEY (`sender_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `messages_ibfk_2` FOREIGN KEY (`receiver_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `patients`
--
ALTER TABLE `patients`
  ADD CONSTRAINT `patients_ibfk_1` FOREIGN KEY (`doctor_id`) REFERENCES `doctors` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;

--
-- Constraints for table `patient_logins`
--
ALTER TABLE `patient_logins`
  ADD CONSTRAINT `patient_logins_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `payments`
--
ALTER TABLE `payments`
  ADD CONSTRAINT `payments_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `payments_ibfk_2` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `salaries`
--
ALTER TABLE `salaries`
  ADD CONSTRAINT `salaries_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;) and this path (Root Files:
bash
Copy code
./index.php
./admin_dashboard.php
./admin_logout.php
./admin_login.php
./update_patient_status.php
./add_health_record.php
./create_patient.php
./manage_comments.php
./admin_report.php
./view_patient.php
./delete_patient.php
./edit_patient.php
./db_connect.php
Accountant Section:
bash
Copy code
./accountant/dashboard.php
./accountant/manage_invoices.php
./accountant/view_invoice.php
./accountant/patient_financial_summary.php
./accountant/create_insurance_claim.php
./accountant/financial_forecasting.php
./accountant/mark_paid.php
./accountant/login.php
./accountant/important_text (should be renamed for clarity)
./accountant/edit_invoice.php
./accountant/generate_report.php
./accountant/view_patient_financial_summary.php
./accountant/manage_salaries.php
./accountant/manage_payments.php
./accountant/accountant_profile.php
./accountant/delete_payment.php
./accountant/generate_payslip.php
./accountant/budget_management.php
./accountant/edit_salary.php
./accountant/insurance_claim_tracker.php
./accountant/delete_invoice.php
./accountant/logout.php
./accountant/trend_analysis.php
./accountant/create_payment.php
./accountant/financial_dashboard.php
./accountant/add_salary.php
./accountant/edit_payment.php
./accountant/create_invoice.php
./accountant/delete_salary.php
./accountant/upload/payslips/payslip_1.pdf
./accountant/upload/payslips/payslip_5.pdf
./accountant/upload/payslips/payslip_6.pdf
./accountant/edit_salary_form.php
./accountant/view_salaries.php
./accountant/bulk_actions.php
Invoice Section:
bash
Copy code
./invoice/view_invoice.php
./invoice/edit_invoice.php
./invoice/print_invoice.php
./invoice/index.php
./invoice/services.php
./invoice/create_invoice.php
Team Section (Employee Management):
bash
Copy code
./team/add_accountant.php
./team/delete_employee.php
./team/add_doctor.php
./team/add_admin.php
./team/add_employee.php
./team/edit_employee.php
./team/manage_employees.php
./team/select_employee.php
./team/view_employee.php
Patient Section:
bash
Copy code
./patients/delete_comment.php
./patients/patient_dashboard.php
./patients/patient_logout.php
./patients/patient_login.php
./patients/send_comment.php
Doctor Section:
bash
Copy code
./doctors/dashboard.php
./doctors/login.php
./doctors/add_health_record.php
./doctors/add_doctor.php
./doctors/view_patient.php
./doctors/delete_health_record.php
./doctors/logout.php
./doctors/edit_health_record.php
./doctors/manage_doctors.php
Chat Section:
bash
Copy code
./chat/index.php
./chat/send_message.php
./chat/get_messages.php
Uploads:
bash
Copy code
./uploads/doaa123_1727919500.jpg
./uploads/payslips/payslip_6.pdf
./uploads/mahmoudtawfik_19.png
./uploads/drengy_18.jpg
./uploads/ali123_1727918034.jpg
./uploads/mahmoudtawfik_1727916558.png
./uploads/engy_14.jpg
Images:
bash
Copy code
./images/gold-logo.png
./images/background-image-admin.jpg
./images/white-logo.png
./images/logo.png) so please fix this codes and make showing data for doctor login (<?php
// doctors/dashboard.php

// Enable error reporting for debugging (Disable in production)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

session_start();
require_once '../db_connect.php'; // Ensure the path is correct

// Ensure the doctor is logged in
if (!isset($_SESSION['employee_id']) || $_SESSION['role'] !== 'doctor') {
    header("Location: login.php");
    exit();
}

$doctor_id = $_SESSION['employee_id'];

// Fetch doctor information
$stmt = $pdo->prepare("SELECT * FROM doctors WHERE employee_id = ?");
$stmt->execute([$doctor_id]);
$doctor = $stmt->fetch();

if (!$doctor) {
    // Invalid session
    session_destroy();
    header("Location: login.php");
    exit();
}

// Initialize search variables
$search = $_GET['search'] ?? '';
$status_filter = $_GET['status_filter'] ?? '';
$start_date = $_GET['start_date'] ?? '';
$end_date = $_GET['end_date'] ?? '';

// Fetch patients assigned to the doctor
$sql = "
    SELECT p.*, pl.username,
           hr.id AS health_record_id, hr.blood_pressure, hr.weight, hr.bmi, hr.cholesterol, 
           hr.prescription, hr.treatment_progress, hr.record_date,
           IFNULL(p.registration_datetime, '1970-01-01 00:00:00') AS reg_time
    FROM patients p
    LEFT JOIN doctor_patient dp ON p.id = dp.patient_id
    LEFT JOIN patient_logins pl ON p.id = pl.patient_id
    LEFT JOIN (
        SELECT hr.*
        FROM health_records hr
        INNER JOIN (
            SELECT patient_id, MAX(record_date) as max_record_date
            FROM health_records
            GROUP BY patient_id
        ) latest_hr ON hr.patient_id = latest_hr.patient_id AND hr.record_date = latest_hr.max_record_date
    ) hr ON p.id = hr.patient_id
    WHERE dp.doctor_id = :doctor_id
";
$params = ['doctor_id' => $doctor_id];

// Apply search filters
if ($search) {
    $sql .= " AND (p.name LIKE :search OR pl.username LIKE :search OR p.phone LIKE :search OR p.email LIKE :search)";
    $params['search'] = "%$search%";
}
if ($status_filter) {
    $sql .= " AND p.status = :status_filter";
    $params['status_filter'] = $status_filter;
}
if ($start_date && $end_date) {
    $sql .= " AND p.registration_date BETWEEN :start_date AND :end_date";
    $params['start_date'] = $start_date;
    $params['end_date'] = $end_date;
}

// Order by registration time descending to have new patients at the top
$sql .= " ORDER BY reg_time DESC";

// Prepare and execute the query
$stmt = $pdo->prepare($sql);
$stmt->execute($params);
$patients = $stmt->fetchAll(PDO::FETCH_ASSOC);

// Fetch patient status distribution for the pie chart
$status_stmt = $pdo->prepare("
    SELECT p.status, COUNT(*) as count 
    FROM patients p
    JOIN doctor_patient dp ON p.id = dp.patient_id
    WHERE dp.doctor_id = :doctor_id
    GROUP BY p.status
");
$status_stmt->execute(['doctor_id' => $doctor_id]);
$status_data = $status_stmt->fetchAll(PDO::FETCH_ASSOC);

// Fetch gender distribution for the bar chart
$gender_stmt = $pdo->prepare("
    SELECT p.gender, COUNT(*) as count 
    FROM patients p
    JOIN doctor_patient dp ON p.id = dp.patient_id
    WHERE dp.doctor_id = :doctor_id
    GROUP BY p.gender
");
$gender_stmt->execute(['doctor_id' => $doctor_id]);
$gender_data = $gender_stmt->fetchAll(PDO::FETCH_ASSOC);

// Fetch age data for the age distribution chart
$age_stmt = $pdo->prepare("
    SELECT p.age 
    FROM patients p
    JOIN doctor_patient dp ON p.id = dp.patient_id
    WHERE dp.doctor_id = :doctor_id
");
$age_stmt->execute(['doctor_id' => $doctor_id]);
$age_data = $age_stmt->fetchAll(PDO::FETCH_COLUMN);

// Fetch key statistics for summary section
$total_male = 0;
$total_female = 0;
$total_other = 0;
foreach ($gender_data as $gender) {
    if ($gender['gender'] == 'Male') {
        $total_male = $gender['count'];
    } elseif ($gender['gender'] == 'Female') {
        $total_female = $gender['count'];
    } else {
        $total_other += $gender['count']; // Accumulate 'Other' genders
    }
}

$total_patients_status = array_sum(array_column($status_data, 'count'));
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Meta tags for responsive design and character encoding -->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Page title -->
    <title>Doctor Dashboard - Patient Health Record System</title>

    <!-- Bootstrap 4.5 CSS for responsive layout and components -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <!-- DataTables CSS for advanced table features -->
    <link rel="stylesheet" href="https://cdn.datatables.net/1.13.4/css/dataTables.bootstrap4.min.css">
    <!-- Date Range Picker CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css">
    <!-- Custom CSS for the design -->
    <style>
        /* Custom CSS for modern design */
        body {
            background-color: #f8f9fa;
            font-family: Arial, sans-serif;
        }

        .dashboard-header {
            background-color: #4F3F02; /* Brown color */
            color: #fff;
            padding: 20px;
            text-align: center;
            border-radius: 8px;
            margin-bottom: 30px;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        }

        h1, h2, h3 {
            font-weight: bold;
        }

        .btn-primary {
            background-color: #D1C287; /* Light golden color */
            border-color: #D1C287;
            color: #4F3F02; /* Brown color */
            font-weight: bold;
            border-radius: 50px;
            transition: all 0.3s ease;
        }

        .btn-primary:hover {
            background-color: #4F3F02; /* Brown color */
            border-color: #D1C287;
            color: #fff;
        }

        .btn-secondary {
            background-color: #4F3F02; /* Brown color */
            border-color: #4F3F02;
            color: #fff;
            font-weight: bold;
            border-radius: 50px;
            transition: all 0.3s ease;
        }

        .btn-secondary:hover {
            background-color: #D1C287; /* Light golden color */
            color: #4F3F02; /* Brown color */
        }

        .btn-info {
            background-color: #17a2b8;
            border-color: #17a2b8;
            color: #fff;
            font-weight: bold;
            border-radius: 50px;
            transition: all 0.3s ease;
        }

        .btn-info:hover {
            background-color: #138496;
            border-color: #117a8b;
            color: #fff;
        }

        .search-bar {
            background-color: #fff;
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 20px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }

        .search-bar .form-control,
        .search-bar .form-select {
            border: 1px solid #D1C287;
            border-radius: 5px;
        }

        .search-bar .form-control:focus,
        .search-bar .form-select:focus {
            border-color: #4F3F02;
            box-shadow: none;
        }

        .table-responsive {
            margin-top: 20px;
        }

        .table {
            background-color: #fff;
            border-radius: 8px;
            overflow: hidden;
        }

        .table thead th {
            background-color: #4F3F02;
            color: #fff;
            border-color: #4F3F02;
            padding: 12px;
            text-align: left;
            cursor: pointer;
        }

        th, td {
            vertical-align: middle !important;
        }

        .card {
            border: none;
            border-radius: 10px;
            margin-bottom: 20px;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        }

        .card .card-title {
            color: #4F3F02;
            font-weight: bold;
            margin-bottom: 20px;
        }

        /* Responsive adjustments */
        @media (max-width: 768px) {
            .search-bar .form-control {
                margin-bottom: 10px;
            }
            .btn-group {
                flex-direction: column;
            }
            .btn-group .btn {
                width: 100%;
                margin-bottom: 5px;
            }
            .chart-container {
                height: 300px; /* Adjust chart height for smaller screens */
            }
        }

        /* Chart Container */
        .chart-container {
            position: relative;
            height: 400px; /* Set a fixed height for the charts */
        }

        .chart-container canvas {
            /* Ensure the canvas fills the container */
            position: absolute;
            top: 0;
            left: 0;
            width: 100% !important;
            height: 100% !important;
        }

        /* Adjust Header Image */
        .dashboard-header img {
            max-width: 20%; /* Adjusted size for better appearance */
            margin-bottom: 20px;
        }

        .summary-box {
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 20px;
            text-align: center;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        .summary-box h3 {
            color: #4F3F02;
            margin-bottom: 10px;
        }
        .summary-box p {
            font-size: 1.5rem;
            color: #D1C287;
            margin: 0;
        }
        .summary-box .icon {
            font-size: 3rem;
            color: #D1C287;
            margin-bottom: 10px;
        }

        /* Tooltip Styling */
        .tooltip-inner {
            background-color: #4F3F02;
            color: #fff;
        }
        .tooltip.bs-tooltip-top .arrow::before {
            border-top-color: #4F3F02;
        }

    </style>
</head>
<body>
    <div class="container-fluid">
        <!-- Dashboard Header -->
        <div class="dashboard-header">
            <img src="../images/white-logo.png" alt="White Logo"> <!-- Logo -->
            <h1>Doctor Dashboard</h1>
            <p>Welcome, Dr. <?= htmlspecialchars($doctor['name']); ?>!</p>
        </div>

        <!-- Navigation Buttons -->
        <div class="d-flex flex-wrap mb-3">
            <a href="chat/" class="btn btn-primary mb-2 mr-2">Chat</a>
            <a href="logout.php" class="btn btn-secondary mb-2 ml-auto">Log Out</a>
        </div>

        <!-- Summary Section -->
        <div class="row">
            <div class="col-md-3 col-sm-6">
                <div class="summary-box">
                    <div class="icon">
                        <i class="fas fa-users"></i>
                    </div>
                    <h3>Total Patients</h3>
                    <p><?= $total_patients_status ?></p>
                </div>
            </div>
            <div class="col-md-3 col-sm-6">
                <div class="summary-box">
                    <div class="icon">
                        <i class="fas fa-male"></i>
                    </div>
                    <h3>Male Patients</h3>
                    <p><?= $total_male ?></p>
                </div>
            </div>
            <div class="col-md-3 col-sm-6">
                <div class="summary-box">
                    <div class="icon">
                        <i class="fas fa-female"></i>
                    </div>
                    <h3>Female Patients</h3>
                    <p><?= $total_female ?></p>
                </div>
            </div>
            <div class="col-md-3 col-sm-6">
                <div class="summary-box">
                    <div class="icon">
                        <i class="fas fa-genderless"></i>
                    </div>
                    <h3>Other Genders</h3>
                    <p><?= $total_other ?></p>
                </div>
            </div>
        </div>

        <!-- Charts Section -->
        <div class="row">
            <!-- Patient Status Distribution Chart -->
            <div class="col-md-6">
                <div class="card">
                    <h2 class="card-title text-center">Patient Status Distribution</h2>
                    <div class="card-body chart-container">
                        <canvas id="statusChart"></canvas>
                    </div>
                </div>
            </div>

            <!-- Gender Distribution Bar Chart -->
            <div class="col-md-6">
                <div class="card">
                    <h2 class="card-title text-center">Gender Distribution</h2>
                    <div class="card-body chart-container">
                        <canvas id="genderChart"></canvas>
                    </div>
                </div>
            </div>
        </div>

        <!-- Age Distribution Chart -->
        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <h2 class="card-title text-center">Age Distribution</h2>
                    <div class="card-body chart-container">
                        <canvas id="ageChart"></canvas>
                    </div>
                </div>
            </div>
        </div>

        <!-- Search Bar -->
        <div class="search-bar">
            <form action="dashboard.php" method="get" class="form-row">
                <div class="form-group col-md-3">
                    <input type="text" name="search" class="form-control" placeholder="Search Patients..." value="<?= htmlspecialchars($search); ?>">
                </div>
                <div class="form-group col-md-3">
                    <select name="status_filter" class="form-control">
                        <option value="">All Statuses</option>
                        <?php
                        $status_options = ['Initial Consultation', 'Diagnostic Phase', 'Treatment in Progress', 'Improving', 'Monitoring', 'Maintenance Phase', 'Awaiting Test Results', 'Follow-up Needed', 'Paused', 'Completed Program', 'Relapsed', 'Discontinued', 'Inactive'];
                        foreach ($status_options as $status) {
                            echo "<option value=\"" . htmlspecialchars($status) . "\"" . ($status_filter == $status ? ' selected' : '') . ">" . htmlspecialchars($status) . "</option>";
                        }
                        ?>
                    </select>
                </div>
                <div class="form-group col-md-4">
                    <input type="text" id="daterange" name="daterange" class="form-control" placeholder="Registration Date Range" value="<?= htmlspecialchars($start_date && $end_date ? "$start_date - $end_date" : '') ?>">
                    <input type="hidden" id="start_date" name="start_date" value="<?= htmlspecialchars($start_date) ?>">
                    <input type="hidden" id="end_date" name="end_date" value="<?= htmlspecialchars($end_date) ?>">
                </div>
                <div class="form-group col-md-2">
                    <button type="submit" class="btn btn-primary w-100">Apply Filters</button>
                </div>
            </form>
            <!-- Reset Filters -->
            <div class="mt-2">
                <a href="dashboard.php" class="btn btn-secondary">Reset Filters</a>
            </div>
        </div>

        <!-- Toggle View Button -->
        <div class="d-flex justify-content-between align-items-center mb-3">
            <div>
                <!-- Entries per page -->
                <label for="entriesPerPage">Show:</label>
                <select id="entriesPerPage" class="custom-select" style="width: auto;">
                    <option value="5">5 entries</option>
                    <option value="10" selected>10 entries</option>
                    <option value="25">25 entries</option>
                    <option value="50">50 entries</option>
                    <option value="100">100 entries</option>
                </select>
            </div>
            <button id="toggleView" class="btn btn-info">Toggle View</button>
        </div>

        <!-- Patients Table -->
        <div id="tableView" class="table-responsive">
            <h2>Your Patients:</h2>
            <?php if ($patients): ?>
                <table id="patientTable" class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>Patient ID</th>
                            <th>Name</th>
                            <th>Username</th>
                            <th>Age</th>
                            <th>Gender</th>
                            <th>Phone</th>
                            <th>Email</th>
                            <th>Registration Time</th>
                            <th>Has Invoice</th>
                            <th>Status</th>
                            <th>Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($patients as $patient): ?>
                            <tr>
                                <td><?= htmlspecialchars($patient['id']); ?></td>
                                <td><?= htmlspecialchars($patient['name']); ?></td>
                                <td><?= htmlspecialchars($patient['username']); ?></td>
                                <td><?= htmlspecialchars($patient['age']); ?></td>
                                <td><?= htmlspecialchars($patient['gender']); ?></td>
                                <td><?= htmlspecialchars($patient['phone']); ?></td>
                                <td><?= htmlspecialchars($patient['email']); ?></td>
                                <td><?= htmlspecialchars($patient['registration_datetime']); ?></td>
                                <td>
                                    <?php
                                    // Check if the patient has any invoices
                                    $invoice_stmt = $pdo->prepare("SELECT COUNT(*) FROM invoices WHERE patient_id = ?");
                                    $invoice_stmt->execute([$patient['id']]);
                                    $invoice_count = $invoice_stmt->fetchColumn();
                                    echo $invoice_count > 0 ? '<span class="badge badge-success">Yes</span>' : '<span class="badge badge-danger">No</span>';
                                    ?>
                                </td>
                                <td><?= htmlspecialchars($patient['status']); ?></td>
                                <td>
                                    <div class="btn-group" role="group">
                                        <a href="view_patient.php?id=<?= htmlspecialchars($patient['id']) ?>" class="btn btn-primary btn-sm m-1">
                                            <i class="fas fa-eye"></i> View
                                        </a>
                                        <?php if ($patient['health_record_id']): ?>
                                            <a href="edit_health_record.php?id=<?= htmlspecialchars($patient['health_record_id']) ?>" class="btn btn-primary btn-sm m-1">
                                                <i class="fas fa-edit"></i> Edit Record
                                            </a>
                                        <?php else: ?>
                                            <a href="add_health_record.php?patient_id=<?= htmlspecialchars($patient['id']) ?>" class="btn btn-primary btn-sm m-1">
                                                <i class="fas fa-plus"></i> Add Record
                                            </a>
                                        <?php endif; ?>
                                    </div>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            <?php else: ?>
                <p>You have no patients assigned.</p>
            <?php endif; ?>
        </div>

        <!-- Patients Card View -->
        <div id="cardView" class="row" style="display: none;">
            <?php if ($patients): ?>
                <?php foreach ($patients as $patient): ?>
                    <div class="col-md-4">
                        <div class="card">
                            <div class="card-body">
                                <h5 class="card-title"><?= htmlspecialchars($patient['name']); ?></h5>
                                <p class="card-text">
                                    <strong>Username:</strong> <?= htmlspecialchars($patient['username']); ?><br>
                                    <strong>Age:</strong> <?= htmlspecialchars($patient['age']); ?><br>
                                    <strong>Gender:</strong> <?= htmlspecialchars($patient['gender']); ?><br>
                                    <strong>Phone:</strong> <?= htmlspecialchars($patient['phone']); ?><br>
                                    <strong>Email:</strong> <?= htmlspecialchars($patient['email']); ?><br>
                                    <strong>Status:</strong> <?= htmlspecialchars($patient['status']); ?>
                                </p>
                                <div class="btn-group" role="group">
                                    <a href="view_patient.php?id=<?= htmlspecialchars($patient['id']) ?>" class="btn btn-primary btn-sm m-1">
                                        <i class="fas fa-eye"></i> View
                                    </a>
                                    <?php if ($patient['health_record_id']): ?>
                                        <a href="edit_health_record.php?id=<?= htmlspecialchars($patient['health_record_id']) ?>" class="btn btn-primary btn-sm m-1">
                                            <i class="fas fa-edit"></i> Edit Record
                                        </a>
                                    <?php else: ?>
                                        <a href="add_health_record.php?patient_id=<?= htmlspecialchars($patient['id']) ?>" class="btn btn-primary btn-sm m-1">
                                            <i class="fas fa-plus"></i> Add Record
                                        </a>
                                    <?php endif; ?>
                                </div>
                            </div>
                        </div>
                    </div>
                <?php endforeach; ?>
            <?php else: ?>
                <p>You have no patients assigned.</p>
            <?php endif; ?>
        </div>

    </div>

    <!-- Include jQuery and Bootstrap JS for components -->
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    <!-- Font Awesome for icons -->
    <script src="https://kit.fontawesome.com/a076d05399.js"></script>
    <!-- DataTables JS -->
    <script src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/1.13.4/js/dataTables.bootstrap4.min.js"></script>
    <!-- Popper.js for Bootstrap tooltips -->
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
    <!-- Bootstrap 4.5 JS -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
    <!-- Date Range Picker JS -->
    <script src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
    <!-- Chart.js Scripts -->
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

    <!-- Initialize DataTables -->
    <script>
        $(document).ready(function() {
            var table = $('#patientTable').DataTable({
                "paging": true,
                "info": true,
                "searching": false, // Disable default search (we have our own search)
                "ordering": true, // Enable column sorting
                "lengthMenu": [[5, 10, 25, 50, 100], [5, 10, 25, 50, 100]],
                "pageLength": 10,
                "order": [[7, 'desc']] // Order by Registration Time descending
            });

            // Set entries per page from the select
            $('#entriesPerPage').on('change', function(){
                var value = $(this).val();
                table.page.len( value ).draw();
            });

            // Initialize tooltips
            $('[data-toggle="tooltip"]').tooltip();

            // Initialize Date Range Picker
            $('#daterange').daterangepicker({
                opens: 'left',
                autoUpdateInput: false,
                locale: {
                    cancelLabel: 'Clear',
                    format: 'YYYY-MM-DD'
                }
            });

            $('#daterange').on('apply.daterangepicker', function(ev, picker) {
                $(this).val(picker.startDate.format('YYYY-MM-DD') + ' - ' + picker.endDate.format('YYYY-MM-DD'));
                $('#start_date').val(picker.startDate.format('YYYY-MM-DD'));
                $('#end_date').val(picker.endDate.format('YYYY-MM-DD'));
            });

            $('#daterange').on('cancel.daterangepicker', function(ev, picker) {
                $(this).val('');
                $('#start_date').val('');
                $('#end_date').val('');
            });

            // Toggle View
            $('#toggleView').click(function() {
                $('#tableView').toggle();
                $('#cardView').toggle();
                $(this).text($(this).text() === 'Toggle View' ? 'Table View' : 'Toggle View');
            });
        });
    </script>

    <!-- Chart.js Scripts -->
    <script>
        // Patient Status Distribution Chart
        const statusCtx = document.getElementById('statusChart').getContext('2d');
        const statusChart = new Chart(statusCtx, {
            type: 'pie',
            data: {
                labels: <?= json_encode(array_column($status_data, 'status')) ?>,
                datasets: [{
                    data: <?= json_encode(array_column($status_data, 'count')) ?>,
                    backgroundColor: [
                        '#4F3F02', // Brown
                        '#D1C287', // Light Golden
                        '#FFCE56', // Yellow
                        '#FF9F40', // Orange
                        '#FF6384', // Red
                        '#36A2EB', // Blue
                        '#9966FF', // Purple
                        '#C9CBCF', // Grey
                        '#8D6E63', // Brown-ish
                        '#81C784', // Green
                        '#DCE775', // Lime
                        '#FFB74D', // Orange
                        '#BA68C8'  // Violet
                    ],
                }]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false,
                plugins: {
                    tooltip: {
                        callbacks: {
                            label: function(context) {
                                let label = context.label || '';
                                let value = context.parsed;
                                let total = context.chart._metasets[context.datasetIndex].total;
                                let percentage = ((value / total) * 100).toFixed(2);
                                return label + ': ' + value + ' (' + percentage + '%)';
                            }
                        }
                    },
                    legend: {
                        position: 'bottom',
                    },
                    title: {
                        display: false
                    }
                }
            },
        });

        // Gender Distribution Bar Chart
        const genderCtx = document.getElementById('genderChart').getContext('2d');
        const genderChart = new Chart(genderCtx, {
            type: 'bar',
            data: {
                labels: <?= json_encode(array_column($gender_data, 'gender')) ?>,
                datasets: [{
                    label: 'Number of Patients',
                    data: <?= json_encode(array_column($gender_data, 'count')) ?>,
                    backgroundColor: ['#4F3F02', '#D1C287', '#FFCE56'], // Colors for genders
                    borderColor: '#4F3F02',
                    borderWidth: 1
                }]
            },
            options: {
                indexAxis: 'y', // Horizontal bar chart
                responsive: true,
                maintainAspectRatio: false,
                scales: {
                    x: {
                        beginAtZero: true,
                        ticks: {
                            precision: 0 // Ensure integer values on x-axis
                        },
                        title: {
                            display: true,
                            text: 'Number of Patients'
                        }
                    },
                    y: {
                        title: {
                            display: true,
                            text: 'Gender'
                        }
                    }
                },
                plugins: {
                    tooltip: {
                        callbacks: {
                            label: function(context) {
                                let label = context.label || '';
                                let value = context.parsed.x;
                                return label + ': ' + value;
                            }
                        }
                    },
                    legend: {
                        display: false,
                    },
                    title: {
                        display: false
                    }
                }
            },
        });

        // Age Distribution Chart
        const ageCtx = document.getElementById('ageChart').getContext('2d');
        const ageData = <?= json_encode($age_data) ?>.map(Number);
        const ageCounts = {};

        ageData.forEach(function(age) {
            const ageGroup = Math.floor(age / 10) * 10;
            const label = ageGroup + '-' + (ageGroup + 9);
            if (!ageCounts[label]) {
                ageCounts[label] = 0;
            }
            ageCounts[label]++;
        });

        const ageLabels = Object.keys(ageCounts);
        const ageDataset = Object.values(ageCounts);

        const ageChart = new Chart(ageCtx, {
            type: 'bar',
            data: {
                labels: ageLabels,
                datasets: [{
                    label: 'Number of Patients',
                    data: ageDataset,
                    backgroundColor: '#D1C287', // Light golden color
                    borderColor: '#4F3F02',
                    borderWidth: 1
                }]
            },
            options: {
                responsive: true,
                maintainAspectRatio: false,
                scales: {
                    y: {
                        beginAtZero: true,
                        ticks: {
                            precision: 0 // Ensure integer values on y-axis
                        },
                        title: {
                            display: true,
                            text: 'Number of Patients'
                        }
                    },
                    x: {
                        title: {
                            display: true,
                            text: 'Age Groups'
                        }
                    }
                },
                plugins: {
                    tooltip: {
                        callbacks: {
                            label: function(context) {
                                let label = context.label || '';
                                let value = context.parsed.y;
                                return label + ': ' + value;
                            }
                        }
                    },
                    legend: {
                        display: false,
                    },
                    title: {
                        display: false
                    }
                }
            },
        });
    </script>
</body>
</html>) and type full codes