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;