fix(turnero): no mostrar consentimientos de toma de muestras en recepcion
Agrega origen_lugar_id a turnero_consentimientos para distinguir consents creados por examen (null) vs por estación (= lugar_id destino). Recepcion filtra los de origen_lugar_id != null; lugar.php muestra solo los suyos + los de examen. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
333e856f38
commit
229977785b
@@ -37,6 +37,7 @@ $stmt = $pdo->prepare(
|
||||
tc.firmado_at,
|
||||
(tc.firma_profesional_svg IS NOT NULL) AS tiene_firma_profesional,
|
||||
tc.firmado_profesional_at,
|
||||
tc.origen_lugar_id,
|
||||
f.nombre AS formulario_nombre,
|
||||
f.esquema AS formulario_esquema
|
||||
FROM turnero_consentimientos tc
|
||||
@@ -139,7 +140,7 @@ if ($incluirSolicitud) {
|
||||
}
|
||||
}
|
||||
|
||||
// Fuente 2: lugar destino del turno
|
||||
// Fuente 2: lugar destino del turno (marcamos origen_lugar_id para filtrar en recepcion)
|
||||
$lugarDestinoId = (int)($turno['lugar_destino_id'] ?? 0);
|
||||
if ($lugarDestinoId) {
|
||||
$stmtL = $pdo->prepare(
|
||||
@@ -152,6 +153,7 @@ if ($incluirSolicitud) {
|
||||
foreach ($stmtL->fetchAll(PDO::FETCH_ASSOC) as $r) {
|
||||
$fid = (int)$r['formulario_id'];
|
||||
if (!in_array($fid, $vistosFIds, true)) {
|
||||
$r['origen_lugar_id'] = $lugarDestinoId;
|
||||
$requeridos[] = $r;
|
||||
$vistosFIds[] = $fid;
|
||||
}
|
||||
@@ -163,8 +165,8 @@ if ($incluirSolicitud) {
|
||||
$existFormIds = array_map('intval', array_column($consentimientos, 'formulario_id'));
|
||||
$stmtIns = $pdo->prepare(
|
||||
"INSERT IGNORE INTO turnero_consentimientos
|
||||
(turno_id, formulario_id, token, estado)
|
||||
VALUES (?, ?, ?, 'pendiente')"
|
||||
(turno_id, formulario_id, token, estado, origen_lugar_id)
|
||||
VALUES (?, ?, ?, 'pendiente', ?)"
|
||||
);
|
||||
$creados = 0;
|
||||
foreach ($requeridos as $r) {
|
||||
@@ -177,7 +179,7 @@ if ($incluirSolicitud) {
|
||||
mt_rand(0,0x3fff)|0x8000,
|
||||
mt_rand(0,0xffff), mt_rand(0,0xffff), mt_rand(0,0xffff)
|
||||
);
|
||||
$stmtIns->execute([$turnoId, (int)$r['formulario_id'], $token]);
|
||||
$stmtIns->execute([$turnoId, (int)$r['formulario_id'], $token, $r['origen_lugar_id'] ?? null]);
|
||||
$creados++;
|
||||
}
|
||||
}
|
||||
@@ -189,6 +191,7 @@ if ($incluirSolicitud) {
|
||||
tc.estado, tc.enviado_at, tc.firmado_at,
|
||||
(tc.firma_profesional_svg IS NOT NULL) AS tiene_firma_profesional,
|
||||
tc.firmado_profesional_at,
|
||||
tc.origen_lugar_id,
|
||||
f.nombre AS formulario_nombre,
|
||||
f.esquema AS formulario_esquema
|
||||
FROM turnero_consentimientos tc
|
||||
|
||||
Reference in New Issue
Block a user