32 lines
1.7 KiB
TypeScript
32 lines
1.7 KiB
TypeScript
export interface SeguimientoQuery { corte?: string; meses: 1 | 3 | 6 | 12; estatus?: string; grupo_edad?: string; mchat?: string; css?: string; estado_caso?: string; alteracion?: string; page: number; page_size: number; }
|
|
export interface SeguimientoStatus { codigo: string; etiqueta: string; }
|
|
// A row names its patient with `pac_id` (a decimal string) or the legacy `id_seudonimo`.
|
|
export interface SeguimientoPaciente {
|
|
pac_id?: string;
|
|
id_seudonimo?: string;
|
|
grupo_edad: string;
|
|
estatus: SeguimientoStatus;
|
|
ultima_citologia: { fecha: string; bethesda: string | null; calidad: string | null } | null;
|
|
ultimo_vph: { fecha: string; resultado: string; genotipo_16_18: boolean | null } | null;
|
|
dias_toma_diagnostico: number | null;
|
|
prioridad: SeguimientoStatus | null;
|
|
}
|
|
export interface SeguimientoResponse {
|
|
simulado: boolean;
|
|
corte: string;
|
|
ventana: { meses: 1 | 3 | 6 | 12; desde: string; hasta: string };
|
|
filtros: { estatus: string | null };
|
|
estatus_disponibles: SeguimientoStatus[];
|
|
reglas: { clave: string; valor: unknown; estado: 'provisional' | 'confirmado' }[];
|
|
paginacion: { page: number; page_size: number; total_items: number; total_pages: number };
|
|
items: SeguimientoPaciente[];
|
|
}
|
|
export function isoDate(value: unknown): value is string {
|
|
if (typeof value !== 'string' || !/^\d{4}-\d{2}-\d{2}$/.test(value) || value.startsWith('0000')) return false;
|
|
const date = new Date(value + 'T00:00:00Z');
|
|
return Number.isFinite(date.getTime()) && date.toISOString().slice(0, 10) === value;
|
|
}
|
|
export function latestStudy(item: SeguimientoPaciente): string | null {
|
|
return [item.ultima_citologia?.fecha, item.ultimo_vph?.fecha].filter(isoDate).sort().at(-1) ?? null;
|
|
}
|