From 368c4c8a5a0c3e3f5922c8ba2aa8ea16f7ad8d44 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Mon, 27 Jul 2026 21:29:52 -0500 Subject: [PATCH] feat(bandeja): vistos/por-revisar, filtro nombre+examen, marcar como visto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Reemplaza activos/cerrados por pendientes (por revisar) / vistos - Columna bandeja_visto_at en turnero_turnos; API marcar_visto.php - Botón "Marcar como visto" → mueve paciente a sección inferior - Filtro en tiempo real por nombre y por código de examen (GROUP_CONCAT) - URL de consentimientos: relativa (consent.php?token=...) Co-Authored-By: Claude Sonnet 4.6 --- modules/turnero/api/get_bandeja.php | 28 +- modules/turnero/api/marcar_visto.php | 16 + modules/turnero/views/bandeja.php | 438 +++++++++++---------------- 3 files changed, 215 insertions(+), 267 deletions(-) create mode 100644 modules/turnero/api/marcar_visto.php diff --git a/modules/turnero/api/get_bandeja.php b/modules/turnero/api/get_bandeja.php index 5d11a62..5c408e4 100644 --- a/modules/turnero/api/get_bandeja.php +++ b/modules/turnero/api/get_bandeja.php @@ -19,6 +19,7 @@ if (isset($_GET['turno_id'])) { $turno = $pdo->prepare(" SELECT t.id, t.codigo, t.estado, t.paciente_nombre, t.inicio_lugar_at, t.fin_lugar_at, + t.bandeja_visto_at, ts.id AS sol_id, ts.numero_orden, p.tipo_documento, p.numero_documento, p.fecha_nacimiento, p.telefono, l.nombre AS lugar_nombre @@ -92,21 +93,24 @@ if (isset($_GET['turno_id'])) { // ── LISTA ───────────────────────────────────────────────────── $stmt = $pdo->prepare(" SELECT t.id, t.codigo, t.paciente_nombre, t.estado, - t.inicio_lugar_at, t.fin_lugar_at, + t.inicio_lugar_at, t.fin_lugar_at, t.bandeja_visto_at, ts.numero_orden, - l.nombre AS lugar_nombre + l.nombre AS lugar_nombre, + GROUP_CONCAT(et.codigo ORDER BY et.codigo SEPARATOR ' ') AS examenes_txt FROM turnero_turnos t - JOIN turnero_solicitudes ts ON ts.turno_id = t.id - JOIN turnero_lugares l ON l.id = t.lugar_destino_id + JOIN turnero_solicitudes ts ON ts.turno_id = t.id + JOIN turnero_lugares l ON l.id = t.lugar_destino_id + LEFT JOIN turnero_examen_items tei ON tei.solicitud_id = ts.id + LEFT JOIN exam_tipos et ON et.id = tei.exam_tipo_id WHERE t.sesion_id = ? AND t.inicio_lugar_at IS NOT NULL + GROUP BY t.id ORDER BY ts.numero_orden ASC "); $stmt->execute([$sesionId]); $todos = $stmt->fetchAll(PDO::FETCH_ASSOC); -$cerradosEstados = ['finalizado', 'ausente', 'cancelado']; -$activos = array_values(array_filter($todos, fn($t) => !in_array($t['estado'], $cerradosEstados))); -$cerrados = array_values(array_filter($todos, fn($t) => in_array($t['estado'], $cerradosEstados))); +$pendientes = array_values(array_filter($todos, fn($t) => $t['bandeja_visto_at'] === null)); +$vistos = array_values(array_filter($todos, fn($t) => $t['bandeja_visto_at'] !== null)); $stmtMp = $pdo->prepare(" SELECT COUNT(*) FROM turnero_muestras tm @@ -118,12 +122,12 @@ $stmtMp->execute([$sesionId]); $muestrasPendientes = (int)$stmtMp->fetchColumn(); jsonOk([ - 'activos' => $activos, - 'cerrados' => $cerrados, - 'stats' => [ + 'pendientes' => $pendientes, + 'vistos' => $vistos, + 'stats' => [ 'total' => count($todos), - 'activos' => count($activos), - 'cerrados' => count($cerrados), + 'pendientes' => count($pendientes), + 'vistos' => count($vistos), 'muestras_pendientes' => $muestrasPendientes, ], ]); diff --git a/modules/turnero/api/marcar_visto.php b/modules/turnero/api/marcar_visto.php new file mode 100644 index 0000000..6ea24c0 --- /dev/null +++ b/modules/turnero/api/marcar_visto.php @@ -0,0 +1,16 @@ +prepare('UPDATE turnero_turnos SET bandeja_visto_at = NOW() WHERE id = ?')->execute([$turnoId]); + +jsonOk([], 'Marcado como visto'); diff --git a/modules/turnero/views/bandeja.php b/modules/turnero/views/bandeja.php index 05e7a9d..92265a2 100644 --- a/modules/turnero/views/bandeja.php +++ b/modules/turnero/views/bandeja.php @@ -2,19 +2,19 @@ Layout::open('Bandeja del día', 'fas fa-layer-group'); ?>
- -
+
Bandeja del día - - Activos: — - Cerrados: — - Muestras pend.: — + + Por revisar: — + Vistos: — + Muestras pend.: —
- -
-
Cargando...
+
+ +
+
Cargando...
+
-
@@ -401,19 +329,16 @@ Layout::open('Bandeja del día', 'fas fa-layer-group');