feat(turnero): devolver paciente a recepción desde toma de muestras

- cambiar_estado: permite en_espera_lugar→en_recepcion y en_servicio→en_recepcion
- Al volver de un lugar limpia lugar_destino_id, llamado_lugar_at, inicio_lugar_at,
  fin_recepcion_at y atendido_lugar_por para que quede reasignable
- lugar.php: botón "A recepción" visible en en_espera_lugar y en_servicio
- resetFicha oculta el botón nuevo al limpiar la ficha

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-22 22:22:05 -05:00
co-authored by Claude Sonnet 4.6
parent 728d78f606
commit a15dceae2a
2 changed files with 36 additions and 2 deletions
+26
View File
@@ -794,6 +794,9 @@ require_once __DIR__ . '/../../../shared/components/sidebar.php';
<button class="btn-accion-sec warning d-none" id="btn-regresar" onclick="regresarCola()">
<i class="fas fa-undo"></i>Regresar cola
</button>
<button class="btn-accion-sec warning d-none" id="btn-devolver" onclick="devolverRecepcion()">
<i class="fas fa-reply"></i>A recepción
</button>
<button class="btn-accion-sec danger" id="btn-ausente" onclick="marcarAusente()">
<i class="fas fa-user-slash"></i>Ausente
</button>
@@ -1733,6 +1736,25 @@ async function regresarCola() {
}
}
async function devolverRecepcion() {
if (!turnoActivo) return;
if (!confirm(`¿Devolver turno ${turnoActivo.codigo} a recepción?`)) return;
try {
const res = await fetch(API + 'cambiar_estado.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ turno_id: turnoActivo.id, nuevo_estado: 'en_recepcion' }),
});
const json = await res.json();
if (!json.ok) { mostrarError(json.error); return; }
mostrarToast('Turno devuelto a recepción', 'info', 3000);
resetFicha();
cargarCola();
} catch (err) {
mostrarError(err.message);
}
}
async function cambiarEstadoTurno(nuevoEstado) {
try {
const res = await fetch(API + 'cambiar_estado.php', {
@@ -1800,6 +1822,7 @@ function resetFicha() {
document.getElementById('btn-finalizar').classList.add('d-none');
document.getElementById('btn-regresar').classList.add('d-none');
document.getElementById('btn-rellamar').classList.add('d-none');
document.getElementById('btn-devolver').classList.add('d-none');
volverACola();
}
@@ -1835,17 +1858,20 @@ function actualizarEstadoBadge(estado) {
const btnFin = document.getElementById('btn-finalizar');
const btnReg = document.getElementById('btn-regresar');
const btnRellamar = document.getElementById('btn-rellamar');
const btnDev = document.getElementById('btn-devolver');
if (estado === 'en_espera_lugar') {
btnIni.classList.remove('d-none'); btnIni.disabled = false;
btnFin.classList.add('d-none');
btnReg.classList.add('d-none');
btnRellamar.classList.add('d-none');
btnDev.classList.remove('d-none');
} else if (estado === 'en_servicio') {
btnIni.classList.add('d-none');
btnFin.classList.remove('d-none');
btnReg.classList.remove('d-none');
btnRellamar.classList.remove('d-none');
btnDev.classList.remove('d-none');
}
}