From ec552136bf3be9b3f57bda341c82fb4d146f0f2a Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Mon, 3 Aug 2026 14:19:35 -0500 Subject: [PATCH] Incluir muestras rechazadas al volver, resaltar servicio prolongado en historial MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Las consultas de "muestras pendientes de visita anterior" solo incluían estado='pendiente'; ahora también 'rechazada', así una muestra rechazada en una visita aparece igual cuando el paciente vuelve, y se puede recibir directo (sin el paso extra de revertir a pendiente primero). En historial.php, la columna Servicio se resalta en rojo con ícono de alerta cuando supera 20 minutos (SERVICIO_PROLONGADO_MIN), para detectar turnos prolongados a simple vista. Co-Authored-By: Claude Sonnet 4.6 --- modules/turnero/api/get_consentimientos.php | 4 ++-- modules/turnero/views/historial.php | 6 +++++- modules/turnero/views/lugar.php | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/turnero/api/get_consentimientos.php b/modules/turnero/api/get_consentimientos.php index fd3c215..97781fe 100644 --- a/modules/turnero/api/get_consentimientos.php +++ b/modules/turnero/api/get_consentimientos.php @@ -399,7 +399,7 @@ if ($incluirSolicitud) { LEFT JOIN lab_tipos_muestra lt ON lt.codigo = tm.tipo_muestra WHERE ts.paciente_id = ? AND tm.solicitud_id != ? - AND tm.estado = 'pendiente' + AND tm.estado IN ('pendiente','rechazada') ORDER BY tm.id ASC" ); $stmtPrev->execute([$solicitud['paciente_id'], $solicitud['id']]); @@ -432,7 +432,7 @@ if ($incluirSolicitud) { JOIN turnero_solicitudes ts ON ts.id = tm.solicitud_id LEFT JOIN lab_tipos_muestra lt ON lt.codigo = tm.tipo_muestra WHERE ts.paciente_id = ? - AND tm.estado = 'pendiente' + AND tm.estado IN ('pendiente','rechazada') ORDER BY tm.id ASC" ); $stmtPrev->execute([$pacId]); diff --git a/modules/turnero/views/historial.php b/modules/turnero/views/historial.php index ad6a698..0e1c51a 100644 --- a/modules/turnero/views/historial.php +++ b/modules/turnero/views/historial.php @@ -251,6 +251,7 @@ Layout::open('Historial de Turnos', 'fas fa-history'); Historial de Turnos ═══════════════════════════════════════════════════════════ */ const API = 'modules/turnero/api/'; +const SERVICIO_PROLONGADO_MIN = 20; // minutos — a partir de aquí se resalta en rojo let _state = { fechaDesde : '', @@ -447,7 +448,10 @@ function renderTabla(turnos) { .toLocaleString('es-CO',{hour:'2-digit',minute:'2-digit'}) : '—'; const espMin = t.espera_min != null ? t.espera_min + ' m' : '—'; - const srvMin = t.servicio_min != null ? t.servicio_min + ' m' : '—'; + const esProlongado = t.servicio_min != null && t.servicio_min > SERVICIO_PROLONGADO_MIN; + const srvMin = t.servicio_min != null + ? `${esProlongado ? '' : ''}${t.servicio_min} m` + : '—'; const totMin = t.total_min != null ? t.total_min + ' m' : '—'; const tel = esc(t.paciente_cel || '—'); const priCls = esc(t.prioridad_color || '#888'); diff --git a/modules/turnero/views/lugar.php b/modules/turnero/views/lugar.php index f52454d..12bef02 100644 --- a/modules/turnero/views/lugar.php +++ b/modules/turnero/views/lugar.php @@ -2492,8 +2492,9 @@ function renderMuestras(lista) { summary.innerHTML = chips; cont.innerHTML = lista.map(m => { - const esPend = m.estado === 'pendiente'; const esPrevio = !!m.es_pendiente_anterior; + // Rechazadas de una visita anterior también se pueden recibir directo (el paciente trae muestra nueva) + const esPend = m.estado === 'pendiente' || (esPrevio && m.estado === 'rechazada'); const label = escHtml(m.label || m.tipo_muestra || 'MUESTRA'); const origenTag = esPrevio ? `