feat(bandeja): filtros por fecha, nombre, # orden y estado
- Inputs desde/hasta pasan al API y filtran por rango de fechas - Buscador cubre nombre, número de orden, código y examen - API usa fecha cuando se pasa, sesión actual como fallback Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
4cb133010a
commit
118e98b360
@@ -91,6 +91,17 @@ if (isset($_GET['turno_id'])) {
|
||||
}
|
||||
|
||||
// ── LISTA ─────────────────────────────────────────────────────
|
||||
$desde = $_GET['desde'] ?? null;
|
||||
$hasta = $_GET['hasta'] ?? null;
|
||||
|
||||
if ($desde && $hasta) {
|
||||
$whereClause = "DATE(t.inicio_lugar_at) BETWEEN ? AND ?";
|
||||
$params = [$desde, $hasta];
|
||||
} else {
|
||||
$whereClause = "t.sesion_id = ?";
|
||||
$params = [$sesionId];
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT t.id, t.codigo, t.paciente_nombre, t.estado,
|
||||
t.inicio_lugar_at, t.fin_lugar_at, t.bandeja_visto_at,
|
||||
@@ -107,24 +118,17 @@ $stmt = $pdo->prepare("
|
||||
LEFT JOIN turnero_examen_items tei ON tei.solicitud_id = ts.id
|
||||
LEFT JOIN exam_tipos et ON et.id = tei.exam_tipo_id
|
||||
LEFT JOIN turnero_comentarios tc ON tc.turno_id = t.id
|
||||
WHERE t.sesion_id = ? AND t.inicio_lugar_at IS NOT NULL
|
||||
WHERE $whereClause AND t.inicio_lugar_at IS NOT NULL
|
||||
GROUP BY t.id
|
||||
ORDER BY ts.numero_orden ASC
|
||||
");
|
||||
$stmt->execute([$sesionId]);
|
||||
$stmt->execute($params);
|
||||
$todos = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$pendientes = array_values(array_filter($todos, fn($t) => $t['bandeja_visto_at'] === null));
|
||||
$vistos = array_values(array_filter($todos, fn($t) => $t['bandeja_visto_at'] !== null));
|
||||
|
||||
$stmtMp = $pdo->prepare("
|
||||
SELECT COUNT(*) FROM turnero_muestras tm
|
||||
JOIN turnero_solicitudes ts ON ts.id = tm.solicitud_id
|
||||
JOIN turnero_turnos t ON t.id = ts.turno_id
|
||||
WHERE t.sesion_id = ? AND tm.estado = 'pendiente'
|
||||
");
|
||||
$stmtMp->execute([$sesionId]);
|
||||
$muestrasPendientes = (int)$stmtMp->fetchColumn();
|
||||
$muestrasPendientes = array_sum(array_column($todos, 'muestras_pendientes'));
|
||||
|
||||
jsonOk([
|
||||
'pendientes' => $pendientes,
|
||||
|
||||
Reference in New Issue
Block a user