Files
whatsapp/modules/lab_examenes/api/list.php
T
Lizandro GuarnizoandClaude Sonnet 4.6 fb0e77523c feat: módulo lab_examenes — CRUD catálogo de exámenes, items y tarifas
- Nuevo módulo lab_examenes con lista paginada, buscador y filtro por categoría
- Vista de detalle/edición con campos completos de exam_tipos (CUPS, protocolo,
  tipo muestra, nivel, abreviatura, seremite, ayuno, instrucciones)
- Sub-tabla inline de items de resultado (lab_items_resultado) con edición por fila
- Sub-tabla de precios por tarifa (lab_tarifas) con modal de edición
- APIs: list, get, save, save_item, save_tarifa, get_tarifas
- Script ETL Firebird→MySQL (scripts/etl_examenes.php) para la migración inicial

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-07 23:06:54 -05:00

38 lines
1.1 KiB
PHP

<?php
require_once __DIR__ . '/_helpers.php';
requireLogin();
$q = trim($_GET['q'] ?? '');
$cat = trim($_GET['categoria'] ?? '');
$page = max(1, (int)($_GET['page'] ?? 1));
$limit = max(1, min(200, (int)($_GET['limit'] ?? 50)));
$offset = ($page - 1) * $limit;
$where = [];
$params = [];
if ($q !== '') {
$like = '%' . $q . '%';
$where[] = '(nombre LIKE ? OR codigo LIKE ? OR cups LIKE ?)';
$params[] = $like; $params[] = $like; $params[] = $like;
}
if ($cat !== '') {
$where[] = 'categoria = ?';
$params[] = $cat;
}
$wSql = $where ? 'WHERE ' . implode(' AND ', $where) : '';
$pdo = db();
$s = $pdo->prepare("SELECT COUNT(*) FROM exam_tipos $wSql");
$s->execute($params);
$total = (int)$s->fetchColumn();
$s = $pdo->prepare(
"SELECT id, codigo, nombre, categoria, activo, cups, seremite, cod_protocolo, tipo_muestra
FROM exam_tipos $wSql ORDER BY categoria, nombre LIMIT $limit OFFSET $offset"
);
$s->execute($params);
jsonOk(['data' => $s->fetchAll(PDO::FETCH_ASSOC), 'total' => $total, 'page' => $page, 'limit' => $limit]);