in this codes (<?php
session_start();
require_once 'db_connect.php'; // Ensure this file connects to your database

// Check if the admin is logged in
if (!isset($_SESSION['admin_id'])) {
    header("Location: admin_login.php");
    exit();
}

try {
    // Initialize filter variables with default values
    $start_date = isset($_GET['start_date']) ? $_GET['start_date'] : date('Y-m-d', strtotime('-30 days'));
    $end_date = isset($_GET['end_date']) ? $_GET['end_date'] : date('Y-m-d');
    $gender_filter = isset($_GET['gender_filter']) ? $_GET['gender_filter'] : '';
    $age_group_filter = isset($_GET['age_group_filter']) ? $_GET['age_group_filter'] : '';
    $status_filter = isset($_GET['status_filter']) ? $_GET['status_filter'] : '';
    $service_filter = isset($_GET['service_filter']) ? $_GET['service_filter'] : '';
    
    // Validate dates
    $start_date = date('Y-m-d', strtotime($start_date));
    $end_date = date('Y-m-d', strtotime($end_date));

    // Build filters array
    $filters = [
        'start_date' => $start_date,
        'end_date' => $end_date,
        'gender' => $gender_filter,
        'age_group' => $age_group_filter,
        'status' => $status_filter,
        'service' => $service_filter
    ];

    // Fetch all the data
    $total_patients = getTotalPatients($pdo, $filters);
    $gender_distribution = getGenderDistribution($pdo, $filters);
    $age_distribution = getAgeDistribution($pdo, $filters);
    $status_distribution = getStatusDistribution($pdo, $filters);
    $services_distribution = getServicesDistribution($pdo, $filters);
    $invoice_trend = getInvoiceTrend($pdo, $filters);
    $registration_trend = getRegistrationTrend($pdo, $filters);

} catch (Exception $e) {
    // Handle exceptions
    die("Error: " . $e->getMessage());
}

// Functions to fetch data
function buildWhereConditions($filters, &$params, $prefix = 'p.') {
    $where = [];
    $params = [];
    if (!empty($filters['start_date']) && !empty($filters['end_date'])) {
        $where[] = $prefix."registration_date BETWEEN :start_date AND :end_date";
        $params[':start_date'] = $filters['start_date'];
        $params[':end_date'] = $filters['end_date'];
    }
    if (!empty($filters['gender'])) {
        $where[] = $prefix."gender = :gender";
        $params[':gender'] = $filters['gender'];
    }
    if (!empty($filters['age_group'])) {
        switch ($filters['age_group']) {
            case 'under_18':
                $where[] = $prefix."age < 18";
                break;
            case '18_30':
                $where[] = $prefix."age BETWEEN 18 AND 30";
                break;
            case '31_50':
                $where[] = $prefix."age BETWEEN 31 AND 50";
                break;
            case '51_70':
                $where[] = $prefix."age BETWEEN 51 AND 70";
                break;
            case 'over_70':
                $where[] = $prefix."age > 70";
                break;
        }
    }
    if (!empty($filters['status'])) {
        $where[] = $prefix."status = :status";
        $params[':status'] = $filters['status'];
    }
    return !empty($where) ? 'WHERE ' . implode(' AND ', $where) : '';
}

function getTotalPatients($pdo, $filters) {
    $where_conditions = buildWhereConditions($filters, $params);
    $stmt = $pdo->prepare("SELECT COUNT(*) FROM patients p $where_conditions");
    $stmt->execute($params);
    return $stmt->fetchColumn();
}

function getGenderDistribution($pdo, $filters) {
    $where_conditions = buildWhereConditions($filters, $params);
    $stmt = $pdo->prepare("SELECT p.gender, COUNT(*) as count FROM patients p $where_conditions GROUP BY p.gender");
    $stmt->execute($params);
    return $stmt->fetchAll(PDO::FETCH_ASSOC);
}

function getAgeDistribution($pdo, $filters) {
    $where_conditions = buildWhereConditions($filters, $params);
    $stmt = $pdo->prepare("SELECT p.age FROM patients p $where_conditions");
    $stmt->execute($params);
    return $stmt->fetchAll(PDO::FETCH_COLUMN);
}

function getStatusDistribution($pdo, $filters) {
    $where_conditions = buildWhereConditions($filters, $params);
    $stmt = $pdo->prepare("SELECT p.status, COUNT(*) as count FROM patients p $where_conditions GROUP BY p.status");
    $stmt->execute($params);
    return $stmt->fetchAll(PDO::FETCH_ASSOC);
}

function getServicesDistribution($pdo, $filters) {
    $params = [];
    if (!empty($filters['gender']) || !empty($filters['age_group']) || !empty($filters['status'])) {
        $patient_conditions = buildWhereConditions($filters, $params, 'p.');
        $service_conditions = "INNER JOIN patients p ON i.patient_id = p.id $patient_conditions";
    } else {
        $service_conditions = '';
        $params[':start_date'] = $filters['start_date'];
        $params[':end_date'] = $filters['end_date'];
    }
    $stmt = $pdo->prepare("
        SELECT s.service_name, COUNT(*) as count
        FROM invoice_services isv
        INNER JOIN invoices i ON isv.invoice_id = i.id
        INNER JOIN services s ON isv.service_id = s.service_id
        $service_conditions
        WHERE i.invoice_date BETWEEN :start_date AND :end_date
        GROUP BY s.service_name
    ");
    $stmt->execute($params);
    return $stmt->fetchAll(PDO::FETCH_ASSOC);
}

function getInvoiceTrend($pdo, $filters) {
    $where_conditions = buildWhereConditions($filters, $params);
    $stmt = $pdo->prepare("
        SELECT DATE(i.invoice_date) as date, SUM(i.total_amount) as total_amount
        FROM invoices i
        INNER JOIN patients p ON i.patient_id = p.id
        $where_conditions
        GROUP BY DATE(i.invoice_date)
        ORDER BY date
    ");
    $stmt->execute($params);
    return $stmt->fetchAll(PDO::FETCH_ASSOC);
}

function getRegistrationTrend($pdo, $filters) {
    $where_conditions = buildWhereConditions($filters, $params);
    $stmt = $pdo->prepare("
        SELECT DATE(p.registration_date) as date, COUNT(*) as count
        FROM patients p
        $where_conditions
        GROUP BY DATE(p.registration_date)
        ORDER BY date
    ");
    $stmt->execute($params);
    return $stmt->fetchAll(PDO::FETCH_ASSOC);
}

?>
<!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>Admin Report Dashboard</title>
    <!-- Bootstrap 5 CSS for responsive layout and components -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Date Range Picker CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css">
    <!-- Chart.js Library -->
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <!-- Custom CSS for the design -->
    <style>
        /* Custom CSS for clean design */
        body {
            background-color: #f8f9fa;
            font-family: 'Roboto', Arial, sans-serif;
        }
        /* Header styling */
        .dashboard-header {
            background-color: #4F3F02; /* Brown */
            color: #fff;
            padding: 20px;
            text-align: center;
            border-radius: 10px;
            margin-bottom: 30px;
            box-shadow: 0 4px 10px rgba(0,0,0,0.1);
        }
        /* Card styling */
        .card {
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
            margin-bottom: 20px;
            background-color: #ffffff;
        }
        .card-header {
            background-color: #D1C287; /* Light golden */
            color: #4F3F02; /* Brown */
            font-weight: bold;
            border-bottom: none;
            padding: 15px;
        }
        /* Button styling */
        .btn-primary {
            background-color: #4F3F02; /* Brown */
            border-color: #4F3F02;
            color: #fff;
            font-weight: bold;
            border-radius: 50px;
        }
        .btn-primary:hover {
            background-color: #D1C287; /* Light golden */
            border-color: #D1C287;
            color: #4F3F02; /* Brown */
        }
        .btn-secondary {
            background-color: #D1C287; /* Light golden */
            border-color: #D1C287;
            color: #4F3F02; /* Brown */
            font-weight: bold;
            border-radius: 50px;
        }
        .btn-secondary:hover {
            background-color: #4F3F02; /* Brown */
            color: #fff;
        }
        /* Form control styling */
        .form-control, .form-select {
            border-radius: 8px;
        }
        /* DateRangePicker styling */
        .daterangepicker td.active, .daterangepicker td.active:hover {
            background-color: #4F3F02;
        }
        /* Print button styling */
        #printReport {
            background-color: #28a745; /* Green */
            border-color: #28a745;
            color: #fff;
            font-weight: bold;
            border-radius: 50px;
        }
        #printReport:hover {
            background-color: #218838; /* Dark green */
            border-color: #1e7e34;
            color: #fff;
        }
        /* Adjust chart sizes */
        canvas {
            max-height: 400px;
        }
    </style>
</head>
<body>
    <!-- Main Container -->
    <div class="container-fluid">
        <!-- Header -->
        <div class="dashboard-header">
            <h1>Admin Report Dashboard</h1>
            <p>Comprehensive Patient Data Analysis</p>
        </div>

        <!-- Filters and Print Button -->
        <div class="row mb-4">
            <div class="col-md-12">
                <!-- Filter Card -->
                <div class="card">
                    <div class="card-header">Filters</div>
                    <div class="card-body">
                        <form id="filterForm" method="GET" class="row g-3">
                            <!-- Date Range Picker -->
                            <div class="col-md-3">
                                <label for="daterange" class="form-label">Date Range:</label>
                                <input type="text" id="daterange" name="daterange" class="form-control" value="<?= htmlspecialchars($start_date) ?> - <?= htmlspecialchars($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>
                            <!-- Gender Filter -->
                            <div class="col-md-3">
                                <label for="gender_filter" class="form-label">Gender:</label>
                                <select id="gender_filter" name="gender_filter" class="form-select">
                                    <option value="">All</option>
                                    <option value="Male" <?= $gender_filter == 'Male' ? 'selected' : '' ?>>Male</option>
                                    <option value="Female" <?= $gender_filter == 'Female' ? 'selected' : '' ?>>Female</option>
                                    <option value="Other" <?= $gender_filter == 'Other' ? 'selected' : '' ?>>Other</option>
                                </select>
                            </div>
                            <!-- Age Group Filter -->
                            <div class="col-md-3">
                                <label for="age_group_filter" class="form-label">Age Group:</label>
                                <select id="age_group_filter" name="age_group_filter" class="form-select">
                                    <option value="">All</option>
                                    <option value="under_18" <?= $age_group_filter == 'under_18' ? 'selected' : '' ?>>Under 18</option>
                                    <option value="18_30" <?= $age_group_filter == '18_30' ? 'selected' : '' ?>>18-30</option>
                                    <option value="31_50" <?= $age_group_filter == '31_50' ? 'selected' : '' ?>>31-50</option>
                                    <option value="51_70" <?= $age_group_filter == '51_70' ? 'selected' : '' ?>>51-70</option>
                                    <option value="over_70" <?= $age_group_filter == 'over_70' ? 'selected' : '' ?>>Over 70</option>
                                </select>
                            </div>
                            <!-- Status Filter -->
                            <div class="col-md-3">
                                <label for="status_filter" class="form-label">Status:</label>
                                <select id="status_filter" name="status_filter" class="form-select">
                                    <option value="">All</option>
                                    <?php
                                    $status_options_display = ['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_display as $option) {
                                        echo "<option value=\"" . htmlspecialchars($option) . "\"" . ($status_filter == $option ? ' selected' : '') . ">" . htmlspecialchars($option) . "</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                            <!-- Service Filter -->
                            <div class="col-md-3">
                                <label for="service_filter" class="form-label">Service:</label>
                                <select id="service_filter" name="service_filter" class="form-select">
                                    <option value="">All</option>
                                    <?php
                                    // Fetch all services from the database
                                    $stmt = $pdo->query("SELECT DISTINCT service_name FROM services ORDER BY service_name");
                                    $services = $stmt->fetchAll(PDO::FETCH_COLUMN);
                                    foreach ($services as $service) {
                                        echo "<option value=\"" . htmlspecialchars($service) . "\"" . ($service_filter == $service ? ' selected' : '') . ">" . htmlspecialchars($service) . "</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                            <!-- Buttons -->
                            <div class="col-md-12 d-flex justify-content-end mt-3">
                                <button type="submit" class="btn btn-primary">Apply Filters</button>
                                <button type="button" id="resetFilters" class="btn btn-secondary ms-2">Reset Filters</button>
                                <button type="button" id="printReport" class="btn btn-success ms-2">Print Report</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

        <!-- Report Content -->
        <div id="reportContent">
            <!-- Total Patients Card -->
            <div class="row">
                <div class="col-md-12">
                    <div class="card text-center">
                        <div class="card-body">
                            <h5 class="card-title">Total Patients</h5>
                            <h2 class="card-text"><?= htmlspecialchars($total_patients) ?></h2>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Charts Row -->
            <div class="row">
                <!-- Gender Distribution Chart -->
                <div class="col-lg-6 col-md-12">
                    <div class="card h-100">
                        <div class="card-header">Gender Distribution</div>
                        <div class="card-body">
                            <canvas id="genderChart"></canvas>
                        </div>
                    </div>
                </div>
                <!-- Age Distribution Chart -->
                <div class="col-lg-6 col-md-12">
                    <div class="card h-100">
                        <div class="card-header">Age Distribution</div>
                        <div class="card-body">
                            <canvas id="ageChart"></canvas>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Additional Charts Row -->
            <div class="row">
                <!-- Status Distribution Chart -->
                <div class="col-lg-6 col-md-12">
                    <div class="card h-100">
                        <div class="card-header">Patient Status Distribution</div>
                        <div class="card-body">
                            <canvas id="statusChart"></canvas>
                        </div>
                    </div>
                </div>
                <!-- Services Rendered Distribution Chart -->
                <div class="col-lg-6 col-md-12">
                    <div class="card h-100">
                        <div class="card-header">Services Rendered Distribution</div>
                        <div class="card-body">
                            <canvas id="servicesChart"></canvas>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Invoice Amount Trend Chart -->
            <div class="row">
                <div class="col-md-6">
                    <div class="card">
                        <div class="card-header">Invoice Amount Over Time</div>
                        <div class="card-body">
                            <canvas id="invoiceTrendChart"></canvas>
                        </div>
                    </div>
                </div>
                <!-- Patient Registration Trend Chart -->
                <div class="col-md-6">
                    <div class="card">
                        <div class="card-header">Patient Registration Over Time</div>
                        <div class="card-body">
                            <canvas id="registrationTrendChart"></canvas>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- End of Report Content -->

        <!-- Back to Dashboard Button -->
        <a href="admin_dashboard.php" class="btn btn-secondary mt-3 mb-5">Back to Dashboard</a>
    </div>
    <!-- Include jQuery and Bootstrap JS for components -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <!-- Bootstrap 5 JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script>
    <!-- Moment.js for date manipulation -->
    <script src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
    <!-- Date Range Picker JS -->
    <script src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
    <!-- Custom JS scripts -->
    <script>
        $(document).ready(function() {
            // Initialize Date Range Picker
            $('#daterange').daterangepicker({
                startDate: moment('<?= htmlspecialchars($start_date) ?>'),
                endDate: moment('<?= htmlspecialchars($end_date) ?>'),
                locale: {
                    format: 'YYYY-MM-DD'
                }
            }, function(start, end, label) {
                $('#start_date').val(start.format('YYYY-MM-DD'));
                $('#end_date').val(end.format('YYYY-MM-DD'));
            });

            // Reset filters by reloading the page without any GET parameters
            $('#resetFilters').click(function() {
                window.location.href = 'admin_report.php';
            });

            // Print Report functionality
            $('#printReport').click(function() {
                window.print();
            });

            // Gender Distribution Chart
            var genderCtx = document.getElementById('genderChart').getContext('2d');
            var genderChart = new Chart(genderCtx, {
                type: 'pie',
                data: {
                    labels: <?= json_encode(array_column($gender_distribution, 'gender')) ?>,
                    datasets: [{
                        data: <?= json_encode(array_column($gender_distribution, 'count')) ?>,
                        backgroundColor: ['#4F3F02', '#D1C287', '#FFCE56'] // Colors for Male, Female, Other
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: {
                        legend: {
                            position: 'bottom'
                        }
                    }
                }
            });

            // Age Distribution Chart (Histogram)
            var ageCtx = document.getElementById('ageChart').getContext('2d');
            var ages = <?= json_encode($age_distribution) ?>;
            var ageCounts = {};
            ages.forEach(function(age) {
                var ageGroup = Math.floor(age / 10) * 10;
                var label = ageGroup + '-' + (ageGroup + 9);
                if (!ageCounts[label]) {
                    ageCounts[label] = 0;
                }
                ageCounts[label]++;
            });
            var ageLabels = Object.keys(ageCounts);
            var ageData = Object.values(ageCounts);

            var ageChart = new Chart(ageCtx, {
                type: 'bar',
                data: {
                    labels: ageLabels,
                    datasets: [{
                        label: 'Number of Patients',
                        data: ageData,
                        backgroundColor: '#4F3F02'
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    scales: {
                        y: {
                            beginAtZero: true,
                            stepSize: 1
                        }
                    },
                    plugins: {
                        legend: {
                            display: false
                        }
                    }
                }
            });

            // Status Distribution Chart
            var statusCtx = document.getElementById('statusChart').getContext('2d');
            var statusChart = new Chart(statusCtx, {
                type: 'pie',
                data: {
                    labels: <?= json_encode(array_column($status_distribution, 'status')) ?>,
                    datasets: [{
                        data: <?= json_encode(array_column($status_distribution, 'count')) ?>,
                        backgroundColor: [
                            '#FF6384', '#36A2EB', '#FFCE56',
                            '#4BC0C0', '#9966FF', '#FF9F40',
                            '#C9CBCF', '#8D6E63', '#7986CB',
                            '#81C784', '#DCE775', '#FFB74D', '#BA68C8'
                        ] // Extend colors as needed
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: {
                        legend: {
                            position: 'bottom'
                        }
                    }
                }
            });

            // Services Rendered Distribution Chart
            var servicesCtx = document.getElementById('servicesChart').getContext('2d');
            var servicesLabels = <?= json_encode(array_column($services_distribution, 'service_name')) ?>;
            var servicesData = <?= json_encode(array_column($services_distribution, 'count')) ?>;
            var servicesChart = new Chart(servicesCtx, {
                type: 'pie',
                data: {
                    labels: servicesLabels,
                    datasets: [{
                        data: servicesData,
                        backgroundColor: [
                            '#4F3F02', '#D1C287', '#FFCE56',
                            '#4BC0C0', '#9966FF', '#FF9F40',
                            '#C9CBCF', '#8D6E63', '#7986CB',
                            '#81C784'
                        ] // Extend colors as needed
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: {
                        legend: {
                            position: 'bottom'
                        }
                    }
                }
            });

            // Invoice Amount Trend Chart (Line)
            var invoiceTrendCtx = document.getElementById('invoiceTrendChart').getContext('2d');
            var invoiceTrendLabels = <?= json_encode(array_column($invoice_trend, 'date')) ?>;
            var invoiceTrendData = <?= json_encode(array_column($invoice_trend, 'total_amount')) ?>;
            var invoiceTrendChart = new Chart(invoiceTrendCtx, {
                type: 'line',
                data: {
                    labels: invoiceTrendLabels,
                    datasets: [{
                        label: 'Total Invoice Amount ($)',
                        data: invoiceTrendData,
                        backgroundColor: 'rgba(79, 63, 2, 0.2)',
                        borderColor: '#4F3F02',
                        fill: true,
                        tension: 0.2
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    scales: {
                        x: {
                            type: 'time',
                            time: {
                                unit: 'day',
                                displayFormats: {
                                    day: 'YYYY-MM-DD'
                                }
                            },
                            title: {
                                display: true,
                                text: 'Date'
                            }
                        },
                        y: {
                            beginAtZero: true,
                            title: {
                                display: true,
                                text: 'Amount ($)'
                            }
                        }
                    },
                    plugins: {
                        legend: {
                            display: true,
                            position: 'top'
                        }
                    }
                }
            });

            // Patient Registration Trend Chart (Line)
            var registrationTrendCtx = document.getElementById('registrationTrendChart').getContext('2d');
            var registrationTrendLabels = <?= json_encode(array_column($registration_trend, 'date')) ?>;
            var registrationTrendData = <?= json_encode(array_column($registration_trend, 'count')) ?>;
            var registrationTrendChart = new Chart(registrationTrendCtx, {
                type: 'line',
                data: {
                    labels: registrationTrendLabels,
                    datasets: [{
                        label: 'New Registrations',
                        data: registrationTrendData,
                        backgroundColor: 'rgba(209, 194, 135, 0.2)',
                        borderColor: '#D1C287',
                        fill: true,
                        tension: 0.2
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    scales: {
                        x: {
                            type: 'time',
                            time: {
                                unit: 'day',
                                displayFormats: {
                                    day: 'YYYY-MM-DD'
                                }
                            },
                            title: {
                                display: true,
                                text: 'Date'
                            }
                        },
                        y: {
                            beginAtZero: true,
                            title: {
                                display: true,
                                text: 'Number of Registrations'
                            }
                        }
                    },
                    plugins: {
                        legend: {
                            display: true,
                            position: 'top'
                        }
                    }
                }
            });
        });
    </script>
</body>
</html>) and make it cool design and use (===Database u406552082_info

== Table structure for table admins

|------
|Column|Type|Null|Default
|------
|//**id**//|int(11)|No|
|**username**|varchar(50)|No|
|password|varchar(255)|No|
|email|varchar(100)|No|
== Dumping data for table admins

|1|mmtawfik|$2y$10$V9jnPR/dZN0uoiHPQa038uBXCS1NC7xV.uVJxnlE6lmICqAwpSr1O|mmtawfik@example.com
|<PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>
== Table structure for table budgets

|------
|Column|Type|Null|Default
|------
|//**id**//|int(11)|No|
|month|varchar(7)|Yes|NULL
|budgeted_revenue|decimal(10,2)|Yes|NULL
|budgeted_expenses|decimal(10,2)|Yes|NULL
|notes|text|Yes|NULL
== Dumping data for table budgets

|1|2024-09|20000.00|1000.00| 
== Table structure for table comments

|------
|Column|Type|Null|Default
|------
|//**id**//|int(11)|No|
|patient_id|int(11)|No|
|sender|enum('patient', 'doctor', 'admin')|No|
|message|text|No|
|timestamp|datetime|Yes|current_timestamp()
|parent_id|int(11)|Yes|NULL
== Dumping data for table comments

|44|16|patient|Good|2024-10-03 03:28:46|NULL
|45|16|admin|Thanks|2024-10-03 03:29:02|44
== Table structure for table doctors

|------
|Column|Type|Null|Default
|------
|//**id**//|int(11)|No|
|employee_id|int(11)|No|
|name|varchar(255)|No|
|**username**|varchar(100)|No|
|password|varchar(255)|No|
|**email**|varchar(255)|No|
|specialization|varchar(255)|Yes|NULL
|phone|varchar(20)|Yes|NULL
|registration_date|date|Yes|curdate()
|profile_picture|varchar(255)|Yes|NULL
|department|varchar(100)|Yes|NULL
|date_of_joining|date|Yes|NULL
|status|enum('active', 'inactive')|Yes|active
== Dumping data for table doctors

|12|18|Dr. Engy Shahbander|drengy|$2y$10$Tx74blqFrEdOB2tOZy/Qye7ndsmS9aBMUo23mOG0a9zgfHPoNBnI2|engy.shahbander@gmail.com|CEO - Longevacare|0151315489|2024-10-03|NULL|NULL|NULL|active
== Table structure for table doctor_patient

|------
|Column|Type|Null|Default
|------
|//**id**//|int(11)|No|
|**doctor_id**|int(11)|No|
|**patient_id**|int(11)|No|
== Dumping data for table doctor_patient

|14|3|13
|31|12|13
|30|12|16
== Table structure for table employees

|------
|Column|Type|Null|Default
|------
|//**id**//|int(11)|No|
|name|varchar(255)|No|
|role|enum('admin', 'doctor', 'staff', 'accountant')|No|
|**email**|varchar(255)|No|
|phone|varchar(20)|Yes|NULL
|department|varchar(100)|Yes|NULL
|date_of_joining|date|Yes|NULL
|status|enum('active', 'inactive')|Yes|active
|**username**|varchar(100)|No|
|password|varchar(255)|No|
|created_at|timestamp|Yes|current_timestamp()
|updated_at|timestamp|Yes|current_timestamp()
|profile_picture|varchar(255)|Yes|NULL
|specialization|varchar(255)|Yes|NULL
== Dumping data for table employees

|<PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>|0105131548|Nursing|2024-10-15|active|doaa123|$2y$10$jezEFBAuvB.2J56DTgGeZ.PbpKBaHGZARBNjy5mvnR21lImE9aala|2024-10-03 01:38:20|2024-10-03 01:38:20|doaa123_1727919500.jpg|Nurse
|18|Dr. Engy <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>|0151315489|Administration|2024-10-03|active|drengy|$2y$10$Tx74blqFrEdOB2tOZy/Qye7ndsmS9aBMUo23mOG0a9zgfHPoNBnI2|2024-10-03 01:51:32|2024-10-03 03:34:49|drengy_18.jpg|CEO - Longevacare
|19|Mahmoud <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>|01119235049|Administration|2024-10-03|active|mahmoudtawfik|$2y$10$qciyhqx0IHsZMviAa9YceOuw8JZ2RaK2CR2b2Ny.nOT1bogVRSKoy|2024-10-03 01:54:51|2024-10-03 03:35:14|mahmoudtawfik_19.png|Developer
|20|Mohamed <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>|0105134856|Accounting|2024-10-01|active|mohamed_5049|$2y$10$/RZk3a7dRiM4zSssCWK8ae7QidsQooQ5Y0U6k9KrE7d5XwN5h5IUC|2024-10-03 04:15:27|2024-10-03 04:15:40|default_profile.png|Accountant
== Table structure for table health_records

|------
|Column|Type|Null|Default
|------
|//**id**//|int(11)|No|
|patient_id|int(11)|No|
|blood_pressure|varchar(20)|Yes|NULL
|weight|decimal(5,2)|Yes|NULL
|bmi|decimal(4,2)|Yes|NULL
|cholesterol|decimal(5,2)|Yes|NULL
|prescription|text|Yes|NULL
|treatment_progress|text|Yes|NULL
|record_date|date|No|
== Dumping data for table health_records

|36|12|80|80.00|80.00|5.00|STR - 32|Isn't good for this patient|2024-10-02
|37|16|80|80.00|99.99|169.00|This new precept|Hi|2024-10-03
== Table structure for table insurance_claims

|------
|Column|Type|Null|Default
|------
|//**id**//|int(11)|No|
|patient_id|int(11)|Yes|NULL
|invoice_id|int(11)|Yes|NULL
|claim_amount|decimal(10,2)|Yes|NULL
|status|enum('Pending', 'Approved', 'Rejected')|Yes|NULL
|submission_date|date|Yes|NULL
|processing_date|date|Yes|NULL
|notes|text|Yes|NULL
== Dumping data for table insurance_claims

|1|16|31|1000.00|Rejected|2024-10-05|2024-10-05| 
== Table structure for table invoices

|------
|Column|Type|Null|Default
|------
|//**id**//|int(11)|No|
|patient_id|int(11)|No|
|service_name|varchar(255)|No|
|service_description|text|Yes|NULL
|cost|decimal(10,2)|No|
|tax_rate|decimal(5,2)|Yes|0.00
|discount|decimal(5,2)|Yes|0.00
|total_amount|decimal(10,2)|No|
|invoice_date|date|Yes|curdate()
|notes|text|Yes|NULL
|tax|decimal(5,2)|Yes|0.00
== Dumping data for table invoices

|19|13| |NULL|0.00|0.00|300.00|1284.00|2024-09-29| |7.00
|28|15| |NULL|0.00|0.00|150.00|720.00|2024-09-30| |20.00
|31|16| | |750.00|5.00|100.00|650.00|2024-10-03| |0.00
== Table structure for table invoice_services

|------
|Column|Type|Null|Default
|------
|//**id**//|int(11)|No|
|invoice_id|int(11)|No|
|service_id|int(11)|No|
|service_name|varchar(255)|No|
|cost|decimal(10,2)|No|
== Dumping data for table invoice_services

|13|19|10|Stress|750.00
|14|19|9|Depression|750.00
|36|28|10|Stress|750.00
|39|31|9|Depression|750.00
== Table structure for table patients

|------
|Column|Type|Null|Default
|------
|//**id**//|int(11)|No|
|name|varchar(100)|No|
|age|int(11)|No|
|gender|enum('Male', 'Female', 'Other')|No|
|phone|varchar(20)|Yes|NULL
|email|varchar(100)|Yes|NULL
|medical_history|text|Yes|NULL
|created_at|timestamp|Yes|current_timestamp()
|updated_at|timestamp|Yes|current_timestamp()
|date_of_birth|date|Yes|NULL
|registration_datetime|datetime|Yes|current_timestamp()
|registration_date|date|Yes|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')|Yes|Initial Consultation
|doctor_id|int(11)|Yes|NULL
== Dumping data for table patients

|<PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>|DEP - XRA 12Mg|2024-09-28 23:15:43|2024-09-29 02:53:36|1999-09-28|2024-09-28 23:15:43|2024-09-28|Discontinued|NULL
|<PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>|Sr - Dep - 323Mg/d|2024-09-28 23:17:04|2024-09-29 02:53:27|1963-09-28|2024-09-28 23:17:04|2024-09-28|Awaiting Test Results|NULL
|13|Ahmed <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>|Has Bad Medical History|2024-09-29 01:14:56|2024-09-29 21:59:09|1988-09-29|2024-09-29 01:14:56|2024-09-29|Relapsed|NULL
|15|Ali <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>|.|2024-09-29 23:23:06|2024-09-29 23:24:12|1998-09-29|2024-09-29 23:23:06|2024-09-29|Paused|NULL
|16|Soha <PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>|Doesn't have Medical History 1|2024-10-03 02:28:58|2024-10-03 02:29:52|2001-10-03|2024-10-03 02:28:58|2024-10-03|Paused|NULL
== Table structure for table patient_logins

|------
|Column|Type|Null|Default
|------
|//**id**//|int(11)|No|
|**patient_id**|int(11)|No|
|**username**|varchar(50)|No|
|password|varchar(255)|No|
== Dumping data for table patient_logins

|24|11|mahmoud_507|$2y$10$aWr138nBYi1CPnOp6Zd2geqUfpAO6zhAGWh0EUtiEMNcUIEIBw4RS
|25|12|mona_630|$2y$10$YMU9RdPOpW1MIELx8W6NBel0fl7NmzGl3GiRitSCQadQYx8Ux4U8e
|26|13|ahmed_697|$2y$10$PVsNfLKdc5gVD0TxjIil8u968rEq3ixyeOKImGLJZXvT8jiOjHNwa
|28|15|ali_127|$2y$10$sNDe.Ka5.Ne9z409SKVew.Diqw6P5cFurRyU1P1pBrTZRV6.LeJFy
|29|16|soha_554|$2y$10$dZEFXbXdX8oe2CWRBFxcOek1DD7O4iiOuvxB3A3cMgdKu7GutJ39K
== Table structure for table payments

|------
|Column|Type|Null|Default
|------
|//**id**//|int(11)|No|
|patient_id|int(11)|No|
|invoice_id|int(11)|No|
|amount_paid|decimal(10,2)|No|
|payment_date|date|No|
|payment_method|varchar(50)|Yes|NULL
|notes|text|Yes|NULL
== Dumping data for table payments

== Table structure for table salaries

|------
|Column|Type|Null|Default
|------
|//**id**//|int(11)|No|
|employee_id|int(11)|No|
|basic_salary|decimal(10,2)|No|
|bonuses|decimal(10,2)|Yes|0.00
|deductions|decimal(10,2)|Yes|0.00
|overtime_hours|int(11)|Yes|0
|overtime_rate|decimal(10,2)|Yes|0.00
|tax|decimal(10,2)|Yes|0.00
|payment_date|date|No|
|net_salary|decimal(10,2)|No|
|status|enum('Pending', 'Paid')|Yes|Pending
|notes|text|Yes|NULL
|payslip_path|varchar(255)|Yes|NULL
== Dumping data for table salaries

== Table structure for table services

|------
|Column|Type|Null|Default
|------
|//**service_id**//|int(11)|No|
|service_name|varchar(255)|No|
|service_price|decimal(10,2)|No|
|service_description|text|Yes|NULL
|created_at|timestamp|Yes|current_timestamp()
|updated_at|timestamp|Yes|current_timestamp()
== Dumping data for table services

|9|Depression|750.00|New Service Depression - longevacare|2024-09-28 23:19:56|2024-09-28 23:19:56
|10|Stress|750.00|New Service Stress - Longevacare|2024-09-29 10:24:07|2024-09-29 10:24:07) and add more features and type full codes and use this (require_once '../assets/libraries/tcpdf/tcpdf.php'; // Correct path to TCPDF library
) to print