up
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/** GET /api/lab/get_domicilios.php — Lista de domicilios con filtros */
|
||||
require_once __DIR__ . '/_helpers.php';
|
||||
requireMethod('GET');
|
||||
|
||||
try {
|
||||
$dom = new Domicilio();
|
||||
|
||||
// Vista de un solo domicilio
|
||||
if (!empty($_GET['id'])) {
|
||||
$d = $dom->obtener((int)$_GET['id']);
|
||||
if (!$d) {
|
||||
jsonError('Domicilio no encontrado', 404);
|
||||
}
|
||||
jsonOk(['domicilio' => $d]);
|
||||
}
|
||||
|
||||
$filtros = array_filter([
|
||||
'fecha' => $_GET['fecha'] ?? '',
|
||||
'desde' => $_GET['desde'] ?? '',
|
||||
'hasta' => $_GET['hasta'] ?? '',
|
||||
'estado' => $_GET['estado'] ?? '',
|
||||
'enfermera_id' => (int)($_GET['enfermera_id'] ?? 0) ?: null,
|
||||
'paciente_id' => (int)($_GET['paciente_id'] ?? 0) ?: null,
|
||||
], fn($v) => $v !== null && $v !== '');
|
||||
|
||||
$pagina = max(1, (int)($_GET['page'] ?? 1));
|
||||
$por = max(1, min(200, (int)($_GET['limit'] ?? 30)));
|
||||
|
||||
$resultado = $dom->listar($filtros, $pagina, $por);
|
||||
|
||||
// Incluir resumen del día
|
||||
if (empty($_GET['no_stats'])) {
|
||||
$resultado['estadisticas_hoy'] = $dom->estadisticasHoy();
|
||||
$resultado['sin_asignar_hoy'] = count($dom->sinAsignar());
|
||||
}
|
||||
|
||||
jsonOk($resultado);
|
||||
} catch (Exception $e) {
|
||||
jsonError($e->getMessage(), 500);
|
||||
}
|
||||
Reference in New Issue
Block a user