temp: debug form schema without underscore prefix

This commit is contained in:
Lizandro Guarnizo
2026-07-08 10:20:40 -05:00
parent 392b8629f7
commit 2d3eebea4b
+26
View File
@@ -0,0 +1,26 @@
<?php
require_once __DIR__ . '/config/config.php';
header('Content-Type: application/json; charset=utf-8');
$pdo = Database::getInstance()->getConnection();
$stmt = $pdo->prepare(
"SELECT id, nombre, codigo, esquema FROM lab_formularios
WHERE LOWER(nombre) LIKE '%helicobacter%' OR codigo = 'F-LAB-28'
LIMIT 5"
);
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (!$rows) {
$all = $pdo->query("SELECT id, nombre, codigo FROM lab_formularios ORDER BY id LIMIT 50")->fetchAll(PDO::FETCH_ASSOC);
echo json_encode(['not_found'=>true,'forms'=>$all], JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT);
exit;
}
foreach ($rows as &$r) {
$dec = json_decode($r['esquema'], true);
$campos = is_array($dec) ? $dec : ($dec['campos'] ?? []);
$fp = array_values(array_filter($campos, fn($f)=>($f['tipo']??'')==='firma_profesional'));
$r['count_fp'] = count($fp);
$r['firma_pro_ids'] = array_column($fp, 'id');
$r['all_tipos'] = array_count_values(array_column($campos, 'tipo'));
unset($r['esquema']);
}
echo json_encode($rows, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT);