T10/T11: the TEA record and the risk page render inside rebuild's patient frame

Paciente renders the TEA record and, on the risk route, the risk page with
the same frame as CaCu and CaMa: back link, title with id, identity block
from the FHIR Patient (name, birth date, sex, one row per identifier
system), sections as one card component, Material controls for the
altered-zones toggle and the pair choice, export button in rebuild's style.
tea-patient.ts, tea-record.html, tea-risk.html and tea-section.html/scss are
deleted; the logic specs follow the new structure.
This commit is contained in:
2026-12-01 02:02:56 -06:00
parent 48e6c9f390
commit 6df008bf8a
13 changed files with 739 additions and 816 deletions
+50 -12
View File
@@ -3,17 +3,8 @@ import { downloadPdf } from '../export/pdf';
import { safeName } from '../export/safe-name';
import type { Figure } from '../plot';
import plotly from '../plotly-bundle';
import {
adosItems,
adosSummary,
alteration,
identity,
Pair,
percent,
shown,
TeaPatient,
} from './tea-data';
import { headMap } from './tea-figures';
import { adosItems, adosSummary, alteration, Pair, percent, shown, TeaPatient } from './tea-data';
import { forest, headMap, probabilityCurve, zBars } from './tea-figures';
type Table = { headers: string[]; rows: string[][] };
type Chart = { title: string; figure: Figure; height?: number };
@@ -46,7 +37,6 @@ function associationRows(pairs: Pair[]): string[][] {
export function recordSections(patient: TeaPatient, norms: ReadonlyMap<string, Chart>): Section[] {
return [
{ title: 'Datos', blocks: [{ fields: identity(patient.patient) }] },
{
title: 'Línea del tiempo',
blocks: [
@@ -112,6 +102,54 @@ export function recordSections(patient: TeaPatient, norms: ReadonlyMap<string, C
];
}
export function riskSections(patient: TeaPatient, alteredOnly: boolean, pair?: Pair): Section[] {
const studies = patient.riskStudy ? [patient.riskStudy] : patient.studies;
const scores = studies
.map((eeg) => ({ date: eeg.date, figure: zBars(eeg) }))
.find(({ figure }) => figure.data[0].x?.length);
const effects = forest(patient.pairs, alteredOnly);
return [
{ title: 'Qué calcula', blocks: [{ text: calculation }] },
{
title: 'Puntuaciones z por métrica y zona',
blocks: scores
? [
{
chart: {
title: scores.date,
figure: scores.figure,
height: Math.max(340, 24 * (scores.figure.data[0].x?.length ?? 0) + 80),
},
},
]
: [],
},
{
title: forestTitle,
blocks: [
effects.data[0].x?.length
? {
chart: {
title: 'OR e IC 95 %',
figure: effects,
height: Math.max(340, 26 * effects.data[0].x.length + 80),
},
}
: { text: '—' },
],
},
{
title: 'Probabilidad frente a la referencia',
blocks: [{ table: probabilityRows(patient.pairs) }],
},
{
title: probabilityTitle,
blocks: pair ? [{ chart: { title: pair.title, figure: probabilityCurve(pair) } }] : [],
},
{ title: 'Limitaciones', blocks: [{ text: limitations }] },
];
}
export function probabilityRows(pairs: Pair[]): Table {
return {
headers: ['Par', 'Probabilidad', 'Referencia'],