<?php
require_once __DIR__ . '/../../config/database.php';
header('Content-Type: application/json');

$db = Database::getInstance()->getConnection();
$categoria_id = $_GET['categoria_id'] ?? null;

if (!$categoria_id) {
    echo json_encode([]);
    exit;
}

$stmt = $db->prepare("SELECT id, codigo, nombre FROM examenes WHERE categoria_id = ? AND activo = 1 ORDER BY nombre");
$stmt->execute([$categoria_id]);
echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC));
