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
+339 -267
View File
@@ -1,296 +1,368 @@
@if (domain() === 'tea') {
<app-tea-record [id]="id()" />
} @else {
<section class="page">
<a mat-button [routerLink]="['/indicadores', domain()]"
><mat-icon>arrow_back</mat-icon> Regresar</a
>
@if (error()) {
<p class="muted" role="alert">No se encontró la paciente.</p>
} @else if (patient(); as p) {
<h1>
{{ identity().name ?? 'Paciente' }} <code class="muted id">{{ p.id!.slice(0, 10) }}</code>
</h1>
<dl class="summary">
<div>
<dt>CURP</dt>
<dd>{{ identity().curp ?? 'Sin dato' }}</dd>
</div>
<div>
<dt>Expedientes</dt>
<dd>{{ identity().numbers.join(', ') || 'Sin dato' }}</dd>
</div>
<div>
<dt>Fecha de nacimiento</dt>
<dd>{{ p.birthDate ?? 'Sin dato' }}</dd>
</div>
<div>
<dt>Sexo</dt>
<dd>
{{ p.gender === 'female' ? 'Femenino' : p.gender === 'male' ? 'Masculino' : 'Sin dato' }}
</dd>
</div>
@if (cama(); as c) {
<div>
<dt>Grupo de edad</dt>
<dd>{{ c.ageGroup || 'No disponible' }}</dd>
</div>
<div>
<dt>Escenario clínico</dt>
<dd>{{ c.scenario }}</dd>
</div>
<div>
<dt>Estatus de seguimiento</dt>
<dd>
{{ c.status ?? 'Fuera de la lista (' + c.window + ' meses al ' + c.cutoff + ')' }}
</dd>
</div>
<div>
<dt>Prioridad</dt>
<dd>{{ c.priority ?? 'No disponible' }}</dd>
</div>
<div>
<dt>Días de mastografía a diagnóstico</dt>
<dd>{{ c.days ?? 'No disponible' }}</dd>
</div>
} @else {
@if (status()) {
<section class="page">
<a
mat-button
[routerLink]="['/indicadores', domain()]"
[queryParams]="domain() === 'tea' ? { seguimiento: id() } : null"
><mat-icon>arrow_back</mat-icon> Regresar</a
>
@if (domain() === 'tea') {
@if (tea.error()) {
<p class="muted" role="alert">No se encontró el paciente.</p>
} @else if (tea.value(); as t) {
@if (risk()) {
<h1>Análisis de riesgo TEA</h1>
@if (t.patient.name?.[0]?.text; as name) {
<p class="subtitle">{{ name }}</p>
}
} @else {
<h1>
{{ t.patient.name?.[0]?.text ?? 'Paciente' }}
<code class="muted id">{{ t.patient.id!.slice(0, 10) }}</code>
</h1>
<dl class="summary">
@for (row of teaIdentity(); track $index) {
<div>
<dt>Estatus de seguimiento</dt>
<dd>{{ status() }}</dd>
<dt>{{ row[0] }}</dt>
<dd>{{ row[1] }}</dd>
</div>
}
</dl>
}
<div class="actions">
<button
mat-stroked-button
type="button"
[disabled]="exporting() || (!risk() && norms.isLoading())"
(click)="download()"
>
Exportar PDF
</button>
@if (risk()) {
<a mat-stroked-button [routerLink]="['/indicadores', 'tea', 'pacientes', id()]"
>Expediente</a
>
} @else {
<a mat-stroked-button [routerLink]="['/indicadores', 'tea', 'pacientes', id(), 'riesgo']"
>Análisis de riesgo</a
>
}
@if (p.deceasedDateTime) {
</div>
@if (exportError()) {
<p class="muted" role="alert">No se pudo exportar el PDF.</p>
}
<div class="cards">
@for (section of teaSections(); track section.title) {
<app-tea-section [section]="section" class="wide">
@if (risk() && section.title === forestTitle) {
<mat-slide-toggle
[checked]="onlyAltered()"
(change)="onlyAltered.set($event.checked)"
>Solo zonas alteradas</mat-slide-toggle
>
}
@if (risk() && section.title === probabilityTitle && t.pairs.length) {
<mat-form-field appearance="outline" subscriptSizing="dynamic">
<mat-label>Par</mat-label>
<mat-select
[value]="selectedPair()?.key"
(selectionChange)="selectedKey.set($event.value)"
>
@for (pair of t.pairs; track pair.key) {
<mat-option [value]="pair.key">{{ pair.title }}</mat-option>
}
</mat-select>
</mat-form-field>
}
</app-tea-section>
}
</div>
} @else {
<app-loading [what]="risk() ? 'el análisis de riesgo' : 'el expediente'" />
}
} @else if (error()) {
<p class="muted" role="alert">No se encontró la paciente.</p>
} @else if (patient(); as p) {
<h1>
{{ identity().name ?? 'Paciente' }} <code class="muted id">{{ p.id!.slice(0, 10) }}</code>
</h1>
<dl class="summary">
<div>
<dt>CURP</dt>
<dd>{{ identity().curp ?? 'Sin dato' }}</dd>
</div>
<div>
<dt>Expedientes</dt>
<dd>{{ identity().numbers.join(', ') || 'Sin dato' }}</dd>
</div>
<div>
<dt>Fecha de nacimiento</dt>
<dd>{{ p.birthDate ?? 'Sin dato' }}</dd>
</div>
<div>
<dt>Sexo</dt>
<dd>
{{ p.gender === 'female' ? 'Femenino' : p.gender === 'male' ? 'Masculino' : 'Sin dato' }}
</dd>
</div>
@if (cama(); as c) {
<div>
<dt>Grupo de edad</dt>
<dd>{{ c.ageGroup || 'No disponible' }}</dd>
</div>
<div>
<dt>Escenario clínico</dt>
<dd>{{ c.scenario }}</dd>
</div>
<div>
<dt>Estatus de seguimiento</dt>
<dd>
{{ c.status ?? 'Fuera de la lista (' + c.window + ' meses al ' + c.cutoff + ')' }}
</dd>
</div>
<div>
<dt>Prioridad</dt>
<dd>{{ c.priority ?? 'No disponible' }}</dd>
</div>
<div>
<dt>Días de mastografía a diagnóstico</dt>
<dd>{{ c.days ?? 'No disponible' }}</dd>
</div>
} @else {
@if (status()) {
<div>
<dt>Defunción</dt>
<dd>{{ p.deceasedDateTime }}</dd>
<dt>Estatus de seguimiento</dt>
<dd>{{ status() }}</dd>
</div>
}
</dl>
}
@if (p.deceasedDateTime) {
<div>
<dt>Defunción</dt>
<dd>{{ p.deceasedDateTime }}</dd>
</div>
}
</dl>
<div class="cards">
@if (cama(); as c) {
<mat-card appearance="outlined" data-section="mastografia">
<mat-card-header><mat-card-title>Mastografía</mat-card-title></mat-card-header>
<mat-card-content>
<h3>Última mastografía</h3>
<dl class="facts">
<div>
<dt>Categoría BI-RADS</dt>
<dd>{{ c.birads ?? 'No disponible' }}</dd>
</div>
<div>
<dt>Fecha</dt>
<dd>{{ c.mammogram ?? 'No disponible' }}</dd>
</div>
</dl>
</mat-card-content>
</mat-card>
<mat-card appearance="outlined" data-section="histopatologia">
<mat-card-header><mat-card-title>Histopatología</mat-card-title></mat-card-header>
<mat-card-content>
<h3>Resultado histopatológico</h3>
<dl class="facts">
<div>
<dt>Resultado</dt>
<dd>{{ c.histology ?? 'No disponible' }}</dd>
</div>
<div>
<dt>Fecha de reporte de la biopsia</dt>
<dd>{{ c.biopsy ?? 'No disponible' }}</dd>
</div>
</dl>
</mat-card-content>
</mat-card>
}
<mat-card appearance="outlined">
<mat-card-header><mat-card-title>Historial médico</mat-card-title></mat-card-header>
<div class="cards">
@if (cama(); as c) {
<mat-card appearance="outlined" data-section="mastografia">
<mat-card-header><mat-card-title>Mastografía</mat-card-title></mat-card-header>
<mat-card-content>
<h3>Última mastografía</h3>
<dl class="facts">
<div>
<dt>Categoría BI-RADS</dt>
<dd>{{ c.birads ?? 'No disponible' }}</dd>
</div>
<div>
<dt>Fecha</dt>
<dd>{{ c.mammogram ?? 'No disponible' }}</dd>
</div>
</dl>
</mat-card-content>
</mat-card>
<mat-card appearance="outlined" data-section="histopatologia">
<mat-card-header><mat-card-title>Histopatología</mat-card-title></mat-card-header>
<mat-card-content>
<h3>Resultado histopatológico</h3>
<dl class="facts">
<div>
<dt>Resultado</dt>
<dd>{{ c.histology ?? 'No disponible' }}</dd>
</div>
<div>
<dt>Fecha de reporte de la biopsia</dt>
<dd>{{ c.biopsy ?? 'No disponible' }}</dd>
</div>
</dl>
</mat-card-content>
</mat-card>
}
<mat-card appearance="outlined">
<mat-card-header><mat-card-title>Historial médico</mat-card-title></mat-card-header>
<mat-card-content>
<table class="plain">
<thead>
<tr>
<th>Fecha</th>
<th>Tipo</th>
<th>Detalle</th>
</tr>
</thead>
<tbody>
@for (h of history(); track $index) {
<tr>
<td class="nowrap">{{ h.date }}</td>
<td>{{ h.kind }}</td>
<td>
{{ h.text }}
@if (h.code && h.code !== h.text) {
<span class="muted">({{ h.code }})</span>
}
</td>
</tr>
} @empty {
<tr>
<td colspan="3" class="muted">Sin registros.</td>
</tr>
}
</tbody>
</table>
</mat-card-content>
</mat-card>
<mat-card appearance="outlined">
<mat-card-header><mat-card-title>Pruebas y resultados</mat-card-title></mat-card-header>
<mat-card-content>
<table class="plain">
<thead>
<tr>
<th>Toma</th>
<th>Estudio</th>
<th>Reporte</th>
<th>Resultados</th>
</tr>
</thead>
<tbody>
@for (t of tests(); track $index) {
<tr>
<td class="nowrap">{{ t.date }}</td>
<td>{{ t.kind }}</td>
<td class="nowrap">{{ t.reported ?? 'Pendiente' }}</td>
<td>{{ t.results.join(' · ') || '—' }}</td>
</tr>
} @empty {
<tr>
<td colspan="4" class="muted">Sin estudios.</td>
</tr>
}
</tbody>
</table>
</mat-card-content>
</mat-card>
<mat-card appearance="outlined" class="wide">
<mat-card-header
><mat-card-title>Riesgos y recomendaciones</mat-card-title></mat-card-header
>
<mat-card-content>
@if (models().length) {
<table class="plain">
<thead>
<tr>
<th>Fecha</th>
<th>Tipo</th>
<th>Detalle</th>
<th>Modelo</th>
<th>Fecha índice</th>
<th>Horizonte</th>
<th>Probabilidad</th>
<th>IC 95 %</th>
</tr>
</thead>
<tbody>
@for (h of history(); track $index) {
<tr>
<td class="nowrap">{{ h.date }}</td>
<td>{{ h.kind }}</td>
<td>
{{ h.text }}
@if (h.code && h.code !== h.text) {
<span class="muted">({{ h.code }})</span>
}
</td>
</tr>
} @empty {
<tr>
<td colspan="3" class="muted">Sin registros.</td>
</tr>
@for (m of models(); track m.model) {
@for (p of m.predictions; track p.years) {
<tr>
<td>{{ $first ? m.text : '' }}</td>
<td>{{ $first ? m.index : '' }}</td>
<td>{{ p.years }} {{ p.years === 1 ? 'año' : 'años' }}</td>
<td>{{ p.p * 100 | number: '1.1-2' }} %</td>
<td>
@if (p.low !== undefined) {
{{ p.low * 100 | number: '1.1-2' }}–{{ p.high! * 100 | number: '1.1-2' }}
%
} @else {
—
}
</td>
</tr>
}
}
</tbody>
</table>
</mat-card-content>
</mat-card>
<app-plot [figure]="curve()" [height]="300" />
} @else {
<p class="muted">Sin evaluación de un modelo en producción.</p>
}
</mat-card-content>
</mat-card>
<mat-card appearance="outlined">
<mat-card-header><mat-card-title>Pruebas y resultados</mat-card-title></mat-card-header>
<mat-card-content>
<table class="plain">
<thead>
<tr>
<th>Toma</th>
<th>Estudio</th>
<th>Reporte</th>
<th>Resultados</th>
</tr>
</thead>
<tbody>
@for (t of tests(); track $index) {
<tr>
<td class="nowrap">{{ t.date }}</td>
<td>{{ t.kind }}</td>
<td class="nowrap">{{ t.reported ?? 'Pendiente' }}</td>
<td>{{ t.results.join(' · ') || '—' }}</td>
</tr>
} @empty {
<tr>
<td colspan="4" class="muted">Sin estudios.</td>
</tr>
}
</tbody>
</table>
</mat-card-content>
</mat-card>
<mat-card appearance="outlined" class="wide">
@if (recurrenceModel(); as rm) {
<mat-card appearance="outlined" class="wide" data-section="recurrencia">
<mat-card-header
><mat-card-title>Riesgos y recomendaciones</mat-card-title></mat-card-header
><mat-card-title>Pronóstico y recomendaciones</mat-card-title></mat-card-header
>
<mat-card-content>
@if (models().length) {
<table class="plain">
<thead>
<h3>Análisis de recurrencia</h3>
<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>
<th>Modelo</th>
<th>Fecha índice</th>
<th>Horizonte</th>
<th>Probabilidad</th>
<th>IC 95 %</th>
<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>
</thead>
<tbody>
@for (m of models(); track m.model) {
@for (p of m.predictions; track p.years) {
<tr>
<td>{{ $first ? m.text : '' }}</td>
<td>{{ $first ? m.index : '' }}</td>
<td>{{ p.years }} {{ p.years === 1 ? 'año' : 'años' }}</td>
<td>{{ p.p * 100 | number: '1.1-2' }} %</td>
<td>
@if (p.low !== undefined) {
{{ p.low * 100 | number: '1.1-2' }}–{{ p.high! * 100 | number: '1.1-2' }}
%
} @else {
—
}
</td>
</tr>
}
}
</tbody>
</table>
<app-plot [figure]="curve()" [height]="300" />
} @else {
<p class="muted">Sin evaluación de un modelo en producción.</p>
}
</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 no tienen recaídas suficientes para trazar curvas.
</p>
}
<app-factores [rows]="s.factors" />
} @else if (recurrence.error()) {
<p class="muted" role="alert">No se pudo leer el informe del modelo.</p>
}
</mat-card-content>
</mat-card>
@if (recurrenceModel(); as rm) {
<mat-card appearance="outlined" class="wide" data-section="recurrencia">
<mat-card-header
><mat-card-title>Pronóstico y recomendaciones</mat-card-title></mat-card-header
>
<mat-card-content>
<h3>Análisis de recurrencia</h3>
<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 no tienen recaídas suficientes para trazar curvas.
</p>
}
@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>Riesgo de muerte</mat-card-title></mat-card-header>
<mat-card-content>
<h3>Análisis de supervivencia</h3>
@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>
}
<app-factores [rows]="s.factors" />
} @else if (recurrence.error()) {
<p class="muted" role="alert">No se pudo leer el informe del modelo.</p>
</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 no tienen fallecimientos suficientes para trazar curvas.
</p>
}
</mat-card-content>
</mat-card>
}
@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>Riesgo de muerte</mat-card-title></mat-card-header>
<mat-card-content>
<h3>Análisis de supervivencia</h3>
@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 no tienen fallecimientos suficientes para trazar curvas.
</p>
}
<app-factores [rows]="s.factors" />
} @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()) {
<app-loading what="el expediente" />
}
</section>
}
<app-factores [rows]="s.factors" />
} @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()) {
<app-loading what="el expediente" />
}
</section>