Compare commits

2 Commits
Author SHA1 Message Date
Lizandro GuarnizoandClaude Sonnet 4.6 7b599b28ef fix(turnero): bacterióloga sin token va al dashboard, no a lugar_id=1
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-28 11:55:30 -05:00
Lizandro GuarnizoandClaude Sonnet 4.6 8472c916b0 fix(turnero): llamar_desde_espera actualiza lugar y dispara display
Al llamar un paciente de toma progresiva desde la espera, ahora se
actualiza lugar_destino_id al puesto que llama, se pone llamado_lugar_at
para que el display anuncie al paciente, y se notifica por SSE. El JS
abre la ficha y muestra el toast igual que un llamar normal.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-28 11:49:37 -05:00
4 changed files with 33 additions and 11 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ if ($_indexRole === 'recepcionista') {
header('Location: erp.php?m=turnero&v=recepcion'); exit; header('Location: erp.php?m=turnero&v=recepcion'); exit;
} }
if (in_array('turnero', $_indexModules, true) && !in_array('whatsapp', $_indexModules, true)) { if (in_array('turnero', $_indexModules, true) && !in_array('whatsapp', $_indexModules, true)) {
$_indexAdminRoles = ['superadmin', 'admin', 'supervisor']; $_indexAdminRoles = ['superadmin', 'admin', 'supervisor', 'bacteriologo'];
$url = in_array($_indexRole, $_indexAdminRoles, true) $url = in_array($_indexRole, $_indexAdminRoles, true)
? 'erp.php?m=turnero&v=dashboard' ? 'erp.php?m=turnero&v=dashboard'
: 'erp.php?m=turnero&v=recepcion'; : 'erp.php?m=turnero&v=recepcion';
+1 -1
View File
@@ -105,7 +105,7 @@ if ($_POST && !$loginBlocked) {
header('Location: enfermero_portal.php'); header('Location: enfermero_portal.php');
} elseif (in_array('turnero', $modules, true)) { } elseif (in_array('turnero', $modules, true)) {
if ($roleSlug === 'bacteriologo') { if ($roleSlug === 'bacteriologo') {
header('Location: erp.php?m=turnero&v=lugar&lugar_id=1'); header('Location: erp.php?m=turnero&v=dashboard');
} elseif (in_array($roleSlug, ['superadmin', 'admin', 'supervisor'], true)) { } elseif (in_array($roleSlug, ['superadmin', 'admin', 'supervisor'], true)) {
header('Location: erp.php?m=turnero&v=dashboard'); header('Location: erp.php?m=turnero&v=dashboard');
} else { } else {
+26 -6
View File
@@ -1,8 +1,7 @@
<?php <?php
/** /**
* POST llamar_desde_espera.php * POST llamar_desde_espera.php
* {turno_id} → devuelve el paciente a la cola activa para la siguiente muestra. * {turno_id, lugar_id} → regresa el paciente a cola, actualiza lugar y dispara display.
* SET muestra_espera_at = NULL.
*/ */
require_once __DIR__ . '/_helpers.php'; require_once __DIR__ . '/_helpers.php';
requireTurnero(); requireTurnero();
@@ -10,10 +9,31 @@ requireMethod('POST');
$input = inputJson(); $input = inputJson();
$turnoId = (int)($input['turno_id'] ?? 0); $turnoId = (int)($input['turno_id'] ?? 0);
$lugarId = (int)($input['lugar_id'] ?? 0);
if (!$turnoId) jsonError('turno_id requerido'); if (!$turnoId) jsonError('turno_id requerido');
if (!$lugarId) jsonError('lugar_id requerido');
db()->prepare( $pdo = db();
"UPDATE turnero_turnos SET muestra_espera_at = NULL WHERE id = ? AND muestra_espera_at IS NOT NULL" $pdo->prepare(
)->execute([$turnoId]); 'UPDATE turnero_turnos
SET muestra_espera_at = NULL,
lugar_destino_id = ?,
llamado_lugar_at = NOW(),
atendido_lugar_por = ?
WHERE id = ? AND muestra_espera_at IS NOT NULL'
)->execute([$lugarId, adminId(), $turnoId]);
jsonOk([], 'Paciente de vuelta en cola'); $stmt = $pdo->prepare(
'SELECT t.*, p.codigo AS prioridad_codigo, p.nombre AS prioridad_nombre, p.color AS prioridad_color,
COALESCE(ts.solo_muestras, 0) AS solo_muestras
FROM turnero_turnos t
JOIN turnero_prioridades p ON p.id = t.prioridad_id
LEFT JOIN turnero_solicitudes ts ON ts.turno_id = t.id
WHERE t.id = ?'
);
$stmt->execute([$turnoId]);
$turno = $stmt->fetch(PDO::FETCH_ASSOC);
if ($turno) notificarSSE((int)$turno['sesion_id']);
jsonOk(['turno' => $turno], 'Paciente llamado');
+5 -3
View File
@@ -2589,11 +2589,13 @@ async function _llamarDesdeEspera(turnoId) {
try { try {
const res = await fetch(API + 'llamar_desde_espera.php', { const res = await fetch(API + 'llamar_desde_espera.php', {
method: 'POST', headers: { 'Content-Type': 'application/json' }, method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ turno_id: turnoId }), body: JSON.stringify({ turno_id: turnoId, lugar_id: lugarId }),
}); });
const j = await res.json(); const j = await res.json();
if (!j.ok) mostrarError(j.error); if (!j.ok) { mostrarError(j.error); return; }
else cargarCola(); mostrarLlamando(j.turno.codigo);
await abrirFicha(j.turno);
cargarCola();
} catch (e) { mostrarError(e.message); } } catch (e) { mostrarError(e.message); }
} }