From 9a18184ad7ebcb9af5b8d055a8d30f8f34dbbfb4 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Thu, 30 Jul 2026 17:55:57 -0500 Subject: [PATCH] =?UTF-8?q?fix(encuesta):=20usar=20paciente=5Fcel=20direct?= =?UTF-8?q?amente=20si=20no=20est=C3=A1=20en=20tabla=20users?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit El paciente siempre tiene celular registrado; el error ocurría porque se requería match en users. Ahora usa paciente_cel como fallback final. Revierte la guarda del frontend del commit anterior. Co-Authored-By: Claude Sonnet 4.6 --- modules/turnero/api/enviar_encuesta.php | 6 +++++- modules/turnero/views/lugar.php | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/turnero/api/enviar_encuesta.php b/modules/turnero/api/enviar_encuesta.php index 3835133..5ea3230 100644 --- a/modules/turnero/api/enviar_encuesta.php +++ b/modules/turnero/api/enviar_encuesta.php @@ -40,7 +40,11 @@ if (!$userId && !empty($pac['paciente_cel'])) { if ($uRow) { $userId = (int)$uRow['id']; $phone = $uRow['phone_number']; } } -if (!$userId || !$phone) jsonError('El paciente no tiene número de WhatsApp registrado.'); +if (!$phone && !empty($pac['paciente_cel'])) { + $phone = $pac['paciente_cel']; +} + +if (!$phone) jsonError('El paciente no tiene número de WhatsApp registrado.'); try { $wa = new WhatsAppService('turnero'); diff --git a/modules/turnero/views/lugar.php b/modules/turnero/views/lugar.php index 99b9589..fab9e9a 100644 --- a/modules/turnero/views/lugar.php +++ b/modules/turnero/views/lugar.php @@ -1989,7 +1989,7 @@ async function finalizarAtencion() { if (hayPendientes) { mostrarError('Debe firmar todos los consentimientos antes de finalizar.'); return; } if (hayMuestrasPendientes) { mostrarError('Debe marcar cada muestra como recibida o pendiente antes de finalizar.'); return; } if (!confirm(`¿Finalizar atención del turno ${turnoActivo.codigo}?`)) return; - const _t = { id: turnoActivo.id, paciente_nombre: turnoActivo.paciente_nombre, paciente_cel: turnoActivo.paciente_cel }; + const _t = { id: turnoActivo.id, paciente_nombre: turnoActivo.paciente_nombre }; const ok = await cambiarEstadoTurno('finalizado'); if (ok) _ofrecerEncuesta(_t); } @@ -2069,7 +2069,6 @@ async function cambiarEstadoTurno(nuevoEstado) { let _encuestaTurnoId = null, _encuestaTimer = null; function _ofrecerEncuesta(turno) { - if (!turno.paciente_cel) return; _encuestaTurnoId = turno.id; const bar = document.getElementById('bar-encuesta'); document.getElementById('bar-encuesta-txt').textContent =