Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3385df4ba3 | |||
| 96b1cabb5a | |||
| 366591f247 | |||
| 241631b884 | |||
| 6c063344a3 | |||
| 2f5b1ce1f2 | |||
| 56b3ac6b0c | |||
| f6603ae76e | |||
| 21ae95b5ed | |||
| ce2e86c045 | |||
| 0f8eb0ec94 | |||
| 2f6d419453 | |||
| f34f9e1607 | |||
| c7dd134fce |
Binary file not shown.
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 717 B |
@@ -30,19 +30,21 @@ import { parConteos } from './indicadores-conteos-pareados';
|
||||
imports: [MatButtonModule, MatCardModule, MatIconModule, IndicadorFigurePanel, IndicadorEu7Escenario, IndicadorTiemposPareados, IndicadorConfirmacionCitologia, IndicadorHistopatologiaCama, IndicadorConteosPareados],
|
||||
template: `
|
||||
<mat-card>
|
||||
<header>
|
||||
<div class="card-identity">
|
||||
<h2 [id]="titleId" tabindex="-1">{{ tituloVisible }}</h2>
|
||||
</div>
|
||||
</header>
|
||||
@if (!conteos) {
|
||||
<header>
|
||||
<div class="card-identity">
|
||||
<h2 [id]="titleId" tabindex="-1">{{ indicador.titulo }}</h2>
|
||||
</div>
|
||||
</header>
|
||||
}
|
||||
@if (!sobrio) {
|
||||
<button class="pin-toggle" mat-button type="button" [attr.aria-pressed]="pinned"
|
||||
[attr.aria-label]="(pinned ? 'Desfijar indicador' : 'Fijar indicador') + ', ' + tituloVisible"
|
||||
[attr.aria-label]="(pinned ? 'Desfijar indicador' : 'Fijar indicador') + ', ' + indicador.titulo"
|
||||
(click)="pinChanged.emit()">
|
||||
<mat-icon aria-hidden="true">push_pin</mat-icon>{{ pinned ? 'Desfijar indicador' : 'Fijar indicador' }}
|
||||
</button>
|
||||
}
|
||||
<div class="catalog-content" [id]="contentId" [attr.aria-labelledby]="titleId">
|
||||
<div class="catalog-content" [id]="contentId" [attr.aria-labelledby]="conteos ? null : titleId">
|
||||
@if (!sobrio) { <p class="catalog-metadata">{{ indicador.figuras.length }} figuras publicadas</p> }
|
||||
@if (isEu7) {
|
||||
<div #visibilityRegion class="eu7-region">
|
||||
@@ -62,7 +64,7 @@ import { parConteos } from './indicadores-conteos-pareados';
|
||||
</div>
|
||||
} @else if (conteos; as par) {
|
||||
<div #visibilityRegion class="conteos-region">
|
||||
<app-indicador-conteos-pareados [dominio]="dominio" [par]="par" [indicador]="indicador" [tema]="tema" [applied]="applied" [visible]="visible" [metadata]="metadata" [metadataAttempt]="metadataAttempt" (metadataRequested)="loadMetadata()" />
|
||||
<app-indicador-conteos-pareados [dominio]="dominio" [par]="par" [indicador]="indicador" [tema]="tema" [applied]="applied" [visible]="visible" />
|
||||
</div>
|
||||
} @else if (selectedFigure) {
|
||||
<div #visibilityRegion class="graphic-region" [class.dual-panels]="isDual">
|
||||
@@ -126,7 +128,6 @@ export class IndicadorCatalogCard implements OnChanges, OnDestroy {
|
||||
private metadataSubscription?: Subscription;
|
||||
private metadataKey = '';
|
||||
metadata?: IndicadorMetadatos;
|
||||
metadataAttempt = 0;
|
||||
private activatedKey = '';
|
||||
constructor() {
|
||||
effect(() => {
|
||||
@@ -136,10 +137,6 @@ export class IndicadorCatalogCard implements OnChanges, OnDestroy {
|
||||
}
|
||||
// CaMa's cards carry no pin, representation selector or figure count, as in the mockup.
|
||||
get sobrio() { return this.dominio === 'cama'; }
|
||||
// The published title keeps «individual»; the card does not.
|
||||
get tituloVisible() {
|
||||
return this.indicador.id === 'cama_birads_456_mastografia' ? this.indicador.titulo.replace(' individual', '') : this.indicador.titulo;
|
||||
}
|
||||
get pair() { return dualFigures(this.indicador); }
|
||||
get isEu7() { return this.dominio === 'cacu' && this.indicador.id === 'cacu_eu7'; }
|
||||
get isConfirmacion() { return this.dominio === 'cacu' && this.indicador.id === ID_CONFIRMACION; }
|
||||
@@ -225,7 +222,6 @@ export class IndicadorCatalogCard implements OnChanges, OnDestroy {
|
||||
if (this.metadataKey !== key) return;
|
||||
if (!value) this.metadataKey = '';
|
||||
this.metadata = value;
|
||||
this.metadataAttempt++;
|
||||
this.changeDetector.markForCheck();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -35,22 +35,23 @@ summary { cursor: pointer; padding-block: .75rem; }
|
||||
table { border-collapse: collapse; width: 100%; margin-block: 1rem; }
|
||||
th, td { padding: .5rem; text-align: start; border-bottom: 1px solid var(--issste-border); }
|
||||
caption { text-align: start; font-weight: 600; }
|
||||
.histo-meta { display: flex; justify-content: flex-end; align-items: flex-start; gap: .75rem; }
|
||||
.view-context { display: flex; flex-direction: column; align-items: flex-end; gap: .1rem; margin: .15rem 0 0; color: var(--issste-text-secondary); font-size: .75rem; line-height: 1.35; }
|
||||
.histo-meta { display: flex; justify-content: flex-end; align-items: flex-start; gap: .75rem; margin: -.85rem -.65rem 0 0; }
|
||||
.view-context { display: flex; flex-direction: column; align-items: flex-end; gap: .1rem; margin: .2rem 0 0; color: var(--issste-text-secondary); font-size: .75rem; line-height: 1.35; }
|
||||
.histo .figure { border-top: 0; }
|
||||
.histo .figure + .figure { border-top: 1px solid var(--issste-border); padding-top: .25rem; }
|
||||
.histo .help { position: relative; display: flex; justify-content: flex-end; padding-bottom: .35rem; }
|
||||
.histo .help .methodology-toggle { display: inline-flex; align-items: center; justify-content: center; width: 1.75rem; height: 1.75rem; min-width: 1.75rem; min-height: 1.75rem; padding: 0; border-radius: 50%; font-weight: 800; font-size: 1rem; line-height: 1; background: color-mix(in srgb, var(--issste-accent) 14%, var(--issste-surface)); }
|
||||
.histo .help { position: relative; display: flex; justify-content: flex-end; padding-bottom: 0; }
|
||||
.histo .help .methodology-toggle { display: inline-flex; align-items: center; justify-content: center; width: 1.75rem; height: 1.75rem; min-width: 1.75rem; min-height: 1.75rem; padding: 0; border: 0; border-radius: 50%; font-weight: 800; font-size: 1rem; line-height: 1; background: var(--issste-accent); color: var(--issste-on-accent); }
|
||||
.histo .help .methodology { position: absolute; z-index: 8; top: 100%; right: 0; width: min(34rem, calc(100vw - 2rem)); max-height: 18rem; overflow: auto; background: var(--issste-surface); box-shadow: 0 10px 28px rgb(0 0 0 / .14); }
|
||||
.histo .legend { display: flex; flex-direction: column; gap: 0; margin-block: .15rem 1rem; }
|
||||
.histo .tab-bar { display: flex; align-items: flex-end; gap: .5rem; border-bottom: 1px solid var(--issste-border); }
|
||||
.histo .tabs { display: flex; flex-wrap: wrap; gap: .2rem; min-width: 0; }
|
||||
.histo .tabs .tab { border: 1px solid transparent; border-bottom: 0; border-radius: .75rem .75rem 0 0; background: transparent; box-shadow: none; }
|
||||
.histo .tabs .tab { display: inline-flex; align-items: center; gap: .45rem; border: 1px solid transparent; border-bottom: 0; border-radius: .75rem .75rem 0 0; background: transparent; box-shadow: none; }
|
||||
.histo .tabs .tab[aria-selected=true] { background: color-mix(in srgb, var(--swatch) 18%, var(--issste-surface)); border-color: var(--issste-border); box-shadow: inset 0 -3px 0 var(--swatch); font-weight: 700; }
|
||||
.histo .tab-panel { display: flex; flex-wrap: wrap; gap: .45rem; padding: .65rem .1rem .1rem; }
|
||||
.histo .tab-panel .child { border-radius: .75rem; border-color: color-mix(in srgb, var(--swatch) 55%, var(--issste-border)); background: var(--issste-surface); }
|
||||
.histo .child-groups { display: flex; flex-wrap: wrap; align-items: center; column-gap: 2rem; row-gap: .45rem; padding: .65rem .1rem .1rem; }
|
||||
.histo .tab-panel { display: flex; flex-wrap: wrap; gap: .45rem; }
|
||||
.histo .tab-panel .child { display: inline-flex; align-items: center; gap: .45rem; border-radius: .75rem; border-color: color-mix(in srgb, var(--swatch) 55%, var(--issste-border)); background: var(--issste-surface); }
|
||||
.histo .tab-panel .child[aria-pressed=true] { background: color-mix(in srgb, var(--swatch) 16%, var(--issste-surface)); border-color: var(--swatch); }
|
||||
.histo .tab .swatch, .histo .tab-panel .swatch { width: .35rem; height: 1.15rem; border: 0; border-radius: .2rem; background: var(--swatch); }
|
||||
.histo .tab .swatch, .histo .tab-panel .swatch { display: block; width: .35rem; height: 1em; margin: 0; border: 0; border-radius: .2rem; background: var(--swatch); align-self: center; }
|
||||
.reading-guide h3 { margin: 0 0 .25rem; }
|
||||
.reading-guide + .reading-guide { margin-top: 1rem; }
|
||||
.reading-guide ul { margin: .5rem 0 0; padding-inline-start: 1.25rem; }
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
<section class="conteos" [attr.aria-label]="indicador.titulo + ', por ' + par.unidades.pacientes.slice(0, -1) + ' y por ' + par.unidades.examenes.slice(0, -1)">
|
||||
<div class="conteos-head">
|
||||
<button type="button" class="help-icon" aria-label="Cómo leer" [matTooltip]="helpText" matTooltipClass="issste-help-tooltip" matTooltipPosition="below" (mouseenter)="showHelp()" (focus)="showHelp()"><span aria-hidden="true">!</span></button>
|
||||
</div>
|
||||
@switch (status()) {
|
||||
@case ('deferred') { <p role="status">La vista se cargará al acercarse a esta región.</p> }
|
||||
@case ('loading') { <mat-progress-bar mode="indeterminate" [attr.aria-label]="'Cargando ' + indicador.titulo" /><p role="status">Cargando {{ par.unidades.examenes }} y {{ par.unidades.pacientes }} del mismo periodo…</p> }
|
||||
@@ -10,6 +7,8 @@
|
||||
@case ('incompatible') { <div role="alert"><p>Respuesta incompatible: {{ message }}</p><button mat-stroked-button type="button" (click)="retry()">Reintentar</button></div> }
|
||||
}
|
||||
@if (status() === 'ready' && model; as m) {
|
||||
@let tituloMastografias = 'Porcentaje de mastografías con resultado en la clasificación de BI-RADS 4, 5 o 6, ' + m.periodo;
|
||||
@let tituloPacientes = 'Porcentaje de pacientes con resultados de BI-RADS 4, 5 o 6, ' + m.periodo;
|
||||
@if (pages.length > 1) {
|
||||
<nav class="periods" [attr.aria-label]="'Periodos, ' + indicador.titulo">
|
||||
<button type="button" aria-label="Periodo anterior" [disabled]="periodIndex === 0" (click)="changePeriod(-1)">‹</button>
|
||||
@@ -18,15 +17,35 @@
|
||||
</nav>
|
||||
}
|
||||
<div class="figures">
|
||||
<section class="figure"><h3>{{ par.unidades.examenes | titlecase }} por categoría, {{ m.periodo }}</h3>
|
||||
<section class="figure">
|
||||
<div class="figure-head">
|
||||
<h3>{{ tituloMastografias }}</h3>
|
||||
<div class="help" (mouseenter)="openHelp('examenes')" (mouseleave)="hideHelp('examenes')" (focusin)="openHelp('examenes')" (focusout)="onHelpFocusOut('examenes', $event)">
|
||||
<button type="button" class="help-icon" aria-label="Cómo leer, mastografías por categoría" [attr.aria-expanded]="helpWhich === 'examenes'"
|
||||
[attr.aria-describedby]="helpWhich === 'examenes' ? 'cama-birads-ayuda-mastografias' : null" (click)="toggleHelp('examenes')"><span aria-hidden="true">!</span></button>
|
||||
@if (helpWhich === 'examenes') {
|
||||
<div class="methodology" id="cama-birads-ayuda-mastografias" role="tooltip">Cada mastografía cuenta en su propia categoría.</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@if (total) {
|
||||
<app-plotly-chart [figure]="donutFigure!" class="donut-chart" (widthChanged)="ajustarAnchoDona($event)" [showNotes]="false" [label]="indicador.titulo + ', dona, ' + m.periodo" />
|
||||
<app-plotly-chart [figure]="donutFigure!" class="donut-chart" (widthChanged)="ajustarAnchoDona($event)" [showNotes]="false" [label]="tituloMastografias" />
|
||||
} @else { <p role="status">{{ total === null ? 'Dona no disponible: hay celdas suprimidas o sin dato.' : 'Sin ' + par.unidades.examenes + ' en el periodo.' }}</p> }
|
||||
@if (m.sinDato) { <p class="note">Fuera de la dona: {{ texto(m.sinDato) }} {{ par.unidades.examenes }} sin categoría.</p> }
|
||||
</section>
|
||||
<section class="figure"><h3>{{ par.unidades.pacientes | titlecase }} por categoría, {{ m.periodo }}</h3>
|
||||
<section class="figure">
|
||||
<div class="figure-head">
|
||||
<h3>{{ tituloPacientes }}</h3>
|
||||
<div class="help" (mouseenter)="openHelp('pacientes')" (mouseleave)="hideHelp('pacientes')" (focusin)="openHelp('pacientes')" (focusout)="onHelpFocusOut('pacientes', $event)">
|
||||
<button type="button" class="help-icon" aria-label="Cómo leer, pacientes por categoría" [attr.aria-expanded]="helpWhich === 'pacientes'"
|
||||
[attr.aria-describedby]="helpWhich === 'pacientes' ? 'cama-birads-ayuda-pacientes' : null" (click)="toggleHelp('pacientes')"><span aria-hidden="true">!</span></button>
|
||||
@if (helpWhich === 'pacientes') {
|
||||
<div class="methodology" id="cama-birads-ayuda-pacientes" role="tooltip">La paciente se cuenta una vez con la categoría más alta de sus mastografías en el periodo.</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@if (totalPacientes) {
|
||||
<app-plotly-chart [figure]="patientsFigure!" class="donut-chart" (widthChanged)="ajustarAnchoPacientes($event)" [showNotes]="false" [label]="indicador.titulo + ', dona de pacientes por categoría BI-RADS, ' + m.periodo" />
|
||||
<app-plotly-chart [figure]="patientsFigure!" class="donut-chart" (widthChanged)="ajustarAnchoPacientes($event)" [showNotes]="false" [label]="tituloPacientes" />
|
||||
} @else { <p role="status">{{ !m.pacientesVerificados ? 'Dona de pacientes no disponible hasta verificar la definición publicada.' : totalPacientes === null ? 'Dona no disponible: hay celdas suprimidas o sin dato.' : 'Sin ' + par.unidades.pacientes + ' en el periodo.' }}</p> }
|
||||
@if (!m.pacientesVerificados) { <p class="note" role="status">Pacientes pendientes: la versión publicada del indicador de pacientes no es una cuya definición se haya verificado para sumar sus categorías.</p> }
|
||||
</section>
|
||||
@@ -34,7 +53,7 @@
|
||||
@for (note of m.notas; track $index) { <p class="note">{{ note }}</p> }
|
||||
<details class="published-values"><summary>Valores publicados</summary>
|
||||
<div class="table-scroll" role="region" [attr.aria-label]="'Tabla de valores, ' + indicador.titulo" tabindex="0">
|
||||
<table><caption>{{ par.unidades.pacientes | titlecase }} (su categoría más grave) y {{ par.unidades.examenes }}, {{ m.periodo }}</caption>
|
||||
<table><caption>{{ par.unidades.pacientes | titlecase }} (su categoría más alta) y {{ par.unidades.examenes }}, {{ m.periodo }}</caption>
|
||||
<thead><tr><th scope="col">Familia de BI-RADS</th><th scope="col">{{ par.unidades.pacientes | titlecase }}</th><th scope="col">{{ par.unidades.examenes | titlecase }}</th></tr></thead>
|
||||
<tbody>@for (f of m.filas; track f.id) { <tr><th scope="row">{{ f.etiqueta }}</th><td>{{ textoPacientes(f.pacientes) }}</td><td>{{ texto(f.examenes) }}</td></tr> }</tbody>
|
||||
</table>
|
||||
|
||||
@@ -3,15 +3,17 @@
|
||||
p, h3, summary { overflow-wrap: anywhere; }
|
||||
.applied-summary, .note { color: var(--issste-text-secondary); }
|
||||
.methodology { padding: 1rem; border: 1px solid var(--issste-border); border-radius: var(--issste-radius); }
|
||||
.reading-guide h3 { margin: 0 0 .25rem; }
|
||||
.reading-guide ul { margin: .5rem 0 0; padding-inline-start: 1.25rem; }
|
||||
.figure-head { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
|
||||
.figure-head h3 { margin: 0; }
|
||||
.help { display: flex; flex: none; justify-content: flex-end; }
|
||||
.help .methodology { position: absolute; z-index: 8; inset-block-start: calc(100% + .35rem); inset-inline-end: 0;
|
||||
box-sizing: border-box; inline-size: min(34rem, 100%); background: var(--issste-surface); box-shadow: 0 10px 28px rgb(0 0 0 / .14); }
|
||||
h3 { font-size: 1rem; font-weight: 500; line-height: 1.5; }
|
||||
.periods { display: flex; align-items: center; gap: var(--issste-space-3); }
|
||||
.periods button { min-width: 44px; min-height: 44px; font-size: 1.25rem; color: var(--issste-text); background: var(--issste-surface);
|
||||
border: 1px solid var(--issste-border); border-radius: var(--issste-radius); cursor: pointer; }
|
||||
.periods button:disabled { opacity: .5; cursor: default; }
|
||||
// The two figures share the card in equal halves; one above the other on a narrow card.
|
||||
.conteos-head { display: flex; justify-content: flex-end; }
|
||||
.help-icon { display: inline-flex; align-items: center; justify-content: center; width: 1.75rem; height: 1.75rem; min-width: 1.75rem; min-height: 1.75rem; padding: 0; border: 0; border-radius: 50%; background: var(--issste-accent); color: var(--issste-on-accent); font: inherit; font-weight: 800; line-height: 1; cursor: pointer; }
|
||||
.help-icon:focus-visible { outline: 2px solid var(--issste-text); outline-offset: 3px; }
|
||||
.figures { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { ChangeDetectorRef, Component, inject, Input, OnChanges, OnDestroy, output, signal, SimpleChanges } from '@angular/core';
|
||||
import { ChangeDetectorRef, Component, inject, Input, OnChanges, OnDestroy, signal, SimpleChanges } from '@angular/core';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { TitleCasePipe } from '@angular/common';
|
||||
import { combineLatest, Subscription, timeout, TimeoutError } from 'rxjs';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { PlotlyChart } from '../../shared/plotly/plotly-chart';
|
||||
import { Dominio, Indicador, IndicadorMetadatos, PlotlyFigure, Tema } from './indicadores.models';
|
||||
import { Dominio, Indicador, PlotlyFigure, Tema } from './indicadores.models';
|
||||
import { filterCompatibility, GlobalApplied } from './indicadores-memory';
|
||||
import { IndicadoresSnapshots, snapshotKey } from './indicadores-snapshots';
|
||||
import { httpMessage } from './indicadores-http';
|
||||
@@ -14,7 +13,7 @@ import { ConteosIncompatibles, donaConteos, donaPacientes, ModeloConteos, modelo
|
||||
|
||||
@Component({
|
||||
selector: 'app-indicador-conteos-pareados',
|
||||
imports: [MatButtonModule, MatProgressBarModule, MatTooltipModule, PlotlyChart, TitleCasePipe],
|
||||
imports: [MatButtonModule, MatProgressBarModule, PlotlyChart, TitleCasePipe],
|
||||
templateUrl: './indicador-conteos-pareados.html',
|
||||
styleUrl: './indicador-conteos-pareados.scss',
|
||||
})
|
||||
@@ -26,10 +25,6 @@ export class IndicadorConteosPareados implements OnChanges, OnDestroy {
|
||||
@Input({ required: true }) tema!: Tema;
|
||||
@Input({ required: true }) applied!: GlobalApplied;
|
||||
@Input() visible = true;
|
||||
@Input() metadata?: IndicadorMetadatos;
|
||||
// Bumps when a metadata request finishes, including a failure that leaves metadata empty.
|
||||
@Input() metadataAttempt = 0;
|
||||
readonly metadataRequested = output<void>();
|
||||
readonly status = signal<'deferred' | 'loading' | 'ready' | 'empty' | 'error' | 'incompatible'>('deferred');
|
||||
message = '';
|
||||
periodIndex = 0;
|
||||
@@ -49,39 +44,31 @@ export class IndicadorConteosPareados implements OnChanges, OnDestroy {
|
||||
get totalPacientes() { return this.model ? totalPacientes(this.model) : null; }
|
||||
texto(n: number | null) { return n === null ? 'Sin dato' : n.toLocaleString('es-MX'); }
|
||||
textoPacientes(n: number | null) { return n === null && this.model && !this.model.pacientesVerificados ? 'Pendiente' : this.texto(n); }
|
||||
// True only while a metadata request is outstanding. A failure leaves metadata empty, so the next
|
||||
// hover may ask again; the catalog card ignores a second ask until that request finishes.
|
||||
private helpAsked = false;
|
||||
// "Cómo leer": what the kit publishes for the exams' donut. Both donuts use the same categories.
|
||||
get donutGuide() {
|
||||
const detail = this.metadata?.figuras_detalle?.find(item => item.figura === 'fig_c2_donas');
|
||||
const descripcion = detail?.descripcion?.trim() ?? '';
|
||||
const como_leer = (detail?.como_leer ?? []).filter(line => line.trim().length > 0);
|
||||
return descripcion || como_leer.length ? { descripcion, como_leer } : undefined;
|
||||
helpWhich: 'examenes' | 'pacientes' | null = null;
|
||||
private helpPinned: 'examenes' | 'pacientes' | null = null;
|
||||
toggleHelp(which: 'examenes' | 'pacientes') {
|
||||
if (this.helpPinned === which) { this.helpPinned = null; this.helpWhich = null; return; }
|
||||
this.helpPinned = which;
|
||||
this.openHelp(which);
|
||||
}
|
||||
get helpText() {
|
||||
const guide = this.donutGuide;
|
||||
const dona = guide
|
||||
? ['Dona por categoría', guide.descripcion, ...guide.como_leer].filter(line => line.length)
|
||||
: [this.metadata ? 'El servicio no publica instrucciones de lectura para esta figura.' : 'Metadatos publicados pendientes.'];
|
||||
const pacientes = this.par.unidades.pacientes;
|
||||
const examenes = this.par.unidades.examenes;
|
||||
return [...dona, `${pacientes[0].toUpperCase()}${pacientes.slice(1)} y ${examenes}`,
|
||||
`Cada ${pacientes.slice(0, -1)} cuenta una vez en el periodo, en la categoría más grave de sus ${examenes}. Cada ${examenes.slice(0, -1)} cuenta en su propia categoría. Cada dona muestra uno de esos conteos; no se calcula cuántas ${examenes} tiene cada ${pacientes.slice(0, -1)}, porque no son las mismas poblaciones.`,
|
||||
].join('\n');
|
||||
openHelp(which: 'examenes' | 'pacientes') {
|
||||
this.helpWhich = which;
|
||||
}
|
||||
showHelp() {
|
||||
if (this.metadata || this.helpAsked) return;
|
||||
this.helpAsked = true;
|
||||
this.metadataRequested.emit();
|
||||
hideHelp(which: 'examenes' | 'pacientes') {
|
||||
if (this.helpPinned === which) return;
|
||||
if (this.helpWhich === which) this.helpWhich = null;
|
||||
}
|
||||
onHelpFocusOut(which: 'examenes' | 'pacientes', event: FocusEvent) {
|
||||
const next = event.relatedTarget;
|
||||
if (next instanceof Node && (event.currentTarget as Node).contains(next)) return;
|
||||
if (this.helpPinned === which) this.helpPinned = null;
|
||||
if (this.helpWhich === which) this.helpWhich = null;
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
if (changes['metadata'] && this.metadata) this.helpAsked = false;
|
||||
else if (changes['metadataAttempt'] && !this.metadata) this.helpAsked = false;
|
||||
const key = snapshotKey(this.dominio, this.indicador, this.applied) + JSON.stringify([this.par.examenes, this.par.pacientes, this.indicador.tipos_periodo]);
|
||||
if (key !== this.key) {
|
||||
this.subscription?.unsubscribe(); this.key = key; this.loaded = false; this.helpAsked = false; this.clear();
|
||||
this.subscription?.unsubscribe(); this.key = key; this.loaded = false; this.clear();
|
||||
if (!this.visible) { this.status.set('deferred'); return; }
|
||||
this.load();
|
||||
} else if (this.visible && !this.loaded) this.load();
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<section class="confirmacion histo" aria-label="Resultado histopatológico por categoría BI-RADS">
|
||||
<div class="histo-meta">
|
||||
<p class="view-context">
|
||||
<span>{{ intervalLabel }}</span>
|
||||
@if (contextPeriod) { <span>Periodo {{ contextPeriod }}</span> }
|
||||
</p>
|
||||
<div class="help" (mouseenter)="showHelp()" (mouseleave)="hideHelp()" (focusin)="showHelp()" (focusout)="onHelpFocusOut($event)">
|
||||
<button type="button" class="methodology-toggle" aria-label="Cómo leer" [attr.aria-expanded]="helpOpen" [attr.aria-describedby]="helpOpen ? 'histo-como-leer' : null" (click)="toggleHelp()"><span aria-hidden="true">!</span></button>
|
||||
@if (helpOpen) {
|
||||
@@ -17,10 +21,6 @@
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<p class="view-context">
|
||||
<span>{{ intervalLabel }}</span>
|
||||
@if (contextPeriod) { <span>Periodo {{ contextPeriod }}</span> }
|
||||
</p>
|
||||
</div>
|
||||
@switch (status()) {
|
||||
@case ('deferred') { <p role="status">La vista se cargará al acercarse a esta región.</p> }
|
||||
@@ -47,9 +47,9 @@
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@for (g of m.grupos; track g.id) {
|
||||
@if (selection?.grupo === g.id) {
|
||||
<div class="tab-panel" role="tabpanel" [id]="'histo-panel-' + g.id" [attr.aria-labelledby]="'histo-tab-' + g.id" [attr.aria-label]="'Resultados de ' + g.etiqueta">
|
||||
<div class="child-groups">
|
||||
@for (g of m.grupos; track g.id) {
|
||||
<div class="tab-panel" role="group" [id]="'histo-panel-' + g.id" [attr.aria-labelledby]="'histo-tab-' + g.id">
|
||||
@for (c of m.categorias; track c.id; let ci = $index) {
|
||||
@if (c.grupo === g.id) {
|
||||
<button type="button" class="child" [style.--swatch]="c.color" [attr.aria-pressed]="selection?.categoria === c.id" (click)="select('categorias', ci)"><span class="swatch" aria-hidden="true"></span>{{ c.etiqueta }}</button>
|
||||
@@ -57,7 +57,7 @@
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="figures">
|
||||
<section class="figure rates"><h3>Por categoría BI-RADS, {{ m.periodo }}</h3>
|
||||
|
||||
@@ -13,7 +13,7 @@ import { MatCardModule } from '@angular/material/card';
|
||||
<p class="value">{{ value }}@if (unit) { <span>{{ unit }}</span> }</p>
|
||||
}
|
||||
<div class="kpi-foot">
|
||||
@if (temporalReference) {
|
||||
@if (showPeriod && temporalReference) {
|
||||
<p class="period">@if (labeledPeriod) { <span class="period-label">Periodo:</span> }<span>{{ temporalReference }}</span></p>
|
||||
}
|
||||
<p class="kpi-state" role="status" [class.visually-hidden]="quietWhenAvailable && state === 'Disponible'">{{ state }}</p>
|
||||
@@ -40,6 +40,7 @@ import { MatCardModule } from '@angular/material/card';
|
||||
// CaMa's cards are as tall as their grid row.
|
||||
:host-context(.kpi-section[data-domain='cama']) { display: flex; flex-direction: column; }
|
||||
:host-context(.kpi-section[data-domain='cama']) mat-card { flex: 1 1 auto; height: auto; }
|
||||
:host-context(.kpi-section[data-domain='cama']) .value { font-size: 1.65rem; }
|
||||
`,
|
||||
})
|
||||
export class IndicadorKpiCard {
|
||||
@@ -47,6 +48,8 @@ export class IndicadorKpiCard {
|
||||
@Input() value?: string | number | null;
|
||||
@Input() unit?: string;
|
||||
@Input() temporalReference?: string;
|
||||
// CaMa's opportunity strip shares one period, shown by the parent instead of on every card.
|
||||
@Input() showPeriod = true;
|
||||
@Input() loading = false;
|
||||
@Input() notes: string[] = [];
|
||||
@Input() state = 'Pendiente de definición';
|
||||
|
||||
@@ -183,14 +183,21 @@ describe('KPI integración con autoridad global', () => {
|
||||
req.forEach(r => r.flush({ ...response(KPI_BY_DOMAIN[domain].findIndex(d => r.request.url.endsWith('/' + d.id + '/datos')), domain), notas: ['Nota del pie de la figura.'] }));
|
||||
fixture.detectChanges();
|
||||
const cards = [...fixture.nativeElement.querySelectorAll('app-indicador-kpi-card')];
|
||||
expect(cards).toHaveLength(domain === 'cacu' ? 5 : 4);
|
||||
expect(cards.map(card => card.querySelector('.value')?.firstChild?.textContent?.trim())).toEqual(domain === 'cacu' ? ['5', undefined, '7', undefined, undefined] : ['5', undefined, '7', undefined]);
|
||||
expect(cards.map(card => card.querySelector('.value span')?.textContent.trim())).toEqual(domain === 'cacu' ? ['pacientes', undefined, 'días (mediana)', undefined, undefined] : ['pacientes', undefined, 'días (mediana)', undefined]);
|
||||
expect(cards.map(card => card.querySelector('.kpi-state')?.textContent.trim())).toEqual(domain === 'cacu' ? ['Disponible', 'Selección no consolidable', 'Disponible', 'Indicador no disponible', 'Indicador no disponible'] : ['Disponible', 'Integración pendiente', 'Disponible', 'Integración pendiente']);
|
||||
expect(cards).toHaveLength(5);
|
||||
expect(cards.map(card => card.querySelector('.value')?.firstChild?.textContent?.trim())).toEqual(['5', undefined, '7', undefined, undefined]);
|
||||
expect(cards.map(card => card.querySelector('.value span')?.textContent.trim())).toEqual(['pacientes', undefined, 'días (mediana)', undefined, undefined]);
|
||||
expect(cards.map(card => card.querySelector('.kpi-state')?.textContent.trim())).toEqual(domain === 'cacu'
|
||||
? ['Disponible', 'Selección no consolidable', 'Disponible', 'Indicador no disponible', 'Indicador no disponible']
|
||||
: ['Disponible', 'Integración pendiente', 'Disponible', 'Integración pendiente', 'Indicador no disponible']);
|
||||
expect(cards.map(card => card.textContent)).toEqual(expect.arrayContaining([
|
||||
expect.stringContaining('2025-S1'),
|
||||
expect.stringContaining(domain === 'cacu' ? '5 citologías; primer cuartil: 3 días; tercer cuartil: 9 días.' : '5 mastografías; Q1 a Q3: 3 a 9 días.'),
|
||||
]));
|
||||
if (domain === 'cama') {
|
||||
expect(fixture.nativeElement.querySelector('.kpi-period')?.textContent).toBe('Periodo 2025-S1');
|
||||
expect(cards.every(card => !card.textContent?.includes('2025-S1'))).toBe(true);
|
||||
} else {
|
||||
expect(cards.map(card => card.textContent)).toEqual(expect.arrayContaining([expect.stringContaining('2025-S1')]));
|
||||
}
|
||||
expect(fixture.nativeElement.textContent).not.toContain('Definición provisional');
|
||||
// CaCu and CaMa cards say only their own line, as in the reference; the kit notes are the figure footer and the definitions.
|
||||
expect(fixture.nativeElement.textContent.includes('Nota del pie de la figura.')).toBe(false);
|
||||
|
||||
@@ -19,7 +19,8 @@ interface KpiDisplay extends KpiResult { period?: string; earlier?: boolean; ver
|
||||
imports: [IndicadorKpiCard, MatButtonModule],
|
||||
template: `<app-indicador-kpi-card [title]="definition.title" [value]="result().value" [unit]="definition.unit"
|
||||
[state]="result().state" [additionalInfo]="result().info" [temporalReference]="temporalReference"
|
||||
[loading]="result().loading ?? false" [notes]="dominio === 'tea' ? result().notes ?? [] : []" [quietWhenAvailable]="dominio === 'cama'" />
|
||||
[loading]="result().loading ?? false" [notes]="dominio === 'tea' ? result().notes ?? [] : []" [quietWhenAvailable]="dominio === 'cama'"
|
||||
[showPeriod]="dominio !== 'cama'" />
|
||||
@if (result().state === 'Error de consulta') {
|
||||
<button type="button" mat-stroked-button (click)="retry()" [attr.aria-label]="'Reintentar ' + definition.title">Reintentar consulta</button>
|
||||
}`,
|
||||
|
||||
@@ -2,7 +2,22 @@
|
||||
|
||||
:host { display: block; min-width: 0; margin: var(--issste-space-4) 0; }
|
||||
// CaMa's compact row: tighter fields and buttons, one line of text under it.
|
||||
:host(.compacto) { margin: 0; @include mat.theme((density: -4)); }
|
||||
:host(.compacto) {
|
||||
margin: 0;
|
||||
@include mat.theme((density: -4));
|
||||
// That theme also rewrites the corner scale, which turns this switch into a pill.
|
||||
// The history switch keeps the slight rounding of the indicators pages.
|
||||
--mat-sys-corner-extra-small: 2px;
|
||||
--mat-sys-corner-small: 2px;
|
||||
--mat-sys-corner-medium: 4px;
|
||||
--mat-sys-corner-large: 4px;
|
||||
--mat-sys-corner-extra-large: 6px;
|
||||
--mat-sys-corner-full: 4px;
|
||||
}
|
||||
:host(.compacto) .interval mat-button-toggle-group {
|
||||
--mat-button-toggle-height: 40px;
|
||||
--mat-button-toggle-shape: 6px;
|
||||
}
|
||||
:host(.compacto) p { line-height: 1.4; margin: var(--issste-space-2) 0 0; font: var(--mat-sys-body-small); }
|
||||
:host(.compacto) .pending { color: var(--issste-text); border-left-color: var(--issste-accent); padding-left: var(--issste-space-2); }
|
||||
:host(.compacto) .apply-button { min-height: 40px; }
|
||||
@@ -23,7 +38,7 @@ p { overflow-wrap: anywhere; line-height: 1.5; margin: var(--issste-space-3) 0;
|
||||
.remove { display: flex; flex-wrap: wrap; gap: var(--issste-space-2); }
|
||||
.remove button { min-height: 44px; }
|
||||
.apply-button { min-height: 44px; margin-top: var(--issste-space-2); }
|
||||
.fields.compact { align-items: center; }
|
||||
.fields.compact { align-items: end; }
|
||||
.fields.compact mat-form-field { flex: 0 1 14rem; }
|
||||
.fields.compact .apply-button { margin-top: 0; }
|
||||
@media (max-width: 550px) {
|
||||
|
||||
@@ -32,7 +32,7 @@ describe('CAM-01 y CAM-02: tarjetas con las respuestas reales de WebApi', () =>
|
||||
it('CAM-01 con el umbral de prueba: un 0 de 1 es un cero válido, con su detalle', () => {
|
||||
// Fails if a published 0/1 becomes "sin valor" or loses its numerator and denominator.
|
||||
expect(kpiResult(dato(tasaVisible), CAMA_TASA_DETECCION_KPI, 'cama', applied))
|
||||
.toEqual({ state: 'Disponible', value: '0.0', info: '0 de 1 biopsias con resultado maligno.' });
|
||||
.toEqual({ state: 'Disponible', value: '0.0', info: '0 de 1 biopsias con riesgo a carcinoma.' });
|
||||
});
|
||||
it('CAM-01 con el umbral normal: el dato está suprimido y no muestra cifra', () => {
|
||||
const r = kpiResult(dato(tasaSuprimida), CAMA_TASA_DETECCION_KPI, 'cama', applied);
|
||||
@@ -113,9 +113,10 @@ describe('CAM-01, CAM-02 y CAM-03 en el panel histórico', () => {
|
||||
fixture.componentRef.setInput('dominio', 'cama'); fixture.componentRef.setInput('catalog', REALES);
|
||||
fixture.componentRef.setInput('tema', 'claro'); fixture.componentRef.setInput('active', true);
|
||||
fixture.componentInstance.elegido.set('semestre'); fixture.detectChanges();
|
||||
const respuestas: Record<string, unknown> = visibles
|
||||
? { cama_tasa_deteccion_histopatologica: tasaVisible, cama_dias_resultado_diagnostico: diasVisible, cama_histopatologia_birads: generalFixture }
|
||||
: { cama_tasa_deteccion_histopatologica: tasaSuprimida, cama_dias_resultado_diagnostico: diasSuprimido, cama_histopatologia_birads: generalFixture };
|
||||
const respuestas: Record<string, unknown> = {
|
||||
cama_dias_resultado_diagnostico: visibles ? diasVisible : diasSuprimido,
|
||||
cama_histopatologia_birads: generalFixture,
|
||||
};
|
||||
const pedidos: string[] = [];
|
||||
for (let ola = http.match(() => true); ola.length; ola = http.match(() => true)) {
|
||||
for (const r of ola) {
|
||||
@@ -132,28 +133,29 @@ describe('CAM-01, CAM-02 y CAM-03 en el panel histórico', () => {
|
||||
const paneles = () => [...(fixture.nativeElement as HTMLElement).querySelectorAll('article.panel')] as HTMLElement[];
|
||||
const graficas = () => fixture.debugElement.queryAll(By.directive(ChartStub)).map(d => d.componentInstance as ChartStub);
|
||||
|
||||
it('los tres indicadores publicados se piden y se dibujan; los cinco restantes de la lista siguen pendientes', () => {
|
||||
it('omite el panel y las consultas de detección aunque la medida figure en el catálogo', () => {
|
||||
const pedidos = montar(true);
|
||||
expect(REALES.map(i => i.id)).toContain('cama_tasa_deteccion_histopatologica');
|
||||
expect(pedidos.some(p => p.includes('cama_tasa_deteccion_histopatologica'))).toBe(false);
|
||||
expect(pedidos.filter(p => p.includes('/datos'))).toEqual([
|
||||
'/cama/indicadores/cama_histopatologia_birads/datos?periodos=2025-S1',
|
||||
'/cama/indicadores/cama_dias_resultado_diagnostico/datos?periodos=2025-S1',
|
||||
'/cama/indicadores/cama_tasa_deteccion_histopatologica/datos?periodos=2025-S1'].sort((a, b) => pedidos.indexOf(a) - pedidos.indexOf(b)));
|
||||
'/cama/indicadores/cama_dias_resultado_diagnostico/datos?periodos=2025-S1'].sort((a, b) => pedidos.indexOf(a) - pedidos.indexOf(b)));
|
||||
const titulos = paneles().map(p => [p.querySelector('h2')!.textContent, p.textContent!.includes('Integración pendiente') ? 'pendiente' : 'dibujado']);
|
||||
expect(titulos.filter(([t]) => ['Resultado histopatológico', 'Días del resultado de la mastografía al diagnóstico', 'Tasa de detección histopatológica'].includes(t!)))
|
||||
.toEqual([['Resultado histopatológico', 'dibujado'], ['Días del resultado de la mastografía al diagnóstico', 'dibujado'], ['Tasa de detección histopatológica', 'dibujado']]);
|
||||
expect(graficas()).toHaveLength(3);
|
||||
expect(graficas().map(g => g.figure!.data.length)).toEqual([6, 2, 2]);
|
||||
expect(titulos.map(([t]) => t)).not.toContain('Tasa de detección histopatológica');
|
||||
expect(titulos.filter(([, estado]) => estado === 'dibujado'))
|
||||
.toEqual([['Resultado histopatológico', 'dibujado'], ['Días del resultado de la mastografía al diagnóstico', 'dibujado']]);
|
||||
expect(graficas().map(g => g.figure!.data.length)).toEqual([6, 2]);
|
||||
});
|
||||
it('con el umbral normal los dos paneles C1 y C3r avisan el periodo suprimido, y la matriz CAM-03 sigue visible', () => {
|
||||
it('el panel C3r avisa el periodo suprimido y la matriz CAM-03 sigue visible', () => {
|
||||
montar(false);
|
||||
const texto = paneles().map(p => p.textContent!);
|
||||
expect(texto.filter(t => t.includes('Datos suprimidos, sombreados en la figura: 2025 S1.'))).toHaveLength(2);
|
||||
expect(graficas()).toHaveLength(3);
|
||||
expect(texto.filter(t => t.includes('Datos suprimidos, sombreados en la figura: 2025 S1.'))).toHaveLength(1);
|
||||
expect(graficas()).toHaveLength(2);
|
||||
});
|
||||
it('la nota de datos suprimidos es una nota al pie colapsable y llega cerrada; al abrirla muestra el texto completo', () => {
|
||||
montar(false);
|
||||
const notas = [...(fixture.nativeElement as HTMLElement).querySelectorAll('details.nota-pie')] as HTMLDetailsElement[];
|
||||
expect(notas).toHaveLength(2);
|
||||
expect(notas).toHaveLength(1);
|
||||
for (const nota of notas) {
|
||||
expect(nota.open).toBe(false);
|
||||
expect(nota.querySelector('summary')!.textContent!.trim()).toBe('Datos suprimidos');
|
||||
@@ -161,7 +163,6 @@ describe('CAM-01, CAM-02 y CAM-03 en el panel histórico', () => {
|
||||
}
|
||||
notas[0].open = true;
|
||||
expect(notas[0].open).toBe(true);
|
||||
expect(notas[1].open).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -202,12 +203,17 @@ describe('CaMa Resumen con CAM-01, CAM-02 y CAM-03 publicados', () => {
|
||||
const tarjetas = () => [...root().querySelectorAll('.catalog-grid > *')] as HTMLElement[];
|
||||
const completo = () => [...KPI_BY_DOMAIN.cama.map(propios), ...REALES];
|
||||
|
||||
it('las cuatro tarjetas de oportunidad tienen datos, ninguna pendiente, con los valores publicados', () => {
|
||||
cargar(completo());
|
||||
expect(kpis()).toHaveLength(4);
|
||||
it('muestra los valores de las cuatro medidas publicadas y deja diagnóstico a tratamiento sin dato', () => {
|
||||
// Fails if the unavailable slot displays a value or displaces the published measures.
|
||||
const pedidos = cargar(completo());
|
||||
expect(kpis()).toHaveLength(5);
|
||||
expect(root().querySelector('.kpi-grid')!.textContent).not.toContain('Integración pendiente');
|
||||
expect(kpis()[1].textContent).toContain('0 de 1 biopsias con resultado maligno.');
|
||||
expect(pedidos.filter(id => id === 'cama_tasa_deteccion_histopatologica')).toHaveLength(1);
|
||||
expect(kpis()[1].querySelector('h3')?.textContent).toBe('Tasa de confirmación histopatológica');
|
||||
expect(kpis()[1].textContent).toContain('0 de 1 biopsias con riesgo a carcinoma.');
|
||||
expect(kpis()[3].textContent).toContain('6.5'); expect(kpis()[3].textContent).toContain('Q1 a Q3: 2.25 a 12.5 días.');
|
||||
expect(kpis()[4].querySelector('.kpi-state')?.textContent).toBe('Indicador no disponible');
|
||||
expect(kpis()[4].querySelector('.value')).toBeNull();
|
||||
});
|
||||
it('CAM-03 ocupa el lugar de la tarjeta pendiente, primero y con su vista especializada; no se consulta mientras no es visible', () => {
|
||||
const pedidos = cargar(completo());
|
||||
@@ -232,6 +238,6 @@ describe('CaMa Resumen con CAM-01, CAM-02 y CAM-03 publicados', () => {
|
||||
});
|
||||
it('solo CAM-01 y CAM-02 sin CAM-03: dos tarjetas con datos y la de histopatología pendiente', () => {
|
||||
cargar([...KPI_BY_DOMAIN.cama.map(propios), ...REALES.filter(i => i.id !== 'cama_histopatologia_birads')]);
|
||||
expect(kpis()).toHaveLength(4); expect(root().querySelector('app-indicador-histopatologia-pendiente')!.textContent).toContain('Integración pendiente');
|
||||
expect(kpis()).toHaveLength(5); expect(root().querySelector('app-indicador-histopatologia-pendiente')!.textContent).toContain('Integración pendiente');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -308,3 +308,33 @@ describe('Tarjeta pareada de mastografías y pacientes BI-RADS 4, 5 y 6', () =>
|
||||
expect(model.filas.map(f => f.pacientes)).toEqual([0, 20, 2]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Conteos publicados de CaMa en la ruta FHIR', () => {
|
||||
let http: HttpTestingController;
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({ providers: [provideHttpClient(), provideHttpClientTesting(), FhirIndicadoresService] });
|
||||
http = TestBed.inject(HttpTestingController);
|
||||
});
|
||||
afterEach(() => http.verify());
|
||||
function pedir(id: string, fhirId: string) {
|
||||
const answer = firstValueFrom(TestBed.inject(FhirIndicadoresService).datos('cama', id, 'semestre', ['2025-S2']));
|
||||
http.expectOne('/cama/fhir/Measure').flush(measuresData);
|
||||
http.expectOne(r => r.url === '/cama/fhir/MeasureReport').flush({ ...answers[fhirId].semestre, entry: reportsOf(fhirId, 'semestre', '2025-07-01').map(resource => ({ resource })) });
|
||||
return answer;
|
||||
}
|
||||
it('las mastografías llegan a la tarjeta con los conteos publicados', async () => {
|
||||
const publicado = datos('CAMA-BIRADS456-MASTOGRAFIA', ...SEMESTRE_CON_DATOS);
|
||||
const mostrado = await pedir('cama_birads_456_mastografia', 'CAMA-BIRADS456-MASTOGRAFIA');
|
||||
expect(mostrado.filas).toEqual(publicado.filas);
|
||||
const pacientes = datos('CAMA-BIRADS456-PACIENTE', ...SEMESTRE_CON_DATOS);
|
||||
const [model] = modelosConteos(parConteos('cama', 'cama_birads_456_mastografia')!, mostrado, pacientes, 'semestre');
|
||||
expect(totalExamenes(model)).toBe(39);
|
||||
expect(model.filas.map(f => f.examenes)).toEqual([16, 21, 2]);
|
||||
expect(model.filas.map(f => f.pacientes)).toEqual([14, 20, 2]);
|
||||
});
|
||||
it('los pacientes conservan sus conteos publicados', async () => {
|
||||
const publicado = datos('CAMA-BIRADS456-PACIENTE', ...SEMESTRE_CON_DATOS);
|
||||
const pacientes = await pedir('cama_birads_456_paciente', 'CAMA-BIRADS456-PACIENTE');
|
||||
expect(pacientes.filas).toEqual(publicado.filas);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -73,7 +73,7 @@ describe('Tasa de detección histopatológica (C1)', () => {
|
||||
expect(d['grupos']).toEqual({ total: 'Total' });
|
||||
expect(d.filas).toEqual([expect.objectContaining({ grupo: 'total', numerador, denominador, valor, suprimido: 0 })]);
|
||||
expect(kpiResult(d, CAMA_TASA_DETECCION_KPI, 'cama', apply(periodo))).toMatchObject({
|
||||
state: 'Disponible', value: valor.toFixed(1), info: `${numerador} de ${denominador} biopsias con resultado maligno.` });
|
||||
state: 'Disponible', value: valor.toFixed(1), info: `${numerador} de ${denominador} biopsias con riesgo a carcinoma.` });
|
||||
});
|
||||
|
||||
it('el numerador nunca supera al denominador y la suma de los periodos es la de los reportes de biopsia del dominio', () => {
|
||||
|
||||
@@ -35,7 +35,7 @@ describe('Tarjetas de oportunidad de CaMa: definiciones', () => {
|
||||
['cama_dias_resultado_diagnostico', 'C3r', 'días (mediana)'],
|
||||
]);
|
||||
expect(CAMA_OPORTUNIDAD_KPIS.map(d => d.title)).toEqual([
|
||||
'Pacientes evaluadas con BI-RADS 4, 5 y 6', 'Tasa de confirmación histopatológica', 'Tiempo de mastografía a resultado', 'Tiempo de resultado a diagnóstico']);
|
||||
'Pacientes evaluadas con BI-RADS 4, 5 o 6', 'Tasa de confirmación histopatológica', 'Tiempo de toma de mastografía a interpretación radiológica', 'Tiempo de interpretación radiológica a diagnóstico']);
|
||||
expect(KPI_BY_DOMAIN.cama[0]).toBe(CAMA_OPORTUNIDAD_KPIS[0]);
|
||||
});
|
||||
it('solo las tarjetas con indicador en el catálogo entran en KPI_BY_DOMAIN, que es lo que se consulta sin pedirlo', () => {
|
||||
@@ -53,7 +53,7 @@ describe('Tarjetas de oportunidad de CaMa: valores', () => {
|
||||
it('la tasa de detección muestra el porcentaje del C1 sin recalcularlo, con su propia línea de detalle', () => {
|
||||
// Fails if the card recomputes the rate or reuses the confirmation wording ("con reporte de biopsia").
|
||||
const result = kpiResult(c1({ valor: 12.34, numerador: 3, denominador: 20 }), CAMA_TASA_DETECCION_KPI, 'cama', applied);
|
||||
expect(result).toEqual({ state: 'Disponible', value: '12.3', info: '3 de 20 biopsias con resultado maligno.' });
|
||||
expect(result).toEqual({ state: 'Disponible', value: '12.3', info: '3 de 20 biopsias con riesgo a carcinoma.' });
|
||||
});
|
||||
it('una tasa de cero con denominador es un cero real, no una ausencia', () => {
|
||||
const result = kpiResult(c1({ valor: 0, numerador: 0, denominador: 8 }), CAMA_TASA_DETECCION_KPI, 'cama', applied);
|
||||
@@ -208,28 +208,35 @@ describe('Tarjetas de oportunidad de CaMa en la página', () => {
|
||||
const cards = () => [...fixture.nativeElement.querySelectorAll('.kpi-grid app-indicador-kpi-card')] as HTMLElement[];
|
||||
const text = (card: HTMLElement, selector: string) => card.querySelector(selector)?.textContent?.trim();
|
||||
|
||||
it('con el catálogo actual: dos tarjetas con datos, dos pendientes y ninguna consulta a indicadores sin publicar', () => {
|
||||
// Fails if a pending indicator is requested, or if a pending card is drawn with a number.
|
||||
it('con el catálogo actual: dos tarjetas con datos, dos pendientes y diagnóstico a tratamiento sin dato ni consulta', () => {
|
||||
// Fails if any card without a published measure makes a request or displays a value.
|
||||
const urls = load(KPI_BY_DOMAIN.cama, { listed: catalog([...KPI_BY_DOMAIN.cama, ...otros()]) });
|
||||
expect(urls.some(url => url.includes('cama_tasa_deteccion_histopatologica') || url.includes('cama_dias_resultado_diagnostico'))).toBe(false);
|
||||
expect(urls.some(url => url.includes('cama_confirmacion_birads45') || url.includes('cama_dias_toma_diagnostico'))).toBe(false);
|
||||
expect([...new Set(urls)].sort()).toEqual(KPI_BY_DOMAIN.cama.map(d => `/cama/indicadores/${d.id}/datos`).sort());
|
||||
expect(fixture.nativeElement.querySelector('#kpi-section-title').textContent).toBe('Indicadores de oportunidad');
|
||||
expect(fixture.nativeElement.querySelector('.kpi-period')?.textContent).toBe('Periodo 2025-S1');
|
||||
expect(cards().every(card => !card.textContent?.includes('Periodo'))).toBe(true);
|
||||
expect(cards().map(card => text(card, 'h3'))).toEqual([
|
||||
'Pacientes evaluadas con BI-RADS 4, 5 y 6', 'Tasa de confirmación histopatológica', 'Tiempo de mastografía a resultado', 'Tiempo de resultado a diagnóstico']);
|
||||
expect(cards().map(card => text(card, '.value'))).toEqual(['5pacientes', undefined, '7días (mediana)', undefined]);
|
||||
expect(cards().map(card => text(card, '.kpi-state'))).toEqual(['Disponible', 'Integración pendiente', 'Disponible', 'Integración pendiente']);
|
||||
'Pacientes evaluadas con BI-RADS 4, 5 o 6', 'Tasa de confirmación histopatológica', 'Tiempo de toma de mastografía a interpretación radiológica',
|
||||
'Tiempo de interpretación radiológica a diagnóstico', 'Tiempo de diagnóstico a tratamiento']);
|
||||
expect(cards().map(card => text(card, '.value'))).toEqual(['5pacientes', undefined, '7días (mediana)', undefined, undefined]);
|
||||
expect(cards().map(card => text(card, '.kpi-state'))).toEqual([
|
||||
'Disponible', 'Integración pendiente', 'Disponible', 'Integración pendiente', 'Indicador no disponible']);
|
||||
expect(cards()[1].textContent).toContain('aún no está publicado');
|
||||
expect(cards()[1].textContent).not.toMatch(/\d/);
|
||||
expect(cards()[4].textContent).toContain('aún no está publicado');
|
||||
expect(cards()[4].textContent).not.toMatch(/\d|días|mediana/);
|
||||
});
|
||||
it('si el catálogo publica los cuatro indicadores no queda ninguna tarjeta pendiente', () => {
|
||||
// Fails if a published opportunity indicator is not queried and drawn.
|
||||
it('dibuja los cuatro indicadores publicados y mantiene diagnóstico a tratamiento sin valor', () => {
|
||||
// Fails if a published measure is skipped or the placeholder borrows data from another measure.
|
||||
const urls = load([...KPI_BY_DOMAIN.cama, CAMA_TASA_DETECCION_KPI, CAMA_RESULTADO_DIAGNOSTICO_KPI]);
|
||||
expect(cards()).toHaveLength(4);
|
||||
expect(cards()).toHaveLength(5);
|
||||
expect(urls.some(url => url.includes('cama_tasa_deteccion_histopatologica'))).toBe(true);
|
||||
expect(urls.some(url => url.includes('cama_dias_resultado_diagnostico'))).toBe(true);
|
||||
expect(cards().map(card => text(card, 'h3'))).toEqual(CAMA_OPORTUNIDAD_KPIS.map(d => d.title));
|
||||
expect(cards().slice(0, 4).map(card => text(card, 'h3'))).toEqual(CAMA_OPORTUNIDAD_KPIS.map(d => d.title));
|
||||
expect(text(cards()[4], '.kpi-state')).toBe('Indicador no disponible');
|
||||
expect(text(cards()[4], '.value')).toBeUndefined();
|
||||
expect(cards().some(card => card.textContent?.includes('Integración pendiente'))).toBe(false);
|
||||
expect(cards()[1].textContent).toContain('2 de 5 biopsias con resultado maligno.');
|
||||
expect(cards()[1].textContent).toContain('2 de 5 biopsias con riesgo a carcinoma.');
|
||||
});
|
||||
it('sin catálogo de CaMa no se dibuja la sección de indicadores destacados', () => {
|
||||
fixture.componentInstance.changeDominio('cama'); fixture.detectChanges();
|
||||
@@ -249,7 +256,7 @@ describe('Tarjetas de oportunidad de CaMa en la página', () => {
|
||||
expect(text(cards()[2], '.kpi-state')).toBe('Error de consulta'); expect(text(cards()[2], '.value')).toBeUndefined();
|
||||
expect(text(cards()[0], '.value')).toBe('5pacientes');
|
||||
expect(fixture.nativeElement.textContent).not.toContain('private');
|
||||
expect(fixture.nativeElement.querySelector('button[aria-label="Reintentar Tiempo de mastografía a resultado"]')).not.toBeNull();
|
||||
expect(fixture.nativeElement.querySelector('button[aria-label="Reintentar Tiempo de toma de mastografía a interpretación radiológica"]')).not.toBeNull();
|
||||
});
|
||||
it('la tarjeta de distribución de biopsias no se dibuja en el resumen de CaMa y el resto de las figuras sigue', () => {
|
||||
// Fails if cama_biopsias comes back to the summary, or if the filter also hides other indicators.
|
||||
|
||||
@@ -13,7 +13,7 @@ const item = (id: string, titulo: string, contrato: string, figuras: string[]) =
|
||||
// The catalog 18080 publishes for CaMa.
|
||||
const CAMA = [
|
||||
item('cama_biopsias', 'Distribución de resultados de biopsia', 'C2', ['fig_c2_donas', 'fig_c2_barras']),
|
||||
item('cama_birads_456_mastografia', 'Porcentaje individual de mastografías', 'C2', ['fig_c2_donas', 'fig_c2_barras']),
|
||||
item('cama_birads_456_mastografia', 'Porcentaje individual de mastografías con resultado en la clasificación de BI-RADS 4, 5 y 6', 'C2', ['fig_c2_donas', 'fig_c2_barras']),
|
||||
item('cama_birads_456_paciente', 'Porcentaje de pacientes con resultados de BI-RADS 4, 5 y 6', 'C2', ['fig_c2_donas', 'fig_c2_barras']),
|
||||
item('cama_confirmacion_birads45', 'Tasa de confirmación histopatológica', 'C1', ['fig_c1_puntos']),
|
||||
item('cama_dias_toma_diagnostico', 'Tiempo de tamizaje a diagnóstico', 'C3r', ['fig_c3r_caja']),
|
||||
@@ -53,8 +53,10 @@ describe('Resumen clínico de CaMa y los demás dominios', () => {
|
||||
expect(titles()).not.toContain('Distribución de resultados de biopsia');
|
||||
// The patients' counts go on the exams' card, so the partner indicator has no card of its own.
|
||||
expect(titles()).not.toContain('Porcentaje de pacientes con resultados de BI-RADS 4, 5 y 6');
|
||||
// Only the paired card is a published indicator the summary draws; the other three are in Histórico.
|
||||
expect(titles()).toEqual(['Porcentaje de mastografías']);
|
||||
// The paired card has no card title; each donut names itself. The other three indicators are in Histórico.
|
||||
expect(titles()).toEqual([]);
|
||||
expect(root().querySelector('app-indicador-conteos-pareados')).not.toBeNull();
|
||||
expect(section().textContent).not.toContain('Porcentaje de mastografías con resultado en la clasificación de BI-RADS 4, 5 y 6');
|
||||
expect(root().textContent).not.toContain('indicador publicado');
|
||||
});
|
||||
it('CaMa: las tarjetas que el mockup no tiene en el Resumen se retiran sin quitarlas del catálogo', () => {
|
||||
@@ -65,6 +67,12 @@ describe('Resumen clínico de CaMa y los demás dominios', () => {
|
||||
expect(root().querySelector('#panel-datos')!.textContent).toContain(titulo);
|
||||
}
|
||||
});
|
||||
it('CaMa: Datos y definiciones muestra el nombre general de mastografías aunque el catálogo entregue el anterior', () => {
|
||||
open('cama', CAMA);
|
||||
const nombres = [...root().querySelectorAll('#panel-datos summary')].map(summary => summary.textContent?.trim());
|
||||
expect(nombres).toContain('Porcentaje de mastografías con resultado en la clasificación de BI-RADS 4, 5 o 6');
|
||||
expect(nombres).not.toContain(CAMA[1].titulo);
|
||||
});
|
||||
it('CaMa: la tarjeta histopatológica ocupa su lugar como pendiente, sin cifras ni figuras', () => {
|
||||
open('cama', CAMA);
|
||||
const tarjeta = root().querySelector('app-indicador-histopatologia-pendiente') as HTMLElement;
|
||||
|
||||
@@ -126,6 +126,7 @@ describe('Conteos pareados de CaMa: lo que no se calcula', () => {
|
||||
const barras = barrasConteos(m, PAR, 'claro') as unknown as { layout: Record<string, unknown> };
|
||||
expect(barras.layout['annotations']).toBeUndefined();
|
||||
expect(JSON.stringify(barras)).not.toMatch(/≈|por paciente|razón/i);
|
||||
expect(JSON.stringify(barras)).toContain('pacientes (su categoría más alta)');
|
||||
expect(Object.keys(m.filas[0])).toEqual(['id', 'etiqueta', 'pacientes', 'examenes']);
|
||||
});
|
||||
it.each([
|
||||
@@ -155,7 +156,7 @@ describe('Tarjeta pareada de CaMa en la página', () => {
|
||||
let fixture: ReturnType<typeof TestBed.createComponent<IndicadoresPage>>, http: HttpTestingController;
|
||||
const item = (id: string, titulo: string, contrato: string, figuras: string[]) => ({ id, titulo, contrato, figuras, tipos_periodo: ['semestre', 'mes'] });
|
||||
const CATALOGO = [
|
||||
item('cama_birads_456_mastografia', 'Porcentaje individual de mastografías', 'C2', ['fig_c2_donas', 'fig_c2_barras']),
|
||||
item('cama_birads_456_mastografia', 'Porcentaje individual de mastografías con resultado en la clasificación de BI-RADS 4, 5 y 6', 'C2', ['fig_c2_donas', 'fig_c2_barras']),
|
||||
item('cama_birads_456_paciente', 'Porcentaje de pacientes con resultados de BI-RADS 4, 5 y 6', 'C2', ['fig_c2_donas', 'fig_c2_barras']),
|
||||
item('cama_confirmacion_birads45', 'Tasa de confirmación histopatológica', 'C1', ['fig_c1_puntos']),
|
||||
];
|
||||
@@ -202,23 +203,53 @@ describe('Tarjeta pareada de CaMa en la página', () => {
|
||||
// Fails if the patients' indicator keeps a card of its own beside the pair.
|
||||
const titulos = [...root().querySelectorAll('.catalog-grid app-indicador-catalog-card h2')].map(e => e.textContent?.trim());
|
||||
// Confirmation is in Histórico and in Datos y definiciones, not in CaMa's summary.
|
||||
expect(titulos).toEqual(['Porcentaje de mastografías']);
|
||||
// The pair has no card title; each donut has its own heading.
|
||||
expect(titulos).toEqual([]);
|
||||
expect(root().textContent).not.toContain('Porcentaje de mastografías con resultado en la clasificación de BI-RADS 4, 5 y 6');
|
||||
expect(root().textContent).not.toContain('indicador publicado');
|
||||
});
|
||||
it('al hacerse visible pide los dos conteos del mismo periodo y dibuja dona, barras y tabla con sus valores', () => {
|
||||
abrir();
|
||||
const texto = (s: string) => root().querySelector(s)?.textContent?.replace(/\s+/g, ' ').trim();
|
||||
const h3 = [...root().querySelectorAll('app-indicador-conteos-pareados h3')].map(e => e.textContent?.trim());
|
||||
expect(h3).toEqual(['Mastografías por categoría, 2025-S2', 'Pacientes por categoría, 2025-S2']);
|
||||
expect(h3).toEqual([
|
||||
'Porcentaje de mastografías con resultado en la clasificación de BI-RADS 4, 5 o 6, 2025-S2',
|
||||
'Porcentaje de pacientes con resultados de BI-RADS 4, 5 o 6, 2025-S2',
|
||||
]);
|
||||
expect(root().querySelector('.conteos')?.getAttribute('aria-label')).toBe(
|
||||
'Porcentaje de mastografías con resultado en la clasificación de BI-RADS 4, 5 o 6, por paciente y por mastografía');
|
||||
const graficas = fixture.debugElement.queryAll(By.directive(ChartStub)).map(d => d.componentInstance as ChartStub);
|
||||
expect(graficas).toHaveLength(2);
|
||||
expect(graficas.map(g => g.label)).toEqual(h3);
|
||||
expect(graficas.map(g => g.figure!.data.length)).toEqual([1, 1]);
|
||||
const filas = [...root().querySelectorAll('.published-values tbody tr')].map(tr => [...tr.children].map(c => c.textContent?.trim()));
|
||||
expect(filas).toEqual([['BI-RADS 4', '13', '15'], ['BI-RADS 5', '18', '18'], ['BI-RADS 6', '0', '0']]);
|
||||
expect(root().querySelector('.published-values caption')?.textContent).toContain('su categoría más alta');
|
||||
expect(texto('app-indicador-conteos-pareados')).not.toContain('no se calcula la razón de mastografías por paciente');
|
||||
expect(root().querySelector('.help-icon')?.getAttribute('aria-label')).toBe('Cómo leer');
|
||||
expect([...root().querySelectorAll('.help-icon')].map(b => b.getAttribute('aria-label'))).toEqual(['Cómo leer, mastografías por categoría', 'Cómo leer, pacientes por categoría']);
|
||||
expect(texto('app-indicador-conteos-pareados')).not.toContain('Sin dato');
|
||||
});
|
||||
it('cada ayuda muestra su explicación exacta sin depender de metadatos de FHIR', () => {
|
||||
abrir();
|
||||
const [mastografias, pacientes] = [...root().querySelectorAll<HTMLButtonElement>('.help-icon')];
|
||||
const ayuda = () => root().querySelector('[role=tooltip]');
|
||||
|
||||
mastografias.dispatchEvent(new FocusEvent('focusin', { bubbles: true }));
|
||||
fixture.detectChanges();
|
||||
expect(ayuda()?.textContent?.trim()).toBe('Cada mastografía cuenta en su propia categoría.');
|
||||
expect(mastografias.getAttribute('aria-describedby')).toBe(ayuda()?.id);
|
||||
|
||||
pacientes.click();
|
||||
fixture.detectChanges();
|
||||
expect(ayuda()?.textContent?.trim()).toBe('La paciente se cuenta una vez con la categoría más alta de sus mastografías en el periodo.');
|
||||
expect(pacientes.getAttribute('aria-describedby')).toBe(ayuda()?.id);
|
||||
expect(mastografias.getAttribute('aria-expanded')).toBe('false');
|
||||
expect(root().querySelectorAll('[role=tooltip]')).toHaveLength(1);
|
||||
pacientes.click();
|
||||
fixture.detectChanges();
|
||||
expect(ayuda()).toBeNull();
|
||||
http.expectNone(r => r.url.endsWith('/metadatos'));
|
||||
});
|
||||
it('sin pacientes verificados dibuja la estructura y deja pendiente solo la cifra de pacientes', () => {
|
||||
abrir(examenes(LAB_E), pacientes(LAB_P, { version: '0.3.0' }));
|
||||
const filas = [...root().querySelectorAll('.published-values tbody tr')].map(tr => [...tr.children].map(c => c.textContent?.trim()));
|
||||
@@ -248,45 +279,3 @@ describe('Tarjeta pareada de CaMa en la página', () => {
|
||||
expect(pedidos().length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Cómo leer de conteos pareados: reintento tras un fallo', () => {
|
||||
it('vuelve a pedir los metadatos después de un fallo, sin duplicar la consulta abierta ni la ya recibida', () => {
|
||||
TestBed.overrideComponent(IndicadorConteosPareados, { remove: { imports: [PlotlyChart] }, add: { imports: [ChartStub] } });
|
||||
TestBed.configureTestingModule({ imports: [IndicadorCatalogCard], providers: [provideHttpClient(), provideHttpClientTesting()] });
|
||||
const fixture = TestBed.createComponent(IndicadorCatalogCard);
|
||||
const http = TestBed.inject(HttpTestingController);
|
||||
fixture.componentRef.setInput('dominio', 'cama');
|
||||
fixture.componentRef.setInput('indicador', {
|
||||
id: 'cama_birads_456_mastografia', titulo: 'Porcentaje individual de mastografías', contrato: 'C2',
|
||||
figuras: ['fig_c2_donas', 'fig_c2_barras'], tipos_periodo: ['semestre', 'mes'],
|
||||
});
|
||||
fixture.componentRef.setInput('tema', 'claro');
|
||||
fixture.componentRef.setInput('applied', { tipo: 'semestre', selection: { mode: 'explicit', periodos: ['2025-S2'] }, revision: 0 });
|
||||
fixture.detectChanges();
|
||||
fixture.componentInstance.setVisible(true);
|
||||
fixture.detectChanges();
|
||||
const conteos = fixture.debugElement.query(By.directive(IndicadorConteosPareados)).componentInstance as IndicadorConteosPareados;
|
||||
const meta = () => http.match(r => r.url.endsWith('/metadatos'));
|
||||
conteos.showHelp();
|
||||
fixture.detectChanges();
|
||||
const primero = meta();
|
||||
expect(primero).toHaveLength(1);
|
||||
conteos.showHelp();
|
||||
fixture.detectChanges();
|
||||
expect(meta()).toHaveLength(0);
|
||||
primero[0].flush('no', { status: 500, statusText: 'Error' });
|
||||
fixture.detectChanges();
|
||||
conteos.showHelp();
|
||||
fixture.detectChanges();
|
||||
const segundo = meta();
|
||||
expect(segundo).toHaveLength(1);
|
||||
segundo[0].flush({ descripcion: 'Lectura de la dona' });
|
||||
fixture.detectChanges();
|
||||
conteos.showHelp();
|
||||
fixture.detectChanges();
|
||||
expect(meta()).toHaveLength(0);
|
||||
fixture.destroy();
|
||||
http.match(() => true);
|
||||
http.verify();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -183,7 +183,7 @@ export function donaPacientes(m: ModeloConteos, par: ParConteos, tema: Tema, anc
|
||||
/** Per BI-RADS family: patients (in their most severe category) next to exams. No ratio between them is drawn. */
|
||||
export function barrasConteos(m: ModeloConteos, par: ParConteos, tema: Tema): PlotlyFigure {
|
||||
const p = c2Theme(tema), y = m.filas.map(f => escapar(f.etiqueta));
|
||||
const nombres = { pacientes: `${par.unidades.pacientes} (su categoría más grave)`, examenes: par.unidades.examenes };
|
||||
const nombres = { pacientes: `${par.unidades.pacientes} (su categoría más alta)`, examenes: par.unidades.examenes };
|
||||
const textoDe = (v: number | null, clave: 'pacientes' | 'examenes') =>
|
||||
v !== null ? miles(v) : clave === 'pacientes' && !m.pacientesVerificados ? 'Pendiente' : 'Sin dato';
|
||||
const traza = (clave: 'pacientes' | 'examenes', color: string) => ({
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Presentation labels for representations confirmed in the published catalog.
|
||||
// Exact IDs remain the option values and HTTP identities; never infer a type
|
||||
// from a prefix. Unknown options keep a neutral label in publication order.
|
||||
export const TITULO_MASTOGRAFIAS_CAMA = 'Porcentaje de mastografías con resultado en la clasificación de BI-RADS 4, 5 o 6';
|
||||
|
||||
const FIGURE_LABELS: Readonly<Record<string, string>> = {
|
||||
fig_c1_barras_alteracion: 'Barras por alteración',
|
||||
fig_c1_barras_apiladas_edad: 'Barras apiladas por grupo de edad',
|
||||
|
||||
@@ -254,7 +254,7 @@ describe('Histopatología por BI-RADS: componente', () => {
|
||||
.toEqual(['No maligno', 'Maligno']);
|
||||
expect(f.nativeElement.querySelector('.tabs button[aria-selected=true]')!.textContent!.trim()).toBe('Maligno');
|
||||
expect([...f.nativeElement.querySelectorAll('.tab-panel button')].map((b: Element) => b.textContent!.trim()))
|
||||
.toEqual(['Carcinoma in situ', 'Carcinoma invasor']);
|
||||
.toEqual(['Benigno', 'Lesión de riesgo (B3)', 'Carcinoma in situ', 'Carcinoma invasor']);
|
||||
const grafica = f.nativeElement.querySelector('.figures') as HTMLElement;
|
||||
const leyenda = f.nativeElement.querySelector('.legend') as HTMLElement;
|
||||
const contexto = f.nativeElement.querySelector('.view-context') as HTMLElement;
|
||||
|
||||
@@ -79,11 +79,15 @@ describe('Histórico de CaMa', () => {
|
||||
expect([...ids].sort()).toEqual(PUBLICADOS.map(i => i.id).sort());
|
||||
expect(vistos.some(u => u.includes('cama_biopsias'))).toBe(false);
|
||||
});
|
||||
it('dibuja los ocho paneles en el orden del mockup: cinco con gráfica y tres pendientes por falta de indicador', () => {
|
||||
it('dibuja siete paneles en orden, cinco con gráfica y dos pendientes', () => {
|
||||
montar(CATALOGO, true); responder();
|
||||
expect(paneles().map(p => p.querySelector('h2')?.textContent)).toEqual(HISTORICO_CAMA.map(e => e.titulo));
|
||||
const pendientes = paneles().filter(p => p.textContent!.includes('Integración pendiente')).map(p => p.querySelector('h2')!.textContent);
|
||||
expect(pendientes).toEqual(['Resultado histopatológico', 'Días del resultado de la mastografía al diagnóstico', 'Tasa de detección histopatológica']);
|
||||
expect(pendientes).toEqual(['Resultado histopatológico', 'Días del resultado de la mastografía al diagnóstico']);
|
||||
expect(paneles()).toHaveLength(7);
|
||||
const titulo = 'Porcentaje de mastografías con resultado en la clasificación de BI-RADS 4, 5 o 6';
|
||||
expect(paneles()[2].querySelector('h2')?.textContent).toBe(titulo);
|
||||
expect(graficas().some(g => g.label?.startsWith('Histórico de ' + titulo))).toBe(true);
|
||||
expect(graficas()).toHaveLength(5);
|
||||
expect(paneles().filter(p => p.textContent!.includes('Integración pendiente') && p.querySelector('app-plotly-chart')).length).toBe(0);
|
||||
});
|
||||
|
||||
@@ -87,7 +87,7 @@ describe('Histórico: C2 (conteos por categoría)', () => {
|
||||
expect((r.figure as unknown as Fig).layout['yaxis']).toMatchObject({ title: { text: 'Mastografías' } });
|
||||
expect(r.comoLeer).toContain('mastografías');
|
||||
});
|
||||
it('Pacientes evaluadas con BI-RADS 4, 5 y 6 conserva la gráfica y omite la explicación de la barra', () => {
|
||||
it('Pacientes evaluadas con BI-RADS 4, 5 o 6 conserva la gráfica y omite la explicación de la barra', () => {
|
||||
const pacientes = figura(d(completo, { id: 'cama_birads_456_paciente' }));
|
||||
expect(pacientes.comoLeer).toBe('');
|
||||
expect((pacientes.figure as unknown as Fig).data.map(t => t['name'])).toEqual(['BI-RADS 5', 'BI-RADS 4 (sin subcategoría)', 'Sin dato']);
|
||||
|
||||
@@ -14,12 +14,9 @@ const record = (v: unknown): v is Record<string, unknown> => !!v && typeof v ===
|
||||
const escape = (v: string) => v.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||
// The EEG indicators avoid green; their colours are shared with their age groups' palette.
|
||||
const LINEAS: Readonly<Record<string, string>> = { M21_diagnosticados_con_eeg: C2_PALETTE.edades[0], M22_diagnosticados_sin_eeg: C2_PALETTE.edades[2] };
|
||||
// CaMa's day-count lines sit next to the histopathology bars, so they borrow that figure's blue, purple and rose.
|
||||
const DIAS: Readonly<Record<string, { claro: string; oscuro: string; relleno: string }>> = {
|
||||
cama_dias_toma_diagnostico: { claro: '#2F6DB3', oscuro: '#9DBFE3', relleno: '#9DBFE380' },
|
||||
cama_eu38a: { claro: '#9C42C2', oscuro: '#D2A4EA', relleno: '#9C42C240' },
|
||||
cama_dias_resultado_diagnostico: { claro: '#C24269', oscuro: '#E7A3B8', relleno: '#C2426940' },
|
||||
};
|
||||
// CaMa's lines share one purple; the quartile or confidence band, when there is one, is the same blue.
|
||||
const MORADO = { claro: '#9C42C2', oscuro: '#D2A4EA' } as const;
|
||||
const FONDO_AZUL = '#9DBFE380';
|
||||
const numero = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v);
|
||||
// sortedPeriods lists the newest first, for selectors; time here runs left to right.
|
||||
export const cronologico = (periodos: readonly string[]) => sortedPeriods(periodos).reverse();
|
||||
@@ -92,17 +89,24 @@ function serie(data: IndicadorDatos, periodos: string[], valor: (row: Record<str
|
||||
return { validas, suprimidos, sinDato };
|
||||
}
|
||||
const campo = (filas: (Record<string, unknown> | null)[], key: string) => filas.map(row => numero(row?.[key]) ? row![key] as number : null);
|
||||
// CaMa's line charts share the purple mark. A band, when the series has one, is blue; a line alone stays purple.
|
||||
function colorDeLinea(id: string, tema: Tema) {
|
||||
if (LINEAS[id]) return { linea: LINEAS[id], relleno: LINEAS[id] + '40' };
|
||||
if (id.startsWith('cama_')) return { linea: MORADO[tema], relleno: FONDO_AZUL };
|
||||
const linea = c2Theme(tema).line;
|
||||
return { linea, relleno: linea + '40' };
|
||||
}
|
||||
|
||||
type Trazo = Omit<HistoricoFigura, 'contrato'>;
|
||||
function porcentaje(data: IndicadorDatos, tema: Tema): Trazo {
|
||||
const periodos = validar(data);
|
||||
// A rate over no denominator is no value; the contract's own rule for it is not reinterpreted here.
|
||||
const { validas, suprimidos, sinDato } = serie(data, periodos, row => numero(row['valor']) && numero(row['denominador']) && row['denominador'] > 0);
|
||||
const layout = ejes(data, periodos, suprimidos, tema, 'Porcentaje'), linea = LINEAS[data.id] ?? c2Theme(tema).line;
|
||||
const layout = ejes(data, periodos, suprimidos, tema, 'Porcentaje'), trazo = colorDeLinea(data.id, tema);
|
||||
return {
|
||||
figure: { data: [
|
||||
banda(periodos.map(etiquetaPeriodo), campo(validas, 'ic_bajo'), campo(validas, 'ic_alto'), 'Intervalo de confianza', linea),
|
||||
{ type: 'scatter', mode: 'lines+markers', name: 'Porcentaje', x: periodos.map(etiquetaPeriodo), y: campo(validas, 'valor'), connectgaps: false, line: { color: linea, width: 2 },
|
||||
banda(periodos.map(etiquetaPeriodo), campo(validas, 'ic_bajo'), campo(validas, 'ic_alto'), 'Intervalo de confianza', trazo.linea, trazo.relleno),
|
||||
{ type: 'scatter', mode: 'lines+markers', name: 'Porcentaje', x: periodos.map(etiquetaPeriodo), y: campo(validas, 'valor'), connectgaps: false, line: { color: trazo.linea, width: 2 }, marker: { color: trazo.linea },
|
||||
text: validas.map(row => row ? `${row['valor']} %<br>${row['numerador']} de ${row['denominador']}<br>IC ${row['ic_bajo']} a ${row['ic_alto']} %` : ''),
|
||||
hovertemplate: '%{x}<br>%{text}<extra></extra>' },
|
||||
], layout: { ...layout, yaxis: { ...layout.yaxis, range: [0, 100], ticksuffix: ' %' } } },
|
||||
@@ -113,13 +117,11 @@ function porcentaje(data: IndicadorDatos, tema: Tema): Trazo {
|
||||
function mediana(data: IndicadorDatos, tema: Tema, opciones: HistoricoOpciones): Trazo {
|
||||
const periodos = validar(data), unidad = unidadDe(data);
|
||||
const { validas, suprimidos, sinDato } = serie(data, periodos, row => numero(row['mediana']) && numero(row['n']) && row['n'] > 0);
|
||||
const propio = DIAS[data.id];
|
||||
const linea = propio ? (tema === 'oscuro' ? propio.oscuro : propio.claro) : c2Theme(tema).line;
|
||||
const relleno = propio && tema === 'claro' ? propio.relleno : linea + '40';
|
||||
const trazo = colorDeLinea(data.id, tema);
|
||||
return {
|
||||
figure: { data: [
|
||||
banda(periodos.map(etiquetaPeriodo), campo(validas, 'q1'), campo(validas, 'q3'), 'Primer a tercer cuartil', linea, relleno),
|
||||
{ type: 'scatter', mode: 'lines+markers', name: 'Mediana', x: periodos.map(etiquetaPeriodo), y: campo(validas, 'mediana'), connectgaps: false, line: { color: linea, width: 2 }, marker: { color: linea },
|
||||
banda(periodos.map(etiquetaPeriodo), campo(validas, 'q1'), campo(validas, 'q3'), 'Primer a tercer cuartil', trazo.linea, trazo.relleno),
|
||||
{ type: 'scatter', mode: 'lines+markers', name: 'Mediana', x: periodos.map(etiquetaPeriodo), y: campo(validas, 'mediana'), connectgaps: false, line: { color: trazo.linea, width: 2 }, marker: { color: trazo.linea },
|
||||
text: validas.map(row => row ? `Mediana: ${row['mediana']} días<br>Q1 a Q3: ${row['q1']} a ${row['q3']} días<br>${row['n']} ${unidad.plural}` : ''),
|
||||
hovertemplate: '%{x}<br>%{text}<extra></extra>' },
|
||||
], layout: (() => {
|
||||
|
||||
@@ -63,15 +63,19 @@ describe('Figuras de histórico', () => {
|
||||
expect(traza(data, 0).y).toEqual([30, 10]);
|
||||
expect(sinDato).toEqual(['feb 2024']); expect(suprimidos).toEqual([]);
|
||||
});
|
||||
it('las líneas de días de CaMa usan el azul, el morado y el rosa de la histopatología', () => {
|
||||
const color = (id: string, tema: 'claro' | 'oscuro') => {
|
||||
it('las líneas de CaMa comparten el morado y, si hay banda, el fondo azul', () => {
|
||||
const dias = (id: string, tema: 'claro' | 'oscuro') => {
|
||||
const figure = historicoFigura({ ...base, id, contrato: 'C3r', filas: [{ periodo: '2024-01', suprimido: 0, n: 9, mediana: 20, q1: 10, q3: 30 }] }, tema).figure;
|
||||
return { linea: (figure.data[1]['line'] as { color: string }).color, banda: figure.data[0]['fillcolor'] };
|
||||
return { linea: (figure.data[1]['line'] as { color: string }).color, puntos: (figure.data[1]['marker'] as { color: string }).color, banda: figure.data[0]['fillcolor'] };
|
||||
};
|
||||
expect(color('cama_dias_toma_diagnostico', 'claro')).toEqual({ linea: '#2F6DB3', banda: '#9DBFE380' });
|
||||
expect(color('cama_eu38a', 'claro')).toEqual({ linea: '#9C42C2', banda: '#9C42C240' });
|
||||
expect(color('cama_dias_resultado_diagnostico', 'claro')).toEqual({ linea: '#C24269', banda: '#C2426940' });
|
||||
expect(color('cama_dias_toma_diagnostico', 'oscuro').linea).toBe('#9DBFE3');
|
||||
for (const id of ['cama_dias_toma_diagnostico', 'cama_eu38a', 'cama_dias_resultado_diagnostico']) {
|
||||
expect(dias(id, 'claro')).toEqual({ linea: '#9C42C2', puntos: '#9C42C2', banda: '#9DBFE380' });
|
||||
}
|
||||
expect(dias('cama_dias_toma_diagnostico', 'oscuro')).toEqual({ linea: '#D2A4EA', puntos: '#D2A4EA', banda: '#9DBFE380' });
|
||||
const tasa = historicoFigura({ ...base, id: 'cama_confirmacion_birads45', contrato: 'C1', filas: base.periodos.map(p => c1(p, 50)) }, 'claro').figure;
|
||||
expect((tasa.data[1]['line'] as { color: string }).color).toBe('#9C42C2');
|
||||
expect((tasa.data[1]['marker'] as { color: string }).color).toBe('#9C42C2');
|
||||
expect(tasa.data[0]['fillcolor']).toBe('#9DBFE380');
|
||||
});
|
||||
it('las líneas usan el verde legible en cada tema', () => {
|
||||
const data: IndicadorDatos = { ...base, contrato: 'C1', filas: base.periodos.map(p => c1(p, 50)) };
|
||||
|
||||
@@ -14,6 +14,7 @@ import { IndicadoresHistoricoPeriodos, PeriodosDialogoDatos } from './indicadore
|
||||
import { IndicadoresPeriodos } from './indicadores-periodos';
|
||||
import { Dominio, Indicador, IndicadorDatos, Tema, TipoPeriodo } from './indicadores.models';
|
||||
import { IndicadoresService } from './indicadores.service';
|
||||
import { TITULO_MASTOGRAFIAS_CAMA } from './indicadores-figure-labels';
|
||||
|
||||
const unidad = (tipo: TipoPeriodo, n: number) => tipo === 'mes' ? (n === 1 ? 'mes' : 'meses') : (n === 1 ? 'semestre' : 'semestres');
|
||||
type Carga = { estado: 'listo'; datos: IndicadorDatos } | { estado: 'vacio' } | { estado: 'error'; mensaje: string };
|
||||
@@ -27,13 +28,12 @@ const PERSONALIZADO = -1;
|
||||
// publish is drawn as a pending panel instead of being left out, so what is missing stays visible.
|
||||
export const HISTORICO_CAMA: readonly { id: string; titulo: string }[] = [
|
||||
{ id: 'cama_histopatologia_birads', titulo: 'Resultado histopatológico' },
|
||||
{ id: 'cama_birads_456_paciente', titulo: 'Pacientes evaluadas con BI-RADS 4, 5 y 6' },
|
||||
{ id: 'cama_birads_456_mastografia', titulo: 'Porcentaje individual de mastografías con resultado en la clasificación de BI-RADS 4, 5 y 6' },
|
||||
{ id: 'cama_birads_456_paciente', titulo: 'Pacientes evaluadas con BI-RADS 4, 5 o 6' },
|
||||
{ id: 'cama_birads_456_mastografia', titulo: TITULO_MASTOGRAFIAS_CAMA },
|
||||
{ id: 'cama_confirmacion_birads45', titulo: 'Tasa de confirmación histopatológica' },
|
||||
{ id: 'cama_dias_toma_diagnostico', titulo: 'Días de tamizaje a diagnóstico' },
|
||||
{ id: 'cama_eu38a', titulo: 'Días de la toma de la mastografía a su resultado' },
|
||||
{ id: 'cama_dias_resultado_diagnostico', titulo: 'Días del resultado de la mastografía al diagnóstico' },
|
||||
{ id: 'cama_tasa_deteccion_histopatologica', titulo: 'Tasa de detección histopatológica' },
|
||||
];
|
||||
|
||||
// The screening steps go together as small charts, and the case counts are followed by their in-process share.
|
||||
@@ -62,7 +62,7 @@ function agrupar(paneles: (Panel & { datos?: IndicadorDatos })[], tema: Tema): P
|
||||
selector: 'app-indicadores-historico',
|
||||
imports: [MatButtonModule, MatButtonToggleModule, MatFormFieldModule, MatProgressBarModule, MatSelectModule, PlotlyChart],
|
||||
template: `
|
||||
<div class="controles">
|
||||
<div class="controles" [class.compacto]="dominio() === 'cama'">
|
||||
<h2>Filtros</h2>
|
||||
<div class="controles-fila">
|
||||
<div class="interval">
|
||||
@@ -127,12 +127,25 @@ function agrupar(paneles: (Panel & { datos?: IndicadorDatos })[], tema: Tema): P
|
||||
</div>
|
||||
`,
|
||||
styles: `
|
||||
@use '@angular/material' as mat;
|
||||
|
||||
:host { display: block; min-width: 0; }
|
||||
.controles { display: flex; flex-direction: column; align-items: stretch; gap: var(--issste-space-3); margin-bottom: var(--issste-space-6); padding: var(--issste-space-3) var(--issste-space-6);
|
||||
background: var(--issste-surface); color: var(--issste-text); border: 1px solid var(--issste-border); border-radius: var(--issste-radius); }
|
||||
.controles h2 { margin: 0; font-family: var(--issste-font-heading); font-size: 1rem; font-weight: 500; line-height: 1.3; }
|
||||
// Same field height as the summary filters. The theme also rewrites corners, which would turn the switch into a pill.
|
||||
.controles.compacto {
|
||||
@include mat.theme((density: -4));
|
||||
--mat-sys-corner-extra-small: 2px;
|
||||
--mat-sys-corner-small: 2px;
|
||||
--mat-sys-corner-medium: 4px;
|
||||
--mat-sys-corner-large: 4px;
|
||||
--mat-sys-corner-extra-large: 6px;
|
||||
--mat-sys-corner-full: 4px;
|
||||
}
|
||||
.controles-fila { display: flex; flex-wrap: wrap; align-items: end; gap: var(--issste-space-3); }
|
||||
.interval { display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; }
|
||||
.interval mat-button-toggle-group { --mat-button-toggle-height: 40px; --mat-button-toggle-shape: 6px; }
|
||||
.field-label { color: var(--issste-text-secondary); font-size: .75rem; line-height: 1.2; }
|
||||
.paneles { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--issste-space-6); }
|
||||
@container dashboard (min-width: 1304px) { .paneles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
||||
@@ -150,7 +163,7 @@ function agrupar(paneles: (Panel & { datos?: IndicadorDatos })[], tema: Tema): P
|
||||
.pasos { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--issste-space-4); margin-top: var(--issste-space-3); }
|
||||
@container dashboard (min-width: 960px) { .pasos { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
|
||||
h3 { margin: 0; font: var(--mat-sys-title-small); }
|
||||
mat-form-field { flex: 0 1 14rem; width: 14rem; min-width: 14rem; max-width: 24rem; }
|
||||
mat-form-field { flex: 0 1 14rem; min-width: 0; max-width: 24rem; }
|
||||
`,
|
||||
})
|
||||
export class IndicadoresHistorico {
|
||||
|
||||
@@ -47,7 +47,7 @@ describe.each(['cacu', 'cama'] as const)('P0 búsqueda del ancla C2 de %s', doma
|
||||
it('conserva los identificadores y la población vigente del ancla, sin recuperar el ancla histórica', () => {
|
||||
if (domain === 'cama') {
|
||||
expect(anchor.id).toBe('cama_birads_456_paciente');
|
||||
expect(anchor.title).toBe('Pacientes evaluadas con BI-RADS 4, 5 y 6');
|
||||
expect(anchor.title).toBe('Pacientes evaluadas con BI-RADS 4, 5 o 6');
|
||||
expect(KPI_BY_DOMAIN.cama.map(d => d.id)).toEqual(['cama_birads_456_paciente', 'cama_eu38a']);
|
||||
} else expect(anchor.id).toBe('cacu_eu7');
|
||||
const run = start(); inventory(); request(periods[0]).flush(data(periods[0]));
|
||||
|
||||
@@ -14,7 +14,7 @@ export const CACU_RESULTADO_KPI: KpiDefinition = {
|
||||
id: 'cacu_eu_tiempo_reporte', title: 'Días de toma a resultado', contrato: 'C3r', unit: 'días (mediana)', singleAppliedPeriod: true,
|
||||
};
|
||||
export const CAMA_TAMIZAJE_RESULTADO_KPI: KpiDefinition = {
|
||||
id: 'cama_eu38a', title: 'Tiempo de mastografía a resultado', contrato: 'C3r', unit: 'días (mediana)', requiresObservations: true,
|
||||
id: 'cama_eu38a', title: 'Tiempo de toma de mastografía a interpretación radiológica', contrato: 'C3r', unit: 'días (mediana)', requiresObservations: true,
|
||||
};
|
||||
// Institutional definitions retained for consumers outside the opportunity strip.
|
||||
export const CAMA_CONFIRMACION_KPI: KpiDefinition = {
|
||||
@@ -25,10 +25,10 @@ export const CAMA_TOMA_DIAGNOSTICO_KPI: KpiDefinition = {
|
||||
};
|
||||
export const CAMA_TASA_DETECCION_KPI: KpiDefinition = {
|
||||
id: 'cama_tasa_deteccion_histopatologica', title: 'Tasa de confirmación histopatológica', contrato: 'C1', unit: '%',
|
||||
c1Info: (n, d) => `${n} de ${d} biopsias con resultado maligno.`,
|
||||
c1Info: (n, d) => `${n} de ${d} biopsias con riesgo a carcinoma.`,
|
||||
};
|
||||
export const CAMA_RESULTADO_DIAGNOSTICO_KPI: KpiDefinition = {
|
||||
id: 'cama_dias_resultado_diagnostico', title: 'Tiempo de resultado a diagnóstico', contrato: 'C3r', unit: 'días (mediana)', requiresObservations: true,
|
||||
id: 'cama_dias_resultado_diagnostico', title: 'Tiempo de interpretación radiológica a diagnóstico', contrato: 'C3r', unit: 'días (mediana)', requiresObservations: true,
|
||||
};
|
||||
// Provisional (oct 2026): titles are copied by hand from the `title` of each indicator's TOML
|
||||
// in indicadores_kit, except the C2 patient counts, whose card shows the sum of the categories
|
||||
@@ -58,7 +58,7 @@ export const KPI_BY_DOMAIN: Record<Dominio, KpiDefinition[]> = {
|
||||
{ id: 'cacu_dias_toma_diagnostico', title: 'Tiempo de tamizaje a diagnóstico', contrato: 'C3r', unit: 'días (mediana)' },
|
||||
],
|
||||
cama: [
|
||||
{ id: 'cama_birads_456_paciente', title: 'Pacientes evaluadas con BI-RADS 4, 5 y 6', contrato: 'C2', unit: 'pacientes' },
|
||||
{ id: 'cama_birads_456_paciente', title: 'Pacientes evaluadas con BI-RADS 4, 5 o 6', contrato: 'C2', unit: 'pacientes' },
|
||||
CAMA_TAMIZAJE_RESULTADO_KPI,
|
||||
],
|
||||
};
|
||||
|
||||
@@ -50,10 +50,13 @@
|
||||
@if (kpis.length && !initialPeriodBlocked) {
|
||||
<section class="kpi-section" aria-labelledby="kpi-section-title" [attr.data-domain]="dominio">
|
||||
@let resumen = teaResumenPeriodo;
|
||||
<h2 id="kpi-section-title" class="section-title">{{ dominio === 'cacu' || dominio === 'cama' ? 'Indicadores de oportunidad' : resumen ? 'Resumen' : 'Indicadores destacados' }}</h2>
|
||||
<div class="kpi-heading">
|
||||
<h2 id="kpi-section-title" class="section-title">{{ dominio === 'cacu' || dominio === 'cama' ? 'Indicadores de oportunidad' : resumen ? 'Resumen' : 'Indicadores destacados' }}</h2>
|
||||
@if (periodoCompartido) { <p class="kpi-period">Periodo {{ periodoCompartido }}</p> }
|
||||
</div>
|
||||
@if (resumen) { <app-tea-resumen-periodo [periodo]="resumen" [paneles]="kpiPanels()" /> }
|
||||
<!-- With the summary the panels keep loading the data, but their cards are not shown. -->
|
||||
<div class="kpi-grid" [class.kpi-grid-oculto]="resumen" [style.--kpi-count]="kpis.length + (dominio === 'cacu' ? 2 : 0)">
|
||||
<div class="kpi-grid" [class.kpi-grid-oculto]="resumen" [style.--kpi-count]="kpis.length + (dominio === 'cacu' ? 2 : dominio === 'cama' ? 1 : 0)">
|
||||
@for (card of kpis; track dominio + ':' + card.definition.id) {
|
||||
@if (card.pending) {
|
||||
<app-indicador-kpi-card [title]="card.definition.title" state="Integración pendiente"
|
||||
@@ -66,6 +69,9 @@
|
||||
@if (dominio === 'cacu') {
|
||||
<app-indicador-kpi-card title="Tiempo de tamizaje a tratamiento" state="Indicador no disponible" />
|
||||
<app-indicador-kpi-card title="Tiempo de diagnóstico a tratamiento" state="Indicador no disponible" />
|
||||
} @else if (dominio === 'cama') {
|
||||
<app-indicador-kpi-card title="Tiempo de diagnóstico a tratamiento" state="Indicador no disponible"
|
||||
additionalInfo="Este indicador aún no está publicado por el catálogo institucional." />
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -13,10 +13,12 @@ header p { color: var(--mat-sys-on-surface-variant); margin-bottom: 1.5rem; }
|
||||
.global-filters[data-domain='cama'] .section-title { font-size: 1rem; margin-bottom: var(--issste-space-3); }
|
||||
.section-title { font-family: var(--issste-font-heading); font-size: 1.25rem; font-weight: 500; line-height: 1.3; margin: 0; overflow-wrap: anywhere; }
|
||||
.section-description { color: var(--issste-text-secondary); margin: var(--issste-space-2) 0 var(--issste-space-4); overflow-wrap: anywhere; }
|
||||
.kpi-section, .graphic-section { box-sizing: border-box; min-width: 0; margin-inline: calc(var(--space-4) * -1);
|
||||
.kpi-section, .graphic-section { box-sizing: border-box; min-width: 0; margin-inline: var(--space-2);
|
||||
padding: var(--issste-space-4) var(--issste-space-5) var(--issste-space-6); border: 1px solid var(--issste-border);
|
||||
border-radius: var(--issste-radius); background: color-mix(in srgb, var(--issste-border) 42%, var(--issste-background)); }
|
||||
.kpi-section > .section-title { margin-bottom: var(--issste-space-4); }
|
||||
border-radius: var(--issste-radius); background: var(--issste-surface); }
|
||||
.kpi-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--issste-space-3); }
|
||||
.kpi-section > .kpi-heading { margin-bottom: var(--issste-space-4); }
|
||||
.kpi-period { margin: .15rem 0 0; color: var(--issste-text-secondary); font-size: .75rem; line-height: 1.35; white-space: nowrap; }
|
||||
.graphic-section { margin-top: var(--issste-space-6); }
|
||||
.kpi-grid, .catalog-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--issste-space-6); }
|
||||
.kpi-section .kpi-grid.kpi-grid-oculto { display: none; }
|
||||
@@ -41,11 +43,8 @@ header p { color: var(--mat-sys-on-surface-variant); margin-bottom: 1.5rem; }
|
||||
|
||||
@container dashboard (min-width: 1000px) { .kpi-grid { grid-template-columns: repeat(min(3, var(--kpi-count)), minmax(0, 1fr)); } }
|
||||
|
||||
// Five opportunity cards: at least ~280px per card; retain existing TEA/CaMa grids.
|
||||
// CaMa's opportunity cards: one size, four in a row on wide screens and two by two below.
|
||||
.kpi-section[data-domain='cama'] .kpi-grid { grid-auto-rows: 1fr; }
|
||||
@container dashboard (min-width: 600px) { .kpi-section[data-domain='cama'] .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
||||
@container dashboard (min-width: 1100px) { .kpi-section[data-domain='cama'] .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
|
||||
@container dashboard (min-width: 1350px) { .kpi-section[data-domain='cama'] .kpi-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
|
||||
.kpi-section[data-domain='cacu'] .kpi-grid {
|
||||
grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
|
||||
align-items: stretch;
|
||||
|
||||
@@ -32,6 +32,7 @@ import { SeleccionSeguimiento } from './indicadores-seguimiento-tabla';
|
||||
import { IndicadoresAnalisis, SeleccionPacientes } from './indicadores-analisis';
|
||||
import { IndicadoresHistorico } from './indicadores-historico';
|
||||
import { IndicadorHistopatologiaPendiente } from './indicador-histopatologia-pendiente';
|
||||
import { TITULO_MASTOGRAFIAS_CAMA } from './indicadores-figure-labels';
|
||||
|
||||
type DashboardSection = 'resumen' | 'historico' | 'analisis' | 'seguimiento' | 'datos';
|
||||
const SECTIONS: readonly { id: DashboardSection; label: string }[] = [
|
||||
@@ -101,6 +102,15 @@ export class IndicadoresPage {
|
||||
private readonly indicatorSelect = viewChild<MatSelect>('indicatorSelect');
|
||||
private readonly graphicCards = viewChildren(IndicadorCatalogCard);
|
||||
readonly kpiPanels = viewChildren(IndicadorKpiPanel);
|
||||
// The opportunity cards share the period their own query already resolved.
|
||||
get periodoCompartido(): string {
|
||||
if (this.dominio !== 'cama') return '';
|
||||
const deConsulta = this.kpiPanels().map(panel => panel.temporalReference.trim())
|
||||
.find(text => /^\d{4}-(?:S[12]|0[1-9]|1[0-2])$/.test(text));
|
||||
if (deConsulta) return deConsulta;
|
||||
const applied = this.filters?.applied;
|
||||
return applied?.selection.mode === 'explicit' && applied.selection.periodos.length === 1 ? applied.selection.periodos[0] : '';
|
||||
}
|
||||
private readonly observedRegions = new Map<Element, IndicadorCatalogCard>();
|
||||
private renderedCards: readonly IndicadorCatalogCard[] = [];
|
||||
private visibilityObserver?: IntersectionObserver;
|
||||
@@ -483,7 +493,8 @@ export class IndicadoresPage {
|
||||
}), takeUntilDestroyed(this.destroyRef)).subscribe(({ items, error }) => {
|
||||
this.catalogLoading.set(false);
|
||||
this.filters = items.length ? this.memory.restoreGlobal(this.dominio, domainTypes(items)) : undefined;
|
||||
this.catalog.set(items);
|
||||
this.catalog.set(this.dominio === 'cama' ? items.map(item => item.id === 'cama_birads_456_mastografia'
|
||||
? { ...item, titulo: TITULO_MASTOGRAFIAS_CAMA } : item) : items);
|
||||
this.filtersEdited();
|
||||
this.catalogError.set(error);
|
||||
this.availabilityRequests.next();
|
||||
|
||||
@@ -142,6 +142,23 @@ describe('UX-04 validación defensiva HTTP', () => {
|
||||
|
||||
describe('contrato datos exclusivo de KPI', () => {
|
||||
beforeEach(() => TestBed.configureTestingModule({ providers: [provideHttpClient(), provideHttpClientTesting()] }));
|
||||
it('conserva los conteos, totales y celdas suprimidas que publica WebApi para mastografías de CaMa', () => {
|
||||
const http = TestBed.inject(HttpTestingController);
|
||||
const payload = {
|
||||
id: 'cama_birads_456_mastografia', contrato: 'C2', tipo_periodo: 'semestre', periodos: ['2025-S1', '2025-S2'],
|
||||
filas: [
|
||||
{ periodo: '2025-S1', categoria: 'BIRADS_4', n: 15, suprimido: 0 },
|
||||
{ periodo: '2025-S1', categoria: 'BIRADS_5', n: 0, suprimido: 0 },
|
||||
{ periodo: '2025-S2', categoria: 'BIRADS_4', n: null, suprimido: 1 },
|
||||
],
|
||||
totales_estrato: [{ periodo: '2025-S1', estrato: 'BIRADS_4', n: 15, suprimido: 0 }],
|
||||
};
|
||||
let result: unknown;
|
||||
TestBed.inject(IndicadoresService).datos('cama', payload.id, 'semestre', payload.periodos).subscribe(value => result = value);
|
||||
http.expectOne(req => req.url === `/cama/indicadores/${payload.id}/datos`).flush(payload);
|
||||
expect(result).toEqual(payload);
|
||||
http.verify();
|
||||
});
|
||||
it('envía sólo periodos explícitos sin intervalo de tiempo ni tema y conserva filas y notas', () => {
|
||||
const http = TestBed.inject(HttpTestingController); let result: unknown;
|
||||
TestBed.inject(IndicadoresService).datos('cacu', 'cacu_eu7', 'mes', ['2025-01']).subscribe(v => result = v);
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
// Covers the histologic-type classification and its column in the follow-up table. It uses the CaMa follow-up
|
||||
// fixture (fixtures/cama_seguimiento.json), to which each test adds a synthetic `tipo_histologico` per row.
|
||||
import fixtureData from './fixtures/cama_seguimiento.json';
|
||||
import { clasificacionHistologica, MAPEO_HISTOLOGICO, SIN_CLASIFICAR } from './mapeo-histologico';
|
||||
import { seguimientoTablaResponse } from './seguimiento-tabla.service';
|
||||
|
||||
const respuesta = () => structuredClone(fixtureData) as unknown as { columnas: { clave: string; etiqueta: string }[]; items: Record<string, string | number | null>[] };
|
||||
|
||||
describe('Clasificación histológica', () => {
|
||||
it.each([
|
||||
['Ductal (NST)', 'Carcinoma invasor'], ['Lobulillar', 'Carcinoma invasor'], ['Ductal-lobulillar mixto', 'Carcinoma invasor'],
|
||||
['Mucinoso', 'Carcinoma invasor'], ['Paget', 'Carcinoma in situ'], ['Papilar', 'Revisar (Benigno / In situ / Invasor)'],
|
||||
['Tubular', 'Carcinoma invasor'], ['cribiforme', 'Revisar (In situ / Invasor)'], ['Micropapilar', 'Revisar (In situ / Invasor)'],
|
||||
['Inflamatorio', 'Carcinoma invasor'], ['Medular', 'Carcinoma invasor'], ['Otros', 'Revisar (Benigno / In situ / Invasor)'],
|
||||
['SIN MAPEAR', 'Sin clasificar'],
|
||||
])('asigna a «%s» la clasificación «%s»', (tipo, clasificacion) => {
|
||||
// Fails if a type is moved to another group or dropped from the mapping.
|
||||
expect(clasificacionHistologica(tipo)).toBe(clasificacion);
|
||||
});
|
||||
it('la categoría combinada «Tubular / cribiforme» del gráfico es carcinoma invasor', () => {
|
||||
// Fails if the chart's merged category stops being classified, which would leave its patients unclassified.
|
||||
expect(clasificacionHistologica('Tubular / cribiforme')).toBe('Carcinoma invasor');
|
||||
});
|
||||
it('un tipo fuera del mapeo, incluido uno heredado del prototipo de objeto, es «Sin clasificar»', () => {
|
||||
// Fails if the lookup returns inherited properties such as «constructor» instead of the fallback.
|
||||
for (const tipo of ['Desconocido', '', 'constructor', 'toString']) expect(clasificacionHistologica(tipo)).toBe(SIN_CLASIFICAR);
|
||||
});
|
||||
it('el mapeo conserva sus trece tipos y sus cuatro clasificaciones directas', () => {
|
||||
// Fails if a type is added or removed without reviewing its classification.
|
||||
expect(Object.keys(MAPEO_HISTOLOGICO)).toHaveLength(14);
|
||||
expect(new Set(Object.values(MAPEO_HISTOLOGICO))).toEqual(new Set([
|
||||
'Carcinoma invasor', 'Carcinoma in situ', 'Revisar (Benigno / In situ / Invasor)', 'Revisar (In situ / Invasor)', 'Sin clasificar']));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Seguimiento: columna de clasificación histológica', () => {
|
||||
const tipos = ['Ductal (NST)', 'Paget', 'Otros', 'SIN MAPEAR', 'Zzz'];
|
||||
it('cada paciente recibe la clasificación de su propio tipo, en una columna tras el tipo o tras el resultado de la biopsia', () => {
|
||||
// Fails if the classification is computed from another row or placed away from the biopsy columns.
|
||||
const datos = respuesta();
|
||||
const conBiopsia = datos.items.filter(item => item['biopsia'] !== null);
|
||||
conBiopsia.forEach((item, i) => { item['tipo_histologico'] = tipos[i % tipos.length]; });
|
||||
const r = seguimientoTablaResponse(datos);
|
||||
const claves = r.columnas.map(c => c.clave);
|
||||
expect(claves[claves.indexOf('biopsia') + 1]).toBe('clasificacion_histologica');
|
||||
expect(r.columnas.find(c => c.clave === 'clasificacion_histologica')!.etiqueta).toBe('Clasificación histológica');
|
||||
for (const item of r.items.filter(item => typeof item['tipo_histologico'] === 'string')) {
|
||||
expect(item['clasificacion_histologica']).toBe(clasificacionHistologica(item['tipo_histologico'] as string));
|
||||
}
|
||||
});
|
||||
it('con una columna de tipo, la clasificación va justo después de ella', () => {
|
||||
// Fails if the derived column ignores the type's own column and lands elsewhere.
|
||||
const datos = respuesta();
|
||||
datos.columnas.splice(datos.columnas.findIndex(c => c.clave === 'biopsia') + 1, 0, { clave: 'tipo_histologico', etiqueta: 'Tipo histológico' });
|
||||
datos.items.forEach(item => { item['tipo_histologico'] = item['biopsia'] === null ? null : 'Lobulillar'; });
|
||||
const claves = seguimientoTablaResponse(datos).columnas.map(c => c.clave);
|
||||
expect(claves.slice(claves.indexOf('tipo_histologico'), claves.indexOf('tipo_histologico') + 2)).toEqual(['tipo_histologico', 'clasificacion_histologica']);
|
||||
});
|
||||
it('un paciente sin tipo no recibe clasificación y los demás campos quedan como llegaron', () => {
|
||||
// Fails if a patient without biopsy is shown as «Sin clasificar», or if other row values are altered.
|
||||
const datos = respuesta();
|
||||
datos.items.forEach((item, i) => { item['tipo_histologico'] = item['biopsia'] === null ? null : 'Medular'; });
|
||||
const original = structuredClone(datos.items);
|
||||
const r = seguimientoTablaResponse(datos);
|
||||
r.items.forEach((item, i) => {
|
||||
if (original[i]['tipo_histologico'] === null) expect('clasificacion_histologica' in item).toBe(false);
|
||||
expect({ ...item, clasificacion_histologica: undefined }).toEqual({ ...original[i], clasificacion_histologica: undefined });
|
||||
});
|
||||
});
|
||||
it('una lista sin tipo histológico no cambia', () => {
|
||||
// Fails if the column appears while the API does not send the field.
|
||||
const r = seguimientoTablaResponse(respuesta());
|
||||
expect(r.columnas.map(c => c.clave)).not.toContain('clasificacion_histologica');
|
||||
expect(r.items.some(item => 'clasificacion_histologica' in item)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
// Groups the histologic type of a biopsy into the classification shown beside it.
|
||||
export const SIN_CLASIFICAR = 'Sin clasificar';
|
||||
|
||||
export const MAPEO_HISTOLOGICO: Readonly<Record<string, string>> = {
|
||||
'Ductal (NST)': 'Carcinoma invasor',
|
||||
'Lobulillar': 'Carcinoma invasor',
|
||||
'Ductal-lobulillar mixto': 'Carcinoma invasor',
|
||||
'Mucinoso': 'Carcinoma invasor',
|
||||
'Paget': 'Carcinoma in situ',
|
||||
'Papilar': 'Revisar (Benigno / In situ / Invasor)',
|
||||
'Tubular': 'Carcinoma invasor',
|
||||
'Tubular / cribiforme': 'Carcinoma invasor',
|
||||
'cribiforme': 'Revisar (In situ / Invasor)',
|
||||
'Micropapilar': 'Revisar (In situ / Invasor)',
|
||||
'Inflamatorio': 'Carcinoma invasor',
|
||||
'Medular': 'Carcinoma invasor',
|
||||
'Otros': 'Revisar (Benigno / In situ / Invasor)',
|
||||
'SIN MAPEAR': SIN_CLASIFICAR,
|
||||
};
|
||||
|
||||
/** The classification of a histologic type; a type outside the mapping is «Sin clasificar». */
|
||||
export const clasificacionHistologica = (tipo: string) =>
|
||||
Object.hasOwn(MAPEO_HISTOLOGICO, tipo) ? MAPEO_HISTOLOGICO[tipo] : SIN_CLASIFICAR;
|
||||
@@ -4,6 +4,7 @@ import { map } from 'rxjs';
|
||||
import { isoDate } from './cacu-seguimiento.models';
|
||||
import { identidadesDe } from './paciente-identidad';
|
||||
import { etiquetaDeFiltro } from './etiquetas-cohorte';
|
||||
import { clasificacionHistologica } from './mapeo-histologico';
|
||||
import { Dominio, requireDominio } from './indicadores.models';
|
||||
|
||||
// A follow-up list whose filters and columns come with the answer, so the view needs no code of its own per
|
||||
@@ -96,10 +97,33 @@ export function seguimientoTablaResponse(v: unknown): SeguimientoTablaResponse {
|
||||
|| !v['items'].every(item => record(item) && Object.values(item).every(valor)) || !identidadesDe(v['items'] as Record<string, unknown>[])) {
|
||||
throw new SeguimientoInvalido('Respuesta de seguimiento inválida');
|
||||
}
|
||||
const respuesta = v as unknown as SeguimientoTablaResponse;
|
||||
const respuesta = clasificarHistologia(v as unknown as SeguimientoTablaResponse);
|
||||
return respuesta.cohorte ? etiquetarCohorte(respuesta) : respuesta;
|
||||
}
|
||||
|
||||
const TIPO_HISTOLOGICO = 'tipo_histologico';
|
||||
const CLASIFICACION_HISTOLOGICA = 'clasificacion_histologica';
|
||||
|
||||
/**
|
||||
* A list that carries the histologic type of each patient (`tipo_histologico`) also shows its classification, computed
|
||||
* from that same value in the same row, in a column placed after the type's (or after the biopsy result when the type
|
||||
* has no column). Rows without a type, and lists without the field, are left as received.
|
||||
*/
|
||||
export function clasificarHistologia(r: SeguimientoTablaResponse): SeguimientoTablaResponse {
|
||||
if (!r.items.some(item => typeof item[TIPO_HISTOLOGICO] === 'string') || r.columnas.some(c => c.clave === CLASIFICACION_HISTOLOGICA)) return r;
|
||||
const columnas = [...r.columnas];
|
||||
const despuesDe = [TIPO_HISTOLOGICO, 'biopsia'].map(k => columnas.findIndex(c => c.clave === k)).find(i => i >= 0) ?? columnas.length - 1;
|
||||
columnas.splice(despuesDe + 1, 0, { clave: CLASIFICACION_HISTOLOGICA, etiqueta: 'Clasificación histológica' });
|
||||
return {
|
||||
...r,
|
||||
columnas,
|
||||
items: r.items.map(item => {
|
||||
const tipo = item[TIPO_HISTOLOGICO];
|
||||
return typeof tipo === 'string' ? { ...item, [CLASIFICACION_HISTOLOGICA]: clasificacionHistologica(tipo) } : item;
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A cohort's list announces its filters with the code as the label and carries the codes as values. The answer is
|
||||
* rewritten once, here, so the table, the record and the files all show «BI-RADS 5» and «50 a 59 años»; the code stays
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<title>Análisis de información | ISSSTELEON</title>
|
||||
<base href="/" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico?v=3" />
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
--issste-space-2: var(--space-2);
|
||||
--issste-space-3: var(--space-3);
|
||||
--issste-space-4: var(--space-4);
|
||||
--issste-space-5: var(--space-5);
|
||||
--issste-space-6: var(--space-6);
|
||||
--issste-radius: var(--mat-sys-corner-medium);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user