update lab

This commit is contained in:
Flatlogic Bot 2026-03-04 07:07:46 +00:00
parent 63a866d898
commit a63d31ec70
11 changed files with 509 additions and 83 deletions

View File

@ -378,9 +378,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name_ar = $_POST['name_ar'] ?? '';
$group_id = $_POST['group_id'] ?: null;
$price = $_POST['price'] ?? 0;
$range = $_POST['normal_range'] ?? '';
if ($name_en && $name_ar) {
$stmt = $db->prepare("INSERT INTO laboratory_tests (name_en, name_ar, group_id, price) VALUES (?, ?, ?, ?)");
$stmt->execute([$name_en, $name_ar, $group_id, $price]);
$stmt = $db->prepare("INSERT INTO laboratory_tests (name_en, name_ar, group_id, price, normal_range) VALUES (?, ?, ?, ?, ?)");
$stmt->execute([$name_en, $name_ar, $group_id, $price, $range]);
$_SESSION['flash_message'] = __('add_test') . ' ' . __('successfully');
$redirect = true;
}
@ -390,9 +391,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name_ar = $_POST['name_ar'] ?? '';
$group_id = $_POST['group_id'] ?: null;
$price = $_POST['price'] ?? 0;
$range = $_POST['normal_range'] ?? '';
if ($id && $name_en && $name_ar) {
$stmt = $db->prepare("UPDATE laboratory_tests SET name_en = ?, name_ar = ?, group_id = ?, price = ? WHERE id = ?");
$stmt->execute([$name_en, $name_ar, $group_id, $price, $id]);
$stmt = $db->prepare("UPDATE laboratory_tests SET name_en = ?, name_ar = ?, group_id = ?, price = ?, normal_range = ? WHERE id = ?");
$stmt->execute([$name_en, $name_ar, $group_id, $price, $range, $id]);
$_SESSION['flash_message'] = __('update_test') . ' ' . __('successfully');
$redirect = true;
}
@ -404,6 +406,43 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$_SESSION['flash_message'] = __('delete_test') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'add_inquiry') {
$patient_name = $_POST['patient_name'] ?? '';
$test_id = $_POST['test_id'] ?: null;
$source = $_POST['source'] ?? 'Internal';
$date = $_POST['inquiry_date'] ?: date('Y-m-d H:i');
$status = $_POST['status'] ?? 'Pending';
$notes = $_POST['notes'] ?? '';
if ($patient_name) {
$stmt = $db->prepare("INSERT INTO laboratory_inquiries (patient_name, test_id, source, inquiry_date, status, notes) VALUES (?, ?, ?, ?, ?, ?)");
$stmt->execute([$patient_name, $test_id, $source, $date, $status, $notes]);
$_SESSION['flash_message'] = __('add_inquiry') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'edit_inquiry') {
$id = $_POST['id'] ?? '';
$patient_name = $_POST['patient_name'] ?? '';
$test_id = $_POST['test_id'] ?: null;
$source = $_POST['source'] ?? 'Internal';
$date = $_POST['inquiry_date'] ?: date('Y-m-d H:i');
$status = $_POST['status'] ?? 'Pending';
$notes = $_POST['notes'] ?? '';
if ($id && $patient_name) {
$stmt = $db->prepare("UPDATE laboratory_inquiries SET patient_name = ?, test_id = ?, source = ?, inquiry_date = ?, status = ?, notes = ? WHERE id = ?");
$stmt->execute([$patient_name, $test_id, $source, $date, $status, $notes, $id]);
$_SESSION['flash_message'] = __('edit_inquiry') . ' ' . __('successfully');
$redirect = true;
}
} elseif ($_POST['action'] === 'delete_inquiry') {
$id = $_POST['id'] ?? '';
if ($id) {
$stmt = $db->prepare("DELETE FROM laboratory_inquiries WHERE id = ?");
$stmt->execute([$id]);
$_SESSION['flash_message'] = __('delete') . ' ' . __('successfully');
$redirect = true;
}
}
}

View File

@ -905,6 +905,10 @@
<?php endforeach; ?>
</select>
</div>
<div class="mb-3">
<label class="form-label"><?php echo __("normal_range"); ?></label>
<input type="text" name="normal_range" class="form-control" placeholder="e.g. Men: 13-17, Women: 12-15 g/dL">
</div>
<div class="mb-3">
<label class="form-label"><?php echo __('price'); ?></label>
<input type="number" step="0.01" name="price" class="form-control" required placeholder="0.00">
@ -941,13 +945,17 @@
</div>
<div class="mb-3">
<label class="form-label"><?php echo __('test_group'); ?></label>
<select name="group_id" id="edit_test_group_id" class="form-select">
<select name="group_id" id="edit_test_group_id_select" class="form-select">
<option value=""><?php echo __('search'); ?>...</option>
<?php foreach ($all_test_groups as $group): ?>
<option value="<?php echo $group['id']; ?>"><?php echo htmlspecialchars($group['name']); ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="mb-3">
<label class="form-label"><?php echo __("normal_range"); ?></label>
<input type="text" name="normal_range" id="edit_test_normal_range" class="form-control" placeholder="e.g. Men: 13-17, Women: 12-15 g/dL">
</div>
<div class="mb-3">
<label class="form-label"><?php echo __('price'); ?></label>
<input type="number" step="0.01" name="price" id="edit_test_price" class="form-control" required placeholder="0.00">
@ -985,6 +993,148 @@
</div>
</div>
<!-- Add Inquiry Modal -->
<div class="modal fade" id="addInquiryModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?section=<?php echo $section; ?>" method="POST">
<input type="hidden" name="action" value="add_inquiry">
<div class="modal-content border-0 shadow">
<div class="modal-header">
<h5 class="modal-title fw-bold"><?php echo __('add_inquiry'); ?></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label class="form-label"><?php echo __('patient'); ?></label>
<input type="text" name="patient_name" class="form-control" required placeholder="<?php echo __('name'); ?>">
</div>
<div class="mb-3">
<label class="form-label"><?php echo __('test'); ?></label>
<select name="test_id" class="form-select">
<option value=""><?php echo __('search'); ?>...</option>
<?php foreach ($all_tests as $test): ?>
<option value="<?php echo $test['id']; ?>"><?php echo htmlspecialchars($test['name']); ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label"><?php echo __('source'); ?></label>
<select name="source" class="form-select">
<option value="Internal"><?php echo __('internal'); ?></option>
<option value="External"><?php echo __('external'); ?></option>
</select>
</div>
<div class="col-md-6 mb-3">
<label class="form-label"><?php echo __('status'); ?></label>
<select name="status" class="form-select">
<option value="Pending"><?php echo __('Pending'); ?></option>
<option value="Completed"><?php echo __('Completed'); ?></option>
<option value="Cancelled"><?php echo __('Cancelled'); ?></option>
</select>
</div>
</div>
<div class="mb-3">
<label class="form-label"><?php echo __('inquiry_date'); ?></label>
<input type="datetime-local" name="inquiry_date" class="form-control" value="<?php echo date('Y-m-d\TH:i'); ?>">
</div>
<div class="mb-3">
<label class="form-label"><?php echo __('notes'); ?></label>
<textarea name="notes" class="form-control" rows="2"></textarea>
</div>
</div>
<div class="modal-footer bg-light">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?php echo __('cancel'); ?></button>
<button type="submit" class="btn btn-primary px-4"><?php echo __('save'); ?></button>
</div>
</div>
</form>
</div>
</div>
<!-- Edit Inquiry Modal -->
<div class="modal fade" id="editInquiryModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?section=<?php echo $section; ?>" method="POST">
<input type="hidden" name="action" value="edit_inquiry">
<input type="hidden" name="id" id="edit_inquiry_id">
<div class="modal-content border-0 shadow">
<div class="modal-header">
<h5 class="modal-title fw-bold"><?php echo __('edit_inquiry'); ?></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label class="form-label"><?php echo __('patient'); ?></label>
<input type="text" name="patient_name" id="edit_inquiry_patient_name" class="form-control" required>
</div>
<div class="mb-3">
<label class="form-label"><?php echo __('test'); ?></label>
<select name="test_id" id="edit_inquiry_test_id" class="form-select">
<option value=""><?php echo __('search'); ?>...</option>
<?php foreach ($all_tests as $test): ?>
<option value="<?php echo $test['id']; ?>"><?php echo htmlspecialchars($test['name']); ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label"><?php echo __('source'); ?></label>
<select name="source" id="edit_inquiry_source" class="form-select">
<option value="Internal"><?php echo __('internal'); ?></option>
<option value="External"><?php echo __('external'); ?></option>
</select>
</div>
<div class="col-md-6 mb-3">
<label class="form-label"><?php echo __('status'); ?></label>
<select name="status" id="edit_inquiry_status" class="form-select">
<option value="Pending"><?php echo __('Pending'); ?></option>
<option value="Completed"><?php echo __('Completed'); ?></option>
<option value="Cancelled"><?php echo __('Cancelled'); ?></option>
</select>
</div>
</div>
<div class="mb-3">
<label class="form-label"><?php echo __('inquiry_date'); ?></label>
<input type="datetime-local" name="inquiry_date" id="edit_inquiry_date" class="form-control">
</div>
<div class="mb-3">
<label class="form-label"><?php echo __('notes'); ?></label>
<textarea name="notes" id="edit_inquiry_notes" class="form-control" rows="2"></textarea>
</div>
</div>
<div class="modal-footer bg-light">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?php echo __('cancel'); ?></button>
<button type="submit" class="btn btn-primary px-4"><?php echo __('save'); ?></button>
</div>
</div>
</form>
</div>
</div>
<!-- Delete Inquiry Modal -->
<div class="modal fade" id="deleteInquiryModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?section=<?php echo $section; ?>" method="POST">
<input type="hidden" name="action" value="delete_inquiry">
<input type="hidden" name="id" id="delete_inquiry_id">
<div class="modal-content border-0 shadow">
<div class="modal-header">
<h5 class="modal-title fw-bold"><?php echo __('delete'); ?></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p><?php echo __('confirm_delete'); ?>?</p>
</div>
<div class="modal-footer bg-light">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?php echo __('cancel'); ?></button>
<button type="submit" class="btn btn-danger px-4"><?php echo __('delete'); ?></button>
</div>
</div>
</form>
</div>
</div>
<!-- Book Appointment Modal -->
<div class="modal fade" id="bookAppointmentModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
@ -1403,7 +1553,8 @@
document.getElementById('edit_test_id').value = test.id;
document.getElementById('edit_test_name_en').value = test.name_en;
document.getElementById('edit_test_name_ar').value = test.name_ar;
document.getElementById('edit_test_group_id').value = test.group_id || '';
document.getElementById('edit_test_group_id_select').value = test.group_id || '';
document.getElementById('edit_test_normal_range').value = test.normal_range || '';
document.getElementById('edit_test_price').value = test.price;
new bootstrap.Modal(document.getElementById('editTestModal')).show();
}
@ -1434,6 +1585,22 @@
new bootstrap.Modal(document.getElementById('recordVisitModal')).show();
}
function showEditInquiryModal(inquiry) {
document.getElementById('edit_inquiry_id').value = inquiry.id;
document.getElementById('edit_inquiry_patient_name').value = inquiry.patient_name;
document.getElementById('edit_inquiry_test_id').value = inquiry.test_id || '';
document.getElementById('edit_inquiry_source').value = inquiry.source;
document.getElementById('edit_inquiry_status').value = inquiry.status;
document.getElementById('edit_inquiry_date').value = inquiry.inquiry_date.replace(' ', 'T').substring(0, 16);
document.getElementById('edit_inquiry_notes').value = inquiry.notes || '';
new bootstrap.Modal(document.getElementById('editInquiryModal')).show();
}
function showDeleteInquiryModal(id) {
document.getElementById('delete_inquiry_id').value = id;
new bootstrap.Modal(document.getElementById('deleteInquiryModal')).show();
}
function addBillItem() {
const container = document.getElementById('bill_items_container');
const row = document.createElement('div');

View File

@ -60,14 +60,15 @@ $message = $message ?? '';
<a href="patients.php" class="sidebar-link <?php echo $section === 'patients' ? 'active' : ''; ?>"><i class="bi bi-people me-2"></i> <?php echo __('patients'); ?></a>
<a href="visits.php" class="sidebar-link <?php echo $section === 'visits' ? 'active' : ''; ?>"><i class="bi bi-clipboard2-pulse me-2"></i> <?php echo __('visits'); ?></a>
<a href="#labSubmenu" data-bs-toggle="collapse" class="sidebar-link <?php echo in_array($section, ['laboratory_tests', 'test_groups']) ? 'active' : ''; ?> d-flex justify-content-between align-items-center">
<a href="#labSubmenu" data-bs-toggle="collapse" class="sidebar-link <?php echo in_array($section, ['laboratory_tests', 'test_groups', 'laboratory_inquiries']) ? 'active' : ''; ?> d-flex justify-content-between align-items-center">
<span><i class="bi bi-prescription2 me-2"></i> <?php echo __('laboratory'); ?></span>
<i class="bi bi-chevron-down small"></i>
</a>
<div class="collapse <?php echo in_array($section, ['laboratory_tests', 'test_groups']) ? 'show' : ''; ?>" id="labSubmenu">
<div class="collapse <?php echo in_array($section, ['laboratory_tests', 'test_groups', 'laboratory_inquiries']) ? 'show' : ''; ?>" id="labSubmenu">
<div class="sidebar-submenu">
<a href="laboratory_tests.php" class="sidebar-link py-2 <?php echo $section === 'laboratory_tests' ? 'active' : ''; ?>"><i class="bi bi-list-check me-2"></i> <?php echo __('tests'); ?></a>
<a href="test_groups.php" class="sidebar-link py-2 <?php echo $section === 'test_groups' ? 'active' : ''; ?>"><i class="bi bi-collection me-2"></i> <?php echo __('test_groups'); ?></a>
<a href="laboratory_inquiries.php" class="sidebar-link py-2 <?php echo $section === 'laboratory_inquiries' ? 'active' : ''; ?>"><i class="bi bi-question-circle me-2"></i> <?php echo __('inquiries'); ?></a>
</div>
</div>

View File

@ -0,0 +1,139 @@
<?php
$search_patient = $_GET['patient'] ?? '';
$search_source = $_GET['source'] ?? '';
$query = "
SELECT i.*, t.name_$lang as test_name
FROM laboratory_inquiries i
LEFT JOIN laboratory_tests t ON i.test_id = t.id
WHERE 1=1";
$params = [];
if ($search_patient) {
$query .= " AND i.patient_name LIKE ?";
$params[] = "%$search_patient%";
}
if ($search_source) {
$query .= " AND i.source = ?";
$params[] = $search_source;
}
$query .= " ORDER BY i.inquiry_date DESC";
$stmt = $db->prepare($query);
$stmt->execute($params);
$inquiries = $stmt->fetchAll();
// Get all tests for the add/edit modal
$stmt = $db->query("SELECT id, name_$lang as name FROM laboratory_tests ORDER BY name_$lang ASC");
$all_tests = $stmt->fetchAll();
?>
<div class="d-flex justify-content-between align-items-center mb-4">
<h3 class="fw-bold text-secondary"><?php echo __('inquiries'); ?></h3>
<button class="btn btn-primary shadow-sm" data-bs-toggle="modal" data-bs-target="#addInquiryModal">
<i class="bi bi-plus-circle me-1"></i> <?php echo __('add_inquiry'); ?>
</button>
</div>
<!-- Search Bar -->
<div class="card shadow-sm border-0 mb-4">
<div class="card-body">
<form method="GET" action="" class="row g-3">
<div class="col-md-6">
<div class="input-group">
<span class="input-group-text bg-light border-end-0 text-muted"><i class="bi bi-search"></i></span>
<input type="text" name="patient" class="form-control bg-light border-start-0" placeholder="<?php echo __('patient'); ?>" value="<?php echo htmlspecialchars($search_patient); ?>">
</div>
</div>
<div class="col-md-4">
<select name="source" class="form-select bg-light">
<option value=""><?php echo __('source'); ?> (<?php echo __('all'); ?>)</option>
<option value="Internal" <?php echo $search_source == 'Internal' ? 'selected' : ''; ?>><?php echo __('internal'); ?></option>
<option value="External" <?php echo $search_source == 'External' ? 'selected' : ''; ?>><?php echo __('external'); ?></option>
</select>
</div>
<div class="col-md-2">
<button type="submit" class="btn btn-secondary w-100"><?php echo __('search'); ?></button>
</div>
</form>
</div>
</div>
<div class="card shadow-sm border-0">
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead class="table-light text-secondary">
<tr>
<th class="px-4 py-3">#</th>
<th class="py-3"><?php echo __('patient'); ?></th>
<th class="py-3"><?php echo __('test'); ?></th>
<th class="py-3"><?php echo __('inquiry_date'); ?></th>
<th class="py-3"><?php echo __('source'); ?></th>
<th class="py-3"><?php echo __('status'); ?></th>
<th class="py-3 text-end px-4"><?php echo __('actions'); ?></th>
</tr>
</thead>
<tbody>
<?php if (empty($inquiries)): ?>
<tr>
<td colspan="7" class="text-center py-5 text-muted">
<i class="bi bi-question-circle display-4 d-block mb-3"></i>
<?php echo __('no_inquiries_found'); ?>
</td>
</tr>
<?php else: ?>
<?php foreach ($inquiries as $inquiry): ?>
<tr>
<td class="px-4 fw-medium text-secondary"><?php echo $inquiry['id']; ?></td>
<td class="fw-semibold text-dark"><?php echo htmlspecialchars($inquiry['patient_name']); ?></td>
<td>
<span class="badge bg-info bg-opacity-10 text-info border border-info border-opacity-25 px-2 py-1">
<?php echo htmlspecialchars($inquiry['test_name'] ?? '-'); ?>
</span>
</td>
<td class="text-secondary"><?php echo date('Y-m-d H:i', strtotime($inquiry['inquiry_date'])); ?></td>
<td>
<?php if ($inquiry['source'] == 'External'): ?>
<span class="badge bg-warning bg-opacity-10 text-warning border border-warning border-opacity-25 px-2 py-1">
<i class="bi bi-hospital me-1"></i> <?php echo __('external'); ?>
</span>
<?php else: ?>
<span class="badge bg-success bg-opacity-10 text-success border border-success border-opacity-25 px-2 py-1">
<i class="bi bi-building me-1"></i> <?php echo __('internal'); ?>
</span>
<?php endif; ?>
</td>
<td>
<?php
$status_class = 'bg-secondary';
if ($inquiry['status'] == 'Pending') $status_class = 'bg-warning';
if ($inquiry['status'] == 'Completed') $status_class = 'bg-success';
if ($inquiry['status'] == 'Cancelled') $status_class = 'bg-danger';
?>
<span class="badge <?php echo $status_class; ?> bg-opacity-10 <?php echo str_replace('bg-', 'text-', $status_class); ?> border <?php echo str_replace('bg-', 'border-', $status_class); ?> border-opacity-25 px-2 py-1">
<?php echo __($inquiry['status']); ?>
</span>
</td>
<td class="text-end px-4">
<div class="btn-group shadow-sm border rounded bg-white">
<button class="btn btn-link text-primary py-1 px-2 border-end"
onclick="showEditInquiryModal(<?php echo htmlspecialchars(json_encode($inquiry)); ?>)"
data-bs-toggle="tooltip" title="<?php echo __('edit'); ?>">
<i class="bi bi-pencil-square"></i>
</button>
<button class="btn btn-link text-danger py-1 px-2"
onclick="showDeleteInquiryModal(<?php echo $inquiry['id']; ?>)"
data-bs-toggle="tooltip" title="<?php echo __('delete'); ?>">
<i class="bi bi-trash3"></i>
</button>
</div>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>

View File

@ -68,6 +68,7 @@ $tests = $stmt->fetchAll();
<th class="px-4 py-3">#</th>
<th class="py-3"><?php echo __('test_name'); ?></th>
<th class="py-3"><?php echo __('test_group'); ?></th>
<th class="py-3"><?php echo __('normal_range'); ?></th>
<th class="py-3"><?php echo __('price'); ?></th>
<th class="py-3 text-end px-4"><?php echo __('actions'); ?></th>
</tr>
@ -75,7 +76,7 @@ $tests = $stmt->fetchAll();
<tbody>
<?php if (empty($tests)): ?>
<tr>
<td colspan="5" class="text-center py-5 text-muted">
<td colspan="6" class="text-center py-5 text-muted">
<i class="bi bi-prescription2 display-4 d-block mb-3"></i>
<?php echo __('no_tests_found'); ?>
</td>
@ -100,6 +101,11 @@ $tests = $stmt->fetchAll();
<?php echo htmlspecialchars($test['group_name'] ?? '-'); ?>
</span>
</td>
<td>
<span class="text-muted small italic">
<?php echo htmlspecialchars($test['normal_range'] ?? '-'); ?>
</span>
</td>
<td class="text-secondary fw-bold"><?php echo number_format($test['price'], 2); ?></td>
<td class="text-end px-4">
<div class="btn-group shadow-sm border rounded bg-white">

View File

@ -157,9 +157,22 @@ try {
name_en VARCHAR(255) NOT NULL,
name_ar VARCHAR(255) NOT NULL,
price DECIMAL(10, 2) NOT NULL DEFAULT 0.00,
normal_range VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (group_id) REFERENCES test_groups(id) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS laboratory_inquiries (
id INT AUTO_INCREMENT PRIMARY KEY,
patient_name VARCHAR(255) NOT NULL,
test_id INT,
inquiry_date DATETIME DEFAULT CURRENT_TIMESTAMP,
source ENUM('Internal', 'External') DEFAULT 'Internal',
status ENUM('Pending', 'Completed', 'Cancelled') DEFAULT 'Pending',
notes TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (test_id) REFERENCES laboratory_tests(id) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
";
$db->exec($sql);
@ -186,6 +199,10 @@ try {
$db->exec("ALTER TABLE doctors ADD COLUMN IF NOT EXISTS email VARCHAR(100)");
} catch (Exception $e) {}
try {
$db->exec("ALTER TABLE laboratory_tests ADD COLUMN IF NOT EXISTS normal_range VARCHAR(255)");
} catch (Exception $e) {}
// Seed departments
$stmt = $db->query("SELECT COUNT(*) FROM departments");
if ($stmt->fetchColumn() == 0) {
@ -214,14 +231,15 @@ try {
('MedGulf', 'ميدغلف', '8004414444')");
}
// Seed test groups (Clear and re-seed if requested or just append if empty)
$stmt = $db->query("SELECT COUNT(*) FROM test_groups");
if ($stmt->fetchColumn() <= 4) { // If only initial seed exists, clear and re-seed with full list
$db->exec("SET FOREIGN_KEY_CHECKS = 0");
$db->exec("TRUNCATE TABLE laboratory_tests");
$db->exec("TRUNCATE TABLE test_groups");
$db->exec("SET FOREIGN_KEY_CHECKS = 1");
// Seed test groups (Clear and re-seed with comprehensive list and normal ranges)
// $db->exec("SET FOREIGN_KEY_CHECKS = 0");
// $db->exec("TRUNCATE TABLE laboratory_tests");
// $db->exec("TRUNCATE TABLE test_groups");
// $db->exec("SET FOREIGN_KEY_CHECKS = 1");
// Check if test groups exist before seeding
$stmt = $db->query("SELECT COUNT(*) FROM test_groups");
if ($stmt->fetchColumn() == 0) {
$db->exec("INSERT INTO test_groups (id, name_en, name_ar) VALUES
(1, 'Hematology', 'علم الدم'),
(2, 'Biochemistry', 'الكيمياء الحيوية'),
@ -234,59 +252,59 @@ try {
(9, 'Urine & Stool', 'البول والبراز'),
(10, 'Cardiac Markers', 'واصمات القلب')");
$db->exec("INSERT INTO laboratory_tests (group_id, name_en, name_ar, price) VALUES
(1, 'Complete Blood Count (CBC)', 'عد دم كامل', 150.00),
(1, 'ESR', 'سرعة الترسيب', 40.00),
(1, 'Reticulocyte count', 'عد الخلايا الشبكية', 60.00),
(1, 'Blood film', 'فيلم الدم', 80.00),
$db->exec("INSERT INTO laboratory_tests (group_id, name_en, name_ar, price, normal_range) VALUES
(1, 'Complete Blood Count (CBC)', 'عد دم كامل', 150.00, 'WBC: 4.5-11.0, RBC: 4.2-6.1, HGB: 12.0-17.5'),
(1, 'ESR', 'سرعة الترسيب', 40.00, 'Men: <15 mm/hr, Women: <20 mm/hr'),
(1, 'Reticulocyte count', 'عد الخلايا الشبكية', 60.00, '0.5% - 1.5%'),
(1, 'Blood film', 'فيلم الدم', 80.00, 'Normal morphology'),
(2, 'Fast Blood Sugar (FBS)', 'سكر الدم الصائم', 50.00),
(2, 'HbA1c', 'السكر التراكمي', 120.00),
(2, 'Lipid Profile', 'فحص الدهون', 200.00),
(2, 'Liver Function Test (LFT)', 'وظائف الكبد', 180.00),
(2, 'Kidney Function Test (KFT)', 'وظائف الكلى', 150.00),
(2, 'Uric Acid', 'حمض اليوريك', 60.00),
(2, 'Fast Blood Sugar (FBS)', 'سكر الدم الصائم', 50.00, '70 - 99 mg/dL'),
(2, 'HbA1c', 'السكر التراكمي', 120.00, '4.0% - 5.6%'),
(2, 'Lipid Profile', 'فحص الدهون', 200.00, 'Chol: <200, Trig: <150, HDL: >40'),
(2, 'Liver Function Test (LFT)', 'وظائف الكبد', 180.00, 'ALT: 7-55 U/L, AST: 8-48 U/L'),
(2, 'Kidney Function Test (KFT)', 'وظائف الكلى', 150.00, 'Creatinine: 0.6-1.3 mg/dL'),
(2, 'Uric Acid', 'حمض اليوريك', 60.00, 'Men: 3.4-7.0, Women: 2.4-6.0 mg/dL'),
(3, 'Urine Culture', 'مزرعة البول', 250.00),
(3, 'Stool Culture', 'مزرعة البراز', 250.00),
(3, 'Blood Culture', 'مزرعة الدم', 450.00),
(3, 'Throat Swab', 'مسحة الحلق', 200.00),
(3, 'Urine Culture', 'مزرعة البول', 250.00, 'No growth'),
(3, 'Stool Culture', 'مزرعة البراز', 250.00, 'No growth'),
(3, 'Blood Culture', 'مزرعة الدم', 450.00, 'No growth'),
(3, 'Throat Swab', 'مسحة الحلق', 200.00, 'Negative for Strep A'),
(4, 'CRP (C-Reactive Protein)', 'البروتين التفاعلي C', 90.00),
(4, 'RF (Rheumatoid Factor)', 'عامل الروماتويد', 100.00),
(4, 'ASO Titre', 'فحص أجسام مضادة للستربتوليسين', 110.00),
(4, 'HBsAg', 'التهاب الكبد ب', 120.00),
(4, 'HIV I & II', 'فيروس نقص المناعة البشرية', 180.00),
(4, 'HCV Antibodies', 'فيروس التهاب الكبد ج', 150.00),
(4, 'CRP (C-Reactive Protein)', 'البروتين التفاعلي C', 90.00, '< 10 mg/L'),
(4, 'RF (Rheumatoid Factor)', 'عامل الروماتويد', 100.00, '< 14 IU/mL'),
(4, 'ASO Titre', 'فحص أجسام مضادة للستربتوليسين', 110.00, '< 200 IU/mL'),
(4, 'HBsAg', 'التهاب الكبد ب', 120.00, 'Non-reactive'),
(4, 'HIV I & II', 'فيروس نقص المناعة البشرية', 180.00, 'Non-reactive'),
(4, 'HCV Antibodies', 'فيروس التهاب الكبد ج', 150.00, 'Non-reactive'),
(5, 'ANA', 'الأجسام المضادة للنواة', 220.00),
(5, 'Anti-dsDNA', 'الأجسام المضادة للحمض النووي', 280.00),
(5, 'Total IgE', 'الغلوبولين المناعي الكلي E', 190.00),
(5, 'ANA', 'الأجسام المضادة للنواة', 220.00, 'Negative'),
(5, 'Anti-dsDNA', 'الأجسام المضادة للحمض النووي', 280.00, '< 30 IU/mL'),
(5, 'Total IgE', 'الغلوبولين المناعي الكلي E', 190.00, '< 100 kU/L'),
(6, 'TSH', 'الهرمون المنبه للدرقية', 130.00),
(6, 'Free T3', 'T3 الحر', 130.00),
(6, 'Free T4', 'T4 الحر', 130.00),
(6, 'Prolactin', 'هرمون الحليب', 150.00),
(6, 'Testosterone', 'هرمون التستوستيرون', 180.00),
(6, 'Vitamin D', 'فيتامين د', 350.00),
(6, 'TSH', 'الهرمون المنبه للدرقية', 130.00, '0.4 - 4.0 mIU/L'),
(6, 'Free T3', 'T3 الحر', 130.00, '2.3 - 4.2 pg/mL'),
(6, 'Free T4', 'T4 الحر', 130.00, '0.8 - 1.8 ng/dL'),
(6, 'Prolactin', 'هرمون الحليب', 150.00, 'Men: 2-18, Women: 2-29 ng/mL'),
(6, 'Testosterone', 'هرمون التستوستيرون', 180.00, 'Men: 300-1000, Women: 15-70 ng/dL'),
(6, 'Vitamin D', 'فيتامين د', 350.00, '30 - 100 ng/mL'),
(7, 'PT (Prothrombin Time)', 'وقت البروثرومبين', 100.00),
(7, 'PTT (Partial Thromboplastin Time)', 'وقت الثرومبوبلاستين الجزئي', 120.00),
(7, 'INR', 'النسبة المعيارية الدولية', 100.00),
(7, 'D-Dimer', 'دي دايمر', 300.00),
(7, 'PT (Prothrombin Time)', 'وقت البروثرومبين', 100.00, '11 - 13.5 seconds'),
(7, 'PTT (Partial Thromboplastin Time)', 'وقت الثرومبوبلاستين الجزئي', 120.00, '25 - 35 seconds'),
(7, 'INR', 'النسبة المعيارية الدولية', 100.00, '0.8 - 1.1'),
(7, 'D-Dimer', 'دي دايمر', 300.00, '< 500 ng/mL'),
(8, 'Sodium (Na)', 'الصوديوم', 70.00),
(8, 'Potassium (K)', 'البوتاسيوم', 70.00),
(8, 'Chloride (Cl)', 'الكلوريد', 70.00),
(8, 'Calcium (Ca)', 'الكالسيوم', 80.00),
(8, 'Magnesium (Mg)', 'المغنيسيوم', 90.00),
(8, 'Sodium (Na)', 'الصوديوم', 70.00, '135 - 145 mEq/L'),
(8, 'Potassium (K)', 'البوتاسيوم', 70.00, '3.6 - 5.2 mEq/L'),
(8, 'Chloride (Cl)', 'الكلوريد', 70.00, '96 - 106 mEq/L'),
(8, 'Calcium (Ca)', 'الكالسيوم', 80.00, '8.5 - 10.2 mg/dL'),
(8, 'Magnesium (Mg)', 'المغنيسيوم', 90.00, '1.7 - 2.2 mg/dL'),
(9, 'Urine Analysis', 'تحليل البول', 50.00),
(9, 'Stool Analysis', 'تحليل البراز', 60.00),
(9, 'Occult Blood in Stool', 'الدم الخفي في البراز', 80.00),
(9, 'Urine Analysis', 'تحليل البول', 50.00, 'Normal'),
(9, 'Stool Analysis', 'تحليل البراز', 60.00, 'Normal'),
(9, 'Occult Blood in Stool', 'الدم الخفي في البراز', 80.00, 'Negative'),
(10, 'Troponin I', 'تروبونين I', 250.00),
(10, 'CK-MB', 'انزيم القلب CK-MB', 180.00)");
(10, 'Troponin I', 'تروبونين I', 250.00, '< 0.04 ng/mL'),
(10, 'CK-MB', 'انزيم القلب CK-MB', 180.00, '< 5.0 ng/mL')");
}
echo "Database setup completed successfully.";

16
laboratory_inquiries.php Normal file
View File

@ -0,0 +1,16 @@
<?php
session_start();
if (!isset($_SESSION['lang'])) {
$_SESSION['lang'] = 'en';
}
if (isset($_GET['lang'])) {
$_SESSION['lang'] = $_GET['lang'] == 'ar' ? 'ar' : 'en';
header("Location: " . strtok($_SERVER['REQUEST_URI'], '?'));
exit;
}
$section = 'laboratory_inquiries';
require_once 'includes/actions.php';
require_once 'includes/layout/header.php';
require_once 'includes/pages/laboratory_inquiries.php';
require_once 'includes/layout/footer.php';

View File

@ -1,9 +1,14 @@
<?php
session_start();
$section = 'laboratory_tests';
require_once 'includes/layout/header.php';
require_once 'includes/common_data.php';
require_once 'includes/actions.php';
require_once 'includes/pages/laboratory_tests.php';
require_once 'includes/layout/footer.php';
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/helpers.php';
$db = db();
$lang = $_SESSION['lang'];
require_once __DIR__ . '/includes/actions.php';
require_once __DIR__ . '/includes/common_data.php';
require_once __DIR__ . '/includes/layout/header.php';
require_once __DIR__ . '/includes/pages/laboratory_tests.php';
require_once __DIR__ . '/includes/layout/footer.php';
?>

View File

@ -151,7 +151,19 @@ $translations = [
'edit_test_group' => 'Edit Test Group',
'update_test_group' => 'Update Test Group',
'delete_test_group' => 'Delete Test Group',
'no_test_groups_found' => 'No test groups found'
'no_test_groups_found' => 'No test groups found',
'normal_range' => 'Normal Range',
'inquiries' => 'Inquiries',
'outside_hospital' => 'Outside Hospital',
'add_inquiry' => 'Add Inquiry',
'edit_inquiry' => 'Edit Inquiry',
'no_inquiries_found' => 'No inquiries found',
'source' => 'Source',
'internal' => 'Internal',
'external' => 'External',
'test' => 'Test',
'inquiry_date' => 'Inquiry Date',
'notes' => 'Notes'
],
'ar' => [
'dashboard' => 'لوحة القيادة',
@ -304,6 +316,18 @@ $translations = [
'edit_test_group' => 'تعديل مجموعة فحوصات',
'update_test_group' => 'تحديث بيانات المجموعة',
'delete_test_group' => 'حذف مجموعة فحوصات',
'no_test_groups_found' => 'لم يتم العثور على مجموعات فحوصات'
'no_test_groups_found' => 'لم يتم العثور على مجموعات فحوصات',
'normal_range' => 'المعدل الطبيعي (رجال-نساء)',
'inquiries' => 'الاستفسارات',
'outside_hospital' => 'خارج المستشفى',
'add_inquiry' => 'إضافة استفسار',
'edit_inquiry' => 'تعديل استفسار',
'no_inquiries_found' => 'لم يتم العثور على استفسارات',
'source' => 'المصدر',
'internal' => 'داخلي',
'external' => 'خارجي',
'test' => 'الفحص',
'inquiry_date' => 'تاريخ الاستفسار',
'notes' => 'ملاحظات'
]
];

View File

@ -1,8 +1,14 @@
<?php
// nurses.php
session_start();
$section = 'nurses';
require_once 'includes/layout/header.php';
require_once 'includes/actions.php';
require_once 'includes/pages/nurses.php';
require_once 'includes/layout/footer.php';
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/helpers.php';
$db = db();
$lang = $_SESSION['lang'];
require_once __DIR__ . '/includes/actions.php';
require_once __DIR__ . '/includes/common_data.php';
require_once __DIR__ . '/includes/layout/header.php';
require_once __DIR__ . '/includes/pages/nurses.php';
require_once __DIR__ . '/includes/layout/footer.php';
?>

View File

@ -1,9 +1,14 @@
<?php
session_start();
$section = 'test_groups';
require_once 'includes/layout/header.php';
require_once 'includes/common_data.php';
require_once 'includes/actions.php';
require_once 'includes/pages/test_groups.php';
require_once 'includes/layout/footer.php';
require_once __DIR__ . '/db/config.php';
require_once __DIR__ . '/helpers.php';
$db = db();
$lang = $_SESSION['lang'];
require_once __DIR__ . '/includes/actions.php';
require_once __DIR__ . '/includes/common_data.php';
require_once __DIR__ . '/includes/layout/header.php';
require_once __DIR__ . '/includes/pages/test_groups.php';
require_once __DIR__ . '/includes/layout/footer.php';
?>