<?php
$page_title = "Patient Profile";
include 'layout.php';

$patient_id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
$result = $conn->query("SELECT * FROM patients WHERE patient_id = $patient_id");
$patient = $result->fetch_assoc();
?>

<div class="card shadow">
    <div class="card-header bg-info text-white">
        <h5>Patient Profile</h5>
    </div>
    <div class="card-body">
        <div class="row">
            <div class="col-md-6">
                <p><strong>Name:</strong> <?= htmlspecialchars($patient['first_name'] . ' ' . $patient['last_name']) ?></p>
                <p><strong>Gender:</strong> <?= $patient['gender'] ?></p>
                <p><strong>Date of Birth:</strong> <?= $patient['date_of_birth'] ?></p>
            </div>
            <div class="col-md-6">
                <p><strong>Email:</strong> <?= htmlspecialchars($patient['email']) ?></p>
                <p><strong>Phone:</strong> <?= htmlspecialchars($patient['phone']) ?></p>
                <p><strong>Status:</strong> <span class="badge bg-success">Active</span></p>
            </div>
        </div>
    </div>
    <div class="card-footer">
        <a href="view_patient_record.php?id=<?= $patient_id ?>" class="btn btn-primary">View Full Medical Record</a>
        <a href="add_prescription.php?patient_id=<?= $patient_id ?>" class="btn btn-success">Prescribe Medication</a>
    </div>
</div>
<?php include 'footer.php'; // if you create one ?>