Record: Relación con el ADOS-2 and Análisis de recurrencia; Gobernanza draws the association
This commit is contained in:
@@ -259,6 +259,92 @@
|
||||
} @else {
|
||||
<p>Sin alteraciones: todas sus métricas están dentro de la norma por edad.</p>
|
||||
}
|
||||
@if (st.valid && scored()) {
|
||||
<section
|
||||
class="relation"
|
||||
aria-label="Relación de las alteraciones del EEG con el ADOS-2"
|
||||
>
|
||||
<h3>Relación con el ADOS-2</h3>
|
||||
@if (!eeg.value()?.analysis?.relation?.length) {
|
||||
<p class="muted">
|
||||
Ningún modelo de asociación vigente ha evaluado este EEG (se promueven en
|
||||
Gobernanza).
|
||||
</p>
|
||||
} @else if (!related().length) {
|
||||
<p>
|
||||
Ninguna zona alterada de este paciente (|z| ≥ 2) tiene una asociación clara
|
||||
con el ADOS-2 en la cohorte.
|
||||
</p>
|
||||
} @else {
|
||||
<p class="muted">
|
||||
Modelo de asociación ajustado en la cohorte ({{ related()[0].n }} niños, por
|
||||
edad y módulo del ADOS-2): qué tanto se asocia cada alteración del EEG por
|
||||
zona con un aspecto del ADOS-2. No es un diagnóstico ni indica qué causa qué.
|
||||
</p>
|
||||
<table class="plain">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Zona del EEG</th>
|
||||
<th>Aspecto del ADOS-2</th>
|
||||
<th>Asociación en la cohorte</th>
|
||||
<th>Probabilidad para este paciente</th>
|
||||
<th>Lo que muestra su ADOS-2</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (f of related(); track f.biomarker + f.zone + f.outcome_code) {
|
||||
<tr>
|
||||
<td>
|
||||
<strong>{{ biomarkerNames[f.biomarker] ?? f.biomarker }}</strong>
|
||||
<small
|
||||
>{{ zoneNames[f.zone] ?? f.zone }} · z =
|
||||
{{ f.z | number: '1.1-2' }}</small
|
||||
>
|
||||
</td>
|
||||
<td>
|
||||
{{ outcomeNames[f.outcome_code] ?? f.outcome_code }}
|
||||
<small>{{ f.kind === 'item' ? 'Reactivo' : 'Dominio' }}</small>
|
||||
</td>
|
||||
<td>
|
||||
OR {{ f.odds_ratio | number: '1.2-2' }}
|
||||
<small
|
||||
>IC 95 % {{ f.ci_low | number: '1.2-2' }}–{{
|
||||
f.ci_high | number: '1.2-2'
|
||||
}}
|
||||
· q {{ qText(f.q) }}</small
|
||||
>
|
||||
<small>{{
|
||||
f.odds_ratio >= 1
|
||||
? 'A mayor z, mayor probabilidad'
|
||||
: 'A menor z, mayor probabilidad'
|
||||
}}</small>
|
||||
</td>
|
||||
<td>
|
||||
<strong>{{ f.probability * 100 | number: '1.0-0' }} %</strong>
|
||||
<small
|
||||
>{{ f.event }} · con z = 0:
|
||||
{{ f.reference_probability * 100 | number: '1.0-0' }} %</small
|
||||
>
|
||||
</td>
|
||||
<td>
|
||||
{{ observed(f) }}
|
||||
@if (matches(f); as m) {
|
||||
<small>{{ m }}</small>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="muted">
|
||||
OR mayor que 1: a mayor z en esa zona, más probable que el aspecto salga
|
||||
alterado; menor que 1, al revés. Solo se muestran las zonas alteradas del
|
||||
paciente (|z| ≥ 2) con una asociación clara en la cohorte (q < 0.05).
|
||||
Versión del modelo: {{ related()[0].model }}.
|
||||
</p>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
} @else {
|
||||
<p class="muted">Sin EEG analizado.</p>
|
||||
}
|
||||
@@ -266,7 +352,7 @@
|
||||
</mat-card>
|
||||
}
|
||||
|
||||
@if (models().some((m) => m.scenarios.length)) {
|
||||
@if (models().some((m) => m.model.endsWith('.survival') && 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
|
||||
@@ -295,6 +381,51 @@
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
}
|
||||
@if (recurrenceModel(); as rm) {
|
||||
<mat-card appearance="outlined" class="wide" data-section="recurrencia">
|
||||
<mat-card-header
|
||||
><mat-card-title>Análisis de recurrencia</mat-card-title></mat-card-header
|
||||
>
|
||||
<mat-card-content>
|
||||
<table class="plain">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Horizonte</th>
|
||||
<th>Probabilidad de recurrencia</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (p of rm.predictions; track p.years) {
|
||||
<tr>
|
||||
<td>{{ p.years | number: '1.0-1' }} {{ p.years === 1 ? 'año' : 'años' }}</td>
|
||||
<td class="num">{{ p.p * 100 | number: '1.1-1' }} %</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
@if (recurrence.isLoading()) {
|
||||
<app-loading what="las curvas de recurrencia" [figure]="true" />
|
||||
} @else if (recurrence.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 recaídas de las necesarias para trazar curvas.
|
||||
</p>
|
||||
}
|
||||
} @else if (recurrence.error()) {
|
||||
<p class="muted" role="alert">No se pudo leer el informe del modelo.</p>
|
||||
}
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
}
|
||||
</div>
|
||||
} @else if (loading()) {
|
||||
<app-loading what="el expediente" />
|
||||
|
||||
@@ -79,3 +79,12 @@ mat-card-content {
|
||||
tr.chosen td {
|
||||
background: var(--mat-sys-surface-container);
|
||||
}
|
||||
|
||||
.relation {
|
||||
margin-top: 16px;
|
||||
td small {
|
||||
display: block;
|
||||
color: var(--mat-sys-on-surface-variant);
|
||||
font-size: 0.8em;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,15 @@ 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 { byDeviation, headMap, METRIC_NAMES, ZONE_NAMES } from '../eeg-labels';
|
||||
import {
|
||||
BIOMARKER_NAMES,
|
||||
byDeviation,
|
||||
headMap,
|
||||
METRIC_NAMES,
|
||||
OUTCOME_NAMES,
|
||||
ZONE_NAMES,
|
||||
} from '../eeg-labels';
|
||||
import type { Relation } from '../api/models/relation';
|
||||
import { Figure, PALETTE, Plot } from '../plot';
|
||||
import { Loading } from '../loading';
|
||||
|
||||
@@ -137,36 +145,58 @@ 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)',
|
||||
/** "Análisis de supervivencia" and "Análisis de recurrencia": the curves of her clinical
|
||||
* scenarios, from the report of the model version that scored her. */
|
||||
protected readonly survival = this.analysis('survival');
|
||||
protected readonly recurrence = this.analysis('recurrence');
|
||||
protected readonly recurrenceModel = computed(() =>
|
||||
this.models().find((m) => m.model.endsWith('.recurrence') && m.version),
|
||||
);
|
||||
|
||||
private analysis(name: 'survival' | 'recurrence') {
|
||||
return resource({
|
||||
params: () => {
|
||||
const m = this.models().find(
|
||||
(x) => x.model === `${this.domain()}.${name}` && 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,
|
||||
version: m.version,
|
||||
report: 'interpretability',
|
||||
});
|
||||
const mine = (all: any[]) => all.filter((e) => m.scenarios.includes(e.escenario));
|
||||
if (name === 'recurrence') {
|
||||
const r = (report?.['recurrencia'] ?? {}) as any;
|
||||
return {
|
||||
scenarios: m.scenarios,
|
||||
figures: mine(r['escenarios'] ?? []).map((e) =>
|
||||
scenarioFigure(
|
||||
`${e.escenario} (n = ${e.n.toLocaleString('es-MX')}, recaídas = ${e.recaidas.toLocaleString('es-MX')})`,
|
||||
e,
|
||||
r['horizons_months'],
|
||||
'Supervivencia libre de recaída',
|
||||
),
|
||||
),
|
||||
};
|
||||
}
|
||||
return {
|
||||
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)',
|
||||
),
|
||||
),
|
||||
),
|
||||
};
|
||||
},
|
||||
});
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
/** TEA: her latest ADOS-2 (an encounter whose observations are the catalog's
|
||||
* `ados2.*` fields), item by item, and its totals. */
|
||||
protected readonly ados2 = computed(() => {
|
||||
@@ -247,6 +277,32 @@ export class Paciente {
|
||||
(s) => s.z !== null && s.z !== undefined,
|
||||
),
|
||||
);
|
||||
protected readonly biomarkerNames = BIOMARKER_NAMES;
|
||||
protected readonly outcomeNames = OUTCOME_NAMES;
|
||||
/** "Relación con el ADOS-2": her altered zones (|z| ≥ 2) with a clear association in the
|
||||
* cohort (q < 0.05), clearest first, as the old summary showed them. */
|
||||
protected readonly related = computed(() =>
|
||||
(this.eeg.value()?.analysis?.relation ?? [])
|
||||
.filter((f) => Math.abs(f.z) >= 2 && f.q !== null && f.q !== undefined && f.q < 0.05)
|
||||
.sort((a, b) => (a.q ?? 1) - (b.q ?? 1)),
|
||||
);
|
||||
protected qText(q?: number | null): string {
|
||||
return q === null || q === undefined ? '—' : q < 0.001 ? '< 0.001' : `= ${q.toFixed(3)}`;
|
||||
}
|
||||
protected observed(f: Relation): string {
|
||||
if (f.observed === null || f.observed === undefined) return 'Sin dato';
|
||||
if (f.kind === 'item')
|
||||
return f.observed >= 1 ? `Alterado (${f.observed})` : 'Sin anormalidad (0)';
|
||||
return `CSS ${f.observed}`;
|
||||
}
|
||||
/** Whether what she shows is what the model leans to (above or below one half). */
|
||||
protected matches(f: Relation): string | undefined {
|
||||
if (f.observed === null || f.observed === undefined) return undefined;
|
||||
const present = f.kind === 'item' ? f.observed >= 1 : f.observed >= 8;
|
||||
return present === f.probability >= 0.5
|
||||
? 'Coincide con lo que el modelo esperaba'
|
||||
: 'No coincide con lo que el modelo esperaba';
|
||||
}
|
||||
protected readonly zoneOrder = computed(() => byDeviation(this.zoned()?.zones ?? []));
|
||||
protected readonly head = computed(() => headMap(this.zoned()?.electrodes ?? []));
|
||||
protected readonly curve = computed<Figure>(() => {
|
||||
|
||||
Reference in New Issue
Block a user