From 1260e0ff2a9ae22f2acfd0024a8b07c82283a87d Mon Sep 17 00:00:00 2001 From: edgar Date: Wed, 2 Dec 2026 18:13:33 -0600 Subject: [PATCH] =?UTF-8?q?Mostrar=20m=C3=A9todos=20y=20escenarios=20sin?= =?UTF-8?q?=20curva=20en=20la=20supervivencia=20de=20la=20ficha?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/paciente/paciente.html | 20 +++++++++++++++----- src/app/paciente/paciente.ts | 34 +++++++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/src/app/paciente/paciente.html b/src/app/paciente/paciente.html index ab982da..853f328 100644 --- a/src/app/paciente/paciente.html +++ b/src/app/paciente/paciente.html @@ -560,7 +560,7 @@ } - @if (models().some((m) => m.model.endsWith('.survival') && m.scenarios.length)) { + @if (models().some((m) => m.model.endsWith('.survival'))) { {{ @@ -585,17 +585,27 @@
  • {{ name }}
  • } + @if (s.methods.length) { +

    Métodos

    +
      + @for (name of s.methods; track name) { +
    • {{ name }}
    • + } +
    + } @for (f of s.figures; track f.title) {

    {{ f.title }}

    - } @empty { -

    - Sus escenarios no tienen fallecimientos suficientes para trazar curvas. -

    + } + @for (name of s.unavailable; track name) { +

    {{ name }}

    +

    No disponible: datos insuficientes.

    } } @else if (survival.error()) { + } @else { +

    No disponible: datos insuficientes.

    }
    diff --git a/src/app/paciente/paciente.ts b/src/app/paciente/paciente.ts index fdde577..12e981a 100644 --- a/src/app/paciente/paciente.ts +++ b/src/app/paciente/paciente.ts @@ -69,6 +69,12 @@ function facts(observations: Observation[]): Fact[] { /** One patient: her history (conditions, procedures), her tests and results, and the * champion models' risks with their curves. Everything read from the FHIR API. */ +/** The names of the methods the figures draw, each once. */ +function methods(figures: { figure: { data: unknown[] } }[]): string[] { + const names = figures.flatMap((f) => f.figure.data.map((t) => (t as { name?: string }).name)); + return [...new Set(names.filter((n): n is string => !!n))]; +} + @Component({ selector: 'app-paciente', imports: [ @@ -347,6 +353,8 @@ export class Paciente { return { factors: mine(summary?.['filas'] ?? []) as ScenarioFactors[], scenarios: m.scenarios, + unavailable: [] as string[], + methods: [] as string[], figures: mine(r['escenarios'] ?? []).map((e) => scenarioFigure( `${e.escenario} (n = ${e.n.toLocaleString('es-MX')}, recaídas = ${e.recaidas.toLocaleString('es-MX')})`, @@ -357,17 +365,22 @@ export class Paciente { ), }; } + const drawn = mine((report?.['escenarios'] ?? []) as any[]); + const figures = drawn.map((e) => + scenarioFigure( + `${e.escenario} (n = ${e.n.toLocaleString('es-MX')}, fallecidos = ${e.fallecidos.toLocaleString('es-MX')})`, + e, + e.horizons_months, + 'Supervivencia S(t)', + ), + ); return { factors: mine((report?.['factores_escenarios'] ?? []) as any[]) as ScenarioFactors[], scenarios: m.scenarios, - figures: mine((report?.['escenarios'] ?? []) as any[]).map((e) => - scenarioFigure( - `${e.escenario} (n = ${e.n.toLocaleString('es-MX')}, fallecidos = ${e.fallecidos.toLocaleString('es-MX')})`, - e, - e.horizons_months, - 'Supervivencia S(t)', - ), - ), + figures, + // her scenarios the report draws no curve for + unavailable: m.scenarios.filter((s) => !drawn.some((e) => e.escenario === s)), + methods: methods(figures), }; }, }); @@ -484,7 +497,10 @@ export class Paciente { protected readonly curve = computed
    (() => curveFigure(this.riskModels(), this.top())); protected readonly curveText = computed(() => curveText(this.riskModels())); private top(): number { - return Math.max(0, ...this.riskModels().flatMap((m) => m.predictions.map((p) => p.high ?? p.p))); + return Math.max( + 0, + ...this.riskModels().flatMap((m) => m.predictions.map((p) => p.high ?? p.p)), + ); } protected readonly name = name; protected readonly levelNames = LEVEL_NAMES;