fix: get_pacientes.php soporta ?id=X para retornar paciente específico con phone_number correcto
This commit is contained in:
@@ -1,11 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
/** GET /api/lab/get_pacientes.php — Lista paginada de pacientes */
|
/** GET /api/lab/get_pacientes.php — Lista paginada de pacientes o detalle por ID */
|
||||||
require_once __DIR__ . '/_helpers.php';
|
require_once __DIR__ . '/_helpers.php';
|
||||||
requireMethod('GET');
|
requireMethod('GET');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$pac = new Paciente();
|
$pac = new Paciente();
|
||||||
|
|
||||||
|
// Detalle de un paciente específico
|
||||||
|
if (!empty($_GET['id']) && ctype_digit($_GET['id'])) {
|
||||||
|
$row = $pac->obtener((int)$_GET['id']);
|
||||||
|
if (!$row) jsonError('Paciente no encontrado', 404);
|
||||||
|
jsonOk(['data' => [$row]]);
|
||||||
|
}
|
||||||
|
|
||||||
$busqueda = trim($_GET['busqueda'] ?? $_GET['search'] ?? '');
|
$busqueda = trim($_GET['busqueda'] ?? $_GET['search'] ?? '');
|
||||||
$pagina = max(1, (int)($_GET['page'] ?? $_GET['pagina'] ?? 1));
|
$pagina = max(1, (int)($_GET['page'] ?? $_GET['pagina'] ?? 1));
|
||||||
$por = max(1, min(100, (int)($_GET['limit'] ?? $_GET['por_pagina'] ?? 30)));
|
$por = max(1, min(100, (int)($_GET['limit'] ?? $_GET['por_pagina'] ?? 30)));
|
||||||
|
|||||||
Reference in New Issue
Block a user