fix: allow explicit es_toma_progresiva override per form; F-LAB-28 forced off
This commit is contained in:
@@ -61,8 +61,9 @@ $stmt = $pdo->prepare(
|
||||
tc.siguiente_toma_at,
|
||||
tc.toma_inicio_at,
|
||||
tc.datos_respuestas,
|
||||
f.nombre AS formulario_nombre,
|
||||
f.esquema AS formulario_esquema
|
||||
f.nombre AS formulario_nombre,
|
||||
f.esquema AS formulario_esquema,
|
||||
f.es_toma_progresiva AS formulario_es_toma_prog
|
||||
FROM turnero_consentimientos tc
|
||||
LEFT JOIN lab_formularios f ON f.id = tc.formulario_id
|
||||
WHERE tc.turno_id = ?
|
||||
@@ -83,9 +84,10 @@ foreach ($consentimientos as &$c) {
|
||||
$tieneFirmaPro = !empty($camposFirmaPro);
|
||||
$tieneFirmaPac = !empty(array_filter($campos, fn($f) => ($f['tipo'] ?? '') === 'firma'));
|
||||
|
||||
// Toma progresiva: más de 1 campo firma_profesional
|
||||
$esTomaProg = count($camposFirmaPro) > 1;
|
||||
$tomasTotal = count($camposFirmaPro);
|
||||
// Toma progresiva: override explícito en DB gana; si es NULL, usar heurística (>1 campo firma_profesional)
|
||||
$overrideProg = $c['formulario_es_toma_prog'] ?? null;
|
||||
$esTomaProg = $overrideProg !== null ? (bool)(int)$overrideProg : count($camposFirmaPro) > 1;
|
||||
$tomasTotal = count($camposFirmaPro);
|
||||
$tomasFirm = 0;
|
||||
if ($esTomaProg && $c['datos_respuestas']) {
|
||||
$dr = json_decode($c['datos_respuestas'], true) ?? [];
|
||||
@@ -103,7 +105,7 @@ foreach ($consentimientos as &$c) {
|
||||
$c['tomas_firmadas'] = $tomasFirm;
|
||||
// Exponer campos firma_profesional (ids) para el frontend
|
||||
$c['campos_firma_pro'] = array_column($camposFirmaPro, 'id');
|
||||
unset($c['formulario_esquema'], $c['datos_respuestas']);
|
||||
unset($c['formulario_esquema'], $c['formulario_es_toma_prog'], $c['datos_respuestas']);
|
||||
}
|
||||
unset($c);
|
||||
|
||||
@@ -235,8 +237,9 @@ if ($incluirSolicitud) {
|
||||
tc.siguiente_toma_at,
|
||||
tc.toma_inicio_at,
|
||||
tc.datos_respuestas,
|
||||
f.nombre AS formulario_nombre,
|
||||
f.esquema AS formulario_esquema
|
||||
f.nombre AS formulario_nombre,
|
||||
f.esquema AS formulario_esquema,
|
||||
f.es_toma_progresiva AS formulario_es_toma_prog
|
||||
FROM turnero_consentimientos tc
|
||||
LEFT JOIN lab_formularios f ON f.id = tc.formulario_id
|
||||
WHERE tc.turno_id = ?
|
||||
@@ -254,7 +257,8 @@ if ($incluirSolicitud) {
|
||||
$camposFirmaPro = array_values(array_filter($campos, fn($f) => ($f['tipo'] ?? '') === 'firma_profesional'));
|
||||
$tieneFirmaPro = !empty($camposFirmaPro);
|
||||
$tieneFirmaPac = !empty(array_filter($campos, fn($f) => ($f['tipo'] ?? '') === 'firma'));
|
||||
$esTomaProg = count($camposFirmaPro) > 1;
|
||||
$overrideProg = $c['formulario_es_toma_prog'] ?? null;
|
||||
$esTomaProg = $overrideProg !== null ? (bool)(int)$overrideProg : count($camposFirmaPro) > 1;
|
||||
$tomasFirm = 0;
|
||||
if ($esTomaProg && $c['datos_respuestas']) {
|
||||
$dr = json_decode($c['datos_respuestas'], true) ?? [];
|
||||
@@ -270,7 +274,7 @@ if ($incluirSolicitud) {
|
||||
$c['tomas_total'] = count($camposFirmaPro);
|
||||
$c['tomas_firmadas'] = $tomasFirm;
|
||||
$c['campos_firma_pro'] = array_column($camposFirmaPro, 'id');
|
||||
unset($c['formulario_esquema'], $c['datos_respuestas']);
|
||||
unset($c['formulario_esquema'], $c['formulario_es_toma_prog'], $c['datos_respuestas']);
|
||||
}
|
||||
unset($c);
|
||||
$respuesta['consentimientos'] = $consentimientos;
|
||||
|
||||
Reference in New Issue
Block a user