Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fea1dbbb79 | ||
|
|
c8d83e1d5c | ||
|
|
f0947adeb2 |
43
add_prescription.php
Normal file
43
add_prescription.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_role('doctor');
|
||||
require_once 'db/config.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$response = ['success' => false, 'message' => 'An unknown error occurred.'];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$visit_id = $_POST['visit_id'] ?? null;
|
||||
$patient_id = $_POST['patient_id'] ?? null;
|
||||
$medication = $_POST['medication'] ?? null;
|
||||
$dosage = $_POST['dosage'] ?? null;
|
||||
$frequency = $_POST['frequency'] ?? null;
|
||||
$notes = $_POST['notes'] ?? '';
|
||||
$doctor_id = $_SESSION['user_id'] ?? null;
|
||||
|
||||
if ($visit_id && $patient_id && $doctor_id && $medication && $dosage && $frequency) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare(
|
||||
"INSERT INTO prescriptions (visit_id, patient_id, doctor_id, medication, dosage, frequency, notes)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)"
|
||||
);
|
||||
$stmt->execute([$visit_id, $patient_id, $doctor_id, $medication, $dosage, $frequency, $notes]);
|
||||
|
||||
$response['success'] = true;
|
||||
$response['message'] = 'Prescription saved successfully.';
|
||||
|
||||
} catch (PDOException $e) {
|
||||
// In a real app, log this error instead of echoing it.
|
||||
$response['message'] = 'Database error: ' . $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
$response['message'] = 'Invalid or missing data provided.';
|
||||
}
|
||||
} else {
|
||||
$response['message'] = 'Invalid request method.';
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
?>
|
||||
12
alter_visits_table.php
Normal file
12
alter_visits_table.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
$sql = "ALTER TABLE `patient_visits` CHANGE `id` `visit_id` INT(11) NOT NULL AUTO_INCREMENT;";
|
||||
$pdo->exec($sql);
|
||||
echo "Table 'patient_visits' altered successfully. Column 'id' renamed to 'visit_id'.\n";
|
||||
} catch (PDOException $e) {
|
||||
die("Database error: " . $e->getMessage());
|
||||
}
|
||||
?>
|
||||
271
assets/css/custom.css
Normal file
271
assets/css/custom.css
Normal file
@ -0,0 +1,271 @@
|
||||
|
||||
:root {
|
||||
--primary-color: #6a5acd; /* SlateBlue */
|
||||
--primary-color-dark: #483d8b; /* DarkSlateBlue */
|
||||
--secondary-color: #f0f8ff; /* AliceBlue */
|
||||
--text-color: #333;
|
||||
--text-color-light: #777;
|
||||
--border-color: #e6e6fa; /* Lavender */
|
||||
--sidebar-bg: #ffffff;
|
||||
--sidebar-link-color: #555;
|
||||
--sidebar-link-hover-bg: #f0f0f0;
|
||||
--sidebar-link-active-color: #ffffff;
|
||||
--sidebar-link-active-bg: var(--primary-color);
|
||||
--card-bg: #ffffff;
|
||||
--card-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
|
||||
--font-family: 'Poppins', sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: var(--font-family);
|
||||
background-color: var(--secondary-color);
|
||||
color: var(--text-color);
|
||||
font-size: 15px;
|
||||
background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23dcdcdc' fill-opacity='0.3'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
|
||||
}
|
||||
|
||||
.page-wrapper {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: 260px;
|
||||
background-color: var(--sidebar-bg);
|
||||
height: 100vh;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
border-right: 1px solid var(--border-color);
|
||||
padding: 1.5rem 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: 0 0 15px rgba(0,0,0,0.05);
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.sidebar-brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
color: var(--primary-color);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.sidebar-brand .bi {
|
||||
font-size: 2rem;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
.sidebar-nav {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.sidebar .nav-link {
|
||||
color: var(--sidebar-link-color);
|
||||
border-radius: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0.75rem 1rem;
|
||||
transition: background-color 0.2s, color 0.2s;
|
||||
}
|
||||
|
||||
.sidebar .nav-link:hover {
|
||||
color: var(--primary-color);
|
||||
background-color: var(--sidebar-link-hover-bg);
|
||||
}
|
||||
|
||||
.sidebar .nav-link.active {
|
||||
color: var(--sidebar-link-active-color);
|
||||
background-color: var(--sidebar-link-active-bg);
|
||||
box-shadow: 0 2px 5px rgba(106, 90, 205, 0.3);
|
||||
}
|
||||
|
||||
.sidebar .nav-link .bi {
|
||||
font-size: 1.2rem;
|
||||
margin-right: 1rem;
|
||||
width: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sidebar-footer {
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
flex-grow: 1;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.header {
|
||||
margin-bottom: 2rem;
|
||||
padding-bottom: 1rem;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.header-title {
|
||||
font-size: 2.2rem;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.header-subtitle {
|
||||
font-size: 1rem;
|
||||
color: var(--text-color-light);
|
||||
}
|
||||
|
||||
.content-card, .card {
|
||||
background-color: var(--card-bg);
|
||||
border-radius: 0.75rem;
|
||||
box-shadow: var(--card-shadow);
|
||||
border: none;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
background-color: transparent;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
padding: 1.5rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.card-title-text, .card-header .m-0 {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.card-body {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.table thead th {
|
||||
border-bottom: 2px solid var(--border-color);
|
||||
font-weight: 600;
|
||||
color: var(--text-color-light);
|
||||
padding: 1rem 1.5rem;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.table tbody tr {
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.table tbody tr:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.table tbody tr:hover {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
.table td, .table th {
|
||||
padding: 1rem 1.5rem;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.table a {
|
||||
color: var(--primary-color);
|
||||
text-decoration: none;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.table a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.badge.bg-success-soft {
|
||||
background-color: rgba(28, 200, 138, 0.1);
|
||||
color: #1cc88a;
|
||||
}
|
||||
|
||||
.badge.bg-warning-soft {
|
||||
background-color: rgba(246, 194, 62, 0.1);
|
||||
color: #f6c23e;
|
||||
}
|
||||
|
||||
.badge.bg-info-soft {
|
||||
background-color: rgba(54, 185, 204, 0.1);
|
||||
color: #36b9cc;
|
||||
}
|
||||
|
||||
.btn {
|
||||
border-radius: 0.5rem;
|
||||
padding: 0.6rem 1.2rem;
|
||||
font-weight: 600;
|
||||
transition: all 0.2s;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
||||
}
|
||||
|
||||
.btn-primary, .btn-primary-custom {
|
||||
background-color: var(--primary-color);
|
||||
border-color: var(--primary-color);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover, .btn-primary-custom:hover {
|
||||
background-color: var(--primary-color-dark);
|
||||
border-color: var(--primary-color-dark);
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.form-control, .form-select {
|
||||
border-radius: 0.5rem;
|
||||
padding: 0.75rem 1rem;
|
||||
border: 1px solid var(--border-color);
|
||||
transition: border-color 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.form-control:focus, .form-select:focus {
|
||||
box-shadow: 0 0 0 0.25rem rgba(106, 90, 205, 0.15);
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
border-radius: 0.75rem;
|
||||
border: none;
|
||||
box-shadow: 0 8px 24px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.search-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
}
|
||||
.search-results {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 1000;
|
||||
border: 1px solid #ccc;
|
||||
background-color: #fff;
|
||||
border-radius: 0 0 5px 5px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
display: none;
|
||||
}
|
||||
.search-results a {
|
||||
display: block;
|
||||
padding: 10px;
|
||||
text-decoration: none;
|
||||
color: #333;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
.search-results a:hover {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.search-results a:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
17
auth.php
Normal file
17
auth.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Optional: Role-based access control
|
||||
function require_role($role) {
|
||||
if ($_SESSION['role'] !== $role) {
|
||||
// Redirect to a generic dashboard or an error page
|
||||
header("Location: login.php?error=unauthorized");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
||||
160
billing.php
Normal file
160
billing.php
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_role('receptionist');
|
||||
require_once 'db/config.php';
|
||||
|
||||
// Handle status update
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'mark_paid') {
|
||||
$visit_id_to_update = $_POST['visit_id'] ?? null;
|
||||
if ($visit_id_to_update) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("UPDATE patient_visits SET payment_status = 'paid' WHERE visit_id = ?");
|
||||
$stmt->execute([$visit_id_to_update]);
|
||||
header("Location: billing.php");
|
||||
exit;
|
||||
} catch (PDOException $e) {
|
||||
// Log error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch unpaid visits and calculate total cost
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare(
|
||||
"SELECT
|
||||
pv.visit_id,
|
||||
pv.cost as consultation_fee,
|
||||
p.patient_name,
|
||||
p.id as patient_id,
|
||||
u.username as doctor_name,
|
||||
pv.service_rendered,
|
||||
COALESCE((SELECT SUM(lt.cost) FROM ordered_tests ot JOIN lab_tests lt ON ot.test_id = lt.test_id WHERE ot.visit_id = pv.visit_id AND ot.test_type = 'lab'), 0) as lab_tests_cost,
|
||||
COALESCE((SELECT SUM(it.cost) FROM ordered_tests ot JOIN imaging_tests it ON ot.test_id = it.test_id WHERE ot.visit_id = pv.visit_id AND ot.test_type = 'imaging'), 0) as imaging_tests_cost
|
||||
FROM patient_visits pv
|
||||
JOIN patients p ON pv.patient_id = p.id
|
||||
JOIN users u ON pv.doctor_id = u.id
|
||||
WHERE pv.status = 'Completed' AND pv.payment_status = 'unpaid'
|
||||
ORDER BY pv.visit_time DESC"
|
||||
);
|
||||
$stmt->execute();
|
||||
$unpaid_visits = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
$unpaid_visits = [];
|
||||
// You should log the error in a real application
|
||||
// error_log($e->getMessage());
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Billing Management</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="page-wrapper">
|
||||
<!-- Sidebar -->
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<a href="index.php" class="sidebar-brand">
|
||||
<i class="bi bi-heart-pulse-fill"></i>
|
||||
<span>ClinicFlow</span>
|
||||
</a>
|
||||
</div>
|
||||
<nav class="sidebar-nav">
|
||||
<a href="reception.php" class="nav-link">
|
||||
<i class="bi bi-people-fill"></i>
|
||||
<span>Reception</span>
|
||||
</a>
|
||||
<a href="billing.php" class="nav-link active">
|
||||
<i class="bi bi-receipt"></i>
|
||||
<span>Billing</span>
|
||||
</a>
|
||||
<a href="doctor_dashboard.php" class="nav-link">
|
||||
<i class="bi bi-person-fill"></i>
|
||||
<span>Doctor</span>
|
||||
</a>
|
||||
</nav>
|
||||
<div class="sidebar-footer">
|
||||
<div class="dropdown">
|
||||
<a href="#" class="d-flex align-items-center text-white text-decoration-none dropdown-toggle" id="dropdownUser1" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-person-circle me-2"></i>
|
||||
<strong><?php echo htmlspecialchars($_SESSION['username']); ?></strong>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-dark text-small shadow" aria-labelledby="dropdownUser1">
|
||||
<li><a class="dropdown-item" href="logout.php">Sign out</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="main-content">
|
||||
<div class="container-fluid">
|
||||
<div class="header">
|
||||
<h1 class="header-title">Billing</h1>
|
||||
<p class="header-subtitle">Manage outstanding payments.</p>
|
||||
</div>
|
||||
|
||||
<div class="card content-card">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title-text"><i class="bi bi-hourglass-split me-2"></i>Pending Payments</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Patient Name</th>
|
||||
<th>Doctor</th>
|
||||
<th>Service Rendered</th>
|
||||
<th>Total Bill</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (!empty($unpaid_visits)):
|
||||
foreach ($unpaid_visits as $visit):
|
||||
$total_bill = $visit['consultation_fee'] + $visit['lab_tests_cost'] + $visit['imaging_tests_cost'];
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="patient_profile.php?id=<?php echo $visit['patient_id']; ?>"><?php echo htmlspecialchars($visit['patient_name']); ?></a></td>
|
||||
<td>Dr. <?php echo htmlspecialchars($visit['doctor_name']); ?></td>
|
||||
<td><?php echo htmlspecialchars($visit['service_rendered']); ?></td>
|
||||
<td>$<?php echo htmlspecialchars(number_format($total_bill, 2)); ?></td>
|
||||
<td>
|
||||
<form method="POST" action="billing.php" style="display:inline;">
|
||||
<input type="hidden" name="visit_id" value="<?php echo $visit['visit_id']; ?>">
|
||||
<input type="hidden" name="action" value="mark_paid">
|
||||
<button type="submit" class="btn btn-sm btn-success"><i class="bi bi-check-lg"></i> Mark as Paid</button>
|
||||
</form>
|
||||
<a href="invoice.php?visit_id=<?php echo $visit['visit_id']; ?>" class="btn btn-sm btn-info" target="_blank"><i class="bi bi-printer"></i> Invoice</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else:
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="5" class="text-center text-muted">No pending payments.</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,17 +1,36 @@
|
||||
<?php
|
||||
// Generated by setup_mariadb_project.sh — edit as needed.
|
||||
define('DB_HOST', '127.0.0.1');
|
||||
define('DB_NAME', 'app_35705');
|
||||
define('DB_USER', 'app_35705');
|
||||
define('DB_PASS', 'cdc156d8-b1ec-4426-86fb-b1e546c1a442');
|
||||
// Prevent direct file access
|
||||
if (basename(__FILE__) == basename($_SERVER['SCRIPT_FILENAME'])) {
|
||||
header('Location: /');
|
||||
exit;
|
||||
}
|
||||
|
||||
function db() {
|
||||
static $pdo;
|
||||
if (!$pdo) {
|
||||
$pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
|
||||
if ($pdo) {
|
||||
return $pdo;
|
||||
}
|
||||
|
||||
$host = getenv('DB_HOST') ?: '127.0.0.1';
|
||||
$port = getenv('DB_PORT') ?: '3306';
|
||||
$dbname = getenv('DB_NAME') ?: 'app_35705';
|
||||
$user = getenv('DB_USER') ?: 'app_35705';
|
||||
$pass = getenv('DB_PASS') ?: 'cdc156d8-b1ec-4426-86fb-b1e546c1a442';
|
||||
$charset = 'utf8mb4';
|
||||
|
||||
$dsn = "mysql:host=$host;port=$port;dbname=$dbname;charset=$charset";
|
||||
$options = [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
]);
|
||||
}
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
];
|
||||
|
||||
try {
|
||||
$pdo = new PDO($dsn, $user, $pass, $options);
|
||||
return $pdo;
|
||||
} catch (PDOException $e) {
|
||||
// In a real app, you'd log this error and show a generic message
|
||||
throw new PDOException($e->getMessage(), (int)$e->getCode());
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
34
dispense.php
Normal file
34
dispense.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_role('receptionist'); // Or a new 'pharmacist' role
|
||||
require_once 'db/config.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
$response = ['success' => false, 'message' => 'Invalid request.'];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$prescription_id = $_POST['prescription_id'] ?? null;
|
||||
$user_id = $_SESSION['user_id'] ?? null;
|
||||
|
||||
if ($prescription_id && $user_id) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare(
|
||||
"UPDATE prescriptions SET status = 'Dispensed', dispensed_at = CURRENT_TIMESTAMP, dispensed_by = ? WHERE id = ?"
|
||||
);
|
||||
|
||||
if ($stmt->execute([$user_id, $prescription_id])) {
|
||||
$response = ['success' => true, 'message' => 'Prescription marked as dispensed.'];
|
||||
} else {
|
||||
$response['message'] = 'Failed to update prescription status.';
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$response['message'] = 'Database error: ' . $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
$response['message'] = 'Missing prescription ID or user not logged in.';
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
?>
|
||||
495
doctor_dashboard.php
Normal file
495
doctor_dashboard.php
Normal file
@ -0,0 +1,495 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_role('doctor');
|
||||
require_once 'db/config.php';
|
||||
|
||||
// Get doctor ID from session
|
||||
$doctor_id = $_SESSION['user_id'] ?? 0;
|
||||
|
||||
// Fetch today's visits for the logged-in doctor
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare(
|
||||
"SELECT
|
||||
pv.id as visit_id,
|
||||
pv.status,
|
||||
pv.notes,
|
||||
p.id as patient_id,
|
||||
p.patient_id as patient_system_id,
|
||||
p.patient_name
|
||||
FROM patient_visits pv
|
||||
JOIN patients p ON pv.patient_id = p.id
|
||||
WHERE pv.doctor_id = ? AND DATE(pv.visit_time) = CURDATE()
|
||||
ORDER BY pv.visit_time DESC"
|
||||
);
|
||||
$stmt->execute([$doctor_id]);
|
||||
$visits = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
$visits = [];
|
||||
// In a real app, you'd want to log this error
|
||||
}
|
||||
|
||||
// Fetch doctor's details from users table
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
|
||||
$stmt->execute([$doctor_id]);
|
||||
$doctor = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
$doctor = null;
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Doctor's Dashboard</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="page-wrapper">
|
||||
<!-- Sidebar -->
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<a href="index.php" class="sidebar-brand">
|
||||
<i class="bi bi-heart-pulse-fill"></i>
|
||||
<span>ClinicFlow</span>
|
||||
</a>
|
||||
</div>
|
||||
<nav class="sidebar-nav">
|
||||
<a href="reception.php" class="nav-link">
|
||||
<i class="bi bi-people-fill"></i>
|
||||
<span>Reception</span>
|
||||
</a>
|
||||
<a href="doctor_dashboard.php" class="nav-link active">
|
||||
<i class="bi bi-person-fill"></i>
|
||||
<span>Doctor</span>
|
||||
</a>
|
||||
<a href="lab_reports.php" class="nav-link">
|
||||
<i class="bi bi-file-earmark-medical"></i>
|
||||
<span>Lab Reports</span>
|
||||
</a>
|
||||
<a href="pharmacy.php" class="nav-link">
|
||||
<i class="bi bi-capsule-pill"></i>
|
||||
<span>Pharmacy</span>
|
||||
</a>
|
||||
</nav>
|
||||
<div class="sidebar-footer">
|
||||
<div class="dropdown">
|
||||
<a href="#" class="d-flex align-items-center dropdown-toggle" id="dropdownUser1" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-person-circle me-2"></i>
|
||||
<strong><?php echo htmlspecialchars($_SESSION['username']); ?></strong>
|
||||
</a>
|
||||
<ul class="dropdown-menu text-small shadow" aria-labelledby="dropdownUser1">
|
||||
<li><a class="dropdown-item" href="logout.php">Sign out</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="main-content">
|
||||
<div class="header d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<h1 class="header-title">Doctor's Dashboard</h1>
|
||||
<p class="header-subtitle mb-0">Welcome, Dr. <?php echo htmlspecialchars($doctor['username'] ?? 'Doctor'); ?>!</p>
|
||||
</div>
|
||||
<div class="search-container">
|
||||
<input type="text" id="patientSearch" class="form-control" placeholder="Search Patient by Name or ID...">
|
||||
<div id="searchResults" class="search-results"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Today's Patients -->
|
||||
<div class="content-card">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title-text"><i class="bi bi-list-ul me-2"></i>Today's Appointments</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Patient ID</th>
|
||||
<th>Name</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (!empty($visits)):
|
||||
foreach ($visits as $visit):
|
||||
?>
|
||||
<tr id="patient-row-<?php echo $visit['visit_id']; ?>">
|
||||
<td><?php echo htmlspecialchars($visit['patient_system_id']); ?></td>
|
||||
<td>
|
||||
<a href="patient_profile.php?id=<?php echo $visit['patient_id']; ?>"><?php echo htmlspecialchars($visit['patient_name']); ?></a>
|
||||
</td>
|
||||
<td><span class="badge bg-<?php echo get_status_badge_class($visit['status']); ?>-soft" id="status-<?php echo $visit['visit_id']; ?>"><?php echo htmlspecialchars($visit['status']); ?></span></td>
|
||||
<td id="action-cell-<?php echo $visit['visit_id']; ?>">
|
||||
<?php echo get_action_buttons($visit); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="notes-row" id="notes-row-<?php echo $visit['visit_id']; ?>" style="<?php echo $visit['status'] !== 'In Progress' ? 'display: none;' : ''; ?>">
|
||||
<td colspan="4">
|
||||
<form class="notes-form" data-visit-id="<?php echo $visit['visit_id']; ?>">
|
||||
<div class="mb-3">
|
||||
<label for="notes-<?php echo $visit['visit_id']; ?>" class="form-label">Consultation Notes</label>
|
||||
<textarea class="form-control" id="notes-<?php echo $visit['visit_id']; ?>" rows="3"><?php echo htmlspecialchars($visit['notes'] ?? ''); ?></textarea>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-8 mb-3">
|
||||
<label for="service-<?php echo $visit['visit_id']; ?>" class="form-label">Service Rendered</label>
|
||||
<input type="text" class="form-control" id="service-<?php echo $visit['visit_id']; ?>" placeholder="e.g., General Consultation">
|
||||
</div>
|
||||
<div class="col-md-4 mb-3">
|
||||
<label for="cost-<?php echo $visit['visit_id']; ?>" class="form-label">Cost ($)</label>
|
||||
<input type="number" class="form-control" id="cost-<?php echo $visit['visit_id']; ?>" placeholder="e.g., 75.00" step="0.01">
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-sm btn-success">
|
||||
<i class="bi bi-check-circle me-1"></i>Complete Consultation & Bill
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else:
|
||||
?>
|
||||
<tr>
|
||||
<td colspan="4" class="text-center text-muted">No patients assigned for today.</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<!-- Prescription Modal -->
|
||||
<div class="modal fade" id="prescriptionModal" tabindex="-1" aria-labelledby="prescriptionModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="prescriptionModalLabel">Add Prescription</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="prescriptionForm">
|
||||
<input type="hidden" id="prescriptionVisitId" name="visit_id">
|
||||
<div class="mb-3">
|
||||
<label for="medication" class="form-label">Medication</label>
|
||||
<input type="text" class="form-control" id="medication" name="medication" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="dosage" class="form-label">Dosage</label>
|
||||
<input type="text" class="form-control" id="dosage" name="dosage" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="frequency" class="form-label">Frequency</label>
|
||||
<input type="text" class="form-control" id="frequency" name="frequency" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="prescriptionNotes" class="form-label">Notes</label>
|
||||
<textarea class="form-control" id="prescriptionNotes" name="notes" rows="3"></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Save Prescription</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Order Tests Modal -->
|
||||
<div class="modal fade" id="orderTestsModal" tabindex="-1" aria-labelledby="orderTestsModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="orderTestsModalLabel">Order Tests</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="orderTestsForm">
|
||||
<input type="hidden" id="orderVisitId" name="visit_id">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h5>Lab Tests</h5>
|
||||
<div id="lab-tests-list" class="list-group" style="max-height: 300px; overflow-y: auto;">
|
||||
<!-- JS will populate this -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<h5>Imaging Tests</h5>
|
||||
<div id="imaging-tests-list" class="list-group" style="max-height: 300px; overflow-y: auto;">
|
||||
<!-- JS will populate this -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
<button type="submit" class="btn btn-primary">Order Selected Tests</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script>
|
||||
document.addEventListener('click', function(e) {
|
||||
if (e.target.matches('.start-consultation-btn')) {
|
||||
const visitId = e.target.dataset.visitId;
|
||||
updatePatientStatus(visitId, 'In Progress');
|
||||
}
|
||||
|
||||
if (e.target.matches('.prescribe-btn')) {
|
||||
const visitId = e.target.dataset.visitId;
|
||||
document.getElementById('prescriptionVisitId').value = visitId;
|
||||
}
|
||||
|
||||
if (e.target.matches('.order-tests-btn')) {
|
||||
const visitId = e.target.dataset.visitId;
|
||||
document.getElementById('orderVisitId').value = visitId;
|
||||
loadTestsForModal();
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('submit', function(e) {
|
||||
if (e.target.matches('.notes-form')) {
|
||||
e.preventDefault();
|
||||
const visitId = e.target.dataset.visitId;
|
||||
const notes = document.getElementById('notes-' + visitId).value;
|
||||
const service = document.getElementById('service-' + visitId).value;
|
||||
const cost = document.getElementById('cost-' + visitId).value;
|
||||
updatePatientStatus(visitId, 'Completed', notes, service, cost);
|
||||
}
|
||||
|
||||
if (e.target.matches('#prescriptionForm')) {
|
||||
e.preventDefault();
|
||||
const formData = new FormData(e.target);
|
||||
|
||||
fetch('add_prescription.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('Prescription saved successfully!');
|
||||
const modal = bootstrap.Modal.getInstance(document.getElementById('prescriptionModal'));
|
||||
modal.hide();
|
||||
e.target.reset();
|
||||
} else {
|
||||
alert('Error: ' + data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
alert('An unexpected error occurred while saving the prescription.');
|
||||
});
|
||||
}
|
||||
|
||||
if (e.target.matches('#orderTestsForm')) {
|
||||
e.preventDefault();
|
||||
const formData = new FormData(e.target);
|
||||
|
||||
fetch('order_tests.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('Tests ordered successfully!');
|
||||
const modal = bootstrap.Modal.getInstance(document.getElementById('orderTestsModal'));
|
||||
modal.hide();
|
||||
e.target.reset();
|
||||
} else {
|
||||
alert('Error: ' + data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
alert('An unexpected error occurred while ordering tests.');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function loadTestsForModal() {
|
||||
fetch('get_tests.php')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
const labList = document.getElementById('lab-tests-list');
|
||||
const imagingList = document.getElementById('imaging-tests-list');
|
||||
labList.innerHTML = '';
|
||||
imagingList.innerHTML = '';
|
||||
|
||||
data.lab_tests.forEach(test => {
|
||||
labList.innerHTML += `
|
||||
<label class="list-group-item">
|
||||
<input class="form-check-input me-1" type="checkbox" name="lab_tests[]" value="${test.test_id}">
|
||||
${test.test_name}
|
||||
</label>`;
|
||||
});
|
||||
|
||||
data.imaging_tests.forEach(test => {
|
||||
imagingList.innerHTML += `
|
||||
<label class="list-group-item">
|
||||
<input class="form-check-input me-1" type="checkbox" name="imaging_tests[]" value="${test.test_id}">
|
||||
${test.test_name}
|
||||
</label>`;
|
||||
});
|
||||
} else {
|
||||
alert('Could not load tests: ' + data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error loading tests:', error);
|
||||
alert('An error occurred while fetching tests.');
|
||||
});
|
||||
}
|
||||
|
||||
function updatePatientStatus(visitId, status, notes = null, service = null, cost = null) {
|
||||
const formData = new FormData();
|
||||
formData.append('visit_id', visitId);
|
||||
formData.append('status', status);
|
||||
if (notes !== null) {
|
||||
formData.append('notes', notes);
|
||||
}
|
||||
if (service !== null) {
|
||||
formData.append('service_rendered', service);
|
||||
}
|
||||
if (cost !== null) {
|
||||
formData.append('cost', cost);
|
||||
}
|
||||
|
||||
fetch('update_patient_status.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
// Update status badge
|
||||
const statusBadge = document.getElementById('status-' + visitId);
|
||||
statusBadge.textContent = status;
|
||||
statusBadge.className = 'badge bg-' + data.status_class + '-soft';
|
||||
|
||||
// Update action buttons/form
|
||||
const actionCell = document.getElementById('action-cell-' + visitId);
|
||||
const notesRow = document.getElementById('notes-row-' + visitId);
|
||||
if (status === 'In Progress') {
|
||||
actionCell.innerHTML = get_action_buttons({ status: 'In Progress', visit_id: visitId });
|
||||
notesRow.style.display = 'table-row';
|
||||
} else if (status === 'Completed') {
|
||||
actionCell.innerHTML = get_action_buttons({ status: 'Completed', visit_id: visitId });
|
||||
notesRow.style.display = 'none';
|
||||
}
|
||||
} else {
|
||||
alert('Error: ' + data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
alert('An unexpected error occurred.');
|
||||
});
|
||||
}
|
||||
|
||||
document.getElementById('patientSearch').addEventListener('input', function() {
|
||||
const searchTerm = this.value;
|
||||
const resultsContainer = document.getElementById('searchResults');
|
||||
|
||||
if (searchTerm.length < 2) {
|
||||
resultsContainer.innerHTML = '';
|
||||
resultsContainer.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`search_patient.php?term=${encodeURIComponent(searchTerm)}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
resultsContainer.innerHTML = '';
|
||||
if (data.length > 0) {
|
||||
data.forEach(patient => {
|
||||
const patientLink = document.createElement('a');
|
||||
patientLink.href = `patient_profile.php?id=${patient.id}`;
|
||||
patientLink.textContent = `${patient.patient_name} (${patient.patient_id})`;
|
||||
resultsContainer.appendChild(patientLink);
|
||||
});
|
||||
resultsContainer.style.display = 'block';
|
||||
} else {
|
||||
resultsContainer.innerHTML = '<a href="#" class="disabled">No patients found</a>';
|
||||
resultsContainer.style.display = 'block';
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
resultsContainer.innerHTML = '<a href="#" class="disabled">Search error</a>';
|
||||
resultsContainer.style.display = 'block';
|
||||
});
|
||||
});
|
||||
|
||||
// Hide results when clicking outside
|
||||
document.addEventListener('click', function(e) {
|
||||
const searchContainer = document.querySelector('.search-container');
|
||||
if (searchContainer && !searchContainer.contains(e.target)) {
|
||||
const resultsContainer = document.getElementById('searchResults');
|
||||
if (resultsContainer) {
|
||||
resultsContainer.style.display = 'none';
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
function get_status_badge_class($status) {
|
||||
switch ($status) {
|
||||
case 'Pending':
|
||||
return 'warning';
|
||||
case 'In Progress':
|
||||
return 'info';
|
||||
case 'Completed':
|
||||
return 'success';
|
||||
default:
|
||||
return 'secondary';
|
||||
}
|
||||
}
|
||||
|
||||
function get_action_buttons($visit) {
|
||||
$status = $visit['status'];
|
||||
$visit_id = $visit['visit_id'];
|
||||
$patient_id = $visit['patient_id'] ?? 0;
|
||||
|
||||
$buttons = '';
|
||||
|
||||
switch ($status) {
|
||||
case 'Pending':
|
||||
$buttons .= '<button class="btn btn-sm btn-primary start-consultation-btn" data-visit-id="' . $visit_id . '"><i class="bi bi-play-circle me-1"></i>Start Consultation</button>';
|
||||
break;
|
||||
case 'In Progress':
|
||||
// The form is shown, but we can add a prescribe button here too
|
||||
$buttons .= '<button class="btn btn-sm btn-info prescribe-btn" data-bs-toggle="modal" data-bs-target="#prescriptionModal" data-visit-id="' . $visit_id . '" data-patient-id="' . $patient_id . '"><i class="bi bi-pen me-1"></i>Prescribe</button>';
|
||||
$buttons .= ' <button class="btn btn-sm btn-secondary order-tests-btn" data-bs-toggle="modal" data-bs-target="#orderTestsModal" data-visit-id="' . $visit_id . '"><i class="bi bi-eyedropper me-1"></i>Order Tests</button>';
|
||||
break;
|
||||
case 'Completed':
|
||||
$buttons .= '<span class="text-success"><i class="bi bi-check-circle-fill me-1"></i>Completed</span>';
|
||||
$buttons .= ' <button class="btn btn-sm btn-outline-primary prescribe-btn" data-bs-toggle="modal" data-bs-target="#prescriptionModal" data-visit-id="' . $visit_id . '" data-patient-id="' . $patient_id . '"><i class="bi bi-pen me-1"></i>Add/View Prescription</button>';
|
||||
$buttons .= ' <button class="btn btn-sm btn-outline-secondary order-tests-btn" data-bs-toggle="modal" data-bs-target="#orderTestsModal" data-visit-id="' . $visit_id . '"><i class="bi bi-eyedropper me-1"></i>Order/View Tests</button>';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return $buttons;
|
||||
}
|
||||
?>
|
||||
32
enter_results.php
Normal file
32
enter_results.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_role('receptionist'); // Or a new 'lab_technician' role
|
||||
require_once 'db/config.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
$response = ['success' => false, 'message' => 'Invalid request.'];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$order_id = $_POST['order_id'] ?? null;
|
||||
$results = $_POST['results'] ?? null;
|
||||
|
||||
if ($order_id && $results) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("UPDATE ordered_tests SET results = ?, status = 'Completed' WHERE order_id = ?");
|
||||
|
||||
if ($stmt->execute([$results, $order_id])) {
|
||||
$response = ['success' => true, 'message' => 'Results submitted successfully.'];
|
||||
} else {
|
||||
$response['message'] = 'Failed to submit results.';
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$response['message'] = 'Database error: ' . $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
$response['message'] = 'Missing order ID or results.';
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
?>
|
||||
18
get_tests.php
Normal file
18
get_tests.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
$lab_tests = $pdo->query("SELECT test_id, test_name FROM lab_tests ORDER BY test_name ASC")->fetchAll(PDO::FETCH_ASSOC);
|
||||
$imaging_tests = $pdo->query("SELECT test_id, test_name FROM imaging_tests ORDER BY test_name ASC")->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'lab_tests' => $lab_tests,
|
||||
'imaging_tests' => $imaging_tests
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Database error: ' . $e->getMessage()]);
|
||||
}
|
||||
?>
|
||||
152
index.php
152
index.php
@ -1,150 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
|
||||
$phpVersion = PHP_VERSION;
|
||||
$now = date('Y-m-d H:i:s');
|
||||
// This is the main entry point of the application.
|
||||
// It will redirect the user to the login page.
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>New Style</title>
|
||||
<?php
|
||||
// Read project preview data from environment
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
?>
|
||||
<?php if ($projectDescription): ?>
|
||||
<!-- Meta description -->
|
||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
||||
<!-- Open Graph meta tags -->
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<!-- Twitter meta tags -->
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<!-- Open Graph image -->
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<!-- Twitter image -->
|
||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<?php endif; ?>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
||||
animation: bg-pan 20s linear infinite;
|
||||
z-index: -1;
|
||||
}
|
||||
@keyframes bg-pan {
|
||||
0% { background-position: 0% 0%; }
|
||||
100% { background-position: 100% 100%; }
|
||||
}
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
.card {
|
||||
background: var(--card-bg-color);
|
||||
border: 1px solid var(--card-border-color);
|
||||
border-radius: 16px;
|
||||
padding: 2rem;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.loader {
|
||||
margin: 1.25rem auto 1.25rem;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@keyframes spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.hint {
|
||||
opacity: 0.9;
|
||||
}
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px; height: 1px;
|
||||
padding: 0; margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap; border: 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
margin: 0 0 1rem;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
p {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
code {
|
||||
background: rgba(0,0,0,0.2);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
font-size: 0.8rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="card">
|
||||
<h1>Analyzing your requirements and generating your website…</h1>
|
||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||
<span class="sr-only">Loading…</span>
|
||||
</div>
|
||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
154
invoice.php
Normal file
154
invoice.php
Normal file
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_once 'db/config.php';
|
||||
|
||||
$visit_id = $_GET['visit_id'] ?? null;
|
||||
|
||||
if (!$visit_id) {
|
||||
die("Visit ID is required.");
|
||||
}
|
||||
|
||||
// Fetch visit details
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare(
|
||||
"SELECT
|
||||
pv.*,
|
||||
p.patient_name,
|
||||
p.address,
|
||||
p.phone_number,
|
||||
u.username as doctor_name
|
||||
FROM patient_visits pv
|
||||
JOIN patients p ON pv.patient_id = p.id
|
||||
JOIN users u ON pv.doctor_id = u.id
|
||||
WHERE pv.visit_id = ?"
|
||||
);
|
||||
$stmt->execute([$visit_id]);
|
||||
$visit = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
// Fetch ordered tests for the visit
|
||||
$tests_stmt = $pdo->prepare(
|
||||
"SELECT
|
||||
ot.test_type,
|
||||
CASE
|
||||
WHEN ot.test_type = 'lab' THEN lt.test_name
|
||||
WHEN ot.test_type = 'imaging' THEN it.test_name
|
||||
END as test_name,
|
||||
CASE
|
||||
WHEN ot.test_type = 'lab' THEN lt.cost
|
||||
WHEN ot.test_type = 'imaging' THEN it.cost
|
||||
END as cost
|
||||
FROM ordered_tests ot
|
||||
LEFT JOIN lab_tests lt ON ot.test_type = 'lab' AND ot.test_id = lt.test_id
|
||||
LEFT JOIN imaging_tests it ON ot.test_type = 'imaging' AND ot.test_id = it.test_id
|
||||
WHERE ot.visit_id = ?"
|
||||
);
|
||||
$tests_stmt->execute([$visit_id]);
|
||||
$ordered_tests = $tests_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
} catch (PDOException $e) {
|
||||
$visit = null;
|
||||
$ordered_tests = [];
|
||||
// In a real app, you would log this error
|
||||
}
|
||||
|
||||
if (!$visit) {
|
||||
die("No completed visit found for this ID or an error occurred.");
|
||||
}
|
||||
|
||||
// Calculate total bill
|
||||
$total_bill = $visit['cost'];
|
||||
foreach ($ordered_tests as $test) {
|
||||
$total_bill += $test['cost'];
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Invoice - Visit #<?php echo htmlspecialchars($visit['visit_id']); ?></title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
body { font-family: 'Poppins', sans-serif; background-color: #f8f9fa; }
|
||||
.invoice-container { max-width: 800px; margin: 40px auto; padding: 40px; background: #fff; border-radius: 15px; box-shadow: 0 4px 20px rgba(0,0,0,0.05); }
|
||||
.invoice-header { text-align: center; margin-bottom: 40px; }
|
||||
.invoice-header h1 { font-weight: 600; color: #343a40; }
|
||||
.invoice-header .brand { font-size: 1.5rem; font-weight: 600; color: #0d6efd; }
|
||||
.invoice-details, .billing-details { margin-bottom: 30px; }
|
||||
.invoice-details h5, .billing-details h5 { font-weight: 600; margin-bottom: 15px; }
|
||||
.invoice-details p, .billing-details p { margin-bottom: 5px; }
|
||||
.table thead { background-color: #e9ecef; }
|
||||
.total-section { text-align: right; margin-top: 30px; }
|
||||
.total-section h4 { font-weight: 600; }
|
||||
.print-btn { display: block; width: 150px; margin: 30px auto 0; }
|
||||
@media print {
|
||||
body { background-color: #fff; }
|
||||
.invoice-container { margin: 0; box-shadow: none; border-radius: 0; }
|
||||
.print-btn, .btn-back { display: none; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="invoice-container">
|
||||
<div class="invoice-header">
|
||||
<div class="brand"><i class="bi bi-heart-pulse-fill"></i> ClinicFlow</div>
|
||||
<h1>Invoice</h1>
|
||||
</div>
|
||||
|
||||
<div class="row justify-content-between invoice-details">
|
||||
<div class="col-md-6">
|
||||
<h5>Billed To:</h5>
|
||||
<p><strong><?php echo htmlspecialchars($visit['patient_name']); ?></strong></p>
|
||||
<p><?php echo htmlspecialchars($visit['address']); ?></p>
|
||||
<p><?php echo htmlspecialchars($visit['phone_number']); ?></p>
|
||||
</div>
|
||||
<div class="col-md-5 text-md-end">
|
||||
<p><strong>Invoice #:</strong> INV-<?php echo htmlspecialchars($visit['visit_id']); ?></p>
|
||||
<p><strong>Date:</strong> <?php echo date("F j, Y", strtotime($visit['visit_time'])); ?></p>
|
||||
<p><strong>Status:</strong> <span class="badge bg-<?php echo $visit['payment_status'] === 'paid' ? 'success' : 'danger'; ?>"><?php echo ucfirst(htmlspecialchars($visit['payment_status'])); ?></span></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="billing-details">
|
||||
<h5>Consultation Details:</h5>
|
||||
<p><strong>Consulting Doctor:</strong> Dr. <?php echo htmlspecialchars($visit['doctor_name']); ?></p>
|
||||
</div>
|
||||
|
||||
<table class="table table-bordered">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>Item</th>
|
||||
<th class="text-end">Cost</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($visit['service_rendered']); ?> (Consultation)</td>
|
||||
<td class="text-end">$<?php echo htmlspecialchars(number_format($visit['cost'], 2)); ?></td>
|
||||
</tr>
|
||||
<?php foreach ($ordered_tests as $test): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($test['test_name']); ?> (<?php echo ucfirst(htmlspecialchars($test['test_type'])); ?> Test)</td>
|
||||
<td class="text-end">$<?php echo htmlspecialchars(number_format($test['cost'], 2)); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="fw-bold">
|
||||
<td class="text-end">Total:</td>
|
||||
<td class="text-end">$<?php echo htmlspecialchars(number_format($total_bill, 2)); ?></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
<button onclick="window.print();" class="btn btn-primary print-btn"><i class="bi bi-printer"></i> Print Invoice</button>
|
||||
<a href="billing.php" class="btn btn-secondary btn-back d-print-none" style="display: block; width: 150px; margin: 10px auto 0;">Back to Billing</a>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
151
lab_imaging_config.php
Normal file
151
lab_imaging_config.php
Normal file
@ -0,0 +1,151 @@
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
require_once 'auth.php';
|
||||
|
||||
// Ensure user is authenticated
|
||||
check_login();
|
||||
|
||||
$pdo = db();
|
||||
$message = '';
|
||||
|
||||
// Handle POST requests to add tests
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (isset($_POST['add_lab_test'])) {
|
||||
$test_name = trim($_POST['test_name']);
|
||||
$cost = trim($_POST['cost']);
|
||||
if (!empty($test_name) && is_numeric($cost)) {
|
||||
$stmt = $pdo->prepare("INSERT INTO lab_tests (test_name, cost) VALUES (?, ?)");
|
||||
$stmt->execute([$test_name, $cost]);
|
||||
$message = '<div class="alert alert-success">Lab test added successfully!</div>';
|
||||
} else {
|
||||
$message = '<div class="alert alert-danger">Invalid input for lab test.</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['add_imaging_test'])) {
|
||||
$test_name = trim($_POST['test_name']);
|
||||
$cost = trim($_POST['cost']);
|
||||
if (!empty($test_name) && is_numeric($cost)) {
|
||||
$stmt = $pdo->prepare("INSERT INTO imaging_tests (test_name, cost) VALUES (?, ?)");
|
||||
$stmt->execute([$test_name, $cost]);
|
||||
$message = '<div class="alert alert-success">Imaging test added successfully!</div>';
|
||||
} else {
|
||||
$message = '<div class="alert alert-danger">Invalid input for imaging test.</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch all tests
|
||||
$lab_tests = $pdo->query("SELECT * FROM lab_tests ORDER BY test_name ASC")->fetchAll();
|
||||
$imaging_tests = $pdo->query("SELECT * FROM imaging_tests ORDER BY test_name ASC")->fetchAll();
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Lab & Imaging Test Configuration</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container mt-5">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1>Test Configuration</h1>
|
||||
<div>
|
||||
<a href="reception.php" class="btn btn-outline-secondary">Back to Reception</a>
|
||||
<a href="doctor_dashboard.php" class="btn btn-outline-primary">Back to Dashboard</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php echo $message; ?>
|
||||
|
||||
<div class="row">
|
||||
<!-- Lab Tests Column -->
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>Lab Tests</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="POST" action="">
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<input type="text" name="test_name" class="form-control" placeholder="Test Name" required>
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="number" step="0.01" name="cost" class="form-control" placeholder="Cost" required>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button type="submit" name="add_lab_test" class="btn btn-primary">Add</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<hr>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Test Name</th>
|
||||
<th>Cost</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($lab_tests as $test): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($test['test_name']); ?></td>
|
||||
<td>$<?php echo htmlspecialchars(number_format($test['cost'], 2)); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Imaging Tests Column -->
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>Imaging Tests</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="POST" action="">
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<input type="text" name="test_name" class="form-control" placeholder="Test Name" required>
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="number" step="0.01" name="cost" class="form-control" placeholder="Cost" required>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button type="submit" name="add_imaging_test" class="btn btn-success">Add</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<hr>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Test Name</th>
|
||||
<th>Cost</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($imaging_tests as $test): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($test['test_name']); ?></td>
|
||||
<td>$<?php echo htmlspecialchars(number_format($test['cost'], 2)); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
280
lab_reports.php
Normal file
280
lab_reports.php
Normal file
@ -0,0 +1,280 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_role('receptionist'); // For now, accessible by receptionists
|
||||
require_once 'db/config.php';
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Fetch all ordered tests that are not yet completed
|
||||
$pending_tests_stmt = $pdo->prepare(
|
||||
"SELECT
|
||||
ot.order_id,
|
||||
ot.ordered_at,
|
||||
ot.test_type,
|
||||
ot.status,
|
||||
p.patient_name,
|
||||
p.id as patient_id,
|
||||
CASE
|
||||
WHEN ot.test_type = 'lab' THEN lt.test_name
|
||||
WHEN ot.test_type = 'imaging' THEN it.test_name
|
||||
END as test_name,
|
||||
u.username as doctor_name
|
||||
FROM ordered_tests ot
|
||||
JOIN patient_visits pv ON ot.visit_id = pv.visit_id
|
||||
JOIN patients p ON pv.patient_id = p.id
|
||||
JOIN users u ON pv.doctor_id = u.id
|
||||
LEFT JOIN lab_tests lt ON ot.test_type = 'lab' AND ot.test_id = lt.test_id
|
||||
LEFT JOIN imaging_tests it ON ot.test_type = 'imaging' AND ot.test_id = it.test_id
|
||||
WHERE ot.status = 'Ordered'
|
||||
ORDER BY ot.ordered_at ASC"
|
||||
);
|
||||
$pending_tests_stmt->execute();
|
||||
$pending_tests = $pending_tests_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Lab & Imaging Reports</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
<style>
|
||||
.search-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
}
|
||||
.search-results {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 1000;
|
||||
border: 1px solid #ccc;
|
||||
background-color: #fff;
|
||||
border-radius: 0 0 5px 5px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
display: none;
|
||||
}
|
||||
.search-results a {
|
||||
display: block;
|
||||
padding: 10px;
|
||||
text-decoration: none;
|
||||
color: #333;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
.search-results a:hover {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.search-results a:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="page-wrapper">
|
||||
<!-- Sidebar -->
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<a href="index.php" class="sidebar-brand">
|
||||
<i class="bi bi-heart-pulse-fill"></i>
|
||||
<span>ClinicFlow</span>
|
||||
</a>
|
||||
</div>
|
||||
<nav class="sidebar-nav">
|
||||
<a href="reception.php" class="nav-link">
|
||||
<i class="bi bi-people-fill"></i>
|
||||
<span>Reception</span>
|
||||
</a>
|
||||
<a href="doctor_dashboard.php" class="nav-link">
|
||||
<i class="bi bi-person-fill"></i>
|
||||
<span>Doctor</span>
|
||||
</a>
|
||||
<a href="lab_reports.php" class="nav-link active">
|
||||
<i class="bi bi-file-earmark-medical"></i>
|
||||
<span>Lab Reports</span>
|
||||
</a>
|
||||
<a href="pharmacy.php" class="nav-link">
|
||||
<i class="bi bi-capsule-pill"></i>
|
||||
<span>Pharmacy</span>
|
||||
</a>
|
||||
</nav>
|
||||
<div class="sidebar-footer">
|
||||
<div class="dropdown">
|
||||
<a href="#" class="d-flex align-items-center text-white text-decoration-none dropdown-toggle" id="dropdownUser1" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-person-circle me-2"></i>
|
||||
<strong><?php echo htmlspecialchars($_SESSION['username']); ?></strong>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-dark text-small shadow" aria-labelledby="dropdownUser1">
|
||||
<li><a class="dropdown-item" href="logout.php">Sign out</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="main-content">
|
||||
<header class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h3 mb-0 text-gray-800">Pending Lab & Imaging Reports</h1>
|
||||
<div class="search-container">
|
||||
<input type="text" id="patientSearch" class="form-control" placeholder="Search Patient by Name or ID...">
|
||||
<div id="searchResults" class="search-results"></div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Date Ordered</th>
|
||||
<th>Patient</th>
|
||||
<th>Test Name</th>
|
||||
<th>Type</th>
|
||||
<th>Ordered By</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($pending_tests)): ?>
|
||||
<tr>
|
||||
<td colspan="7" class="text-center">No pending tests found.</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($pending_tests as $test): ?>
|
||||
<tr>
|
||||
<td><?= date("d M, Y", strtotime($test['ordered_at'])) ?></td>
|
||||
<td><a href="patient_profile.php?id=<?= $test['patient_id'] ?>"><?= htmlspecialchars($test['patient_name']) ?></a></td>
|
||||
<td><?= htmlspecialchars($test['test_name']) ?></td>
|
||||
<td><?= htmlspecialchars(ucfirst($test['test_type'])) ?></td>
|
||||
<td>Dr. <?= htmlspecialchars($test['doctor_name'] ?? 'N/A') ?></td>
|
||||
<td><span class="badge bg-warning-soft"><?= htmlspecialchars($test['status']) ?></span></td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-primary enter-results-btn" data-bs-toggle="modal" data-bs-target="#resultsModal" data-order-id="<?= $test['order_id'] ?>">Enter Results</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<!-- Enter Results Modal -->
|
||||
<div class="modal fade" id="resultsModal" tabindex="-1" aria-labelledby="resultsModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="resultsModalLabel">Enter Test Results</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="resultsForm">
|
||||
<input type="hidden" id="orderId" name="order_id">
|
||||
<div class="mb-3">
|
||||
<label for="resultsText" class="form-label">Results</label>
|
||||
<textarea class="form-control" id="resultsText" name="results" rows="5" required></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Save Results & Complete</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script>
|
||||
document.addEventListener('click', function(e) {
|
||||
if (e.target.matches('.enter-results-btn')) {
|
||||
const orderId = e.target.dataset.orderId;
|
||||
document.getElementById('orderId').value = orderId;
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('submit', function(e) {
|
||||
if (e.target.matches('#resultsForm')) {
|
||||
e.preventDefault();
|
||||
const formData = new FormData(e.target);
|
||||
const orderId = formData.get('order_id');
|
||||
|
||||
fetch('enter_results.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('Results submitted successfully!');
|
||||
const modal = bootstrap.Modal.getInstance(document.getElementById('resultsModal'));
|
||||
modal.hide();
|
||||
e.target.reset();
|
||||
// Remove the row from the table
|
||||
document.querySelector(`[data-order-id="${orderId}"]`).closest('tr').remove();
|
||||
} else {
|
||||
alert('Error: ' + data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
alert('An unexpected error occurred while submitting the results.');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('patientSearch').addEventListener('input', function() {
|
||||
const searchTerm = this.value;
|
||||
const resultsContainer = document.getElementById('searchResults');
|
||||
|
||||
if (searchTerm.length < 2) {
|
||||
resultsContainer.innerHTML = '';
|
||||
resultsContainer.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`search_patient.php?term=${encodeURIComponent(searchTerm)}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
resultsContainer.innerHTML = '';
|
||||
if (data.length > 0) {
|
||||
data.forEach(patient => {
|
||||
const patientLink = document.createElement('a');
|
||||
patientLink.href = `patient_profile.php?id=${patient.id}`;
|
||||
patientLink.textContent = `${patient.patient_name} (${patient.patient_id})`;
|
||||
resultsContainer.appendChild(patientLink);
|
||||
});
|
||||
resultsContainer.style.display = 'block';
|
||||
} else {
|
||||
resultsContainer.innerHTML = '<a href="#" class="disabled">No patients found</a>';
|
||||
resultsContainer.style.display = 'block';
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
resultsContainer.innerHTML = '<a href="#" class="disabled">Search error</a>';
|
||||
resultsContainer.style.display = 'block';
|
||||
});
|
||||
});
|
||||
|
||||
// Hide results when clicking outside
|
||||
document.addEventListener('click', function(e) {
|
||||
const searchContainer = document.querySelector('.search-container');
|
||||
if (searchContainer && !searchContainer.contains(e.target)) {
|
||||
const resultsContainer = document.getElementById('searchResults');
|
||||
if (resultsContainer) {
|
||||
resultsContainer.style.display = 'none';
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
120
login.php
Normal file
120
login.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
$error = '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$username = $_POST['username'] ?? '';
|
||||
$password = $_POST['password'] ?? '';
|
||||
|
||||
if (empty($username) || empty($password)) {
|
||||
$error = 'Please enter both username and password.';
|
||||
} else {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("SELECT * FROM `users` WHERE `username` = ?");
|
||||
$stmt->execute([$username]);
|
||||
$user = $stmt->fetch();
|
||||
|
||||
if ($user && password_verify($password, $user['password'])) {
|
||||
$_SESSION['user_id'] = $user['id'];
|
||||
$_SESSION['username'] = $user['username'];
|
||||
$_SESSION['role'] = $user['role'];
|
||||
|
||||
// Redirect based on role
|
||||
if ($user['role'] === 'doctor') {
|
||||
header("Location: doctor_dashboard.php");
|
||||
} else {
|
||||
header("Location: reception.php");
|
||||
}
|
||||
exit;
|
||||
} else {
|
||||
$error = 'Invalid username or password.';
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$error = 'Database error. Please try again later.';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Login - Clinic Management</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
<style>
|
||||
body {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
.login-container {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.login-card {
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
border: none;
|
||||
border-radius: 1rem;
|
||||
box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.1);
|
||||
}
|
||||
.login-card-header {
|
||||
background-color: #0d6efd;
|
||||
color: white;
|
||||
border-top-left-radius: 1rem;
|
||||
border-top-right-radius: 1rem;
|
||||
padding: 1.5rem;
|
||||
text-align: center;
|
||||
}
|
||||
.login-card-header h3 {
|
||||
margin: 0;
|
||||
font-weight: 300;
|
||||
}
|
||||
.login-card-body {
|
||||
padding: 2rem;
|
||||
}
|
||||
.form-floating > .form-control {
|
||||
height: calc(3.5rem + 2px);
|
||||
padding: 1rem;
|
||||
}
|
||||
.form-floating > label {
|
||||
padding: 1rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-container">
|
||||
<div class="card login-card">
|
||||
<div class="login-card-header">
|
||||
<h3><i class="fas fa-clinic-medical"></i> Clinic Login</h3>
|
||||
</div>
|
||||
<div class="card-body login-card-body">
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-danger"><?php echo htmlspecialchars($error); ?></div>
|
||||
<?php endif; ?>
|
||||
<form action="login.php" method="POST">
|
||||
<div class="form-floating mb-3">
|
||||
<input type="text" class="form-control" id="username" name="username" placeholder="Username" required>
|
||||
<label for="username">Username</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<input type="password" class="form-control" id="password" name="password" placeholder="Password" required>
|
||||
<label for="password">Password</label>
|
||||
</div>
|
||||
<div class="d-grid">
|
||||
<button type="submit" class="btn btn-primary btn-lg">Login</button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="mt-3 text-center">
|
||||
<small class="text-muted">Default Logins: reception/password, doctor/password</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
7
logout.php
Normal file
7
logout.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
session_start();
|
||||
session_unset();
|
||||
session_destroy();
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
?>
|
||||
42
order_tests.php
Normal file
42
order_tests.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_role('doctor');
|
||||
require_once 'db/config.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
$response = ['success' => false, 'message' => 'Invalid request.'];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$visit_id = $_POST['visit_id'] ?? null;
|
||||
$lab_tests = $_POST['lab_tests'] ?? [];
|
||||
$imaging_tests = $_POST['imaging_tests'] ?? [];
|
||||
|
||||
if ($visit_id && (!empty($lab_tests) || !empty($imaging_tests))) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$pdo->beginTransaction();
|
||||
|
||||
$stmt = $pdo->prepare("INSERT INTO ordered_tests (visit_id, test_type, test_id) VALUES (?, ?, ?)");
|
||||
|
||||
foreach ($lab_tests as $test_id) {
|
||||
$stmt->execute([$visit_id, 'lab', $test_id]);
|
||||
}
|
||||
|
||||
foreach ($imaging_tests as $test_id) {
|
||||
$stmt->execute([$visit_id, 'imaging', $test_id]);
|
||||
}
|
||||
|
||||
$pdo->commit();
|
||||
$response = ['success' => true, 'message' => 'Tests ordered successfully.'];
|
||||
|
||||
} catch (PDOException $e) {
|
||||
$pdo->rollBack();
|
||||
$response['message'] = 'Database error: ' . $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
$response['message'] = 'Missing visit ID or no tests selected.';
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
?>
|
||||
320
patient_profile.php
Normal file
320
patient_profile.php
Normal file
@ -0,0 +1,320 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_once 'db/config.php';
|
||||
|
||||
// Check if patient ID is provided
|
||||
if (!isset($_GET['id'])) {
|
||||
header("Location: reception.php");
|
||||
exit();
|
||||
}
|
||||
|
||||
$patient_id = $_GET['id'];
|
||||
|
||||
// Fetch patient details
|
||||
$stmt = db()->prepare("SELECT * FROM patients WHERE id = ?");
|
||||
$stmt->execute([$patient_id]);
|
||||
$patient = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$patient) {
|
||||
die("Patient not found.");
|
||||
}
|
||||
|
||||
// Fetch all visits for this patient
|
||||
$visit_history_stmt = db()->prepare(
|
||||
"SELECT pv.*, u.username as doctor_name
|
||||
FROM patient_visits pv
|
||||
LEFT JOIN users u ON pv.doctor_id = u.id
|
||||
WHERE pv.patient_id = ?
|
||||
ORDER BY pv.visit_time DESC"
|
||||
);
|
||||
$visit_history_stmt->execute([$patient_id]);
|
||||
$visit_history = $visit_history_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Fetch all prescriptions for this patient
|
||||
$prescriptions_stmt = db()->prepare(
|
||||
"SELECT pr.*, u.username as doctor_name
|
||||
FROM prescriptions pr
|
||||
LEFT JOIN users u ON pr.doctor_id = u.id
|
||||
WHERE pr.patient_id = ?
|
||||
ORDER BY pr.prescription_date DESC"
|
||||
);
|
||||
$prescriptions_stmt->execute([$patient_id]);
|
||||
$prescriptions = $prescriptions_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Fetch all ordered tests for this patient
|
||||
$ordered_tests_stmt = db()->prepare(
|
||||
"SELECT
|
||||
ot.ordered_at,
|
||||
ot.test_type,
|
||||
ot.status,
|
||||
ot.results,
|
||||
CASE
|
||||
WHEN ot.test_type = 'lab' THEN lt.test_name
|
||||
WHEN ot.test_type = 'imaging' THEN it.test_name
|
||||
END as test_name,
|
||||
u.username as doctor_name
|
||||
FROM ordered_tests ot
|
||||
JOIN patient_visits pv ON ot.visit_id = pv.visit_id
|
||||
JOIN users u ON pv.doctor_id = u.id
|
||||
LEFT JOIN lab_tests lt ON ot.test_type = 'lab' AND ot.test_id = lt.test_id
|
||||
LEFT JOIN imaging_tests it ON ot.test_type = 'imaging' AND ot.test_id = it.test_id
|
||||
WHERE pv.patient_id = ?
|
||||
ORDER BY ot.ordered_at DESC"
|
||||
);
|
||||
$ordered_tests_stmt->execute([$patient_id]);
|
||||
$ordered_tests = $ordered_tests_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Patient Profile - <?= htmlspecialchars($patient['patient_name']) ?></title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="page-wrapper">
|
||||
<!-- Sidebar -->
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<a href="index.php" class="sidebar-brand">
|
||||
<i class="bi bi-heart-pulse-fill"></i>
|
||||
<span>ClinicFlow</span>
|
||||
</a>
|
||||
</div>
|
||||
<nav class="sidebar-nav">
|
||||
<a href="reception.php" class="nav-link active">
|
||||
<i class="bi bi-people-fill"></i>
|
||||
<span>Reception</span>
|
||||
</a>
|
||||
<a href="doctor_dashboard.php" class="nav-link">
|
||||
<i class="bi bi-person-fill"></i>
|
||||
<span>Doctor</span>
|
||||
</a>
|
||||
</nav>
|
||||
<div class="sidebar-footer">
|
||||
<div class="dropdown">
|
||||
<a href="#" class="d-flex align-items-center text-white text-decoration-none dropdown-toggle" id="dropdownUser1" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-person-circle me-2"></i>
|
||||
<strong><?php echo htmlspecialchars($_SESSION['username']); ?></strong>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-dark text-small shadow" aria-labelledby="dropdownUser1">
|
||||
<li><a class="dropdown-item" href="logout.php">Sign out</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="main-content">
|
||||
<header class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h3 mb-0 text-gray-800">Patient Profile</h1>
|
||||
<a href="reception.php" class="btn btn-sm btn-outline-primary">
|
||||
<i class="bi bi-arrow-left me-2"></i>Back to Dashboard
|
||||
</a>
|
||||
</header>
|
||||
|
||||
<!-- Patient Details Card -->
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">
|
||||
<i class="bi bi-person-badge me-2"></i>
|
||||
<?= htmlspecialchars($patient['patient_name']) ?>
|
||||
</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<p><strong>Patient ID:</strong> <?= htmlspecialchars($patient['patient_id']) ?></p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<p><strong>Phone:</strong> <?= htmlspecialchars($patient['phone_number']) ?></p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<p><strong>Address:</strong> <?= htmlspecialchars($patient['address']) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Prescription History -->
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">
|
||||
<i class="bi bi-file-earmark-medical me-2"></i>
|
||||
Prescription History
|
||||
</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Doctor</th>
|
||||
<th>Medication</th>
|
||||
<th>Dosage</th>
|
||||
<th>Frequency</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($prescriptions)): ?>
|
||||
<tr>
|
||||
<td colspan="7" class="text-center">No prescription history found.</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($prescriptions as $prescription): ?>
|
||||
<tr>
|
||||
<td><?= date("d M, Y", strtotime($prescription['prescription_date'])) ?></td>
|
||||
<td>Dr. <?= htmlspecialchars($prescription['doctor_name'] ?? 'N/A') ?></td>
|
||||
<td><?= htmlspecialchars($prescription['medication']) ?></td>
|
||||
<td><?= htmlspecialchars($prescription['dosage']) ?></td>
|
||||
<td><?= htmlspecialchars($prescription['frequency']) ?></td>
|
||||
<td>
|
||||
<span class="badge bg-<?php echo $prescription['status'] === 'Dispensed' ? 'success' : 'warning'; ?>-soft"><?= htmlspecialchars($prescription['status']) ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="prescription_view.php?id=<?= $prescription['id'] ?>" class="btn btn-sm btn-outline-primary" target="_blank">
|
||||
<i class="bi bi-printer me-1"></i> View/Print
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ordered Tests History -->
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">
|
||||
<i class="bi bi-eyedropper me-2"></i>
|
||||
Ordered Tests History
|
||||
</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Date Ordered</th>
|
||||
<th>Test Name</th>
|
||||
<th>Type</th>
|
||||
<th>Ordered By</th>
|
||||
<th>Status</th>
|
||||
<th>Results</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($ordered_tests)): ?>
|
||||
<tr>
|
||||
<td colspan="6" class="text-center">No tests have been ordered for this patient.</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($ordered_tests as $index => $test): ?>
|
||||
<tr>
|
||||
<td><?= date("d M, Y", strtotime($test['ordered_at'])) ?></td>
|
||||
<td><?= htmlspecialchars($test['test_name']) ?></td>
|
||||
<td><?= htmlspecialchars(ucfirst($test['test_type'])) ?></td>
|
||||
<td>Dr. <?= htmlspecialchars($test['doctor_name'] ?? 'N/A') ?></td>
|
||||
<td>
|
||||
<span class="badge bg-<?php echo $test['status'] === 'Completed' ? 'success' : 'info'; ?>-soft"><?= htmlspecialchars($test['status']) ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($test['status'] === 'Completed' && !empty($test['results'])): ?>
|
||||
<button class="btn btn-sm btn-outline-secondary view-results-btn" data-bs-toggle="modal" data-bs-target="#viewResultsModal" data-results="<?= htmlspecialchars($test['results']) ?>">View Results</button>
|
||||
<?php else: ?>
|
||||
<span class="text-muted">N/A</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Visit History -->
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary">
|
||||
<i class="bi bi-clock-history me-2"></i>
|
||||
Visit History
|
||||
</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Visit Date</th>
|
||||
<th>Assigned Doctor</th>
|
||||
<th>Status</th>
|
||||
<th>Consultation Notes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($visit_history)): ?>
|
||||
<tr>
|
||||
<td colspan="4" class="text-center">No visit history found.</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($visit_history as $visit): ?>
|
||||
<tr>
|
||||
<td><?= date("d M, Y h:i A", strtotime($visit['visit_time'])) ?></td>
|
||||
<td>Dr. <?= htmlspecialchars($visit['doctor_name'] ?? 'N/A') ?></td>
|
||||
<td>
|
||||
<span class="badge bg-primary-soft"><?= htmlspecialchars($visit['status']) ?></span>
|
||||
</td>
|
||||
<td><?= nl2br(htmlspecialchars($visit['notes'] ?? 'No notes added.')) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<!-- View Results Modal -->
|
||||
<div class="modal fade" id="viewResultsModal" tabindex="-1" aria-labelledby="viewResultsModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-scrollable">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="viewResultsModalLabel">Test Results</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body" id="resultsModalBody">
|
||||
<!-- Results will be injected here by JS -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('click', function(e) {
|
||||
if (e.target.matches('.view-results-btn')) {
|
||||
const results = e.target.dataset.results;
|
||||
document.getElementById('resultsModalBody').innerText = results;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
152
patient_register.php
Normal file
152
patient_register.php
Normal file
@ -0,0 +1,152 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_role('receptionist');
|
||||
require_once 'db/config.php';
|
||||
|
||||
$message = '';
|
||||
$error = '';
|
||||
$doctors = [];
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
// Fetch doctors (users with role 'doctor') for the dropdown
|
||||
$stmt = $pdo->query("SELECT id, username FROM users WHERE role = 'doctor' ORDER BY username");
|
||||
$doctors = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
$error = "Database error: " . $e->getMessage();
|
||||
}
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$patient_name = trim($_POST['patient_name']);
|
||||
$phone_number = trim($_POST['phone_number']);
|
||||
$address = trim($_POST['address']);
|
||||
$doctor_id = $_POST['doctor_id'];
|
||||
|
||||
if (empty($patient_name) || empty($doctor_id)) {
|
||||
$error = "Patient name and assigned doctor are required.";
|
||||
} else {
|
||||
try {
|
||||
// Generate a unique patient ID
|
||||
$prefix = 'PT';
|
||||
$stmt = $pdo->query("SELECT MAX(id) FROM patients");
|
||||
$last_id = $stmt->fetchColumn();
|
||||
$next_id = ($last_id) ? $last_id + 1 : 1;
|
||||
$patient_id = $prefix . str_pad($next_id, 6, '0', STR_PAD_LEFT);
|
||||
|
||||
// Set initial status
|
||||
$status = 'Pending';
|
||||
$total_fee = 20.00; // Example fee
|
||||
|
||||
$sql = "INSERT INTO patients (patient_id, patient_name, phone_number, address, doctor_id, status, total_fee) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
|
||||
if ($stmt->execute([$patient_id, $patient_name, $phone_number, $address, $doctor_id, $status, $total_fee])) {
|
||||
$_SESSION['message'] = "Patient registered successfully! Patient ID: $patient_id";
|
||||
header("Location: reception.php");
|
||||
exit();
|
||||
} else {
|
||||
$error = "Failed to register patient.";
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$error = "Database error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Register Patient - Hospital Management</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="d-flex">
|
||||
<!-- Sidebar -->
|
||||
<div class="sidebar d-flex flex-column flex-shrink-0 p-3" style="width: 280px;">
|
||||
<a href="/" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-white text-decoration-none">
|
||||
<i class="bi bi-heart-pulse-fill me-2"></i>
|
||||
<span class="fs-4">ClinicSys</span>
|
||||
</a>
|
||||
<hr>
|
||||
<ul class="nav nav-pills flex-column mb-auto">
|
||||
<li class="nav-item">
|
||||
<a href="reception.php" class="nav-link text-white">
|
||||
<i class="bi bi-grid-fill me-2"></i>
|
||||
Dashboard
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="patient_register.php" class="nav-link active" aria-current="page">
|
||||
<i class="bi bi-person-plus-fill me-2"></i>
|
||||
Register Patient
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<hr>
|
||||
<div class="dropdown">
|
||||
<a href="#" class="d-flex align-items-center text-white text-decoration-none dropdown-toggle" id="dropdownUser1" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-person-circle me-2"></i>
|
||||
<strong><?php echo htmlspecialchars($_SESSION['username']); ?></strong>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-dark text-small shadow" aria-labelledby="dropdownUser1">
|
||||
<li><a class="dropdown-item" href="logout.php">Sign out</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Main Content -->
|
||||
<div class="main-content flex-grow-1 p-4">
|
||||
<header class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h3 mb-0 text-gray-800">Register New Patient</h1>
|
||||
</header>
|
||||
|
||||
<?php if (!empty($error)): ?>
|
||||
<div class="alert alert-danger"><?php echo $error; ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="card shadow">
|
||||
<div class="card-body p-5">
|
||||
<form action="patient_register.php" method="post">
|
||||
<div class="mb-4">
|
||||
<label for="patient_name" class="form-label">Patient Name <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="patient_name" name="patient_name" required>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label for="phone_number" class="form-label">Phone Number</label>
|
||||
<input type="text" class="form-control" id="phone_number" name="phone_number">
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label for="address" class="form-label">Address</label>
|
||||
<input type="text" class="form-control" id="address" name="address">
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label for="doctor_id" class="form-label">Assign Doctor <span class="text-danger">*</span></label>
|
||||
<select class="form-select" id="doctor_id" name="doctor_id" required>
|
||||
<option value="">Select a Doctor</option>
|
||||
<?php foreach ($doctors as $doctor): ?>
|
||||
<option value="<?php echo htmlspecialchars($doctor['id']); ?>">
|
||||
Dr. <?php echo htmlspecialchars($doctor['username']); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="d-flex justify-content-end">
|
||||
<button type="submit" class="btn btn-primary-custom">Register Patient</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
246
pharmacy.php
Normal file
246
pharmacy.php
Normal file
@ -0,0 +1,246 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_role('receptionist'); // For now, accessible by receptionists/pharmacists
|
||||
require_once 'db/config.php';
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Fetch all prescriptions that have not been dispensed
|
||||
$pending_prescriptions_stmt = $pdo->prepare(
|
||||
"SELECT
|
||||
pr.id as prescription_id,
|
||||
pr.prescription_date,
|
||||
pr.medication,
|
||||
pr.dosage,
|
||||
pr.frequency,
|
||||
p.patient_name,
|
||||
p.id as patient_id,
|
||||
u.username as doctor_name
|
||||
FROM prescriptions pr
|
||||
JOIN patients p ON pr.patient_id = p.id
|
||||
JOIN users u ON pr.doctor_id = u.id
|
||||
WHERE pr.status = 'Prescribed'
|
||||
ORDER BY pr.prescription_date ASC"
|
||||
);
|
||||
$pending_prescriptions_stmt->execute();
|
||||
$pending_prescriptions = $pending_prescriptions_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Pharmacy Dashboard</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
<style>
|
||||
.search-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
}
|
||||
.search-results {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 1000;
|
||||
border: 1px solid #ccc;
|
||||
background-color: #fff;
|
||||
border-radius: 0 0 5px 5px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
display: none;
|
||||
}
|
||||
.search-results a {
|
||||
display: block;
|
||||
padding: 10px;
|
||||
text-decoration: none;
|
||||
color: #333;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
.search-results a:hover {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.search-results a:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="page-wrapper">
|
||||
<!-- Sidebar -->
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<a href="index.php" class="sidebar-brand">
|
||||
<i class="bi bi-heart-pulse-fill"></i>
|
||||
<span>ClinicFlow</span>
|
||||
</a>
|
||||
</div>
|
||||
<nav class="sidebar-nav">
|
||||
<a href="reception.php" class="nav-link">
|
||||
<i class="bi bi-people-fill"></i>
|
||||
<span>Reception</span>
|
||||
</a>
|
||||
<a href="doctor_dashboard.php" class="nav-link">
|
||||
<i class="bi bi-person-fill"></i>
|
||||
<span>Doctor</span>
|
||||
</a>
|
||||
<a href="lab_reports.php" class="nav-link">
|
||||
<i class="bi bi-file-earmark-medical"></i>
|
||||
<span>Lab Reports</span>
|
||||
</a>
|
||||
<a href="pharmacy.php" class="nav-link active">
|
||||
<i class="bi bi-capsule-pill"></i>
|
||||
<span>Pharmacy</span>
|
||||
</a>
|
||||
</nav>
|
||||
<div class="sidebar-footer">
|
||||
<div class="dropdown">
|
||||
<a href="#" class="d-flex align-items-center text-white text-decoration-none dropdown-toggle" id="dropdownUser1" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-person-circle me-2"></i>
|
||||
<strong><?php echo htmlspecialchars($_SESSION['username']); ?></strong>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-dark text-small shadow" aria-labelledby="dropdownUser1">
|
||||
<li><a class="dropdown-item" href="logout.php">Sign out</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="main-content">
|
||||
<header class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h3 mb-0 text-gray-800">Pharmacy - Pending Prescriptions</h1>
|
||||
<div class="search-container">
|
||||
<input type="text" id="patientSearch" class="form-control" placeholder="Search Patient by Name or ID...">
|
||||
<div id="searchResults" class="search-results"></div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Date Prescribed</th>
|
||||
<th>Patient</th>
|
||||
<th>Doctor</th>
|
||||
<th>Medication</th>
|
||||
<th>Dosage</th>
|
||||
<th>Frequency</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($pending_prescriptions)): ?>
|
||||
<tr>
|
||||
<td colspan="7" class="text-center">No pending prescriptions found.</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($pending_prescriptions as $prescription): ?>
|
||||
<tr id="prescription-row-<?= $prescription['prescription_id'] ?>">
|
||||
<td><?= date("d M, Y", strtotime($prescription['prescription_date'])) ?></td>
|
||||
<td><a href="patient_profile.php?id=<?= $prescription['patient_id'] ?>"><?= htmlspecialchars($prescription['patient_name']) ?></a></td>
|
||||
<td>Dr. <?= htmlspecialchars($prescription['doctor_name']) ?></td>
|
||||
<td><?= htmlspecialchars($prescription['medication']) ?></td>
|
||||
<td><?= htmlspecialchars($prescription['dosage']) ?></td>
|
||||
<td><?= htmlspecialchars($prescription['frequency']) ?></td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-success dispense-btn" data-prescription-id="<?= $prescription['prescription_id'] ?>">Dispense</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script>
|
||||
document.addEventListener('click', function(e) {
|
||||
if (e.target.matches('.dispense-btn')) {
|
||||
if (!confirm('Are you sure you want to mark this prescription as dispensed?')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const prescriptionId = e.target.dataset.prescriptionId;
|
||||
const formData = new FormData();
|
||||
formData.append('prescription_id', prescriptionId);
|
||||
|
||||
fetch('dispense.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
alert('Prescription dispensed successfully!');
|
||||
// Remove the row from the table
|
||||
document.getElementById('prescription-row-' + prescriptionId).remove();
|
||||
} else {
|
||||
alert('Error: ' + data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
alert('An unexpected error occurred.');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('patientSearch').addEventListener('input', function() {
|
||||
const searchTerm = this.value;
|
||||
const resultsContainer = document.getElementById('searchResults');
|
||||
|
||||
if (searchTerm.length < 2) {
|
||||
resultsContainer.innerHTML = '';
|
||||
resultsContainer.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`search_patient.php?term=${encodeURIComponent(searchTerm)}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
resultsContainer.innerHTML = '';
|
||||
if (data.length > 0) {
|
||||
data.forEach(patient => {
|
||||
const patientLink = document.createElement('a');
|
||||
patientLink.href = `patient_profile.php?id=${patient.id}`;
|
||||
patientLink.textContent = `${patient.patient_name} (${patient.patient_id})`;
|
||||
resultsContainer.appendChild(patientLink);
|
||||
});
|
||||
resultsContainer.style.display = 'block';
|
||||
} else {
|
||||
resultsContainer.innerHTML = '<a href="#" class="disabled">No patients found</a>';
|
||||
resultsContainer.style.display = 'block';
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
resultsContainer.innerHTML = '<a href="#" class="disabled">Search error</a>';
|
||||
resultsContainer.style.display = 'block';
|
||||
});
|
||||
});
|
||||
|
||||
// Hide results when clicking outside
|
||||
document.addEventListener('click', function(e) {
|
||||
const searchContainer = document.querySelector('.search-container');
|
||||
if (searchContainer && !searchContainer.contains(e.target)) {
|
||||
const resultsContainer = document.getElementById('searchResults');
|
||||
if (resultsContainer) {
|
||||
resultsContainer.style.display = 'none';
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
134
prescription_view.php
Normal file
134
prescription_view.php
Normal file
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_GET['id'])) {
|
||||
die("No prescription ID provided.");
|
||||
}
|
||||
|
||||
$prescription_id = $_GET['id'];
|
||||
|
||||
// Fetch prescription details along with patient and doctor info
|
||||
$stmt = db()->prepare(
|
||||
"SELECT
|
||||
pr.*,
|
||||
p.patient_name, p.patient_id as patient_system_id, p.address, p.phone_number,
|
||||
u.username as doctor_name
|
||||
FROM prescriptions pr
|
||||
JOIN patients p ON pr.patient_id = p.id
|
||||
JOIN users u ON pr.doctor_id = u.id
|
||||
WHERE pr.id = ?"
|
||||
);
|
||||
$stmt->execute([$prescription_id]);
|
||||
$prescription = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$prescription) {
|
||||
die("Prescription not found.");
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Prescription for <?= htmlspecialchars($prescription['patient_name']) ?></title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
body { background-color: #f8f9fa; }
|
||||
.prescription-container {
|
||||
max-width: 800px;
|
||||
margin: 40px auto;
|
||||
padding: 30px;
|
||||
background-color: #fff;
|
||||
border: 1px solid #dee2e6;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 8px rgba(0,0,0,0.05);
|
||||
}
|
||||
.prescription-header, .prescription-footer {
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.prescription-header h2 { font-weight: 600; }
|
||||
.patient-details, .doctor-details {
|
||||
margin-bottom: 20px;
|
||||
padding: 15px;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.medication-details { margin-top: 30px; }
|
||||
@media print {
|
||||
body { background-color: #fff; }
|
||||
.prescription-container {
|
||||
margin: 0;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
max-width: 100%;
|
||||
}
|
||||
.no-print { display: none; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="prescription-container">
|
||||
<div class="prescription-header">
|
||||
<h2>Prescription</h2>
|
||||
<p class="text-muted">Date: <?= date("F j, Y", strtotime($prescription['prescription_date'])) ?></p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<h5>Patient Details</h5>
|
||||
<div class="patient-details">
|
||||
<strong>Name:</strong> <?= htmlspecialchars($prescription['patient_name']) ?><br>
|
||||
<strong>Patient ID:</strong> <?= htmlspecialchars($prescription['patient_system_id']) ?><br>
|
||||
<strong>Address:</strong> <?= htmlspecialchars($prescription['address']) ?><br>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<h5>Prescribing Doctor</h5>
|
||||
<div class="doctor-details">
|
||||
<strong>Dr. <?= htmlspecialchars($prescription['doctor_name']) ?></strong><br>
|
||||
ClinicFlow Medical Center<br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="medication-details">
|
||||
<h4><i class="bi bi-file-medical"></i> Rx</h4>
|
||||
<table class="table table-bordered">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Medication</th>
|
||||
<th>Dosage</th>
|
||||
<th>Frequency</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong><?= htmlspecialchars($prescription['medication']) ?></strong></td>
|
||||
<td><?= htmlspecialchars($prescription['dosage']) ?></td>
|
||||
<td><?= htmlspecialchars($prescription['frequency']) ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if (!empty($prescription['notes'])) : ?>
|
||||
<div class="mt-3">
|
||||
<strong>Notes:</strong>
|
||||
<p class="text-muted"><?= nl2br(htmlspecialchars($prescription['notes'])) ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="prescription-footer mt-5">
|
||||
<p class="text-muted small">This is a computer-generated prescription and does not require a physical signature.</p>
|
||||
</div>
|
||||
|
||||
<div class="text-center mt-4 no-print">
|
||||
<button onclick="window.print();" class="btn btn-primary">Print Prescription</button>
|
||||
<a href="patient_profile.php?id=<?= $prescription['patient_id'] ?>" class="btn btn-secondary">Back to Profile</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
238
reception.php
Normal file
238
reception.php
Normal file
@ -0,0 +1,238 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_role('receptionist');
|
||||
require_once 'db/config.php';
|
||||
|
||||
$pdo = db();
|
||||
|
||||
// Fetch stats for dashboard cards
|
||||
$patients_today = $pdo->query("SELECT count(id) FROM patients WHERE DATE(created_at) = CURDATE()")->fetchColumn();
|
||||
$total_patients = $pdo->query("SELECT count(id) FROM patients")->fetchColumn();
|
||||
$total_revenue = $pdo->query("SELECT SUM(total_fee) FROM patients WHERE status = 'Completed'")->fetchColumn();
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Reception Dashboard - Hospital Management</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="d-flex">
|
||||
<!-- Sidebar -->
|
||||
<div class="sidebar d-flex flex-column flex-shrink-0 p-3" style="width: 280px;">
|
||||
<a href="/" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-white text-decoration-none">
|
||||
<i class="bi bi-heart-pulse-fill me-2"></i>
|
||||
<span class="fs-4">ClinicSys</span>
|
||||
</a>
|
||||
<hr>
|
||||
<nav class="sidebar-nav">
|
||||
<a href="reception.php" class="nav-link active">
|
||||
<i class="bi bi-people-fill"></i>
|
||||
<span>Reception</span>
|
||||
</a>
|
||||
<a href="billing.php" class="nav-link">
|
||||
<i class="bi bi-receipt"></i>
|
||||
<span>Billing</span>
|
||||
</a>
|
||||
<a href="lab_imaging_config.php" class="nav-link">
|
||||
<i class="bi bi-gear-fill"></i>
|
||||
<span>Test Config</span>
|
||||
</a>
|
||||
<a href="lab_reports.php" class="nav-link">
|
||||
<i class="bi bi-file-earmark-medical"></i>
|
||||
<span>Lab Reports</span>
|
||||
</a>
|
||||
<a href="pharmacy.php" class="nav-link">
|
||||
<i class="bi bi-capsule-pill"></i>
|
||||
<span>Pharmacy</span>
|
||||
</a>
|
||||
<a href="doctor_dashboard.php" class="nav-link">
|
||||
<i class="bi bi-person-fill"></i>
|
||||
<span>Doctor</span>
|
||||
</a>
|
||||
</nav>
|
||||
<hr>
|
||||
<div class="dropdown">
|
||||
<a href="#" class="d-flex align-items-center text-white text-decoration-none dropdown-toggle" id="dropdownUser1" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-person-circle me-2"></i>
|
||||
<strong><?php echo htmlspecialchars($_SESSION['username']); ?></strong>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-dark text-small shadow" aria-labelledby="dropdownUser1">
|
||||
<li><a class="dropdown-item" href="logout.php">Sign out</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Main Content -->
|
||||
<div class="main-content flex-grow-1 p-4">
|
||||
<header class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="h3 mb-0 text-gray-800">Receptionist Dashboard</h1>
|
||||
<div class="search-container">
|
||||
<input type="text" id="patientSearch" class="form-control" placeholder="Search Patient by Name or ID...">
|
||||
<div id="searchResults" class="search-results"></div>
|
||||
</div>
|
||||
<a href="patient_register.php" class="btn btn-primary-custom">
|
||||
<i class="bi bi-person-plus-fill me-2"></i>
|
||||
Register New Patient
|
||||
</a>
|
||||
</header>
|
||||
|
||||
<!-- Info Cards -->
|
||||
<div class="row">
|
||||
<div class="col-xl-4 col-md-6 mb-4">
|
||||
<div class="card border-left-primary shadow h-100 py-2">
|
||||
<div class="card-body">
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
|
||||
Patients Registered (Today)</div>
|
||||
<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $patients_today; ?></div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<i class="bi bi-calendar-day fs-2 text-gray-300"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xl-4 col-md-6 mb-4">
|
||||
<div class="card border-left-success shadow h-100 py-2">
|
||||
<div class="card-body">
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-success text-uppercase mb-1">
|
||||
Total Patients</div>
|
||||
<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $total_patients; ?></div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<i class="bi bi-people-fill fs-2 text-gray-300"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xl-4 col-md-6 mb-4">
|
||||
<div class="card border-left-info shadow h-100 py-2">
|
||||
<div class="card-body">
|
||||
<div class="row no-gutters align-items-center">
|
||||
<div class="col mr-2">
|
||||
<div class="text-xs font-weight-bold text-info text-uppercase mb-1">Total Revenue
|
||||
</div>
|
||||
<div class="h5 mb-0 font-weight-bold text-gray-800">$<?php echo number_format($total_revenue, 2); ?></div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<i class="bi bi-currency-dollar fs-2 text-gray-300"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- Patient List -->
|
||||
<div class="card shadow">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary"><?php echo isset($_GET['search_query']) ? 'Search Results' : 'Recent Patients'; ?></h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Patient ID</th>
|
||||
<th>Patient Name</th>
|
||||
<th>Phone Number</th>
|
||||
<th>Registration Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$sql = "SELECT * FROM patients ORDER BY created_at DESC LIMIT 10";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
while ($row = $stmt->fetch()) {
|
||||
echo "<tr>";
|
||||
echo "<td><a href='patient_profile.php?id=" . $row['id'] . "'>" . htmlspecialchars($row['patient_id']) . "</a></td>";
|
||||
echo "<td><a href='patient_profile.php?id=" . $row['id'] . "'>" . htmlspecialchars($row['patient_name']) . "</a></td>";
|
||||
echo "<td>" . htmlspecialchars($row['phone']) . "</td>";
|
||||
echo "<td>" . date("Y-m-d H:i", strtotime($row['created_at'])) . "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
} else {
|
||||
echo '<tr><td colspan="4" class="text-center">No patients found.</td></tr>';
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script>
|
||||
document.getElementById('patientSearch').addEventListener('input', function() {
|
||||
const searchTerm = this.value;
|
||||
const resultsContainer = document.getElementById('searchResults');
|
||||
|
||||
if (searchTerm.length < 2) {
|
||||
resultsContainer.innerHTML = '';
|
||||
resultsContainer.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(`search_patient.php?term=${encodeURIComponent(searchTerm)}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
resultsContainer.innerHTML = '';
|
||||
if (data.length > 0) {
|
||||
data.forEach(patient => {
|
||||
const patientLink = document.createElement('a');
|
||||
patientLink.href = `patient_profile.php?id=${patient.id}`;
|
||||
patientLink.textContent = `${patient.patient_name} (${patient.patient_id})`;
|
||||
resultsContainer.appendChild(patientLink);
|
||||
});
|
||||
resultsContainer.style.display = 'block';
|
||||
} else {
|
||||
resultsContainer.innerHTML = '<a href="#" class="disabled">No patients found</a>';
|
||||
resultsContainer.style.display = 'block';
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
resultsContainer.innerHTML = '<a href="#" class="disabled">Search error</a>';
|
||||
resultsContainer.style.display = 'block';
|
||||
});
|
||||
});
|
||||
|
||||
// Hide results when clicking outside
|
||||
document.addEventListener('click', function(e) {
|
||||
const searchContainer = document.querySelector('.search-container');
|
||||
if (searchContainer && !searchContainer.contains(e.target)) {
|
||||
const resultsContainer = document.getElementById('searchResults');
|
||||
if (resultsContainer) {
|
||||
resultsContainer.style.display = 'none';
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
13
search_patient.php
Normal file
13
search_patient.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (isset($_GET['term'])) {
|
||||
$term = $_GET['term'];
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare('SELECT id, patient_id, patient_name FROM patients WHERE patient_name LIKE :term OR patient_id LIKE :term LIMIT 10');
|
||||
$stmt->execute(['term' => '%' . $term . '%']);
|
||||
$patients = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($patients);
|
||||
}
|
||||
?>
|
||||
78
update_patient_status.php
Normal file
78
update_patient_status.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
require_once 'auth.php';
|
||||
require_role('doctor');
|
||||
require_once 'db/config.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$response = ['success' => false, 'message' => 'Invalid request'];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$visit_id = $_POST['visit_id'] ?? null;
|
||||
$status = $_POST['status'] ?? null;
|
||||
$notes = $_POST['notes'] ?? null;
|
||||
$service_rendered = $_POST['service_rendered'] ?? null;
|
||||
$cost = $_POST['cost'] ?? null;
|
||||
|
||||
if ($visit_id && $status) {
|
||||
try {
|
||||
$pdo = db();
|
||||
// All updates now go to the patient_visits table
|
||||
$sql = "UPDATE patient_visits SET status = ?";
|
||||
$params = [$status];
|
||||
|
||||
if ($notes !== null) {
|
||||
$sql .= ", notes = ?";
|
||||
$params[] = $notes;
|
||||
}
|
||||
|
||||
if ($service_rendered !== null) {
|
||||
$sql .= ", service_rendered = ?";
|
||||
$params[] = $service_rendered;
|
||||
}
|
||||
|
||||
if ($cost !== null) {
|
||||
$sql .= ", cost = ?";
|
||||
$params[] = $cost;
|
||||
}
|
||||
|
||||
// When completing, set payment_status to unpaid for this specific visit
|
||||
if ($status === 'Completed') {
|
||||
$sql .= ", payment_status = 'unpaid'";
|
||||
}
|
||||
|
||||
$sql .= " WHERE visit_id = ?";
|
||||
$params[] = $visit_id;
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
|
||||
if ($stmt->execute($params)) {
|
||||
$response['success'] = true;
|
||||
$response['message'] = 'Visit status updated successfully.';
|
||||
$response['status_class'] = get_status_badge_class($status);
|
||||
} else {
|
||||
$response['message'] = 'Failed to update visit status.';
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$response['message'] = 'Database error: ' . $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
$response['message'] = 'Missing visit ID or status.';
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
|
||||
function get_status_badge_class($status) {
|
||||
switch ($status) {
|
||||
case 'Pending':
|
||||
return 'warning';
|
||||
case 'In Progress':
|
||||
return 'info';
|
||||
case 'Completed':
|
||||
return 'success';
|
||||
default:
|
||||
return 'secondary';
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
x
Reference in New Issue
Block a user