<?php
session_start();
if (!isset($_SESSION['user_id'])) {
    header("Location: login.php");
    exit;
}

header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename="patients_import_template.csv"');

// Output UTF-8 BOM for Excel
echo "\xEF\xBB\xBF";

$output = fopen('php://output', 'w');

// Header row
fputcsv($output, [
    'Patient Name', 
    'DOB', 
    'Nationality', 
    'Telephone', 
    'City'
]);

// Sample row
fputcsv($output, [
    'John Doe', 
    '1990-01-01', 
    'Omani', 
    '96812345678', 
    'Muscat'
]);

fclose($output);
exit;
