feat(recepcion): panel muestras muestra último turno atendido por letra

API: agrega por_prioridad con último código llamado a muestras por letra.
Vista: badges con color de prioridad mostrando "A: A-023", "B: B-011", etc.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-30 19:51:10 -05:00
co-authored by Claude Sonnet 4.6
parent 498a144c18
commit 941b6740f0
2 changed files with 25 additions and 6 deletions
@@ -46,8 +46,26 @@ $s2 = $pdo->prepare(
$s2->execute([$sesionId]);
$enEsperaMuestra = (int)$s2->fetchColumn();
// Último turno atendido en muestras por prioridad (letra)
$sp = $pdo->prepare(
"SELECT p.codigo, p.color,
(SELECT t.codigo FROM turnero_turnos t
WHERE t.sesion_id = ? AND t.prioridad_id = p.id
AND t.lugar_destino_id IN (SELECT id FROM turnero_lugares WHERE tipo='muestras' AND activo=1)
AND t.inicio_lugar_at IS NOT NULL
ORDER BY t.numero DESC LIMIT 1) AS ultimo_codigo
FROM turnero_prioridades p
ORDER BY p.orden_peso ASC"
);
$sp->execute([$sesionId]);
$porPrioridad = array_values(array_filter(
$sp->fetchAll(PDO::FETCH_ASSOC),
fn($r) => $r['ultimo_codigo'] !== null
));
jsonOk([
'estaciones' => $estaciones,
'en_espera' => $enEspera,
'en_espera_muestra' => $enEsperaMuestra,
'por_prioridad' => $porPrioridad,
]);
+7 -6
View File
@@ -3096,12 +3096,13 @@ async function _cargarResumenMuestras() {
if (!j.ok) return;
const cont = document.getElementById('muestras-estaciones');
if (!cont) return;
cont.innerHTML = j.estaciones.map(e => {
const libre = !e.turno_id;
return `<span class="badge ${libre ? 'bg-secondary' : 'bg-success'}" style="font-size:.75rem;font-weight:500" title="${libre ? 'Libre' : escHtml(e.paciente_nombre || '')}">
${escHtml(e.nombre)}: ${libre ? '—' : escHtml(e.codigo)}
</span>`;
}).join('');
cont.innerHTML = (j.por_prioridad || []).map(p =>
`<span style="display:inline-flex;align-items:center;gap:4px;font-size:.78rem;font-weight:700;
padding:2px 8px;border-radius:99px;background:${escHtml(p.color)}22;color:${escHtml(p.color)};
border:1.5px solid ${escHtml(p.color)}55;white-space:nowrap">
${escHtml(p.codigo)}: ${escHtml(p.ultimo_codigo)}
</span>`
).join('');
const cb = document.getElementById('muestras-cola-badge');
cb.textContent = `${j.en_espera} en espera`;
cb.classList.toggle('d-none', j.en_espera === 0);