Files
WebApp/src/app/paciente/paciente.html
T
Angel Capetillo Zavala 44f3dce911 Integrate CaCu indicators, risk views and exports
Adapted from Angel Capetillo Zavala commits c0e4920 and 31400c7 and Edgar Hinojosas CaCu measures. Includes the existing 6F presentation and external donut labels.

Co-authored-by: edgar <edgar.hinojosas@uanl.edu.mx>
2026-11-30 16:02:00 -06:00

585 lines
23 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<section class="page">
@if (domain() === 'cacu' && patient()) {
<div class="export-actions">
<button mat-stroked-button type="button" [disabled]="exporting()" (click)="exportPatient()">
Exportar ficha PDF
</button>
</div>
}
@if (exportError()) {
<p class="muted" role="alert">{{ exportError() }}</p>
}
<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>
@if (domain() === 'cacu') {
· Edad: {{ age() ?? 'No disponible' }}
}
</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>Estatus de seguimiento</dt>
<dd>{{ status() }}</dd>
</div>
}
}
@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>
<mat-card-content>
@if (domain() === 'cacu') {
<app-stages
[sample]="sample()"
[report]="sampleReportDate()"
[cutoff]="cutoff()"
[facts]="sampleFacts()"
[detail]="true"
/>
<p class="muted route-note">
Etapas de la citología{{ sample() ? ' del ' + sample() : '' }} a la fecha de corte
{{ cutoff() }}. «Inferida temporalmente» es una asociación por cercanía de fechas, no
un vínculo clínico confirmado; «Desconocida» indica que no hay dato.
</p>
}
<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 (domain() === 'cacu') {
<p class="muted">
Divisiones numéricas descriptivas; no representan umbrales clínicos.
</p>
@for (model of riskScales(); track model.model) {
<h3>{{ model.model }} · fecha índice {{ model.index }}</h3>
@for (
scale of [
{ label: 'Riesgo inmediato (al índice)', value: model.immediate },
{ label: 'Riesgo a 5 años', value: model.five },
];
track scale.label
) {
<div class="risk-scale">
<p>
<strong>{{ scale.label }}</strong>
@if (scale.value; as v) {
@if (v.low !== undefined && v.high !== undefined) {
· IC 95 %: {{ v.low * 100 | number: '1.1-2' }}–{{
v.high * 100 | number: '1.1-2'
}}
%
}
} @else {
· No disponible
}
</p>
<div class="risk-plot" [class.unavailable]="!scale.value">
<div class="risk-line" aria-hidden="true"></div>
@if (scale.value; as v) {
<span
class="risk-marker"
[style.left.%]="v.value * 100"
aria-hidden="true"
></span>
<strong
class="risk-value"
[style.left]="'clamp(2.5rem, ' + v.value * 100 + '%, calc(100% - 2.5rem))'"
>{{ v.value * 100 | number: '1.1-2' }} %</strong
>
}
</div>
<div class="risk-labels">
<span>0 %</span><span>25 %</span><span>50 %</span><span>75 %</span
><span>100 %</span>
</div>
</div>
}
} @empty {
@for (label of ['Riesgo inmediato', 'Riesgo a 5 años']; track label) {
<div class="risk-scale">
<p>
<strong>{{ label }}</strong> · No disponible
</p>
<div class="risk-plot unavailable">
<div class="risk-line" aria-hidden="true"></div>
</div>
<div class="risk-labels">
<span>0 %</span><span>25 %</span><span>50 %</span><span>75 %</span
><span>100 %</span>
</div>
</div>
}
<p class="muted">Ningún modelo vigente la ha evaluado.</p>
}
}
@if (models().length) {
<table class="plain">
<thead>
<tr>
<th>Modelo</th>
<th>Fecha índice</th>
<th>Horizonte</th>
<th>Probabilidad</th>
<th>IC 95 %</th>
</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>
}
</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) {
({{ levelNames[st.level] ?? st.level }})
}
</p>
<h3>Alteraciones del EEG</h3>
@if (!st.valid) {
<p class="muted">EEG no aceptable: no se compara con la norma por edad.</p>
} @else if (!scored()) {
<p class="muted">Sin curva por edad en producción para este EEG.</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 [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>
<td>{{ m.z | number: '1.1-2' }}</td>
<td>{{ m.outside! > 0 ? 'Aumentado' : 'Disminuido' }}</td>
</tr>
}
</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>
}
@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">Sin modelo de asociación en producción para este EEG.</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>Resultado en 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 &lt; 0.05).
Versión del modelo: {{ related()[0].model }}.
</p>
}
</section>
}
} @else {
<p class="muted">Sin EEG analizado.</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>
}
<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 (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>