<?php
// ajax_get_patient.php
session_start();
require_once 'config.php';

if (!isset($_SESSION['doctor_id'])) {
    echo json_encode(['error' => 'Unauthorized']);
    exit;
}

$patient_id = (int)$_GET['patient_id'];
$appointment_id = (int)$_GET['appointment_id'];

$patient = $conn->query("SELECT * FROM opd_patients WHERE id = $patient_id")->fetch_assoc();
$appointment = $conn->query("SELECT * FROM opd_appointments WHERE id = $appointment_id")->fetch_assoc();

echo json_encode([
    'patient' => $patient,
    'appointment' => $appointment
]);
?>