Autosave: 20260322-101548

This commit is contained in:
Flatlogic Bot 2026-03-22 10:15:48 +00:00
parent 6933c13c3e
commit 4472d09232
3 changed files with 18 additions and 12 deletions

View File

@ -1,14 +1,20 @@
<?php
require_once __DIR__ . '/db/config.php';
require_once 'db/config.php';
$db = db();
try {
$patient = $db->query("SELECT id, name FROM patients LIMIT 1")->fetch(PDO::FETCH_ASSOC);
$doctor = $db->query("SELECT id, name_en FROM doctors LIMIT 1")->fetch(PDO::FETCH_ASSOC);
echo "Patient: " . ($patient ? "ID=" . $patient['id'] . ", Name=" . $patient['name'] : "None") . "\n";
echo "Doctor: " . ($doctor ? "ID=" . $doctor['id'] . ", Name=" . $doctor['name_en'] : "None") . "\n";
} catch (PDOException $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Fetch one patient
$patient = $db->query("SELECT id, name FROM patients LIMIT 1")->fetch(PDO::FETCH_ASSOC);
// Fetch one doctor (employee with position 'Doctor')
$doctor = $db->query("
SELECT e.id, e.name_en
FROM employees e
JOIN positions p ON e.position_id = p.id
WHERE UPPER(p.name_en) = 'DOCTOR'
LIMIT 1")->fetch(PDO::FETCH_ASSOC);
if ($patient && $doctor) {
echo "Found Patient: " . $patient['name'] . " (ID: " . $patient['id'] . ")\n";
echo "Found Doctor: " . $doctor['name_en'] . " (ID: " . $doctor['id'] . ")\n";
} else {
echo "Could not find patient or doctor.\n";
}

View File

@ -41,7 +41,7 @@ try {
FROM bills b
JOIN patients p ON b.patient_id = p.id
LEFT JOIN visits v ON b.visit_id = v.id
LEFT JOIN doctors d ON v.doctor_id = d.id
LEFT JOIN employees d ON v.doctor_id = d.id
WHERE p.insurance_company_id = ?
AND b.insurance_covered > 0
AND DATE(b.created_at) BETWEEN ? AND ?

View File

@ -19,7 +19,7 @@ $stmt = $db->prepare("
FROM xray_inquiries xi
LEFT JOIN patients p ON xi.patient_id = p.id
LEFT JOIN visits v ON xi.visit_id = v.id
LEFT JOIN doctors d ON v.doctor_id = d.id
LEFT JOIN employees d ON v.doctor_id = d.id
WHERE xi.id = ?
");
$stmt->execute([$id]);