Identify follow-up patients by pac_id

Rows name their patient with pac_id (a decimal string) or the legacy
id_seudonimo. pac_id wins; an invalid pac_id is never replaced by the
legacy field, and a page that repeats a patient or mixes both fields is
not drawn or exported. The table, patient record, PDF and spreadsheet
follow the announced identifier column and label. CaCu requests risk
only with a pac_id.
This commit is contained in:
Angel Capetillo Zavala
2026-11-13 18:19:27 -06:00
parent caf5f954b7
commit 3b246b4f1f
31 changed files with 392 additions and 89 deletions
@@ -2,6 +2,7 @@ import { inject, Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { map } from 'rxjs';
import { isoDate } from './cacu-seguimiento.models';
import { identidadesDe } from './paciente-identidad';
import { etiquetaDeFiltro } from './etiquetas-cohorte';
import { Dominio, requireDominio } from './indicadores.models';
@@ -30,7 +31,7 @@ export interface SeguimientoTablaResponse extends Partial<ContextoLista> {
filtros_disponibles: SeguimientoFiltro[];
columnas: SeguimientoColumna[];
paginacion: { page: number; page_size: number; total_items: number; total_pages: number };
// Every item has `id_seudonimo`; the rest are the columns' keys and their details.
// Every item names its patient (`pac_id`, or the legacy `id_seudonimo`); the rest are the columns' keys and their details.
items: Record<string, SeguimientoValor>[];
}
export class SeguimientoInvalido extends Error {}
@@ -92,7 +93,7 @@ export function seguimientoTablaResponse(v: unknown): SeguimientoTablaResponse {
|| !filtrosOk || !columnasOk
|| !record(filters) || !Object.entries(filters).every(([k, f]) => (f === null || typeof f === 'string') && (available as Record<string, unknown>[]).some(a => a['clave'] === k))
|| !Array.isArray(v['items']) || v['items'].length > p['page_size']
|| !v['items'].every(item => record(item) && text(item['id_seudonimo']) && Object.values(item).every(valor))) {
|| !v['items'].every(item => record(item) && Object.values(item).every(valor)) || !identidadesDe(v['items'] as Record<string, unknown>[])) {
throw new SeguimientoInvalido('Respuesta de seguimiento inválida');
}
const respuesta = v as unknown as SeguimientoTablaResponse;