Mostrar métodos y escenarios sin curva en la supervivencia de la ficha
This commit is contained in:
@@ -560,7 +560,7 @@
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
}
|
||||
@if (models().some((m) => m.model.endsWith('.survival') && m.scenarios.length)) {
|
||||
@if (models().some((m) => m.model.endsWith('.survival'))) {
|
||||
<mat-card appearance="outlined" class="wide" data-section="supervivencia">
|
||||
<mat-card-header>
|
||||
<mat-card-title>{{
|
||||
@@ -585,17 +585,27 @@
|
||||
<li>{{ name }}</li>
|
||||
}
|
||||
</ul>
|
||||
@if (s.methods.length) {
|
||||
<h3>Métodos</h3>
|
||||
<ul class="scenarios methods">
|
||||
@for (name of s.methods; track name) {
|
||||
<li>{{ name }}</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
@for (f of s.figures; track f.title) {
|
||||
<h4>{{ f.title }}</h4>
|
||||
<app-plot [figure]="f.figure" [height]="340" />
|
||||
} @empty {
|
||||
<p class="muted">
|
||||
Sus escenarios no tienen fallecimientos suficientes para trazar curvas.
|
||||
</p>
|
||||
}
|
||||
@for (name of s.unavailable; track name) {
|
||||
<h4>{{ name }}</h4>
|
||||
<p class="muted">No disponible: datos insuficientes.</p>
|
||||
}
|
||||
<app-factores [rows]="s.factors" />
|
||||
} @else if (survival.error()) {
|
||||
<p class="muted" role="alert">No se pudo leer el informe del modelo.</p>
|
||||
} @else {
|
||||
<p class="muted">No disponible: datos insuficientes.</p>
|
||||
}
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
@@ -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<Figure>(() => 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;
|
||||
|
||||
Reference in New Issue
Block a user