<?php
require_once '../includes/config.php';
require_once '../includes/functions.php';

// Verificar login
if (!isLoggedIn() || $_SESSION['user']['type'] !== 'admin') {
    header('Content-Type: application/json');
    echo json_encode(['error' => 'Não autorizado']);
    exit();
}

$search = $_GET['search'] ?? '';
$patients = searchPatients($search);

header('Content-Type: application/json');
echo json_encode($patients); 