obtener((int)$_GET['id']); if (!$row) jsonError('Paciente no encontrado', 404); jsonOk(['data' => [$row]]); } $busqueda = trim($_GET['busqueda'] ?? $_GET['search'] ?? ''); $pagina = max(1, (int)($_GET['page'] ?? $_GET['pagina'] ?? 1)); $por = max(1, min(100, (int)($_GET['limit'] ?? $_GET['por_pagina'] ?? 30))); jsonOk($pac->listar($busqueda, $pagina, $por)); } catch (Exception $e) { jsonError($e->getMessage(), 500); }