diff --git a/modules/turnero/views/recepcion.php b/modules/turnero/views/recepcion.php index d0f2e19..0d7fa63 100644 --- a/modules/turnero/views/recepcion.php +++ b/modules/turnero/views/recepcion.php @@ -177,6 +177,9 @@ require_once __DIR__ . '/../../../shared/components/sidebar.php';
+ + Ver Lugar + @@ -208,7 +211,7 @@ require_once __DIR__ . '/../../../shared/components/sidebar.php';

Sin turno activo

- Haga clic en "Llamar siguiente" o seleccione un turno de la cola + Haga clic en de un turno para llamarlo, o use "Llamar siguiente"
@@ -395,13 +398,18 @@ function renderCola(snap) { return; } lista.innerHTML = espera.map(t => ` -
-
${t.prioridad_codigo}
-
+
+
${t.prioridad_codigo}
+
${escHtml(t.codigo)}
-
${escHtml(t.paciente_nombre || 'Paciente')}
+
${escHtml(t.paciente_nombre || 'Sin nombre')}
+
`).join(''); } @@ -432,10 +440,8 @@ async function llamarSiguiente() { } } -// ── Seleccionar turno de la cola (para ver ficha de uno ya llamado) ─ +// ── Seleccionar turno de la cola (ver ficha sin cambiar estado) ───── async function seleccionarTurno(turnoId) { - // No abrir si ya hay uno activo en recepción - if (turnoActivo && turnoActivo.estado === 'en_recepcion') return; try { const res = await fetch(API + 'get_turno.php?id=' + turnoId); const json = await res.json(); @@ -446,6 +452,23 @@ async function seleccionarTurno(turnoId) { } } +// ── Llamar turno específico (cambia estado → en_recepcion) ───────── +async function llamarTurnoEspecifico(turnoId) { + try { + const res = await fetch(API + 'cambiar_estado.php', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ turno_id: turnoId, nuevo_estado: 'en_recepcion' }), + }); + const json = await res.json(); + if (!json.ok) { mostrarError(json.error); return; } + abrirFicha(json.turno); + cargarCola(); + } catch (err) { + mostrarError('Error al llamar turno: ' + err.message); + } +} + // ── Abrir ficha ─────────────────────────────────────────────── function abrirFicha(turno) { turnoActivo = turno; @@ -659,13 +682,27 @@ async function pasarALugar() { if (!json.ok) { mostrarError(json.error); btn.disabled = false; return; } // Reiniciar ficha - turnoActivo = null; + turnoActivo = null; solicitudActiva = null; document.getElementById('ficha-turno').classList.add('d-none'); - document.getElementById('ficha-placeholder').classList.remove('d-none'); document.getElementById('badge-turno-activo').classList.add('d-none'); cargarCola(); + // Mostrar aviso con link al lugar + const ph = document.getElementById('ficha-placeholder'); + ph.classList.remove('d-none'); + ph.innerHTML = ` + +

Turno pasado al lugar correctamente

+ El paciente aparece en la cola del puesto de toma de muestras + + Ir a Vista Lugar + + `; + } catch (err) { mostrarError(err.message); btn.disabled = false; @@ -705,6 +742,14 @@ function escHtml(str) { return d.innerHTML; } +function resetPlaceholder() { + const ph = document.getElementById('ficha-placeholder'); + ph.innerHTML = ` + +

Sin turno activo

+ Haga clic en "Llamar siguiente" o en de un turno de la cola`; +} + function mostrarError(msg) { alert('Error: ' + msg); }