Conectar dialog by kind of source; plain-language canvas; login page and guard; loading indicators as the old app; survival curves of her clinical scenarios in the CaMa record
This commit is contained in:
@@ -146,8 +146,38 @@
|
||||
}
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
@if (models().some((m) => m.scenarios.length)) {
|
||||
<mat-card appearance="outlined" class="wide" data-section="supervivencia">
|
||||
<mat-card-header
|
||||
><mat-card-title>Análisis de supervivencia</mat-card-title></mat-card-header
|
||||
>
|
||||
<mat-card-content>
|
||||
@if (survival.isLoading()) {
|
||||
<app-loading what="las curvas de supervivencia" [figure]="true" />
|
||||
} @else if (survival.value(); as s) {
|
||||
<h3>Escenario clínico de la paciente</h3>
|
||||
<ul class="scenarios">
|
||||
@for (name of s.scenarios; 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 tienen menos fallecimientos de los necesarios para trazar curvas.
|
||||
</p>
|
||||
}
|
||||
} @else if (survival.error()) {
|
||||
<p class="muted" role="alert">No se pudo leer el informe del modelo.</p>
|
||||
}
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
}
|
||||
</div>
|
||||
} @else if (loading()) {
|
||||
<p class="muted">Cargando…</p>
|
||||
<app-loading what="el expediente" />
|
||||
}
|
||||
</section>
|
||||
|
||||
@@ -33,3 +33,20 @@
|
||||
mat-card-content {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.scenarios {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 8px;
|
||||
list-style: none;
|
||||
margin: 0 0 12px;
|
||||
padding: 0;
|
||||
|
||||
li {
|
||||
background: var(--color-action-hover, #f1f6f6);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 999px;
|
||||
font-size: 13px;
|
||||
padding: 2px 10px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,15 @@ import type {
|
||||
Procedure,
|
||||
RiskAssessment,
|
||||
} from 'fhir/r4';
|
||||
import { code, ext, Fhir, label, resources } from '../fhir';
|
||||
import { Api } from '../api/api';
|
||||
import { readReport$Json } from '../api/fn/models/read-report-json';
|
||||
import type { Domain } from '../api/models/domain';
|
||||
import { code, EXT, ext, Fhir, label, resources } from '../fhir';
|
||||
import { scenarioFigure } from '../gobernanza/figures';
|
||||
import { CURP } from '../indicadores/follow-up';
|
||||
import { name } from '../indicadores/measures';
|
||||
import { Figure, PALETTE, Plot } from '../plot';
|
||||
import { Loading } from '../loading';
|
||||
|
||||
/** An Observation's value as the screens say it, whatever its type. */
|
||||
function shown(o: Observation): string {
|
||||
@@ -30,12 +35,13 @@ function shown(o: Observation): string {
|
||||
* champion models' risks with their curves. Everything read from the FHIR API. */
|
||||
@Component({
|
||||
selector: 'app-paciente',
|
||||
imports: [DecimalPipe, MatButtonModule, MatCardModule, MatIconModule, RouterLink, Plot],
|
||||
imports: [Loading, DecimalPipe, MatButtonModule, MatCardModule, MatIconModule, RouterLink, Plot],
|
||||
templateUrl: './paciente.html',
|
||||
styleUrl: './paciente.scss',
|
||||
})
|
||||
export class Paciente {
|
||||
private readonly fhir = inject(Fhir);
|
||||
private readonly api = inject(Api);
|
||||
readonly domain = input.required<string>();
|
||||
readonly id = input.required<string>();
|
||||
|
||||
@@ -114,7 +120,12 @@ export class Paciente {
|
||||
return [...latest.values()].map((r) => ({
|
||||
model: code(r.method) ?? '',
|
||||
text: r.method?.text ?? '',
|
||||
version: Number(/v(\d+)$/.exec(r.method?.text ?? '')?.[1] ?? 0),
|
||||
index: r.occurrenceDateTime ?? '',
|
||||
// the clinical scenarios of the model's report she falls in
|
||||
scenarios: (r.extension ?? [])
|
||||
.filter((e) => e.url === EXT + 'escenario-clinico')
|
||||
.map((e) => e.valueString ?? ''),
|
||||
predictions: (r.prediction ?? []).map((p) => ({
|
||||
years: p.whenRange?.high?.value ?? 0,
|
||||
p: p.probabilityDecimal ?? 0,
|
||||
@@ -123,6 +134,36 @@ export class Paciente {
|
||||
})),
|
||||
}));
|
||||
});
|
||||
/** "Análisis de supervivencia": the curves of her clinical scenarios, from the report of
|
||||
* the model version that scored her. */
|
||||
protected readonly survival = resource({
|
||||
params: () => {
|
||||
const m = this.models().find((x) => x.scenarios.length && x.version);
|
||||
return m ? { m, domain: this.domain() } : undefined;
|
||||
},
|
||||
loader: async ({ params: { m, domain } }) => {
|
||||
const report = await this.api.invoke(readReport$Json, {
|
||||
domain: domain as Domain,
|
||||
name: m.model.replace(`${domain}.`, ''),
|
||||
version: m.version,
|
||||
report: 'interpretability',
|
||||
});
|
||||
const drawn = ((report?.['escenarios'] ?? []) as any[]).filter((e) =>
|
||||
m.scenarios.includes(e.escenario),
|
||||
);
|
||||
return {
|
||||
scenarios: m.scenarios,
|
||||
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)',
|
||||
),
|
||||
),
|
||||
};
|
||||
},
|
||||
});
|
||||
protected readonly shown = signal<string | undefined>(undefined);
|
||||
protected readonly curve = computed<Figure>(() => {
|
||||
const models = this.models().filter((m) => m.predictions.length > 1);
|
||||
|
||||
Reference in New Issue
Block a user