diff --git a/src/app/features/indicadores/paciente-detalle/paciente-riesgo-tabla.html b/src/app/features/indicadores/paciente-detalle/paciente-riesgo-tabla.html
index faa62eb..a2c33dc 100644
--- a/src/app/features/indicadores/paciente-detalle/paciente-riesgo-tabla.html
+++ b/src/app/features/indicadores/paciente-detalle/paciente-riesgo-tabla.html
@@ -13,7 +13,6 @@
- Definición de cohorte
- {{ cohorte.url }}
- Versión de cohorte
- {{ cohorte.version }}
- - Fecha índice
- {{ cohorte.fecha_indice }}
Variables del modelo PIMM
@@ -35,6 +34,7 @@
- Modelo
- {{ riesgo.modelo_nombre }}
- Versión del modelo
- {{ riesgo.modelo_version }}
+ - Fecha índice
- {{ riesgo.fecha_indice ?? 'No disponible' }}
- Evaluado en (UTC)
- {{ riesgo.evaluado_en }}
- Estado del lote
- {{ riesgo.estado_lote === 'final' ? 'Final (final)' : 'Preliminar (preliminary)' }}
diff --git a/src/app/features/indicadores/paciente-detalle/paciente-riesgo.models.ts b/src/app/features/indicadores/paciente-detalle/paciente-riesgo.models.ts
index b7ff381..f1eb19d 100644
--- a/src/app/features/indicadores/paciente-detalle/paciente-riesgo.models.ts
+++ b/src/app/features/indicadores/paciente-detalle/paciente-riesgo.models.ts
@@ -28,6 +28,8 @@ export interface LoteRiesgoCacu {
lote_id: number;
modelo_nombre: string;
modelo_version: string;
+ /** The model's index date for this patient (ISO date): the horizons count from it. Absent from older APIs. */
+ fecha_indice?: string | null;
evaluado_en: string;
estado_lote: EstadoEvaluacionCacu;
horizontes: HorizonteRiesgoCacu[];
diff --git a/src/app/features/indicadores/paciente-detalle/paciente-riesgo.spec.ts b/src/app/features/indicadores/paciente-detalle/paciente-riesgo.spec.ts
index 4eea34d..56d0b02 100644
--- a/src/app/features/indicadores/paciente-detalle/paciente-riesgo.spec.ts
+++ b/src/app/features/indicadores/paciente-detalle/paciente-riesgo.spec.ts
@@ -46,9 +46,11 @@ describe('RIESGO-CACU-02: presentación y aislamiento', () => {
expect(root.querySelector('.interval')!.textContent).toContain('5 % – 12 %');
expect(root.textContent).toContain('Final (final)');
expect(root.textContent).toContain('Preliminar (preliminary)');
- for (const value of ['modelo-cacu', '2.1.0', '2026-10-01T00:00:00Z', 'cacu/cohorte_vigilancia', '0.2.0', '2023-04-15', 'incidente', 'ASC-US', 'POSITIVO']) {
+ for (const value of ['modelo-cacu', '2.1.0', '2026-10-01T00:00:00Z', 'cacu/cohorte_vigilancia', '0.2.0', '2026-06-01', 'incidente', 'ASC-US', 'POSITIVO']) {
expect(root.textContent).toContain(value);
}
+ // The index date shown is the risk's (the model's decision point), not the cohort member's.
+ expect(root.textContent).not.toContain('2023-04-15');
expect(root.querySelector('table')!.getAttribute('aria-describedby')).toBe('riesgo-simulado');
expect(root.querySelector('#riesgo-simulado')!.textContent).toContain('Información simulada · Entorno DEV');
expect(root.textContent).not.toMatch(/Caso nuevo observado|BAJO|INTERMEDIO|ALTO|CIN3/);
diff --git a/src/app/features/indicadores/paciente-detalle/paciente-riesgo.testing.ts b/src/app/features/indicadores/paciente-detalle/paciente-riesgo.testing.ts
index 511c042..ecf05cf 100644
--- a/src/app/features/indicadores/paciente-detalle/paciente-riesgo.testing.ts
+++ b/src/app/features/indicadores/paciente-detalle/paciente-riesgo.testing.ts
@@ -9,7 +9,7 @@ export function riesgoCacuEjemplo(): RiesgoPacienteCacu {
tipo_censura: 'incidente', c: 0, l: 0.164, r: 0.548, pap_0: 'ASC-US', hpv_0: 'POSITIVO',
},
riesgo: {
- lote_id: 12, modelo_nombre: 'modelo-cacu', modelo_version: '2.1.0',
+ lote_id: 12, modelo_nombre: 'modelo-cacu', modelo_version: '2.1.0', fecha_indice: '2026-06-01',
evaluado_en: '2026-10-01T00:00:00Z', estado_lote: 'final',
horizontes: [
{ horizonte_anios: 1, probabilidad: 0.08, ic_bajo: 0.05, ic_alto: 0.12, estado: 'final' },
diff --git a/src/app/features/indicadores/paciente-detalle/paciente-riesgo.validation.spec.ts b/src/app/features/indicadores/paciente-detalle/paciente-riesgo.validation.spec.ts
index 7716d4a..fbc8b28 100644
--- a/src/app/features/indicadores/paciente-detalle/paciente-riesgo.validation.spec.ts
+++ b/src/app/features/indicadores/paciente-detalle/paciente-riesgo.validation.spec.ts
@@ -90,6 +90,8 @@ describe('RIESGO-CACU-02: frontera del contrato DEV', () => {
['lote string', v => v.riesgo.lote_id = '12'],
['modelo omitido', v => delete v.riesgo.modelo_nombre],
['versión no textual', v => v.riesgo.modelo_version = 2],
+ ['fecha índice del riesgo inválida', v => v.riesgo.fecha_indice = '2026-02-30'],
+ ['fecha índice del riesgo no textual', v => v.riesgo.fecha_indice = 20260601],
['evaluación fecha imposible', v => v.riesgo.evaluado_en = '2026-02-30T00:00:00Z'],
['evaluación sin UTC', v => v.riesgo.evaluado_en = '2026-10-01T00:00:00-06:00'],
['hora inválida', v => v.riesgo.evaluado_en = '2026-10-01T25:00:00Z'],
diff --git a/src/app/features/indicadores/paciente-detalle/paciente-riesgo.validation.ts b/src/app/features/indicadores/paciente-detalle/paciente-riesgo.validation.ts
index e26ba5a..a920048 100644
--- a/src/app/features/indicadores/paciente-detalle/paciente-riesgo.validation.ts
+++ b/src/app/features/indicadores/paciente-detalle/paciente-riesgo.validation.ts
@@ -38,6 +38,7 @@ function riesgoValido(v: unknown) {
if (v === null) return true;
if (!record(v) || !Number.isSafeInteger(v['lote_id']) || !text(v['modelo_nombre']) || !text(v['modelo_version'])
|| !utcTimestamp(v['evaluado_en']) || !estado(v['estado_lote']) || !Array.isArray(v['horizontes'])) return false;
+ if (Object.hasOwn(v, 'fecha_indice') && v['fecha_indice'] !== null && !isoDate(v['fecha_indice'])) return false;
const horizontes = v['horizontes'];
return horizontes.every(horizonteValido)
&& horizontes.every((h, i) => i === 0 || horizontes[i - 1]['horizonte_anios'] < h['horizonte_anios']);