TEA record: Zonas más afectadas (head map and zones by deviation); survival scenarios leave Gobernanza

This commit is contained in:
Roberto Treviño
2026-11-28 17:15:43 -06:00
parent 20e26b847a
commit fd19fdaefa
10 changed files with 244 additions and 18 deletions
+45 -2
View File
@@ -202,8 +202,18 @@
</thead>
<tbody>
@for (m of alterations(); track m.code) {
<tr>
<td>{{ m.code }}</td>
<tr [class.chosen]="zoned()?.code === m.code">
<td>
<button
mat-button
type="button"
class="metric"
[attr.aria-expanded]="zoned()?.code === m.code"
(click)="zone.set(zoned()?.code === m.code ? undefined : m.code)"
>
{{ metricNames[m.code] ?? m.code }}
</button>
</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>
@@ -213,6 +223,39 @@
}
</tbody>
</table>
<p class="muted">Elija una alteración para ver sus zonas más afectadas.</p>
@if (zoned(); as z) {
<section class="zones" aria-label="Zonas más afectadas">
<h3>Zonas más afectadas</h3>
<p class="muted">
{{ metricNames[z.code] ?? z.code }} ·
{{
zonesScored()
? 'desviación de cada zona frente a su norma por edad'
: 'valor de cada zona (sin norma por edad por zona)'
}}
</p>
@if (z.electrodes.length) {
<app-plot [figure]="head()" [height]="280" />
}
@if (z.zones.length) {
<ol class="regions" aria-label="Zonas ordenadas por desviación">
@for (r of zoneOrder(); track r.site) {
<li [class.marked]="(r.z ?? 0) >= 2 || (r.z ?? 0) <= -2">
<span>{{ zoneNames[r.site] ?? r.site }}</span>
<span>{{
r.z !== null && r.z !== undefined
? 'z = ' + (r.z | number: '1.1-2')
: (r.value | number: '1.0-3')
}}</span>
</li>
}
</ol>
} @else if (!z.electrodes.length) {
<p class="muted">Esta métrica no se mide por zona.</p>
}
</section>
}
} @else {
<p>Sin alteraciones: todas sus métricas están dentro de la norma por edad.</p>
}
+23
View File
@@ -56,3 +56,26 @@ mat-card-content {
flex-wrap: wrap;
gap: 16px;
}
.zones {
margin-top: 12px;
}
.regions {
list-style: none;
margin: 8px 0 0;
padding: 0;
max-width: 420px;
li {
display: flex;
justify-content: space-between;
padding: 4px 8px;
border-bottom: 1px solid var(--mat-sys-outline-variant);
}
li.marked {
font-weight: 600;
color: var(--mat-sys-error);
}
}
tr.chosen td {
background: var(--mat-sys-surface-container);
}
+16
View File
@@ -21,6 +21,7 @@ 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 { Figure, PALETTE, Plot } from '../plot';
import { Loading } from '../loading';
@@ -233,6 +234,21 @@ export class Paciente {
(this.eeg.value()?.analysis?.metrics ?? []).some((m) => m.z !== null && m.z !== undefined),
);
protected readonly shown = signal<string | undefined>(undefined);
protected readonly metricNames = METRIC_NAMES;
protected readonly zoneNames = ZONE_NAMES;
/** "Zonas más afectadas": the alteration chosen, its zones and electrodes. */
protected readonly zone = signal<string | undefined>(undefined);
protected readonly zoned = computed(() => {
const m = this.alterations().find((a) => a.code === this.zone());
return m ? { code: m.code, zones: m.zones ?? [], electrodes: m.electrodes ?? [] } : undefined;
});
protected readonly zonesScored = computed(() =>
[...(this.zoned()?.zones ?? []), ...(this.zoned()?.electrodes ?? [])].some(
(s) => s.z !== null && s.z !== undefined,
),
);
protected readonly zoneOrder = computed(() => byDeviation(this.zoned()?.zones ?? []));
protected readonly head = computed(() => headMap(this.zoned()?.electrodes ?? []));
protected readonly curve = computed<Figure>(() => {
const models = this.models().filter((m) => m.predictions.length > 1);
return {