fix(encuesta): usar paciente_cel directamente si no está en tabla users
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
a4ddc63b6f
commit
9a18184ad7
@@ -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');
|
||||
|
||||
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user