From b1264da9795ab42eac9a97bcedcddd6ea609635f Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Tue, 21 Jul 2026 17:53:48 -0500 Subject: [PATCH] create_turno: priority F skips recepcion, goes direct to toma de muestras When a patient selects 'Muestra pendiente' (prioridad F) at the kiosk, the turn is immediately set to en_espera_lugar pointing to the first active muestras location. Recepcion never sees it; toma de muestras picks it up from its queue with no consent forms required. Co-Authored-By: Claude Sonnet 4.6 --- modules/turnero/api/create_turno.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/modules/turnero/api/create_turno.php b/modules/turnero/api/create_turno.php index 0de00d4..35f898f 100644 --- a/modules/turnero/api/create_turno.php +++ b/modules/turnero/api/create_turno.php @@ -120,11 +120,32 @@ try { $turnoId = (int) $pdo->lastInsertId(); $pdo->commit(); + // ── Prioridad F: saltar recepción, ir directo a toma de muestras ── + $esSoloMuestra = ($prioCodigo === 'F'); + if ($esSoloMuestra) { + try { + $stmtLugar = $pdo->prepare( + "SELECT id FROM turnero_lugares WHERE tipo = 'muestras' AND activo = 1 ORDER BY sort_order ASC LIMIT 1" + ); + $stmtLugar->execute(); + $lugarMuestras = $stmtLugar->fetchColumn(); + if ($lugarMuestras) { + $pdo->prepare( + "UPDATE turnero_turnos + SET estado = 'en_espera_lugar', + lugar_destino_id = ?, + fin_recepcion_at = NOW() + WHERE id = ?" + )->execute([(int)$lugarMuestras, $turnoId]); + notificarSSE($sesionId); + } + } catch (\Throwable $_) {} + } + notificarSSE($sesionId); // ── Crear registro de consentimiento (siempre, con o sin teléfono) ── $enlaceConsentimiento = null; - $esSoloMuestra = ($prioCodigo === 'F'); if (!$esSoloMuestra) { try { $stmtForms = $pdo->prepare(