feat(cama): Análisis epidemiológico frame with category cards, cut-off bar and the BI-RADS count
This commit is contained in:
@@ -114,6 +114,32 @@ describe('Pestaña Análisis epidemiológico', () => {
|
||||
expect(filas.map(f => f.querySelector('th')!.textContent!.trim())).toEqual(['BI-RADS 4', 'BI-RADS 4A', 'BI-RADS 4B', 'BI-RADS 4C', 'BI-RADS 5', 'BI-RADS 6']);
|
||||
expect(filas.map(f => f.children[1].textContent!.trim())).toEqual(['No publicado', 'No publicado', 'No publicado', 'No publicado', '6', 'No publicado']);
|
||||
});
|
||||
it('encabeza la vista y deriva las dos tarjetas de los estados de los grupos, sin sumar pacientes', () => {
|
||||
// Fails if the cards count patients instead of categories, appear before an answer, or the heading and denominator are lost.
|
||||
abrir();
|
||||
expect(root().querySelector('h2')!.textContent).toBe('Análisis epidemiológico');
|
||||
expect(root().querySelector('app-indicador-kpi-card')).toBeNull();
|
||||
pedido().flush(agregadoJson({ corte: hoyIso() })); fixture.detectChanges();
|
||||
const tarjetas = Array.from(root().querySelectorAll('app-indicador-kpi-card')) as HTMLElement[];
|
||||
expect(tarjetas.map(t => t.querySelector('h3')!.textContent)).toEqual(['Categorías publicadas', 'Categorías no publicadas']);
|
||||
expect(tarjetas.map(t => t.querySelector('.value')!.textContent!.trim())).toEqual(['1', '5']);
|
||||
expect(tarjetas[0].textContent).toContain('de 6 categorías BI-RADS');
|
||||
expect(tarjetas[0].textContent).not.toContain('6 pacientes');
|
||||
expect(root().querySelector('h3#birads-titulo')!.textContent).toBe('Pacientes por categoría BI-RADS');
|
||||
expect(text()).toContain('Denominador: pacientes elegibles con última mastografía reportada BI-RADS 4 a 6.');
|
||||
expect(text()).toContain('abrir la lista en Seguimiento');
|
||||
});
|
||||
it('las tarjetas cuentan 0 publicadas cuando todas se suprimen y desaparecen en carga, pendiente y error', () => {
|
||||
// Fails if the cards stay on screen without an answer with categories.
|
||||
abrir();
|
||||
const grupos = agregado().grupos.map(g => ({ codigo: g.codigo, n: null, suprimido: true }));
|
||||
pedido().flush(agregadoJson({ corte: hoyIso(), grupos })); fixture.detectChanges();
|
||||
expect(Array.from(root().querySelectorAll('app-indicador-kpi-card .value')).map(v => v.textContent!.trim())).toEqual(['0', '6']);
|
||||
fixture.componentInstance.consultar(); fixture.detectChanges();
|
||||
expect(root().querySelector('app-indicador-kpi-card')).toBeNull();
|
||||
pedido().flush({}, { status: 404, statusText: 'Not found' }); fixture.detectChanges();
|
||||
expect(root().querySelector('app-indicador-kpi-card')).toBeNull();
|
||||
});
|
||||
it('«Consultar» pide el agregado a la fecha elegida y la respuesta tardía de una consulta anterior no se dibuja', async () => {
|
||||
// Fails if a slow answer replaces the aggregate of a later cut-off.
|
||||
abrir();
|
||||
|
||||
@@ -6,6 +6,7 @@ import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
import { catchError, map, Observable, of, startWith, Subject, switchMap } from 'rxjs';
|
||||
import { PlotlyChart } from '../../shared/plotly/plotly-chart';
|
||||
import { IndicadorKpiCard } from './indicador-kpi-card';
|
||||
import { isoDate } from './cacu-seguimiento.models';
|
||||
import { grupoDelClic, gruposFigura } from './indicadores-analisis-figuras';
|
||||
import { etiquetaBirads } from './etiquetas-cohorte';
|
||||
@@ -53,62 +54,80 @@ function contenedorDeScroll(el: HTMLElement): HTMLElement {
|
||||
// a suppressed one says why it does not. Nothing is requested until the tab is first opened.
|
||||
@Component({
|
||||
selector: 'app-indicadores-analisis',
|
||||
imports: [FormsModule, MatButtonModule, MatProgressBarModule, PlotlyChart],
|
||||
imports: [FormsModule, MatButtonModule, MatProgressBarModule, PlotlyChart, IndicadorKpiCard],
|
||||
template: `
|
||||
<section class="panel" aria-labelledby="analisis-titulo">
|
||||
<h2 id="analisis-titulo">Pacientes por categoría BI-RADS</h2>
|
||||
<p class="nota">Conteo descriptivo de las pacientes de la cohorte en cada categoría BI-RADS a la fecha de corte. No estima incidencia, recurrencia ni supervivencia.</p>
|
||||
<section class="analisis" aria-labelledby="analisis-titulo">
|
||||
<h2 id="analisis-titulo">Análisis epidemiológico</h2>
|
||||
<p class="nota">Conteo de pacientes de la cohorte por categoría BI-RADS a la fecha de corte. No estima incidencia, recurrencia ni supervivencia.</p>
|
||||
@if (datos(); as d) {
|
||||
<p class="contexto">Fecha de corte: {{ d.corte }}. Denominador: {{ d.denominador }}.</p>
|
||||
<div class="tarjetas">
|
||||
<app-indicador-kpi-card title="Categorías publicadas" [value]="publicadas()" state="Disponible" [quietWhenAvailable]="true"
|
||||
[additionalInfo]="'de ' + d.grupos.length + ' categorías BI-RADS.'" />
|
||||
<app-indicador-kpi-card title="Categorías no publicadas" [value]="d.grupos.length - publicadas()" state="Disponible" [quietWhenAvailable]="true"
|
||||
[additionalInfo]="'Con menos de ' + d.umbral_supresion + ' pacientes: su conteo y su lista no se publican.'" />
|
||||
</div>
|
||||
}
|
||||
<form class="controles" (ngSubmit)="consultar()">
|
||||
<label>Fecha de corte <input name="corte" type="date" required [(ngModel)]="corte" [max]="hoy" /></label>
|
||||
<button type="submit" mat-stroked-button [disabled]="carga().estado === 'cargando'">Consultar</button>
|
||||
</form>
|
||||
@switch (carga().estado) {
|
||||
@case ('cargando') { <mat-progress-bar mode="indeterminate" aria-label="Consultando el análisis" /> }
|
||||
@case ('pendiente') { <p role="status">Funcionalidad pendiente de publicación.</p> }
|
||||
@case ('no-disponible') {
|
||||
<p role="status">La cohorte no está disponible en este momento.</p>
|
||||
<button type="button" mat-stroked-button (click)="reintentar()">Reintentar consulta</button>
|
||||
<article class="panel" aria-labelledby="birads-titulo">
|
||||
<h3 id="birads-titulo">Pacientes por categoría BI-RADS</h3>
|
||||
@switch (carga().estado) {
|
||||
@case ('cargando') { <mat-progress-bar mode="indeterminate" aria-label="Consultando el análisis" /> }
|
||||
@case ('pendiente') { <p role="status">Funcionalidad pendiente de publicación.</p> }
|
||||
@case ('no-disponible') {
|
||||
<p role="status">La cohorte no está disponible en este momento.</p>
|
||||
<button type="button" mat-stroked-button (click)="reintentar()">Reintentar consulta</button>
|
||||
}
|
||||
@case ('error') {
|
||||
<div role="alert"><p>{{ $any(carga()).mensaje }}</p><button type="button" mat-stroked-button (click)="reintentar()">Reintentar consulta</button></div>
|
||||
}
|
||||
}
|
||||
@case ('error') {
|
||||
<div role="alert"><p>{{ $any(carga()).mensaje }}</p><button type="button" mat-stroked-button (click)="reintentar()">Reintentar consulta</button></div>
|
||||
@if (datos(); as d) {
|
||||
@if (todasSuprimidas()) {
|
||||
<p class="nota">Ninguna categoría alcanza el mínimo de {{ d.umbral_supresion }} pacientes para publicarse a esta fecha de corte.</p>
|
||||
}
|
||||
<p class="aviso" role="status">{{ aviso() }}</p>
|
||||
<app-plotly-chart [style.--plot-height]="'360px'" [style.--plot-min-width]="'480px'" [showNotes]="false" [figure]="figura()" (plotClick)="clicGrupo($event)"
|
||||
label="Pacientes por categoría BI-RADS" />
|
||||
<p class="nota">Haga clic en una barra o use «Ver pacientes» para abrir la lista en Seguimiento. Una categoría con menos de {{ d.umbral_supresion }} pacientes no se publica.</p>
|
||||
<div class="tabla-scroll" role="region" tabindex="0" aria-label="Pacientes por categoría BI-RADS, tabla">
|
||||
<table>
|
||||
<caption>Pacientes por categoría BI-RADS a la fecha de corte {{ d.corte }}</caption>
|
||||
<thead><tr><th scope="col">Categoría</th><th scope="col">Pacientes</th><th scope="col"><span class="visually-hidden">Seguimiento</span></th></tr></thead>
|
||||
<tbody>
|
||||
@for (g of d.grupos; track g.codigo) {
|
||||
<tr [attr.data-grupo]="g.codigo">
|
||||
<th scope="row">{{ etiqueta(g.codigo) }}</th>
|
||||
<td>{{ g.suprimido ? 'No publicado' : miles(g.n!) }}</td>
|
||||
<td>@if (g.suprimido) { <span class="sin-lista">{{ motivo }}</span> }
|
||||
@else { <button type="button" class="ver" (click)="verGrupo(g.codigo, $event.currentTarget)" [attr.aria-label]="'Ver pacientes de ' + etiqueta(g.codigo) + ' en Seguimiento'">Ver pacientes</button> }</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@if (datos(); as d) {
|
||||
<p class="contexto">Fecha de corte: {{ d.corte }}. Denominador: {{ d.denominador }}.</p>
|
||||
@if (todasSuprimidas()) {
|
||||
<p class="nota">Ninguna categoría alcanza el mínimo de {{ d.umbral_supresion }} pacientes para publicarse a esta fecha de corte.</p>
|
||||
}
|
||||
<p class="aviso" role="status">{{ aviso() }}</p>
|
||||
<app-plotly-chart [style.--plot-height]="'360px'" [style.--plot-min-width]="'480px'" [showNotes]="false" [figure]="figura()" (plotClick)="clicGrupo($event)"
|
||||
label="Pacientes por categoría BI-RADS" />
|
||||
<p class="nota">Haga clic en una barra publicada para ver sus pacientes en Seguimiento. Una categoría con menos de {{ d.umbral_supresion }} pacientes no se publica.</p>
|
||||
<div class="tabla-scroll" role="region" tabindex="0" aria-label="Pacientes por categoría BI-RADS, tabla">
|
||||
<table>
|
||||
<caption>Pacientes por categoría BI-RADS a la fecha de corte {{ d.corte }}</caption>
|
||||
<thead><tr><th scope="col">Categoría</th><th scope="col">Pacientes</th><th scope="col"><span class="visually-hidden">Seguimiento</span></th></tr></thead>
|
||||
<tbody>
|
||||
@for (g of d.grupos; track g.codigo) {
|
||||
<tr [attr.data-grupo]="g.codigo">
|
||||
<th scope="row">{{ etiqueta(g.codigo) }}</th>
|
||||
<td>{{ g.suprimido ? 'No publicado' : miles(g.n!) }}</td>
|
||||
<td>@if (g.suprimido) { <span class="sin-lista">{{ motivo }}</span> }
|
||||
@else { <button type="button" class="ver" (click)="verGrupo(g.codigo, $event.currentTarget)" [attr.aria-label]="'Ver pacientes de ' + etiqueta(g.codigo) + ' en Seguimiento'">Ver pacientes</button> }</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
}
|
||||
</article>
|
||||
</section>
|
||||
`,
|
||||
styles: `
|
||||
:host { display: block; min-width: 0; }
|
||||
.analisis { display: flex; flex-direction: column; gap: var(--issste-space-4); min-width: 0; }
|
||||
.analisis > * { margin: 0; }
|
||||
/* The dark theme paints the panel's own surfaces, not the page: the loose heading and notes get the dark background so their light text stays legible. */
|
||||
:host-context(.dark-theme) .analisis { padding: var(--issste-space-4); background: var(--issste-background); color: var(--issste-text); border-radius: var(--issste-radius); }
|
||||
.tarjetas { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--issste-space-4); }
|
||||
@media (min-width: 700px) { .tarjetas { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
||||
.panel { box-sizing: border-box; min-width: 0; padding: var(--issste-space-6); background: var(--issste-surface); color: var(--issste-text);
|
||||
border: 1px solid var(--issste-border); border-radius: var(--issste-radius); }
|
||||
h2 { margin: 0; font-family: var(--issste-font-heading); font-size: 1.25rem; line-height: 1.3; overflow-wrap: anywhere; }
|
||||
h2, h3 { margin: 0; font-family: var(--issste-font-heading); font-size: 1.25rem; line-height: 1.3; overflow-wrap: anywhere; }
|
||||
p { margin: var(--issste-space-3) 0 0; overflow-wrap: anywhere; }
|
||||
.nota, .contexto, .sin-lista { color: var(--issste-text-secondary); font: var(--mat-sys-body-medium); }
|
||||
.controles { display: flex; flex-wrap: wrap; align-items: end; gap: var(--issste-space-3); margin-top: var(--issste-space-4); }
|
||||
.controles { display: flex; flex-wrap: wrap; align-items: end; gap: var(--issste-space-3); padding: var(--issste-space-3) var(--issste-space-4); background: var(--issste-surface);
|
||||
border: 1px solid var(--issste-border); border-radius: var(--issste-radius); }
|
||||
label { display: flex; flex-direction: column; gap: .5rem; max-width: 100%; }
|
||||
input { color: inherit; background: var(--issste-surface); border: 1px solid var(--issste-border); border-radius: 4px; padding: .6rem; min-height: 44px; box-sizing: border-box; font: inherit; max-width: 100%; }
|
||||
input:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
|
||||
@@ -150,6 +169,8 @@ export class IndicadoresAnalisis {
|
||||
// Why the last click on a bar opened nothing.
|
||||
readonly aviso = signal('');
|
||||
readonly datos = computed(() => { const c = this.carga(); return c.estado === 'listo' ? c.datos : undefined; });
|
||||
// How many categories the answer publishes; the rest are suppressed. Counts categories only, never patients.
|
||||
readonly publicadas = computed(() => this.datos()?.grupos.filter(g => !g.suprimido).length ?? 0);
|
||||
// The answer cannot tell an empty cohort from categories that are all under the threshold: it only says none is published.
|
||||
readonly todasSuprimidas = computed(() => !!this.datos()?.grupos.every(g => g.suprimido));
|
||||
readonly figura = computed(() => { const d = this.datos(); return d ? gruposFigura(d, this.tema()) : { data: [], layout: {} }; });
|
||||
|
||||
@@ -67,7 +67,7 @@ describe('Recorrido de cáncer de mama: análisis, lista, ficha y regreso', () =
|
||||
// Fails if any step of the journey drops the selection, repeats a request, loses the focus or the answer already loaded.
|
||||
const e = await entrar();
|
||||
await abrirAnalisis(e);
|
||||
const origen = e.root.querySelector<HTMLButtonElement>('#analisis-titulo ~ .tabla-scroll tr[data-grupo="BIRADS_5"] button.ver')!;
|
||||
const origen = e.root.querySelector<HTMLButtonElement>('#birads-titulo ~ .tabla-scroll tr[data-grupo="BIRADS_5"] button.ver')!;
|
||||
origen.focus(); origen.click(); e.harness.detectChanges();
|
||||
|
||||
// Seguimiento on the whole cohort of the group, at the analysis' cut-off, quoting its cohort and revision.
|
||||
|
||||
Reference in New Issue
Block a user