Merge parity/main into parity/T13-gobernanza
This commit is contained in:
@@ -16,8 +16,8 @@ export const routes: Routes = [
|
||||
{
|
||||
path: 'indicadores/tea/pacientes/:id/riesgo',
|
||||
canActivate: [domainAllowed],
|
||||
data: { domain: 'tea' },
|
||||
loadComponent: () => import('./paciente/tea-patient').then((m) => m.TeaRisk),
|
||||
data: { domain: 'tea', risk: true },
|
||||
loadComponent: () => import('./paciente/paciente').then((m) => m.Paciente),
|
||||
},
|
||||
{
|
||||
path: 'indicadores/:domain/pacientes/:id',
|
||||
|
||||
@@ -619,6 +619,11 @@ export const HISTORY: Record<string, History> = {
|
||||
['bad', 'No aceptable', '#B8433A'],
|
||||
['not_analyzed', 'Sin analizar', GREY],
|
||||
]),
|
||||
{
|
||||
title: 'Porcentaje de EEG con alteraciones',
|
||||
measure: 'M30_RESULTADO_EEG',
|
||||
kind: 'percent',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
+339
-267
@@ -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>
|
||||
|
||||
@@ -18,6 +18,13 @@
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-3);
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
|
||||
.cards {
|
||||
display: grid;
|
||||
gap: var(--space-4);
|
||||
@@ -54,44 +61,6 @@ mat-card-content {
|
||||
}
|
||||
}
|
||||
|
||||
.totals {
|
||||
display: flex;
|
||||
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);
|
||||
}
|
||||
|
||||
.relation {
|
||||
margin-top: 16px;
|
||||
td small {
|
||||
display: block;
|
||||
color: var(--mat-sys-on-surface-variant);
|
||||
font-size: 0.8em;
|
||||
}
|
||||
}
|
||||
|
||||
h1 .id {
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { DecimalPipe } from '@angular/common';
|
||||
import { Component, computed, inject, input, resource } from '@angular/core';
|
||||
import { Component, computed, ElementRef, inject, input, resource, signal } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import type {
|
||||
Condition,
|
||||
@@ -13,6 +16,7 @@ import type {
|
||||
RiskAssessment,
|
||||
} from 'fhir/r4';
|
||||
import { Api } from '../api/api';
|
||||
import { curve } from '../api/fn/models/curve';
|
||||
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';
|
||||
@@ -22,7 +26,17 @@ import { LABELS, name, PRIORITY } from '../indicadores/measures';
|
||||
import { Figure, PALETTE, Plot } from '../plot';
|
||||
import { Loading } from '../loading';
|
||||
import { Factores, ScenarioFactors } from './factores';
|
||||
import { TeaRecord } from './tea-patient';
|
||||
import { identityRows, loadTeaPatient, Study } from './tea-data';
|
||||
import { ageNorm, Centile } from './tea-figures';
|
||||
import { TeaSection } from './tea-section';
|
||||
import {
|
||||
exportTeaPdf,
|
||||
forestTitle,
|
||||
probabilityTitle,
|
||||
recordSections,
|
||||
riskSections,
|
||||
Section,
|
||||
} from './tea-sections';
|
||||
|
||||
/** An Observation's value as the screens say it, whatever its type. */
|
||||
function shown(o: Observation): string {
|
||||
@@ -46,10 +60,13 @@ function shown(o: Observation): string {
|
||||
DecimalPipe,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatSelectModule,
|
||||
MatSlideToggleModule,
|
||||
RouterLink,
|
||||
Plot,
|
||||
TeaRecord,
|
||||
TeaSection,
|
||||
],
|
||||
templateUrl: './paciente.html',
|
||||
styleUrl: './paciente.scss',
|
||||
@@ -57,11 +74,13 @@ function shown(o: Observation): string {
|
||||
export class Paciente {
|
||||
private readonly fhir = inject(Fhir);
|
||||
private readonly api = inject(Api);
|
||||
private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
|
||||
readonly domain = input.required<string>();
|
||||
readonly id = input.required<string>();
|
||||
/** The follow-up list she was opened from: its window (months) and cut-off. */
|
||||
readonly ventana = input<string>();
|
||||
readonly corte = input<string>();
|
||||
readonly risk = input(false);
|
||||
|
||||
private readonly data = resource({
|
||||
params: () => (this.domain() === 'tea' ? undefined : { domain: this.domain(), id: this.id() }),
|
||||
@@ -345,4 +364,89 @@ export class Paciente {
|
||||
const p = this.patient();
|
||||
return p ? name(ext(p, 'follow-up-status')?.valueCoding?.code ?? '') : '';
|
||||
});
|
||||
protected readonly tea = resource({
|
||||
params: () => (this.domain() === 'tea' ? this.id() : undefined),
|
||||
loader: ({ params }) => loadTeaPatient(this.fhir, params),
|
||||
});
|
||||
protected readonly norms = resource({
|
||||
params: () => (this.risk() || !this.tea.hasValue() ? undefined : this.tea.value().studies),
|
||||
loader: ({ params }) => this.loadNorms(params),
|
||||
});
|
||||
protected readonly onlyAltered = signal(false);
|
||||
protected readonly selectedKey = signal('');
|
||||
protected readonly selectedPair = computed(() => {
|
||||
const pairs = this.tea.hasValue() ? this.tea.value().pairs : [];
|
||||
return pairs.find((pair) => pair.key === this.selectedKey()) ?? pairs[0];
|
||||
});
|
||||
protected readonly teaIdentity = computed(() =>
|
||||
this.tea.hasValue() ? identityRows(this.tea.value().patient) : [],
|
||||
);
|
||||
protected readonly teaSections = computed<Section[]>(() => {
|
||||
if (!this.tea.hasValue()) return [];
|
||||
const patient = this.tea.value();
|
||||
return this.risk()
|
||||
? riskSections(patient, this.onlyAltered(), this.selectedPair())
|
||||
: recordSections(patient, this.norms.hasValue() ? this.norms.value() : new Map());
|
||||
});
|
||||
protected readonly forestTitle = forestTitle;
|
||||
protected readonly probabilityTitle = probabilityTitle;
|
||||
protected readonly exporting = signal(false);
|
||||
protected readonly exportError = signal(false);
|
||||
|
||||
private async loadNorms(studies: Study[]) {
|
||||
const curves = new Map<string, Promise<Centile[]>>();
|
||||
const charts = await Promise.all(
|
||||
studies.flatMap((eeg) =>
|
||||
eeg.metrics.map(async (metric) => {
|
||||
const model = /^tea\.([^/]+)\/([1-9]\d*)$/.exec(metric.model ?? '');
|
||||
if (
|
||||
!model ||
|
||||
metric.key === 'paroxysmal_spikes' ||
|
||||
metric.value == null ||
|
||||
eeg.age == null
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
const [, name, version] = model;
|
||||
const key = model[0];
|
||||
if (!curves.has(key)) {
|
||||
curves.set(
|
||||
key,
|
||||
this.api
|
||||
.invoke(curve, { domain: 'tea', name, version: Number(version) })
|
||||
.then((rows) => rows as Centile[])
|
||||
.catch(() => []),
|
||||
);
|
||||
}
|
||||
const rows = await curves.get(key)!;
|
||||
if (!rows.some((row) => row.median != null)) return undefined;
|
||||
return [
|
||||
`${eeg.id}|${metric.key}`,
|
||||
{
|
||||
title: 'Norma por edad · p5–p95',
|
||||
figure: ageNorm(rows, metric, eeg.age),
|
||||
},
|
||||
] as const;
|
||||
}),
|
||||
),
|
||||
);
|
||||
return new Map(charts.filter((chart) => chart !== undefined));
|
||||
}
|
||||
|
||||
protected async download(): Promise<void> {
|
||||
this.exportError.set(false);
|
||||
this.exporting.set(true);
|
||||
try {
|
||||
await exportTeaPdf(
|
||||
this.risk() ? 'riesgos' : 'seguimiento',
|
||||
this.risk() ? 'Análisis de riesgo TEA' : 'Expediente TEA',
|
||||
this.teaSections(),
|
||||
this.host.nativeElement.querySelectorAll<HTMLDivElement>('app-plot .plot'),
|
||||
);
|
||||
} catch {
|
||||
this.exportError.set(true);
|
||||
} finally {
|
||||
this.exporting.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type {
|
||||
DiagnosticReport,
|
||||
Identifier,
|
||||
Observation,
|
||||
ObservationComponent,
|
||||
Patient,
|
||||
@@ -7,6 +8,9 @@ import type {
|
||||
} from 'fhir/r4';
|
||||
import { ados2Component, ados2Groups } from '../ados2';
|
||||
import { code, ext, Fhir, label, resources } from '../fhir';
|
||||
import { CURP } from '../indicadores/follow-up';
|
||||
|
||||
const NSS = 'https://isssteleon.org/fhir/sid/nss';
|
||||
|
||||
const steps: Record<string, string> = {
|
||||
mchat_only: 'Solo M-CHAT',
|
||||
@@ -81,15 +85,30 @@ function observationValue(o: Observation | ObservationComponent): string {
|
||||
return shown(label(o.valueCodeableConcept) || o.valueString || o.valueInteger);
|
||||
}
|
||||
|
||||
export function identity(patient: Patient): string[][] {
|
||||
export function identityRows(patient: Patient): string[][] {
|
||||
const group = ext(patient, 'tea-age-group')?.valueCode;
|
||||
const step = ext(patient, 'tea-step')?.valueCode;
|
||||
const sex = { female: 'Femenino', male: 'Masculino', other: 'Otro', unknown: '—' };
|
||||
const system = (id: Identifier): string | undefined =>
|
||||
id.system === CURP
|
||||
? 'CURP'
|
||||
: id.system === NSS
|
||||
? 'NSS'
|
||||
: id.system?.startsWith('urn:isssteleon:')
|
||||
? 'Expediente'
|
||||
: undefined;
|
||||
const identifiers = ['Expediente', 'CURP', 'NSS'].flatMap((row) => {
|
||||
const values = [
|
||||
...new Set(
|
||||
(patient.identifier ?? []).filter((id) => system(id) === row).map((id) => id.value ?? ''),
|
||||
),
|
||||
].filter(Boolean);
|
||||
return values.length ? [[row, values.join(', ')]] : [];
|
||||
});
|
||||
return [
|
||||
['Nombre', shown(patient.name?.[0]?.text)],
|
||||
...(patient.identifier ?? []).map((id) => [id.type?.text || 'Identificador', shown(id.value)]),
|
||||
['Sexo', patient.gender ? sex[patient.gender] : '—'],
|
||||
...identifiers,
|
||||
['Fecha de nacimiento', shown(patient.birthDate)],
|
||||
['Sexo', patient.gender ? sex[patient.gender] : '—'],
|
||||
['Grupo de edad', group && group !== 'no_data' ? `${group} meses` : '—'],
|
||||
['Paso', shown(steps[step ?? ''] ?? step)],
|
||||
];
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { Component, input } from '@angular/core';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { provideRouter } from '@angular/router';
|
||||
import type { Observation } from 'fhir/r4';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { EXT, Fhir } from '../fhir';
|
||||
import { Paciente } from './paciente';
|
||||
import { loadTeaPatient, Metric, Pair } from './tea-data';
|
||||
import type { Observation, Patient } from 'fhir/r4';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { EXT } from '../fhir';
|
||||
import { identityRows, Metric, Pair } from './tea-data';
|
||||
import { ageNorm, forest, headMap, probabilityCurve, zBars } from './tea-figures';
|
||||
import { TeaRecord, TeaSection } from './tea-patient';
|
||||
import { recordSections, teaPdfContent, teaPdfName } from './tea-sections';
|
||||
|
||||
import {
|
||||
forestTitle,
|
||||
probabilityTitle,
|
||||
recordSections,
|
||||
riskSections,
|
||||
teaPdfContent,
|
||||
teaPdfName,
|
||||
} from './tea-sections';
|
||||
|
||||
const metric: Metric = {
|
||||
key: 'spindles_n2',
|
||||
@@ -38,6 +39,20 @@ const pair: Pair = {
|
||||
reference: 0.2,
|
||||
};
|
||||
|
||||
const centiles = [
|
||||
{ age_months: 20, p5: 0, median: 1, p95: 2 },
|
||||
{ age_months: 21, p5: 0.2, median: 1.2, p95: 2.2 },
|
||||
];
|
||||
|
||||
const eeg = {
|
||||
id: 'eeg-1',
|
||||
date: '2025-11-30',
|
||||
age: 20.5,
|
||||
summary: [],
|
||||
checks: [],
|
||||
metrics: [metric],
|
||||
};
|
||||
|
||||
const ados: Observation = {
|
||||
resourceType: 'Observation',
|
||||
id: 'ados2-child-2025-11-22',
|
||||
@@ -104,14 +119,7 @@ describe('Figuras del paciente TEA', () => {
|
||||
});
|
||||
|
||||
it('dibuja los centiles del campeón y el valor observado a la edad del paciente', () => {
|
||||
const figure = ageNorm(
|
||||
[
|
||||
{ age_months: 20, p5: 0, median: 1, p95: 2 },
|
||||
{ age_months: 21, p5: 0.2, median: 1.2, p95: 2.2 },
|
||||
],
|
||||
metric,
|
||||
20.5,
|
||||
);
|
||||
const figure = ageNorm(centiles, metric, 20.5);
|
||||
expect(figure.data[0]).toMatchObject({ fill: 'toself', y: [2, 2.2, 0.2, 0] });
|
||||
expect(figure.data[2]).toMatchObject({ mode: 'markers', x: [20.5], y: [1.7] });
|
||||
});
|
||||
@@ -128,14 +136,7 @@ describe('Figuras del paciente TEA', () => {
|
||||
});
|
||||
|
||||
it('marca la banda de z entre −2 y 2', () => {
|
||||
const figure = zBars({
|
||||
id: 'eeg-1',
|
||||
date: '2025-11-22',
|
||||
age: 20.5,
|
||||
checks: [],
|
||||
summary: [],
|
||||
metrics: [metric],
|
||||
});
|
||||
const figure = zBars(eeg);
|
||||
expect(figure.data[0]).toMatchObject({
|
||||
x: [0.3, 2.4],
|
||||
y: ['Husos N2 · Global', 'Husos N2 · Central'],
|
||||
@@ -152,35 +153,90 @@ describe('Figuras del paciente TEA', () => {
|
||||
});
|
||||
|
||||
describe('Expediente TEA', () => {
|
||||
it('muestra solo los ítems del módulo con dominio, subdominio, código y título', async () => {
|
||||
const fixture = TestBed.createComponent(TeaSection);
|
||||
fixture.componentRef.setInput(
|
||||
'section',
|
||||
recordSections(record, new Map()).find((section) => section.title === 'ADOS-2'),
|
||||
);
|
||||
await fixture.whenStable();
|
||||
const rows = fixture.nativeElement.querySelectorAll('tbody tr');
|
||||
expect(rows).toHaveLength(2);
|
||||
const cells = Array.from(rows[0].cells, (c: HTMLTableCellElement) => c.textContent?.trim());
|
||||
expect(cells).toEqual(['Afectación social (AS)', 'Comunicación', 'A-7', 'Señalar', '0']);
|
||||
expect(rows[1].cells[2].textContent.trim()).toBe('A-3');
|
||||
it('resume la identidad con un renglón por sistema de identificador', () => {
|
||||
const patient: Patient = {
|
||||
resourceType: 'Patient',
|
||||
id: 'child',
|
||||
name: [{ text: 'Paciente de prueba' }],
|
||||
birthDate: '2024-01-15',
|
||||
gender: 'female',
|
||||
identifier: [
|
||||
{ system: 'urn:isssteleon:tea', value: 'N-1001' },
|
||||
{ system: 'urn:isssteleon:tea-eeg', value: 'N-1001' },
|
||||
{ system: 'https://isssteleon.org/fhir/sid/curp', value: 'XAXX010101HDFXXX01' },
|
||||
{ system: 'https://isssteleon.org/fhir/sid/nss', value: '12345678901' },
|
||||
],
|
||||
extension: [
|
||||
{ url: EXT + 'tea-age-group', valueCode: '24-29' },
|
||||
{ url: EXT + 'tea-step', valueCode: 'eeg' },
|
||||
],
|
||||
};
|
||||
expect(identityRows(patient)).toEqual([
|
||||
['Expediente', 'N-1001'],
|
||||
['CURP', 'XAXX010101HDFXXX01'],
|
||||
['NSS', '12345678901'],
|
||||
['Fecha de nacimiento', '2024-01-15'],
|
||||
['Sexo', 'Femenino'],
|
||||
['Grupo de edad', '24-29 meses'],
|
||||
['Paso', 'EEG'],
|
||||
]);
|
||||
});
|
||||
|
||||
it('exporta las secciones, tablas y figuras con un nombre sin identificador', async () => {
|
||||
const table = recordSections(record, new Map());
|
||||
it('ordena las secciones del expediente sin tarjeta de datos', () => {
|
||||
expect(recordSections(record, new Map()).map((section) => section.title)).toEqual([
|
||||
'Línea del tiempo',
|
||||
'ADOS-2',
|
||||
'Calidad del EEG',
|
||||
'Alteraciones',
|
||||
'Relación con el ADOS-2',
|
||||
]);
|
||||
});
|
||||
|
||||
it('agrupa los ítems del módulo con dominio, subdominio, código y título', () => {
|
||||
const section = recordSections(record, new Map()).find((s) => s.title === 'ADOS-2');
|
||||
expect(section?.blocks).toHaveLength(1);
|
||||
expect(section?.blocks[0].title).toBe('2025-11-22');
|
||||
expect(section?.blocks[0].fields).toEqual([
|
||||
['Módulo', 'Módulo 1'],
|
||||
['CSS', '0'],
|
||||
['Clasificación', '—'],
|
||||
]);
|
||||
expect(section?.blocks[0].table?.rows).toEqual([
|
||||
['Afectación social (AS)', 'Comunicación', 'A-7', 'Señalar', '0'],
|
||||
[
|
||||
'Comportamiento restringido y repetitivo (CRR)',
|
||||
'Comportamientos restringidos y repetitivos',
|
||||
'A-3',
|
||||
'Entonación de las vocalizaciones o verbalizaciones',
|
||||
'2',
|
||||
],
|
||||
]);
|
||||
});
|
||||
|
||||
it('pone la norma de cada métrica tras su mapa de la cabeza', () => {
|
||||
const patient = { ...record, studies: [eeg] };
|
||||
const norm = { title: 'Norma por edad · p5–p95', figure: ageNorm(centiles, metric, eeg.age) };
|
||||
const norms = new Map([[`eeg-1|${metric.key}`, norm]]);
|
||||
const altered = recordSections(patient, norms).find((s) => s.title === 'Alteraciones');
|
||||
expect(altered?.blocks.map((block) => block.chart?.title)).toEqual([
|
||||
'Mapa de la cabeza',
|
||||
'Norma por edad · p5–p95',
|
||||
]);
|
||||
const without = recordSections(patient, new Map()).find((s) => s.title === 'Alteraciones');
|
||||
expect(without?.blocks).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('exporta las secciones, tablas y figuras con un nombre sin identificador', () => {
|
||||
const sections = [
|
||||
...table,
|
||||
{
|
||||
title: 'Normas',
|
||||
blocks: [{ chart: { title: 'Mapa', figure: headMap(metric.sites) } }],
|
||||
},
|
||||
...recordSections(record, new Map()),
|
||||
{ title: 'Normas', blocks: [{ chart: { title: 'Mapa', figure: headMap(metric.sites) } }] },
|
||||
];
|
||||
const filename = teaPdfName('seguimiento');
|
||||
const content = teaPdfContent('Expediente TEA', sections, ['data:image/png;base64,YQ==']);
|
||||
expect(filename).toMatch(/^tea-seguimiento-\d{4}-\d{2}-\d{2}$/);
|
||||
expect(content).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ text: 'Datos' }),
|
||||
expect.objectContaining({ text: 'Línea del tiempo' }),
|
||||
expect.objectContaining({ text: 'Relación con el ADOS-2' }),
|
||||
expect.objectContaining({
|
||||
table: expect.objectContaining({
|
||||
@@ -199,78 +255,26 @@ describe('Expediente TEA', () => {
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
it('usa los eventos visibles de la búsqueda y ordena primero el par principal', async () => {
|
||||
const entry = [
|
||||
{ resource: record.patient, search: { mode: 'match' } },
|
||||
{ resource: ados, search: { mode: 'include' } },
|
||||
{
|
||||
resource: {
|
||||
resourceType: 'Observation',
|
||||
code: { coding: [{ code: 'eeg.lab_record_id' }] },
|
||||
effectiveDateTime: '2025-11-30',
|
||||
valueString: 'LAB-01',
|
||||
},
|
||||
search: { mode: 'include' },
|
||||
},
|
||||
{
|
||||
resource: {
|
||||
resourceType: 'RiskAssessment',
|
||||
prediction: [
|
||||
{ outcome: { coding: [{ code: 'spikes|occipital|CSS' }] } },
|
||||
{
|
||||
outcome: { coding: [{ code: pair.key }] },
|
||||
extension: [{ url: EXT + 'association-headline', valueBoolean: true }],
|
||||
},
|
||||
],
|
||||
},
|
||||
search: { mode: 'include' },
|
||||
},
|
||||
];
|
||||
const search = vi.fn(async () => ({ entry }));
|
||||
const data = await loadTeaPatient({ search } as unknown as Fhir, 'child');
|
||||
expect(search).toHaveBeenCalledWith('tea', 'Patient', {
|
||||
_id: 'child',
|
||||
_revinclude: ['Observation:subject', 'DiagnosticReport:subject', 'RiskAssessment:subject'],
|
||||
});
|
||||
expect(data.timeline[0]).toEqual(['2025-11-30', 'EEG', 'LAB-01']);
|
||||
expect(data.studies).toHaveLength(0);
|
||||
expect(data.pairs[0].key).toBe(pair.key);
|
||||
});
|
||||
});
|
||||
|
||||
@Component({ selector: 'app-tea-record', template: '<h2>Datos</h2><h2>Línea del tiempo</h2>' })
|
||||
class RecordStub {
|
||||
readonly id = input.required<string>();
|
||||
}
|
||||
|
||||
describe('Secciones por dominio', () => {
|
||||
it('elige las secciones TEA y sigue mostrando las secciones de CaCu y CaMa', async () => {
|
||||
const read = vi.fn(async () => record.patient);
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
provideRouter([]),
|
||||
{ provide: Fhir, useValue: { read, all: async () => [], search: async () => ({}) } },
|
||||
],
|
||||
}).overrideComponent(Paciente, {
|
||||
remove: { imports: [TeaRecord] },
|
||||
add: { imports: [RecordStub] },
|
||||
});
|
||||
const fixture = TestBed.createComponent(Paciente);
|
||||
fixture.componentRef.setInput('id', 'child');
|
||||
fixture.componentRef.setInput('domain', 'tea');
|
||||
await fixture.whenStable();
|
||||
expect(fixture.nativeElement.querySelector('app-tea-record')?.textContent).toContain(
|
||||
'Línea del tiempo',
|
||||
describe('Análisis de riesgo TEA', () => {
|
||||
it('arma las secciones con las zonas alteradas filtradas y el par elegido', () => {
|
||||
const sections = riskSections({ ...record, studies: [eeg] }, true, pair);
|
||||
expect(sections.map((section) => section.title)).toEqual([
|
||||
'Qué calcula',
|
||||
'Puntuaciones z por métrica y zona',
|
||||
forestTitle,
|
||||
'Probabilidad frente a la referencia',
|
||||
probabilityTitle,
|
||||
'Limitaciones',
|
||||
]);
|
||||
const scores = sections.find(
|
||||
(section) => section.title === 'Puntuaciones z por métrica y zona',
|
||||
);
|
||||
expect(read).not.toHaveBeenCalled();
|
||||
|
||||
for (const domain of ['cacu', 'cama']) {
|
||||
fixture.componentRef.setInput('domain', domain);
|
||||
await fixture.whenStable();
|
||||
expect(fixture.nativeElement.querySelector('app-tea-record')).toBeNull();
|
||||
expect(fixture.nativeElement.textContent).toContain('Historial médico');
|
||||
expect(read).toHaveBeenCalledWith(domain, 'Patient', 'child');
|
||||
}
|
||||
expect(scores?.blocks[0].chart?.figure.data[0]).toMatchObject({ x: [0.3, 2.4] });
|
||||
const effects = sections.find((section) => section.title === forestTitle);
|
||||
expect(effects?.blocks[0].chart?.figure.data[0]).toMatchObject({ x: [3] });
|
||||
const chosen = sections.find((section) => section.title === probabilityTitle);
|
||||
expect(chosen?.blocks[0].chart?.title).toBe(pair.title);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,207 +0,0 @@
|
||||
import { Component, computed, ElementRef, inject, input, resource, signal } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { Api } from '../api/api';
|
||||
import { curve } from '../api/fn/models/curve';
|
||||
import { Fhir } from '../fhir';
|
||||
import { Plot } from '../plot';
|
||||
import { loadTeaPatient, Study } from './tea-data';
|
||||
import { ageNorm, Centile, forest, probabilityCurve, zBars } from './tea-figures';
|
||||
import {
|
||||
calculation,
|
||||
exportTeaPdf,
|
||||
forestTitle,
|
||||
limitations,
|
||||
probabilityRows,
|
||||
probabilityTitle,
|
||||
recordSections,
|
||||
Section,
|
||||
} from './tea-sections';
|
||||
|
||||
@Component({
|
||||
selector: 'app-tea-section',
|
||||
imports: [MatCardModule, Plot],
|
||||
templateUrl: './tea-section.html',
|
||||
styleUrl: './tea-section.scss',
|
||||
})
|
||||
export class TeaSection {
|
||||
readonly section = input.required<Section>();
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-tea-record',
|
||||
imports: [TeaSection, RouterLink, MatButtonModule],
|
||||
templateUrl: './tea-record.html',
|
||||
})
|
||||
export class TeaRecord {
|
||||
private readonly fhir = inject(Fhir);
|
||||
private readonly api = inject(Api);
|
||||
private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
|
||||
readonly id = input.required<string>();
|
||||
protected readonly patient = resource({
|
||||
params: () => this.id(),
|
||||
loader: ({ params }) => loadTeaPatient(this.fhir, params),
|
||||
});
|
||||
protected readonly norms = resource({
|
||||
params: () => (this.patient.hasValue() ? this.patient.value().studies : undefined),
|
||||
loader: ({ params }) => this.loadNorms(params),
|
||||
});
|
||||
protected readonly sections = computed(() => {
|
||||
const patient = this.patient.hasValue() ? this.patient.value() : undefined;
|
||||
return patient
|
||||
? recordSections(patient, this.norms.hasValue() ? this.norms.value() : new Map())
|
||||
: [];
|
||||
});
|
||||
protected readonly exporting = signal(false);
|
||||
protected readonly exportError = signal(false);
|
||||
|
||||
private async loadNorms(studies: Study[]) {
|
||||
const curves = new Map<string, Promise<Centile[]>>();
|
||||
const charts = await Promise.all(
|
||||
studies.flatMap((eeg) =>
|
||||
eeg.metrics.map(async (metric) => {
|
||||
const model = /^tea\.([^/]+)\/([1-9]\d*)$/.exec(metric.model ?? '');
|
||||
if (
|
||||
!model ||
|
||||
metric.key === 'paroxysmal_spikes' ||
|
||||
metric.value == null ||
|
||||
eeg.age == null
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
const [, name, version] = model;
|
||||
const key = model[0];
|
||||
if (!curves.has(key)) {
|
||||
curves.set(
|
||||
key,
|
||||
this.api
|
||||
.invoke(curve, { domain: 'tea', name, version: Number(version) })
|
||||
.then((rows) => rows as Centile[])
|
||||
.catch(() => []),
|
||||
);
|
||||
}
|
||||
const rows = await curves.get(key)!;
|
||||
if (!rows.some((row) => row.median != null)) return undefined;
|
||||
return [
|
||||
`${eeg.id}|${metric.key}`,
|
||||
{
|
||||
title: 'Norma por edad · p5–p95',
|
||||
figure: ageNorm(rows, metric, eeg.age),
|
||||
},
|
||||
] as const;
|
||||
}),
|
||||
),
|
||||
);
|
||||
return new Map(charts.filter((chart) => chart !== undefined));
|
||||
}
|
||||
|
||||
protected async download(): Promise<void> {
|
||||
this.exportError.set(false);
|
||||
this.exporting.set(true);
|
||||
try {
|
||||
await exportTeaPdf(
|
||||
'seguimiento',
|
||||
'Expediente TEA',
|
||||
this.sections(),
|
||||
this.host.nativeElement.querySelectorAll<HTMLDivElement>('app-plot .plot'),
|
||||
);
|
||||
} catch {
|
||||
this.exportError.set(true);
|
||||
} finally {
|
||||
this.exporting.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-tea-risk',
|
||||
imports: [TeaSection, RouterLink, MatButtonModule],
|
||||
templateUrl: './tea-risk.html',
|
||||
})
|
||||
export class TeaRisk {
|
||||
private readonly fhir = inject(Fhir);
|
||||
private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
|
||||
readonly id = input.required<string>();
|
||||
protected readonly patient = resource({
|
||||
params: () => this.id(),
|
||||
loader: ({ params }) => loadTeaPatient(this.fhir, params),
|
||||
});
|
||||
protected readonly onlyAltered = signal(false);
|
||||
protected readonly selectedKey = signal('');
|
||||
protected readonly selectedPair = computed(() => {
|
||||
const pairs = this.patient.hasValue() ? this.patient.value().pairs : [];
|
||||
return pairs.find((pair) => pair.key === this.selectedKey()) ?? pairs[0];
|
||||
});
|
||||
protected readonly forestTitle = forestTitle;
|
||||
protected readonly probabilityTitle = probabilityTitle;
|
||||
protected readonly sections = computed<Section[]>(() => {
|
||||
if (!this.patient.hasValue()) return [];
|
||||
const patient = this.patient.value();
|
||||
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, this.onlyAltered());
|
||||
const pair = this.selectedPair();
|
||||
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 }] },
|
||||
];
|
||||
});
|
||||
protected readonly exporting = signal(false);
|
||||
protected readonly exportError = signal(false);
|
||||
|
||||
protected async download(): Promise<void> {
|
||||
this.exportError.set(false);
|
||||
this.exporting.set(true);
|
||||
try {
|
||||
await exportTeaPdf(
|
||||
'riesgos',
|
||||
'Análisis de riesgo TEA',
|
||||
this.sections(),
|
||||
this.host.nativeElement.querySelectorAll<HTMLDivElement>('app-plot .plot'),
|
||||
);
|
||||
} catch {
|
||||
this.exportError.set(true);
|
||||
} finally {
|
||||
this.exporting.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<section class="page">
|
||||
<nav aria-label="Paciente">
|
||||
<a mat-button [routerLink]="['/indicadores', 'tea']" [queryParams]="{ seguimiento: id() }"
|
||||
>Regresar a Seguimiento</a
|
||||
>
|
||||
<a mat-button [routerLink]="['/indicadores', 'tea', 'pacientes', id(), 'riesgo']"
|
||||
>Análisis de riesgo</a
|
||||
>
|
||||
</nav>
|
||||
@if (patient.error()) {
|
||||
<p role="alert">No se encontró el paciente.</p>
|
||||
} @else if (patient.value(); as data) {
|
||||
<h1>{{ data.patient.name?.[0]?.text ?? 'Expediente TEA' }}</h1>
|
||||
<button
|
||||
mat-stroked-button
|
||||
type="button"
|
||||
[disabled]="exporting() || norms.isLoading()"
|
||||
(click)="download()"
|
||||
>
|
||||
Exportar PDF
|
||||
</button>
|
||||
@if (exportError()) {
|
||||
<p role="alert">No se pudo exportar el PDF.</p>
|
||||
}
|
||||
@for (section of sections(); track section.title) {
|
||||
<app-tea-section [section]="section" />
|
||||
}
|
||||
} @else if (patient.isLoading()) {
|
||||
<p class="muted">Cargando…</p>
|
||||
}
|
||||
</section>
|
||||
@@ -1,51 +0,0 @@
|
||||
<section class="page">
|
||||
<nav aria-label="Paciente">
|
||||
<a mat-button [routerLink]="['/indicadores', 'tea']" [queryParams]="{ seguimiento: id() }"
|
||||
>Regresar a Seguimiento</a
|
||||
>
|
||||
<a mat-button [routerLink]="['/indicadores', 'tea', 'pacientes', id()]">Expediente</a>
|
||||
</nav>
|
||||
<h1>Análisis de riesgo TEA</h1>
|
||||
@if (patient.error()) {
|
||||
<p role="alert">No se encontró el paciente.</p>
|
||||
} @else if (patient.value(); as data) {
|
||||
@if (data.patient.name?.[0]?.text; as name) {
|
||||
<p class="subtitle">{{ name }}</p>
|
||||
}
|
||||
<button mat-stroked-button type="button" [disabled]="exporting()" (click)="download()">
|
||||
Exportar PDF
|
||||
</button>
|
||||
@if (exportError()) {
|
||||
<p role="alert">No se pudo exportar el PDF.</p>
|
||||
}
|
||||
@for (section of sections(); track section.title) {
|
||||
<app-tea-section [section]="section">
|
||||
@if (section.title === forestTitle) {
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
#altered
|
||||
[checked]="onlyAltered()"
|
||||
(change)="onlyAltered.set(altered.checked)"
|
||||
/>
|
||||
Solo zonas alteradas
|
||||
</label>
|
||||
}
|
||||
@if (section.title === probabilityTitle && data.pairs.length) {
|
||||
<label>
|
||||
Par
|
||||
<select #pairs (change)="selectedKey.set(pairs.value)">
|
||||
@for (pair of data.pairs; track pair.key) {
|
||||
<option [value]="pair.key" [selected]="pair.key === selectedPair()?.key">
|
||||
{{ pair.title }}
|
||||
</option>
|
||||
}
|
||||
</select>
|
||||
</label>
|
||||
}
|
||||
</app-tea-section>
|
||||
}
|
||||
} @else if (patient.isLoading()) {
|
||||
<p class="muted">Cargando…</p>
|
||||
}
|
||||
</section>
|
||||
@@ -1,56 +0,0 @@
|
||||
<mat-card appearance="outlined">
|
||||
<mat-card-header
|
||||
><h2>{{ section().title }}</h2></mat-card-header
|
||||
>
|
||||
<mat-card-content>
|
||||
<ng-content />
|
||||
@for (block of section().blocks; track $index) {
|
||||
@if (block.title) {
|
||||
<h3>{{ block.title }}</h3>
|
||||
}
|
||||
@if (block.text) {
|
||||
<p>{{ block.text }}</p>
|
||||
}
|
||||
@if (block.fields; as fields) {
|
||||
<dl>
|
||||
@for (field of fields; track $index) {
|
||||
<div>
|
||||
<dt>{{ field[0] }}</dt>
|
||||
<dd>{{ field[1] }}</dd>
|
||||
</div>
|
||||
}
|
||||
</dl>
|
||||
}
|
||||
@if (block.table; as table) {
|
||||
@if (table.rows.length) {
|
||||
<table class="plain">
|
||||
<thead>
|
||||
<tr>
|
||||
@for (header of table.headers; track $index) {
|
||||
<th scope="col">{{ header }}</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (row of table.rows; track $index) {
|
||||
<tr>
|
||||
@for (cell of row; track $index) {
|
||||
<td>{{ cell }}</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
} @else {
|
||||
<p class="muted">—</p>
|
||||
}
|
||||
}
|
||||
@if (block.chart; as chart) {
|
||||
<h3>{{ chart.title }}</h3>
|
||||
<app-plot [figure]="chart.figure" [height]="chart.height ?? 340" />
|
||||
}
|
||||
} @empty {
|
||||
<p class="muted">—</p>
|
||||
}
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
@@ -1,28 +0,0 @@
|
||||
:host {
|
||||
display: block;
|
||||
margin-block: var(--space-4);
|
||||
}
|
||||
|
||||
mat-card-content {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 0 0 var(--space-3);
|
||||
}
|
||||
|
||||
dl {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-4);
|
||||
margin-block: var(--space-3);
|
||||
}
|
||||
|
||||
dt {
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
dd {
|
||||
margin: 0;
|
||||
font-weight: 500;
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { Component, input } from '@angular/core';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { Plot } from '../plot';
|
||||
import { Section } from './tea-sections';
|
||||
|
||||
@Component({
|
||||
selector: 'app-tea-section',
|
||||
imports: [MatCardModule, Plot],
|
||||
template: `
|
||||
<mat-card appearance="outlined">
|
||||
<mat-card-header><mat-card-title>{{ section().title }}</mat-card-title></mat-card-header>
|
||||
<mat-card-content>
|
||||
<ng-content />
|
||||
@for (block of section().blocks; track $index) {
|
||||
@if (block.title) {
|
||||
<h3>{{ block.title }}</h3>
|
||||
}
|
||||
@if (block.text) {
|
||||
<p>{{ block.text }}</p>
|
||||
}
|
||||
@if (block.fields; as fields) {
|
||||
<dl>
|
||||
@for (field of fields; track $index) {
|
||||
<div>
|
||||
<dt>{{ field[0] }}</dt>
|
||||
<dd>{{ field[1] }}</dd>
|
||||
</div>
|
||||
}
|
||||
</dl>
|
||||
}
|
||||
@if (block.table; as table) {
|
||||
@if (table.rows.length) {
|
||||
<table class="plain">
|
||||
<thead>
|
||||
<tr>
|
||||
@for (header of table.headers; track $index) {
|
||||
<th scope="col">{{ header }}</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (row of table.rows; track $index) {
|
||||
<tr>
|
||||
@for (cell of row; track $index) {
|
||||
<td>{{ cell }}</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
} @else {
|
||||
<p class="muted">—</p>
|
||||
}
|
||||
}
|
||||
@if (block.chart; as chart) {
|
||||
<h3>{{ chart.title }}</h3>
|
||||
<app-plot [figure]="chart.figure" [height]="chart.height ?? 340" />
|
||||
}
|
||||
} @empty {
|
||||
<p class="muted">—</p>
|
||||
}
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
`,
|
||||
styles: `
|
||||
:host {
|
||||
display: block;
|
||||
}
|
||||
mat-card-content {
|
||||
overflow-x: auto;
|
||||
}
|
||||
dl {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-4);
|
||||
margin-block: var(--space-3);
|
||||
}
|
||||
dt {
|
||||
color: var(--color-text-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
dd {
|
||||
margin: 0;
|
||||
font-weight: 500;
|
||||
}
|
||||
`,
|
||||
})
|
||||
export class TeaSection {
|
||||
readonly section = input.required<Section>();
|
||||
}
|
||||
@@ -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'],
|
||||
|
||||
Reference in New Issue
Block a user