Historial turnero: usar el formulario real de tomas prolongadas (F-LAB-28)

El desglose anterior se basaba en turnero_muestras, que no representa el
formulario "Control de Tomas de Muestras Prolongadas" que el laboratorio
ya usa para tomas seriadas (curvas de glicemia, etc.). Ahora el doc-pill
del historial muestra "X/Y tomas" usando es_toma_progresiva/tomas_firmadas
que get_consentimientos.php ya calculaba, sin duplicar lógica.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-08-03 11:57:27 -05:00
co-authored by Claude Sonnet 4.6
parent 0b8418ec76
commit 86aea30f62
2 changed files with 7 additions and 43 deletions
-21
View File
@@ -144,7 +144,6 @@ $turnoIds = array_column($turnos, 'id');
$examenes = [];
$consentimientos = [];
$comentarios = [];
$tomas = [];
if ($turnoIds) {
$ph = implode(',', array_fill(0, count($turnoIds), '?'));
@@ -195,25 +194,6 @@ if ($turnoIds) {
}
}
// Tomas de muestra — batch (una solicitud por turno, varias tomas por solicitud)
$stmtTom = $pdo->prepare(
"SELECT ts.turno_id, tm.tipo_muestra, tm.estado, tm.creado_at, tm.recibida_at,
ar.full_name AS recibida_por_nombre
FROM turnero_muestras tm
JOIN turnero_solicitudes ts ON ts.id = tm.solicitud_id
LEFT JOIN admin_users ar ON ar.id = tm.recibida_por
WHERE ts.turno_id IN ($ph)
ORDER BY tm.creado_at ASC"
);
$stmtTom->execute($turnoIds);
foreach ($stmtTom->fetchAll(PDO::FETCH_ASSOC) as $row) {
$tid = (int)$row['turno_id'];
unset($row['turno_id']);
$row['tiempo_min'] = ($row['creado_at'] && $row['recibida_at'])
? round((strtotime($row['recibida_at']) - strtotime($row['creado_at'])) / 60, 1)
: null;
$tomas[$tid][] = $row;
}
}
foreach ($turnos as &$turno) {
@@ -221,7 +201,6 @@ foreach ($turnos as &$turno) {
$turno['examenes'] = $examenes[$tid] ?? [];
$turno['consentimientos'] = $consentimientos[$tid] ?? [];
$turno['comentarios'] = $comentarios[$tid] ?? [];
$turno['tomas'] = $tomas[$tid] ?? [];
}
// ── Resumen por estado (del rango filtrado) ───────────────────