From a7b5f4c50bfae10de7edf6e67c09e9b460f6213e Mon Sep 17 00:00:00 2001 From: rockdrigo Date: Sat, 21 Nov 2026 10:53:41 -0600 Subject: [PATCH] CaMa patient survival figure: the legend claims an interval only when one is drawn --- .../paciente-detalle/cama/cama-supervivencia-paciente.ts | 4 ++-- .../indicadores/paciente-detalle/paciente-riesgo-cama.spec.ts | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/features/indicadores/paciente-detalle/cama/cama-supervivencia-paciente.ts b/src/app/features/indicadores/paciente-detalle/cama/cama-supervivencia-paciente.ts index 2f33227..fac1ee3 100644 --- a/src/app/features/indicadores/paciente-detalle/cama/cama-supervivencia-paciente.ts +++ b/src/app/features/indicadores/paciente-detalle/cama/cama-supervivencia-paciente.ts @@ -6,7 +6,7 @@ import { tieneIntervalo } from '../paciente-riesgo.validation'; export const ETIQUETAS_PACIENTE = { titulo: 'Supervivencia de la paciente desde el primer reporte de biopsia con carcinoma invasor', eje_x: 'Meses desde el reporte de biopsia', eje_y: 'Probabilidad de supervivencia', - curva: 'Supervivencia estimada', puntos: 'Modelo (LR + red bayesiana) con IC 95 %', + curva: 'Supervivencia estimada', puntos: 'Modelo (LR + red bayesiana)', puntosConIntervalo: 'Modelo (LR + red bayesiana) con IC 95 %', } as const; export const COLOR_MODELO = '#6a3d9a'; /** The curve runs to this many months, as the cohort's does. */ @@ -48,7 +48,7 @@ export function figuraSupervivenciaPaciente(horizontes: readonly HorizonteRiesgo const data: Record[] = [ { type: 'scatter', mode: 'lines', x: curva.meses, y: curva.S, name: ETIQUETAS_PACIENTE.curva, line: { color: COLOR_MODELO, width: 2.6 }, hovertemplate: '%{x} meses: %{y:.1%}' }, - { type: 'scatter', mode: 'markers', name: ETIQUETAS_PACIENTE.puntos, x: puntos.map(p => p.meses), y: puntos.map(p => p.S), + { type: 'scatter', mode: 'markers', name: conIntervalo ? ETIQUETAS_PACIENTE.puntosConIntervalo : ETIQUETAS_PACIENTE.puntos, x: puntos.map(p => p.meses), y: puntos.map(p => p.S), marker: { symbol: 'diamond', size: 12, color: COLOR_MODELO, line: { color: 'white', width: 1 } }, ...(conIntervalo ? { error_y: { type: 'data', symmetric: false, visible: true, color: COLOR_MODELO, thickness: 1.8, width: 5, array: puntos.map(p => p.alto! - p.S), arrayminus: puntos.map(p => p.S - p.bajo!) } } : {}), diff --git a/src/app/features/indicadores/paciente-detalle/paciente-riesgo-cama.spec.ts b/src/app/features/indicadores/paciente-detalle/paciente-riesgo-cama.spec.ts index 70a95ab..187c2ce 100644 --- a/src/app/features/indicadores/paciente-detalle/paciente-riesgo-cama.spec.ts +++ b/src/app/features/indicadores/paciente-detalle/paciente-riesgo-cama.spec.ts @@ -78,6 +78,9 @@ describe('Supervivencia individual de la paciente CaMa', () => { expect(rombos(con).marker.symbol).toBe('diamond'); expect(rombos(con).error_y).toBeDefined(); expect(rombos(sin).error_y).toBeUndefined(); + // The legend claims an interval only when one is drawn. + expect(rombos(con).name).toContain('IC 95 %'); + expect(rombos(sin).name).not.toContain('IC'); expect(figuraSupervivenciaPaciente([])).toBeNull(); }); });