TEA record: ADOS-2 by item, EEG quality and its alterations against the age norm; page tests follow the cards' and dialog's words
This commit is contained in:
@@ -3,8 +3,11 @@
|
||||
|
||||
export interface Metric {
|
||||
code: string;
|
||||
median?: (number | null);
|
||||
model: (string | null);
|
||||
outside: (number | null);
|
||||
p5?: (number | null);
|
||||
p95?: (number | null);
|
||||
value: number;
|
||||
z: (number | null);
|
||||
}
|
||||
|
||||
@@ -147,6 +147,82 @@
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
@if (domain() === 'tea') {
|
||||
<mat-card appearance="outlined" class="wide" data-section="tea">
|
||||
<mat-card-header><mat-card-title>ADOS-2</mat-card-title></mat-card-header>
|
||||
<mat-card-content>
|
||||
@if (ados2(); as a) {
|
||||
<h3>Puntajes por reactivo · {{ a.date }}</h3>
|
||||
<app-plot [figure]="a.figure" [height]="a.height" />
|
||||
<p class="totals">
|
||||
@for (t of a.totals; track t.label) {
|
||||
<span
|
||||
>{{ t.label }}: <strong>{{ t.value }}</strong></span
|
||||
>
|
||||
}
|
||||
</p>
|
||||
} @else {
|
||||
<p class="muted">Sin evaluación ADOS-2.</p>
|
||||
}
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
<mat-card appearance="outlined" class="wide" data-section="eeg">
|
||||
<mat-card-header><mat-card-title>EEG</mat-card-title></mat-card-header>
|
||||
<mat-card-content>
|
||||
@if (eeg.isLoading()) {
|
||||
<app-loading what="el EEG" />
|
||||
} @else if (eeg.value()?.study; as st) {
|
||||
<h3>Calidad del EEG</h3>
|
||||
<p>
|
||||
Estudio del {{ st.study_date }}:
|
||||
<strong>{{ st.valid ? 'aceptable para el análisis' : 'no aceptable' }}</strong>
|
||||
@if (st.level) {
|
||||
({{ st.level }})
|
||||
}
|
||||
</p>
|
||||
<h3>Alteraciones del EEG</h3>
|
||||
@if (!st.valid) {
|
||||
<p class="muted">Un EEG no aceptable no se compara con la norma por edad.</p>
|
||||
} @else if (!scored()) {
|
||||
<p class="muted">
|
||||
Ninguna curva por edad vigente ha evaluado este EEG (se promueven en Gobernanza).
|
||||
</p>
|
||||
} @else if (alterations().length) {
|
||||
<table class="plain">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Métrica</th>
|
||||
<th>Valor</th>
|
||||
<th>Norma por edad (P5–P95)</th>
|
||||
<th>Mediana</th>
|
||||
<th>Desviación (z)</th>
|
||||
<th>Detalle</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (m of alterations(); track m.code) {
|
||||
<tr>
|
||||
<td>{{ m.code }}</td>
|
||||
<td>{{ m.value | number: '1.0-3' }}</td>
|
||||
<td>{{ m.p5 | number: '1.0-3' }} – {{ m.p95 | number: '1.0-3' }}</td>
|
||||
<td>{{ m.median | number: '1.0-3' }}</td>
|
||||
<td>{{ m.z | number: '1.1-2' }}</td>
|
||||
<td>{{ m.outside! > 0 ? 'Aumentado' : 'Disminuido' }}</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
} @else {
|
||||
<p>Sin alteraciones: todas sus métricas están dentro de la norma por edad.</p>
|
||||
}
|
||||
} @else {
|
||||
<p class="muted">Sin EEG analizado.</p>
|
||||
}
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
}
|
||||
|
||||
@if (models().some((m) => m.scenarios.length)) {
|
||||
<mat-card appearance="outlined" class="wide" data-section="supervivencia">
|
||||
<mat-card-header
|
||||
|
||||
@@ -50,3 +50,9 @@ mat-card-content {
|
||||
padding: 2px 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.totals {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ import type {
|
||||
RiskAssessment,
|
||||
} from 'fhir/r4';
|
||||
import { Api } from '../api/api';
|
||||
import { studies as eegStudies } from '../api/fn/eeg/studies';
|
||||
import { study as eegStudy } from '../api/fn/eeg/study';
|
||||
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';
|
||||
@@ -164,6 +166,72 @@ export class Paciente {
|
||||
};
|
||||
},
|
||||
});
|
||||
/** 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(() => {
|
||||
const d = this.data.value();
|
||||
if (!d) return undefined;
|
||||
const field = (o: Observation) => (code(o.code) ?? '').replace(/^ados2\./, '');
|
||||
const scored = [...d.observations.values()].filter(
|
||||
(o) => (code(o.code) ?? '').startsWith('ados2.') && o.valueQuantity?.value !== undefined,
|
||||
);
|
||||
const latest = scored
|
||||
.map((o) => o.effectiveDateTime ?? '')
|
||||
.sort()
|
||||
.at(-1);
|
||||
if (latest === undefined) return undefined;
|
||||
const results = scored.filter((o) => (o.effectiveDateTime ?? '') === latest);
|
||||
const totals = ['social_affect_total', 'restricted_repetitive_total', 'overall_total'];
|
||||
const items = results.filter((o) => !totals.includes(field(o)));
|
||||
const figure: Figure = {
|
||||
data: [
|
||||
{
|
||||
type: 'bar',
|
||||
orientation: 'h',
|
||||
y: items.map((o) => label(o.code)),
|
||||
x: items.map((o) => o.valueQuantity!.value!),
|
||||
marker: { color: PALETTE[0] },
|
||||
hovertemplate: '%{y}: %{x}<extra></extra>',
|
||||
},
|
||||
],
|
||||
layout: {
|
||||
showlegend: false,
|
||||
margin: { t: 10, r: 16, b: 40, l: 16 },
|
||||
xaxis: { title: { text: 'Puntaje (0 a 3)' }, range: [0, 3], dtick: 1 },
|
||||
yaxis: { autorange: 'reversed', automargin: true, type: 'category' },
|
||||
},
|
||||
};
|
||||
return {
|
||||
date: latest.slice(0, 10),
|
||||
figure,
|
||||
height: 60 + items.length * 22,
|
||||
totals: results
|
||||
.filter((o) => totals.includes(field(o)))
|
||||
.map((o) => ({ label: label(o.code), value: o.valueQuantity!.value! })),
|
||||
};
|
||||
});
|
||||
|
||||
/** TEA: her EEG as analysed (the latest), its quality and its metrics against the age
|
||||
* curves: those outside the band are its alterations. */
|
||||
protected readonly eeg = resource({
|
||||
params: () => (this.domain() === 'tea' ? this.id() : undefined),
|
||||
loader: async ({ params: person }) => {
|
||||
const mine = (await this.api.invoke(eegStudies))
|
||||
.filter((s) => s.person_id === person && s.analysed)
|
||||
.sort((a, b) => b.study_date.localeCompare(a.study_date));
|
||||
if (!mine.length) return { study: undefined, analysis: undefined };
|
||||
return {
|
||||
study: mine[0],
|
||||
analysis: await this.api.invoke(eegStudy, { eeg_id: mine[0].id }),
|
||||
};
|
||||
},
|
||||
});
|
||||
protected readonly alterations = computed(() =>
|
||||
(this.eeg.value()?.analysis?.metrics ?? []).filter((m) => m.outside),
|
||||
);
|
||||
protected readonly scored = computed(() =>
|
||||
(this.eeg.value()?.analysis?.metrics ?? []).some((m) => m.z !== null && m.z !== undefined),
|
||||
);
|
||||
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