`).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);
}