venus
VENUS-79
Informes: NULL-safe práctica dedup — pacienteDni NULL collapses distinct prácticas, understates totals (ticket #3, Antonella 26→54)
Done high
cvcoder-venus-cc
Questions
No questions.
Activity
-
ROOT CAUSE: report aggregates count distinct prácticas via COUNT(DISTINCT (p.pacienteDni,p.fecha,p.sedeId)). pacienteDni is OPTIONAL/nullable; Postgres COUNT(DISTINCT) treats NULL composite tuples as EQUAL, so genuinely-distinct prácticas that lack a DNI but share fecha+sede collapse into one -> totals understated. Antonella Tajes: 54 distinct prácticas (36 NULL-dni) shown as 26. Verified on prod: current=26, patched=54. FIX (defect #1 only; defect #2 card-vs-role grain is a separate design call held by Elazar): make the dedup NULL-safe by COALESCE(pacienteDni, practica.id::text) inside the distinct tuple. Cross-student same-surgery dedup still fires when a DNI exists; DNI-less rows stop collapsing. 9 SITES (patch ALL for consistency): - src/lib/report-actions.ts:96 (getReporteSummary totalPracticasDistinct) - src/lib/report-actions.ts:187 (getAlumnoReporteDetail moduloRes totalDistinct) - src/lib/report-actions.ts:205 (getAlumnoReporteDetail totalRes) - src/lib/report-actions.ts:320 (getReporteDataset sedeRes totalPracticas) - src/lib/report-actions.ts:338 (getReporteDataset moduloRes totalPracticas) - src/lib/report-actions.ts:342 (getReporteDataset moduloRes ultimos30d, tuple inside CASE THEN) - src/app/informes/pdf/route.tsx:178 (ROW(...) syntax) - src/lib/admin-actions.ts:2162 (ROW(...), UNALIASED cols -> COALESCE("pacienteDni", "id"::text)) - src/app/api/internal/soporte-cron/route.ts:310 (ROW(...) weekly digest) PATCH: aliased -> COALESCE(p."pacienteDni", p."id"::text); unaliased (admin-actions) -> COALESCE("pacienteDni", "id"::text). practicas.id is uuid, ::text safe. Keep ROW()/bare-tuple syntax as-is per site. ACCEPTANCE: Antonella /informes total reads 54; no other alumno total DROPS (patched >= current everywhere).
-
NULL-safe práctica dedup across 9 sites — COALESCE(pacienteDni, id::text) stops NULL-DNI prácticas collapsing; Antonella 26->54, +42 recovered cohort-wide, no alumno drop. f091612/v0.68.14, audit PASS + db numeric PASS
-
Shipped f091612/v0.68.14. COALESCE(pacienteDni,id::text) across 9 dedup sites. DB numeric PASS: Antonella 26->54, +42 cohort-wide, zero alumno-total drops. audit PASS. Defect #2 (card-vs-role grain) held separate for Elazar.
bug
7w ago by wi-cli-venus
6w ago
2026-06-28 23:12