Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| edd6e4b640 | |||
| 3674a43587 | |||
| 27bd4d4a65 | |||
| cbae29bc24 | |||
| 35b329e235 | |||
| 7f303d1160 | |||
| e2b307abf5 | |||
| 39974b8533 |
+19
-6
@@ -4,12 +4,25 @@
|
|||||||
<a class="brand" routerLink="/" aria-label="ISSSTELEON, inicio">
|
<a class="brand" routerLink="/" aria-label="ISSSTELEON, inicio">
|
||||||
<img src="assets/branding/isssteleon-logo.png" alt="ISSSTELEON" />
|
<img src="assets/branding/isssteleon-logo.png" alt="ISSSTELEON" />
|
||||||
</a>
|
</a>
|
||||||
<nav class="site-header__nav" aria-label="Secciones">
|
@if (activeDomain(); as domain) {
|
||||||
<a class="site-header__section" routerLink="/">Análisis de información</a>
|
<span class="platform-title">{{ title }}</span>
|
||||||
@if (breadcrumb(); as crumb) {
|
<button class="domain-selector" mat-button [matMenuTriggerFor]="domainMenu"
|
||||||
<span class="site-header__crumb" aria-current="page">› {{ crumb }}</span>
|
[attr.aria-label]="'Dominio actual: ' + domainLabels[domain] + '. Cambiar dominio'">
|
||||||
}
|
{{ domainLabels[domain] }} <span aria-hidden="true">▾</span>
|
||||||
</nav>
|
</button>
|
||||||
|
<mat-menu #domainMenu="matMenu" aria-label="Cambiar dominio de indicadores">
|
||||||
|
@for (option of otherDomains(); track option) {
|
||||||
|
<a mat-menu-item [routerLink]="['/indicadores', option]">{{ domainLabels[option] }}</a>
|
||||||
|
}
|
||||||
|
</mat-menu>
|
||||||
|
} @else {
|
||||||
|
<nav class="site-header__nav" aria-label="Secciones">
|
||||||
|
<a class="site-header__section" routerLink="/">Análisis de información</a>
|
||||||
|
@if (breadcrumb(); as crumb) {
|
||||||
|
<span class="site-header__crumb" aria-current="page">› {{ crumb }}</span>
|
||||||
|
}
|
||||||
|
</nav>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,31 @@
|
|||||||
width: clamp(180px, 16vw, 200px);
|
width: clamp(180px, 16vw, 200px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.platform-title {
|
||||||
|
color: var(--color-text);
|
||||||
|
font-family: var(--issste-font-heading);
|
||||||
|
font-size: 1.25rem;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1.15;
|
||||||
|
margin-inline-start: var(--issste-space-4);
|
||||||
|
margin-inline-end: auto;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
.domain-selector {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
background-color: var(--issste-accent);
|
||||||
|
color: var(--issste-text);
|
||||||
|
font-weight: 700;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.domain-selector:hover { background-color: var(--issste-accent); filter: brightness(.94); }
|
||||||
|
.domain-selector:focus-visible { outline: 2px solid var(--issste-text); outline-offset: 2px; }
|
||||||
|
|
||||||
|
@media (max-width: 599px) {
|
||||||
|
.platform-title { font-size: 1.125rem; min-width: 0; }
|
||||||
|
}
|
||||||
|
|
||||||
.site-header__nav {
|
.site-header__nav {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -30,6 +30,17 @@ describe('App', () => {
|
|||||||
expect(page.querySelector('.site-footer')).not.toBeNull();
|
expect(page.querySelector('.site-footer')).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('an indicators page shows the platform title and a menu named after its domain', async () => {
|
||||||
|
// Fails if the header stops naming the domain or offers the current one among the others.
|
||||||
|
const page = await render('/indicadores/cama');
|
||||||
|
expect(page.querySelector('.platform-title')?.textContent).toContain('Plataforma de Indicadores');
|
||||||
|
expect(page.querySelector('.domain-selector')?.textContent).toContain('Cáncer de mama');
|
||||||
|
(page.querySelector('.domain-selector') as HTMLButtonElement).click();
|
||||||
|
const options = Array.from(document.querySelectorAll('.mat-mdc-menu-panel a')).map(a => a.textContent?.trim());
|
||||||
|
expect(options).toEqual(['TEA', 'CaCu']);
|
||||||
|
expect(page.querySelector('.site-header__crumb')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
it('/conectar opens the full-height workspace (breadcrumb, no footer)', async () => {
|
it('/conectar opens the full-height workspace (breadcrumb, no footer)', async () => {
|
||||||
const page = await render('/conectar');
|
const page = await render('/conectar');
|
||||||
expect(page.querySelector('app-connect-page')).not.toBeNull();
|
expect(page.querySelector('app-connect-page')).not.toBeNull();
|
||||||
|
|||||||
+13
-1
@@ -1,10 +1,13 @@
|
|||||||
import { Component, computed, inject } from '@angular/core';
|
import { Component, computed, inject } from '@angular/core';
|
||||||
import { toSignal } from '@angular/core/rxjs-interop';
|
import { toSignal } from '@angular/core/rxjs-interop';
|
||||||
import { ActivatedRoute, NavigationEnd, Router, RouterLink, RouterOutlet } from '@angular/router';
|
import { ActivatedRoute, NavigationEnd, Router, RouterLink, RouterOutlet } from '@angular/router';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
import { MatMenuModule } from '@angular/material/menu';
|
||||||
import { filter, map } from 'rxjs';
|
import { filter, map } from 'rxjs';
|
||||||
|
import { Dominio, DOMINIOS } from './features/indicadores/indicadores.models';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
imports: [RouterLink, RouterOutlet],
|
imports: [RouterLink, RouterOutlet, MatButtonModule, MatMenuModule],
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
styleUrl: './app.scss',
|
styleUrl: './app.scss',
|
||||||
templateUrl: './app.html',
|
templateUrl: './app.html',
|
||||||
@@ -13,6 +16,15 @@ export class App {
|
|||||||
private readonly router = inject(Router);
|
private readonly router = inject(Router);
|
||||||
private readonly route = inject(ActivatedRoute);
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
|
||||||
|
protected readonly title = 'Plataforma de Indicadores';
|
||||||
|
protected readonly domainLabels: Record<Dominio, string> = { tea: 'TEA', cacu: 'CaCu', cama: 'Cáncer de mama' };
|
||||||
|
private readonly url = toSignal(this.router.events.pipe(
|
||||||
|
filter((event) => event instanceof NavigationEnd), map(event => event.urlAfterRedirects)), { initialValue: this.router.url });
|
||||||
|
// On an indicators page the header names its domain and switches to the others.
|
||||||
|
protected readonly activeDomain = computed(() =>
|
||||||
|
DOMINIOS.find(domain => new RegExp(`^/indicadores/${domain}(?:[/?#]|$)`).test(this.url())));
|
||||||
|
protected readonly otherDomains = computed(() => DOMINIOS.filter(domain => domain !== this.activeDomain()));
|
||||||
|
|
||||||
private readonly leafRouteData = toSignal(
|
private readonly leafRouteData = toSignal(
|
||||||
this.router.events.pipe(
|
this.router.events.pipe(
|
||||||
filter((event) => event instanceof NavigationEnd),
|
filter((event) => event instanceof NavigationEnd),
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
export interface SeguimientoQuery { corte?: string; meses: 1 | 3 | 6 | 12; estatus?: string; grupo_edad?: string; mchat?: string; css?: string; estado_caso?: string; alteracion?: string; page: number; page_size: number; }
|
export interface SeguimientoQuery { corte?: string; meses: 1 | 3 | 6 | 12; estatus?: string; grupo_edad?: string; mchat?: string; css?: string; estado_caso?: string; alteracion?: string; page: number; page_size: number;
|
||||||
|
// Filters a list announces in `filtros_disponibles`, by key.
|
||||||
|
filtros?: Record<string, string>; }
|
||||||
export interface SeguimientoStatus { codigo: string; etiqueta: string; }
|
export interface SeguimientoStatus { codigo: string; etiqueta: string; }
|
||||||
export interface SeguimientoPaciente {
|
export interface SeguimientoPaciente {
|
||||||
id_seudonimo: string;
|
id_seudonimo: string;
|
||||||
|
|||||||
@@ -91,13 +91,6 @@ describe('Seguimiento CaCu con contrato de demostración', () => {
|
|||||||
expect(()=>seguimientoResponse({...fixtureData,items:[{...fixtureData.items[2],ultima_citologia:{...fixtureData.items[2].ultima_citologia,calidad:42}}]})).toThrow();
|
expect(()=>seguimientoResponse({...fixtureData,items:[{...fixtureData.items[2],ultima_citologia:{...fixtureData.items[2].ultima_citologia,calidad:42}}]})).toThrow();
|
||||||
open().flush({...fixtureData,simulado:false}); fixture.detectChanges(); expect(fixture.nativeElement.querySelector('tbody')).toBeNull();
|
open().flush({...fixtureData,simulado:false}); fixture.detectChanges(); expect(fixture.nativeElement.querySelector('tbody')).toBeNull();
|
||||||
});
|
});
|
||||||
it.each(['cama'])('%s conserva su estado pendiente sin consultas de pacientes', dominio => {
|
|
||||||
fixture.componentRef.setInput('dominio',dominio); fixture.componentRef.setInput('active',true); fixture.detectChanges(); http.expectNone(()=>true);
|
|
||||||
expect(fixture.nativeElement.textContent).toContain('El seguimiento aún no está disponible');
|
|
||||||
expect(fixture.nativeElement.textContent).not.toContain('Columnas propuestas para revisión.');
|
|
||||||
expect(fixture.nativeElement.querySelector('table')).not.toBeNull();
|
|
||||||
expect(fixture.nativeElement.querySelector('caption')).toBeNull();
|
|
||||||
});
|
|
||||||
it('valida parámetros antes del transporte sin confundir fechas del filtro general', () => {
|
it('valida parámetros antes del transporte sin confundir fechas del filtro general', () => {
|
||||||
const service=TestBed.inject(CacuSeguimientoService);
|
const service=TestBed.inject(CacuSeguimientoService);
|
||||||
for(const q of [{corte:'2026-02-30'},{page:0},{page_size:201},{meses:2}]) expect(()=>service.consultar({meses:3,page:1,page_size:50,...q} as never)).toThrow();
|
for(const q of [{corte:'2026-02-30'},{page:0},{page_size:201},{meses:2}]) expect(()=>service.consultar({meses:3,page:1,page_size:50,...q} as never)).toThrow();
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { filterCompatibility } from './indicadores-memory';
|
|||||||
import { DonutSelection } from './indicadores-donut-drilldown';
|
import { DonutSelection } from './indicadores-donut-drilldown';
|
||||||
import { IndicadoresService } from './indicadores.service';
|
import { IndicadoresService } from './indicadores.service';
|
||||||
import { IndicadorEu7Escenario } from './indicador-eu7-escenario';
|
import { IndicadorEu7Escenario } from './indicador-eu7-escenario';
|
||||||
|
import { vistaEscenario } from './indicadores-eu7-escenario';
|
||||||
import { IndicadorTiemposPareados } from './indicador-tiempos-pareados';
|
import { IndicadorTiemposPareados } from './indicador-tiempos-pareados';
|
||||||
import { IndicadorConfirmacionCitologia } from './indicador-confirmacion-citologia';
|
import { IndicadorConfirmacionCitologia } from './indicador-confirmacion-citologia';
|
||||||
import { ID_CONFIRMACION } from './indicadores-confirmacion-citologia';
|
import { ID_CONFIRMACION } from './indicadores-confirmacion-citologia';
|
||||||
@@ -91,7 +92,7 @@ import { parTiempos } from './indicadores-tiempos-pareados';
|
|||||||
}
|
}
|
||||||
.card-identity { min-width: 0; }
|
.card-identity { min-width: 0; }
|
||||||
h2, p { overflow-wrap: anywhere; }
|
h2, p { overflow-wrap: anywhere; }
|
||||||
h2 { margin: 0; font-family: var(--issste-font-heading); font-weight: 700; font-size: 1.5rem; line-height: 1.25; }
|
h2 { margin: 0; font-family: var(--issste-font-heading); font-weight: 500; font-size: 1.125rem; line-height: 1.3; }
|
||||||
.pin-toggle { align-self: start; margin-top: var(--issste-space-1); max-width: 100%; height: auto;
|
.pin-toggle { align-self: start; margin-top: var(--issste-space-1); max-width: 100%; height: auto;
|
||||||
min-width: 48px; min-height: 48px; color: var(--issste-text); }
|
min-width: 48px; min-height: 48px; color: var(--issste-text); }
|
||||||
.pin-toggle mat-icon { flex-shrink: 0; }
|
.pin-toggle mat-icon { flex-shrink: 0; }
|
||||||
@@ -120,7 +121,7 @@ export class IndicadorCatalogCard implements OnChanges, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
get pair() { return dualFigures(this.indicador); }
|
get pair() { return dualFigures(this.indicador); }
|
||||||
get isEu7() { return this.dominio === 'cacu' && this.indicador.id === 'cacu_eu7'; }
|
get isEu7() { return !!vistaEscenario(this.dominio, this.indicador); }
|
||||||
get isConfirmacion() { return this.dominio === 'cacu' && this.indicador.id === ID_CONFIRMACION; }
|
get isConfirmacion() { return this.dominio === 'cacu' && this.indicador.id === ID_CONFIRMACION; }
|
||||||
// Connected time pairs replace the diagnosis card with one coordinated box plot.
|
// Connected time pairs replace the diagnosis card with one coordinated box plot.
|
||||||
get tiempos() { return parTiempos(this.dominio, this.indicador.id); }
|
get tiempos() { return parTiempos(this.dominio, this.indicador.id); }
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ p, h3, summary { overflow-wrap: anywhere; }
|
|||||||
.keys { display: flex; flex-wrap: wrap; gap: .5rem; }
|
.keys { display: flex; flex-wrap: wrap; gap: .5rem; }
|
||||||
.legend > button { justify-self: start; }
|
.legend > button { justify-self: start; }
|
||||||
button { min-height: 44px; max-width: 100%; padding: .5rem .8rem; border: 1px solid var(--issste-border);
|
button { min-height: 44px; max-width: 100%; padding: .5rem .8rem; border: 1px solid var(--issste-border);
|
||||||
border-radius: 999px; color: var(--issste-text); background: var(--issste-surface); font: inherit; cursor: pointer; }
|
border-radius: var(--issste-radius); color: var(--issste-text); background: var(--issste-surface); font: inherit; cursor: pointer; }
|
||||||
.keys button { display: inline-flex; align-items: center; gap: .4rem; text-align: start; overflow-wrap: anywhere; }
|
.keys button { display: inline-flex; align-items: center; gap: .4rem; text-align: start; overflow-wrap: anywhere; }
|
||||||
button[aria-pressed=true] { border-color: var(--issste-accent); box-shadow: inset 0 0 0 1px var(--issste-accent); font-weight: 700; }
|
button[aria-pressed=true] { border-color: var(--issste-accent); box-shadow: inset 0 0 0 1px var(--issste-accent); font-weight: 700; }
|
||||||
button:disabled { opacity: .5; cursor: default; }
|
button:disabled { opacity: .5; cursor: default; }
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<section class="eu7" aria-label="Resultados citológicos por escenario clínico">
|
<section class="eu7" [attr.aria-label]="indicador.titulo + ' por ' + etiquetaEstrato">
|
||||||
<p class="applied-summary">Filtro general aplicado: {{ appliedSummary }}</p>
|
<p class="applied-summary">Filtro general aplicado: {{ appliedSummary }}</p>
|
||||||
<button mat-button type="button" class="methodology-toggle" [attr.aria-expanded]="helpOpen" (click)="toggleHelp()">Cómo leer</button>
|
<button mat-button type="button" class="methodology-toggle" [attr.aria-expanded]="helpOpen" (click)="toggleHelp()">Cómo leer</button>
|
||||||
@if (helpOpen) {
|
@if (helpOpen) {
|
||||||
@@ -16,24 +16,24 @@
|
|||||||
}
|
}
|
||||||
@switch (status()) {
|
@switch (status()) {
|
||||||
@case ('deferred') { <p role="status">La vista se cargará al acercarse a esta región.</p> }
|
@case ('deferred') { <p role="status">La vista se cargará al acercarse a esta región.</p> }
|
||||||
@case ('loading') { <mat-progress-bar mode="indeterminate" aria-label="Cargando resultados citológicos y escenarios" /><p role="status">Cargando el mismo periodo para dona y barras…</p> }
|
@case ('loading') { <mat-progress-bar mode="indeterminate" [attr.aria-label]="'Cargando ' + indicador.titulo" /><p role="status">Cargando el mismo periodo para dona y barras…</p> }
|
||||||
@case ('error') { <div role="alert"><p>{{ message }}</p><button mat-stroked-button type="button" (click)="retry()">Reintentar</button></div> }
|
@case ('error') { <div role="alert"><p>{{ message }}</p><button mat-stroked-button type="button" (click)="retry()">Reintentar</button></div> }
|
||||||
@case ('incompatible') { <div role="alert"><p>Respuesta incompatible: {{ message }}</p><button mat-stroked-button type="button" (click)="retry()">Reintentar</button></div> }
|
@case ('incompatible') { <div role="alert"><p>Respuesta incompatible: {{ message }}</p><button mat-stroked-button type="button" (click)="retry()">Reintentar</button></div> }
|
||||||
}
|
}
|
||||||
@if (status() === 'ready' || status() === 'empty') {
|
@if (status() === 'ready' || status() === 'empty') {
|
||||||
@if (periods.length > 1) {
|
@if (periods.length > 1) {
|
||||||
<nav class="periods" aria-label="Periodos de dona y barras EU7">
|
<nav class="periods" [attr.aria-label]="'Periodos de dona y barras, ' + indicador.titulo">
|
||||||
<button type="button" aria-label="Periodo anterior de EU7" [disabled]="periodIndex === 0" (click)="changePeriod(-1)">‹</button>
|
<button type="button" aria-label="Periodo anterior" [disabled]="periodIndex === 0" (click)="changePeriod(-1)">‹</button>
|
||||||
<span role="status">{{ periods[periodIndex] }}, {{ periodIndex + 1 }} de {{ periods.length }}</span>
|
<span role="status">{{ periods[periodIndex] }}, {{ periodIndex + 1 }} de {{ periods.length }}</span>
|
||||||
<button type="button" aria-label="Periodo siguiente de EU7" [disabled]="periodIndex === periods.length - 1" (click)="changePeriod(1)">›</button>
|
<button type="button" aria-label="Periodo siguiente" [disabled]="periodIndex === periods.length - 1" (click)="changePeriod(1)">›</button>
|
||||||
</nav>
|
</nav>
|
||||||
}
|
}
|
||||||
@if (model; as m) {
|
@if (model; as m) {
|
||||||
<p class="selection-status" role="status" aria-live="polite">{{ m.periodo }}, selección: {{ selectionLabel }}</p>
|
<p class="selection-status" role="status" aria-live="polite">{{ m.periodo }}, selección: {{ selectionLabel }}</p>
|
||||||
@if (status() === 'empty') { <p role="status">No hay pacientes publicados para este periodo.</p> }
|
@if (status() === 'empty') { <p role="status">No hay pacientes publicados para este periodo.</p> }
|
||||||
@else {
|
@else {
|
||||||
<div class="legend" role="group" aria-label="Explorar grupos y categorías de EU7">
|
<div class="legend" role="group" [attr.aria-label]="'Explorar grupos y categorías, ' + indicador.titulo">
|
||||||
<button type="button" (click)="select('centro')" [disabled]="!selection.grupo && !selection.categoria" aria-label="Volver en la selección de EU7">Volver</button>
|
<button type="button" (click)="select('centro')" [disabled]="!selection.grupo && !selection.categoria" aria-label="Volver en la selección">Volver</button>
|
||||||
<div class="keys" role="group" aria-label="Grupos del anillo interior">
|
<div class="keys" role="group" aria-label="Grupos del anillo interior">
|
||||||
@for (g of m.grupos; track g.id; let i = $index) {
|
@for (g of m.grupos; track g.id; let i = $index) {
|
||||||
<button type="button" [attr.aria-pressed]="selection.grupo === g.id" (click)="select('grupos', i)"><span class="swatch" [style.background]="g.color" aria-hidden="true"></span>{{ g.etiqueta }}</button>
|
<button type="button" [attr.aria-pressed]="selection.grupo === g.id" (click)="select('grupos', i)"><span class="swatch" [style.background]="g.color" aria-hidden="true"></span>{{ g.etiqueta }}</button>
|
||||||
@@ -48,27 +48,27 @@
|
|||||||
<div class="figures">
|
<div class="figures">
|
||||||
<section class="figure"><h3>Distribución de resultados, {{ m.periodo }}</h3>
|
<section class="figure"><h3>Distribución de resultados, {{ m.periodo }}</h3>
|
||||||
@if (m.total !== null && m.total > 0 && donutFigure) {
|
@if (m.total !== null && m.total > 0 && donutFigure) {
|
||||||
<app-plotly-chart [figure]="donutFigure" [animated]="true" [showNotes]="false" [label]="'EU7, dona de dos anillos, ' + m.periodo + ', ' + selectionLabel" (plotClick)="plotClicked($event)" />
|
<app-plotly-chart [figure]="donutFigure" [animated]="true" [showNotes]="false" [label]="indicador.titulo + ', dona de dos anillos, ' + m.periodo + ', ' + selectionLabel" (plotClick)="plotClicked($event)" />
|
||||||
} @else { <p role="status">{{ m.total === null ? 'Dona no disponible: hay celdas suprimidas o datos incompletos. No se calcula un total parcial.' : 'Sin pacientes con resultado disponible para la dona.' }}</p> }
|
} @else { <p role="status">{{ m.total === null ? 'Dona no disponible: hay celdas suprimidas o datos incompletos. No se calcula un total parcial.' : 'Sin pacientes con resultado disponible para la dona.' }}</p> }
|
||||||
<p>{{ sinDatoNote }}</p>
|
<p>{{ sinDatoNote }}</p>
|
||||||
</section>
|
</section>
|
||||||
<section class="figure"><h3>{{ selectionLabel }} por escenario clínico, {{ m.periodo }}</h3>
|
<section class="figure"><h3>{{ selectionLabel }} por {{ etiquetaEstrato }}, {{ m.periodo }}</h3>
|
||||||
<p>Porcentaje del total válido de cada escenario; excluye «Sin dato».</p>
|
<p>Porcentaje del total válido de cada {{ etiquetaEstrato }}; excluye «{{ m.sinDatoEtiqueta }}».</p>
|
||||||
@if (m.escenarios.length && barsFigure) {
|
@if (m.escenarios.length && barsFigure) {
|
||||||
<app-plotly-chart [figure]="barsFigure" [animated]="true" [showNotes]="false" [style.--plot-min-width]="'440px'" [label]="'EU7, barras por escenario clínico, ' + m.periodo + ', ' + selectionLabel" />
|
<app-plotly-chart [figure]="barsFigure" [animated]="true" [showNotes]="false" [style.--plot-min-width]="'440px'" [label]="indicador.titulo + ', barras por ' + etiquetaEstrato + ', ' + m.periodo + ', ' + selectionLabel" />
|
||||||
}
|
}
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@for (note of m.notas; track $index) { <p class="note">{{ note }}</p> }
|
@for (note of m.notas; track $index) { <p class="note">{{ note }}</p> }
|
||||||
<details class="published-values"><summary>Valores publicados</summary>
|
<details class="published-values"><summary>Valores publicados</summary>
|
||||||
<div class="table-scroll" role="region" aria-label="Tabla de valores EU7" tabindex="0">
|
<div class="table-scroll" role="region" [attr.aria-label]="'Tabla de valores, ' + indicador.titulo" tabindex="0">
|
||||||
<table><caption>Datos generales, {{ m.periodo }}</caption>
|
<table><caption>Datos generales, {{ m.periodo }}</caption>
|
||||||
<thead><tr><th scope="col">Categoría</th><th scope="col">Conteo</th></tr></thead>
|
<thead><tr><th scope="col">Categoría</th><th scope="col">Conteo</th></tr></thead>
|
||||||
<tbody>@for (row of generalCells; track $index) { <tr><th scope="row">{{ row.etiqueta }}</th><td>{{ cellText(row.celda) }}</td></tr> }</tbody>
|
<tbody>@for (row of generalCells; track $index) { <tr><th scope="row">{{ row.etiqueta }}</th><td>{{ cellText(row.celda) }}</td></tr> }</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table><caption>Escenarios clínicos, {{ m.periodo }}, porcentajes sin «Sin dato»</caption>
|
<table><caption>Por {{ etiquetaEstrato }}, {{ m.periodo }}, porcentajes sin «{{ m.sinDatoEtiqueta }}»</caption>
|
||||||
<thead><tr><th scope="col">Escenario</th><th scope="col">Categoría</th><th scope="col">Conteo</th><th scope="col">Denominador válido</th><th scope="col">Porcentaje</th></tr></thead>
|
<thead><tr><th scope="col">{{ etiquetaEstrato.charAt(0).toUpperCase() + etiquetaEstrato.slice(1) }}</th><th scope="col">Categoría</th><th scope="col">Conteo</th><th scope="col">Denominador válido</th><th scope="col">Porcentaje</th></tr></thead>
|
||||||
<tbody>@for (row of scenarioCells; track $index) { <tr><th scope="row">{{ row.escenario }}</th><td>{{ row.categoria }}</td><td>{{ cellText(row.celda) }}</td><td>{{ row.den === null ? 'No disponible / no aplica' : row.den }}</td><td>{{ percentText(row.pct) }}</td></tr> }</tbody>
|
<tbody>@for (row of scenarioCells; track $index) { <tr><th scope="row">{{ row.escenario }}</th><td>{{ row.categoria }}</td><td>{{ cellText(row.celda) }}</td><td>{{ row.den === null ? 'No disponible / no aplica' : row.den }}</td><td>{{ percentText(row.pct) }}</td></tr> }</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ p, h3, summary { overflow-wrap: anywhere; }
|
|||||||
.keys { display: flex; flex-wrap: wrap; gap: .5rem; }
|
.keys { display: flex; flex-wrap: wrap; gap: .5rem; }
|
||||||
.legend > button { justify-self: start; }
|
.legend > button { justify-self: start; }
|
||||||
button { min-height: 44px; max-width: 100%; padding: .5rem .8rem; border: 1px solid var(--issste-border);
|
button { min-height: 44px; max-width: 100%; padding: .5rem .8rem; border: 1px solid var(--issste-border);
|
||||||
border-radius: 999px; color: var(--issste-text); background: var(--issste-surface); font: inherit; cursor: pointer; }
|
border-radius: var(--issste-radius); color: var(--issste-text); background: var(--issste-surface); font: inherit; cursor: pointer; }
|
||||||
.keys button { display: inline-flex; align-items: center; gap: .4rem; text-align: start; overflow-wrap: anywhere; }
|
.keys button { display: inline-flex; align-items: center; gap: .4rem; text-align: start; overflow-wrap: anywhere; }
|
||||||
button[aria-pressed=true] { border-color: var(--issste-accent); box-shadow: inset 0 0 0 1px var(--issste-accent); font-weight: 700; }
|
button[aria-pressed=true] { border-color: var(--issste-accent); box-shadow: inset 0 0 0 1px var(--issste-accent); font-weight: 700; }
|
||||||
button:disabled { opacity: .5; cursor: default; }
|
button:disabled { opacity: .5; cursor: default; }
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ describe('EU7 integración Angular y caché compartida', () => {
|
|||||||
f.detectChanges(); flush(); expect(f.nativeElement.textContent).toContain('Suprimido');
|
f.detectChanges(); flush(); expect(f.nativeElement.textContent).toContain('Suprimido');
|
||||||
expect(f.nativeElement.textContent).not.toContain('987654');
|
expect(f.nativeElement.textContent).not.toContain('987654');
|
||||||
expect(f.nativeElement.querySelector('table caption')).not.toBeNull();
|
expect(f.nativeElement.querySelector('table caption')).not.toBeNull();
|
||||||
expect(f.nativeElement.querySelector('[aria-label="Tabla de valores EU7"]').tabIndex).toBe(0);
|
expect(f.nativeElement.querySelector('[aria-label="Tabla de valores, Distribución de resultados citológicos"]').tabIndex).toBe(0);
|
||||||
});
|
});
|
||||||
it('catálogo sin capacidad temporal o clínica no inicia GET', () => {
|
it('catálogo sin capacidad temporal o clínica no inicia GET', () => {
|
||||||
f.componentRef.setInput('indicador', { ...indicador, filtros: [] }); f.detectChanges();
|
f.componentRef.setInput('indicador', { ...indicador, filtros: [] }); f.detectChanges();
|
||||||
|
|||||||
@@ -4,16 +4,14 @@ import { combineLatest, Subscription, timeout, TimeoutError } from 'rxjs';
|
|||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||||
import { PlotlyChart } from '../../shared/plotly/plotly-chart';
|
import { PlotlyChart } from '../../shared/plotly/plotly-chart';
|
||||||
import { Dominio, Indicador, IndicadorMetadatos, PlotlyFigure, Tema } from './indicadores.models';
|
import { Dominio, Indicador, IndicadorMetadatos, PlotlyFigure, Tema, VistaEscenario } from './indicadores.models';
|
||||||
import { describePeriods, filterCompatibility, GlobalApplied } from './indicadores-memory';
|
import { describePeriods, filterCompatibility, GlobalApplied } from './indicadores-memory';
|
||||||
import { IndicadoresSnapshots, snapshotKey } from './indicadores-snapshots';
|
import { IndicadoresSnapshots, snapshotKey } from './indicadores-snapshots';
|
||||||
import { httpMessage } from './indicadores-http';
|
import { httpMessage } from './indicadores-http';
|
||||||
import { percentText } from './indicadores-format';
|
import { percentText } from './indicadores-format';
|
||||||
import { stratifiedCapabilities } from './indicadores-stratified';
|
import { stratifiedCapabilities } from './indicadores-stratified';
|
||||||
import { barras, Celda, clic, dona, ESTRATO, Escenario, Eu7Incompatible, Modelo, modelo, porcentaje,
|
import { barras, Celda, clic, dona, esEu7, Escenario, Eu7Incompatible, Modelo, modelo, porcentaje,
|
||||||
periodosCompatibles, Seleccion, seleccionEtiqueta } from './indicadores-eu7-escenario';
|
periodosCompatibles, Seleccion, seleccionEtiqueta, vistaEscenario } from './indicadores-eu7-escenario';
|
||||||
|
|
||||||
const EU7_FIGURES = [['fig_c2_donas', 'Dona de dos anillos'], ['fig_c2_barras', 'Barras por escenario clínico']] as const;
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-indicador-eu7-escenario',
|
selector: 'app-indicador-eu7-escenario',
|
||||||
@@ -44,6 +42,8 @@ export class IndicadorEu7Escenario implements OnChanges, OnDestroy {
|
|||||||
private key = '';
|
private key = '';
|
||||||
private loaded = false;
|
private loaded = false;
|
||||||
private pages: Modelo[] = [];
|
private pages: Modelo[] = [];
|
||||||
|
get vista(): VistaEscenario | undefined { return vistaEscenario(this.dominio, this.indicador); }
|
||||||
|
get etiquetaEstrato() { return this.vista?.etiqueta ?? 'escenario clínico'; }
|
||||||
get appliedSummary() { return describePeriods(this.applied.tipo, this.applied.selection); }
|
get appliedSummary() { return describePeriods(this.applied.tipo, this.applied.selection); }
|
||||||
get selectionLabel() { return this.model ? seleccionEtiqueta(this.model, this.selection) : 'TOTAL'; }
|
get selectionLabel() { return this.model ? seleccionEtiqueta(this.model, this.selection) : 'TOTAL'; }
|
||||||
get sinDatoNote() {
|
get sinDatoNote() {
|
||||||
@@ -51,6 +51,8 @@ export class IndicadorEu7Escenario implements OnChanges, OnDestroy {
|
|||||||
if (!m) return '';
|
if (!m) return '';
|
||||||
if (m.vacio) return 'No hay registros publicados en este periodo.';
|
if (m.vacio) return 'No hay registros publicados en este periodo.';
|
||||||
const n = m.sinDato.n;
|
const n = m.sinDato.n;
|
||||||
|
if (this.vista && !esEu7(this.vista)) return n === null ? `${m.sinDatoEtiqueta}: ${m.sinDato.estado}. Fuera de la dona.`
|
||||||
|
: `Fuera de la dona: ${n} pacientes con «${m.sinDatoEtiqueta}»${m.total === null ? '' : ` de ${m.total + n}`}.`;
|
||||||
return n === null ? `${m.sinDatoEtiqueta}: ${m.sinDato.estado}. Fuera de la dona.`
|
return n === null ? `${m.sinDatoEtiqueta}: ${m.sinDato.estado}. Fuera de la dona.`
|
||||||
: m.total === null ? `Fuera de la dona: ${n} pacientes con resultado no disponible o de calidad de espécimen insatisfactoria a la fecha de corte. Total de la dona no disponible.`
|
: m.total === null ? `Fuera de la dona: ${n} pacientes con resultado no disponible o de calidad de espécimen insatisfactoria a la fecha de corte. Total de la dona no disponible.`
|
||||||
: `Fuera de la dona: ${n} de ${m.total + n} pacientes con resultado no disponible o de calidad de espécimen insatisfactoria a la fecha de corte.`;
|
: `Fuera de la dona: ${n} de ${m.total + n} pacientes con resultado no disponible o de calidad de espécimen insatisfactoria a la fecha de corte.`;
|
||||||
@@ -69,7 +71,8 @@ export class IndicadorEu7Escenario implements OnChanges, OnDestroy {
|
|||||||
// "Cómo leer" shows only what the kit publishes for the two figures of this view.
|
// "Cómo leer" shows only what the kit publishes for the two figures of this view.
|
||||||
get readingGuide() {
|
get readingGuide() {
|
||||||
const details = this.metadata?.figuras_detalle ?? [];
|
const details = this.metadata?.figuras_detalle ?? [];
|
||||||
return EU7_FIGURES.flatMap(([figura, nombre]) => {
|
const figuras = [['fig_c2_donas', 'Dona de dos anillos'], ['fig_c2_barras', 'Barras por ' + this.etiquetaEstrato]] as const;
|
||||||
|
return figuras.flatMap(([figura, nombre]) => {
|
||||||
const detail = details.find(item => item.figura === figura);
|
const detail = details.find(item => item.figura === figura);
|
||||||
const descripcion = detail?.descripcion?.trim() ?? '';
|
const descripcion = detail?.descripcion?.trim() ?? '';
|
||||||
const como_leer = (detail?.como_leer ?? []).filter(line => line.trim().length > 0);
|
const como_leer = (detail?.como_leer ?? []).filter(line => line.trim().length > 0);
|
||||||
@@ -99,10 +102,11 @@ export class IndicadorEu7Escenario implements OnChanges, OnDestroy {
|
|||||||
this.loaded = true; this.model = undefined; this.pages = []; this.periods = [];
|
this.loaded = true; this.model = undefined; this.pages = []; this.periods = [];
|
||||||
this.selection = {}; this.donutFigure = undefined; this.barsFigure = undefined;
|
this.selection = {}; this.donutFigure = undefined; this.barsFigure = undefined;
|
||||||
const compatibility = filterCompatibility(this.applied, this.indicador.tipos_periodo);
|
const compatibility = filterCompatibility(this.applied, this.indicador.tipos_periodo);
|
||||||
if (this.dominio !== 'cacu' || this.indicador.id !== 'cacu_eu7' || this.indicador.contrato !== 'C2'
|
const vista = this.vista;
|
||||||
|
if (!vista || this.indicador.contrato !== 'C2'
|
||||||
|| !this.indicador.figuras.includes('fig_c2_donas') || !this.indicador.figuras.includes('fig_c2_barras')
|
|| !this.indicador.figuras.includes('fig_c2_donas') || !this.indicador.figuras.includes('fig_c2_barras')
|
||||||
|| !stratifiedCapabilities(this.indicador).includes(ESTRATO) || !compatibility.compatible) {
|
|| !stratifiedCapabilities(this.indicador).includes(vista.estrato) || !compatibility.compatible) {
|
||||||
this.message = !compatibility.compatible ? compatibility.reason : 'El catálogo no publica las capacidades necesarias para esta vista EU7.';
|
this.message = !compatibility.compatible ? compatibility.reason : 'El catálogo no publica las capacidades necesarias para esta vista.';
|
||||||
this.status.set('incompatible'); return;
|
this.status.set('incompatible'); return;
|
||||||
}
|
}
|
||||||
const key = this.key;
|
const key = this.key;
|
||||||
@@ -110,13 +114,13 @@ export class IndicadorEu7Escenario implements OnChanges, OnDestroy {
|
|||||||
this.status.set('loading');
|
this.status.set('loading');
|
||||||
this.subscription = combineLatest([
|
this.subscription = combineLatest([
|
||||||
this.snapshots.datos(this.dominio, this.indicador.id, this.applied.tipo, periods, this.indicador.version),
|
this.snapshots.datos(this.dominio, this.indicador.id, this.applied.tipo, periods, this.indicador.version),
|
||||||
this.snapshots.datos(this.dominio, this.indicador.id, this.applied.tipo, periods, this.indicador.version, { estrato: ESTRATO }),
|
this.snapshots.datos(this.dominio, this.indicador.id, this.applied.tipo, periods, this.indicador.version, { estrato: vista.estrato }),
|
||||||
]).pipe(timeout({ first: 40000 })).subscribe({
|
]).pipe(timeout({ first: 40000 })).subscribe({
|
||||||
next: ([general, escenarios]) => {
|
next: ([general, escenarios]) => {
|
||||||
if (key !== this.key) return;
|
if (key !== this.key) return;
|
||||||
try {
|
try {
|
||||||
this.periods = periodosCompatibles(general, escenarios, this.applied.tipo, periods);
|
this.periods = periodosCompatibles(general, escenarios, this.applied.tipo, periods);
|
||||||
this.pages = this.periods.map(p => modelo(general, escenarios, p));
|
this.pages = this.periods.map(p => modelo(general, escenarios, p, vista.estrato));
|
||||||
this.periodIndex = 0; this.activatePeriod();
|
this.periodIndex = 0; this.activatePeriod();
|
||||||
} catch (error) { this.failure(error); }
|
} catch (error) { this.failure(error); }
|
||||||
},
|
},
|
||||||
@@ -151,7 +155,7 @@ export class IndicadorEu7Escenario implements OnChanges, OnDestroy {
|
|||||||
private draw() {
|
private draw() {
|
||||||
if (!this.model) return;
|
if (!this.model) return;
|
||||||
this.donutFigure = dona(this.model, this.selection, this.tema);
|
this.donutFigure = dona(this.model, this.selection, this.tema);
|
||||||
this.barsFigure = barras(this.model, this.selection, this.tema);
|
this.barsFigure = barras(this.model, this.selection, this.tema, `% de pacientes de cada ${this.etiquetaEstrato}`);
|
||||||
this.changeDetector.markForCheck();
|
this.changeDetector.markForCheck();
|
||||||
}
|
}
|
||||||
ngOnDestroy() { this.subscription?.unsubscribe(); }
|
ngOnDestroy() { this.subscription?.unsubscribe(); }
|
||||||
|
|||||||
@@ -120,7 +120,7 @@
|
|||||||
.highlight-back { justify-self: start; }
|
.highlight-back { justify-self: start; }
|
||||||
.highlight-keys { display: flex; flex-wrap: wrap; gap: .5rem; }
|
.highlight-keys { display: flex; flex-wrap: wrap; gap: .5rem; }
|
||||||
.highlight-legend button { display: inline-flex; align-items: center; gap: .4rem; min-height: 36px; padding: .3rem .75rem; text-align: start;
|
.highlight-legend button { display: inline-flex; align-items: center; gap: .4rem; min-height: 36px; padding: .3rem .75rem; text-align: start;
|
||||||
overflow-wrap: anywhere; color: inherit; background: var(--issste-surface); border: 1px solid var(--issste-border); border-radius: 999px; font: inherit; cursor: pointer; }
|
overflow-wrap: anywhere; color: inherit; background: var(--issste-surface); border: 1px solid var(--issste-border); border-radius: var(--issste-radius); font: inherit; cursor: pointer; }
|
||||||
.highlight-legend button:disabled { opacity: .45; cursor: default; }
|
.highlight-legend button:disabled { opacity: .45; cursor: default; }
|
||||||
.highlight-legend button[aria-pressed=true] { border-color: var(--issste-accent); box-shadow: inset 0 0 0 1px var(--issste-accent); font-weight: 700; }
|
.highlight-legend button[aria-pressed=true] { border-color: var(--issste-accent); box-shadow: inset 0 0 0 1px var(--issste-accent); font-weight: 700; }
|
||||||
.highlight-legend button:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
|
.highlight-legend button:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
|
|||||||
.distribution-toggle, .distribution-dimensions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
|
.distribution-toggle, .distribution-dimensions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
|
||||||
.distribution-dimensions { margin-top: .75rem; }
|
.distribution-dimensions { margin-top: .75rem; }
|
||||||
.distribution-toggle button, .distribution-dimensions button { min-height: 44px; max-width: 100%; padding: .65rem .9rem;
|
.distribution-toggle button, .distribution-dimensions button { min-height: 44px; max-width: 100%; padding: .65rem .9rem;
|
||||||
border: 1px solid var(--issste-border); border-radius: 999px; background: var(--issste-surface); color: var(--issste-text);
|
border: 1px solid var(--issste-border); border-radius: var(--issste-radius); background: var(--issste-surface); color: var(--issste-text);
|
||||||
font: inherit; text-align: start; overflow-wrap: anywhere; cursor: pointer; }
|
font: inherit; text-align: start; overflow-wrap: anywhere; cursor: pointer; }
|
||||||
.distribution-toggle button.active, .distribution-dimensions button.active { border-color: var(--issste-accent); background: var(--issste-accent); color: var(--issste-on-accent, #fff); font-weight: 600; }
|
.distribution-toggle button.active, .distribution-dimensions button.active { border-color: var(--issste-accent); background: var(--issste-accent); color: var(--issste-on-accent, #fff); font-weight: 600; }
|
||||||
.distribution-toggle button:disabled, .distribution-dimensions button:disabled { opacity: .5; cursor: not-allowed; }
|
.distribution-toggle button:disabled, .distribution-dimensions button:disabled { opacity: .5; cursor: not-allowed; }
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||||
import { MatCardModule } from '@angular/material/card';
|
import { MatCardModule } from '@angular/material/card';
|
||||||
|
import { percentNumber } from './indicadores-format';
|
||||||
|
import { KpiIntervalo } from './indicadores-kpi';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-indicador-kpi-card',
|
selector: 'app-indicador-kpi-card',
|
||||||
@@ -12,8 +14,22 @@ import { MatCardModule } from '@angular/material/card';
|
|||||||
@if (value !== null && value !== undefined) {
|
@if (value !== null && value !== undefined) {
|
||||||
<p class="value">{{ value }}@if (unit) { <span>{{ unit }}</span> }</p>
|
<p class="value">{{ value }}@if (unit) { <span>{{ unit }}</span> }</p>
|
||||||
}
|
}
|
||||||
|
@if (intervalo; as ic) {
|
||||||
|
<div class="intervalo" role="img" [attr.aria-label]="'Intervalo de confianza de Wilson al 95 %: ' + texto(ic.bajo) + ' a ' + texto(ic.alto) + ' %'">
|
||||||
|
<svg viewBox="0 0 100 12" preserveAspectRatio="none" aria-hidden="true">
|
||||||
|
<line class="eje" x1="0" y1="6" x2="100" y2="6" />
|
||||||
|
<line class="ic" [attr.x1]="ic.bajo" y1="6" [attr.x2]="ic.alto" y2="6" />
|
||||||
|
<line class="ic" [attr.x1]="ic.bajo" y1="2" [attr.x2]="ic.bajo" y2="10" />
|
||||||
|
<line class="ic" [attr.x1]="ic.alto" y1="2" [attr.x2]="ic.alto" y2="10" />
|
||||||
|
<line class="punto" [attr.x1]="ic.valor" y1="1" [attr.x2]="ic.valor" y2="11" />
|
||||||
|
</svg>
|
||||||
|
<span class="escala" aria-hidden="true"><span>0 %</span><span>100 %</span></span>
|
||||||
|
<span class="leyenda">IC 95 % (Wilson): {{ texto(ic.bajo) }} a {{ texto(ic.alto) }} %</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
@if (temporalReference) { <p>{{ temporalReference }}</p> }
|
@if (temporalReference) { <p>{{ temporalReference }}</p> }
|
||||||
<p class="kpi-state" role="status">{{ state }}</p>
|
<!-- A card with its value says nothing more about its state; any other state is the message. -->
|
||||||
|
@if (state !== 'Disponible') { <p class="kpi-state" role="status">{{ state }}</p> }
|
||||||
@if (informationLine) { <p class="additional-info">{{ informationLine }}</p> }
|
@if (informationLine) { <p class="additional-info">{{ informationLine }}</p> }
|
||||||
</mat-card>
|
</mat-card>
|
||||||
`,
|
`,
|
||||||
@@ -22,12 +38,20 @@ import { MatCardModule } from '@angular/material/card';
|
|||||||
mat-card { box-sizing: border-box; height: 100%; padding: var(--issste-space-6);
|
mat-card { box-sizing: border-box; height: 100%; padding: var(--issste-space-6);
|
||||||
background: var(--issste-surface); color: var(--issste-text); border: 1px solid var(--issste-border);
|
background: var(--issste-surface); color: var(--issste-text); border: 1px solid var(--issste-border);
|
||||||
border-radius: var(--issste-radius); box-shadow: none; }
|
border-radius: var(--issste-radius); box-shadow: none; }
|
||||||
h3 { margin: 0; font-family: var(--issste-font-heading); font-size: 1.25rem; line-height: 1.3; }
|
h3 { margin: 0; font-family: var(--issste-font-heading); font-size: 1rem; font-weight: 500; line-height: 1.3; }
|
||||||
h3, p { overflow-wrap: anywhere; }
|
h3, p { overflow-wrap: anywhere; }
|
||||||
p { margin: var(--issste-space-3) 0 0; }
|
p { margin: var(--issste-space-3) 0 0; }
|
||||||
.kpi-state, .additional-info { color: var(--issste-text-secondary); font: var(--mat-sys-body-medium); }
|
.kpi-state, .additional-info { color: var(--issste-text-secondary); font: var(--mat-sys-body-medium); }
|
||||||
.value { font: var(--mat-sys-headline-medium); }
|
.value { font-size: 1.75rem; font-weight: 500; line-height: 1.2; }
|
||||||
.value span { margin-inline-start: .3em; }
|
.value span { margin-inline-start: .3em; }
|
||||||
|
.intervalo { margin-top: var(--issste-space-3); }
|
||||||
|
.intervalo svg { display: block; width: 100%; height: 14px; overflow: visible; }
|
||||||
|
.intervalo line { vector-effect: non-scaling-stroke; }
|
||||||
|
.eje { stroke: var(--issste-border); stroke-width: 2; }
|
||||||
|
.ic { stroke: var(--issste-text); stroke-width: 2; }
|
||||||
|
.punto { stroke: var(--issste-accent); stroke-width: 4; }
|
||||||
|
.escala { display: flex; justify-content: space-between; color: var(--issste-text-secondary); font: var(--mat-sys-body-small); }
|
||||||
|
.leyenda { display: block; color: var(--issste-text-secondary); font: var(--mat-sys-body-medium); }
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
export class IndicadorKpiCard {
|
export class IndicadorKpiCard {
|
||||||
@@ -39,6 +63,8 @@ export class IndicadorKpiCard {
|
|||||||
@Input() notes: string[] = [];
|
@Input() notes: string[] = [];
|
||||||
@Input() state = 'Pendiente de definición';
|
@Input() state = 'Pendiente de definición';
|
||||||
@Input() additionalInfo?: string;
|
@Input() additionalInfo?: string;
|
||||||
|
@Input() intervalo?: KpiIntervalo;
|
||||||
|
texto(valor: number) { return percentNumber(valor); }
|
||||||
get informationLine(): string | undefined {
|
get informationLine(): string | undefined {
|
||||||
const lines = [this.additionalInfo, ...this.notes].map(value => value?.trim()).filter((value): value is string => !!value);
|
const lines = [this.additionalInfo, ...this.notes].map(value => value?.trim()).filter((value): value is string => !!value);
|
||||||
return [...new Set(lines)].join(' ');
|
return [...new Set(lines)].join(' ');
|
||||||
|
|||||||
@@ -52,6 +52,18 @@ describe('KPI integración con autoridad global', () => {
|
|||||||
const d = KPI_BY_DOMAIN[domain][index]; return { id: d.id, contrato: d.contrato, tipo_periodo: period.includes('-S') ? 'semestre' : 'mes', periodos: [period], categorias: { A: {} }, filas: [
|
const d = KPI_BY_DOMAIN[domain][index]; return { id: d.id, contrato: d.contrato, tipo_periodo: period.includes('-S') ? 'semestre' : 'mes', periodos: [period], categorias: { A: {} }, filas: [
|
||||||
{ periodo: period, grupo: d.contrato === 'C1' && domain !== 'tea' ? 'total' : 'TOTAL', estrato: null, categoria: 'A', n: 5, valor: 40, numerador: 2, denominador: 5, mediana: 7, q1: 3, q3: 9, unidad: 'dias', suprimido: 0 }] };
|
{ periodo: period, grupo: d.contrato === 'C1' && domain !== 'tea' ? 'total' : 'TOTAL', estrato: null, categoria: 'A', n: 5, valor: 40, numerador: 2, denominador: 5, mediana: 7, q1: 3, q3: 9, unidad: 'dias', suprimido: 0 }] };
|
||||||
}
|
}
|
||||||
|
// Answers every card by its URL until none is waiting: a domain with more cards than the concurrent
|
||||||
|
// requests gets them in batches.
|
||||||
|
function flushAll(domain: Dominio, extra: Partial<IndicadorDatos> = {}) {
|
||||||
|
for (let reqs = requests(); reqs.length; reqs = requests()) {
|
||||||
|
// A flushed answer can cancel its siblings (a new anchor period); those are not answered.
|
||||||
|
for (const r of reqs.filter(r => !r.cancelled)) {
|
||||||
|
const index = KPI_BY_DOMAIN[domain].findIndex(d => r.request.url.includes('/' + d.id + '/'));
|
||||||
|
r.flush({ ...response(index, domain, r.request.params.get('periodos') ?? '2025-S1'), ...extra });
|
||||||
|
}
|
||||||
|
fixture.detectChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
function apply(periods: string[], tipo: 'mes' | 'semestre' = 'semestre') {
|
function apply(periods: string[], tipo: 'mes' | 'semestre' = 'semestre') {
|
||||||
const state = fixture.componentInstance.filters!; state.tipo = tipo; state.editors[tipo]!.draft = { mode: 'explicit', periodos: periods as [string, ...string[]] };
|
const state = fixture.componentInstance.filters!; state.tipo = tipo; state.editors[tipo]!.draft = { mode: 'explicit', periodos: periods as [string, ...string[]] };
|
||||||
fixture.componentInstance.applyFilters(); fixture.detectChanges();
|
fixture.componentInstance.applyFilters(); fixture.detectChanges();
|
||||||
@@ -104,8 +116,9 @@ describe('KPI integración con autoridad global', () => {
|
|||||||
it('dominio cancela solicitudes salientes y restaura aplicado independiente del borrador', () => {
|
it('dominio cancela solicitudes salientes y restaura aplicado independiente del borrador', () => {
|
||||||
load('cacu'); const outgoing = requests(); apply(['2025-S1']); const applied = requests(); expect(outgoing.every(r => r.cancelled)).toBe(true);
|
load('cacu'); const outgoing = requests(); apply(['2025-S1']); const applied = requests(); expect(outgoing.every(r => r.cancelled)).toBe(true);
|
||||||
fixture.componentInstance.filters!.editors.semestre!.draft = { mode: 'explicit', periodos: ['2025-S2'] };
|
fixture.componentInstance.filters!.editors.semestre!.draft = { mode: 'explicit', periodos: ['2025-S2'] };
|
||||||
load('cama'); expect(applied.every(r => r.cancelled)).toBe(true); const cama = requests(); expect(cama.every(r => r.request.url.startsWith('/cama/'))).toBe(true); cama.forEach((r,i) => r.flush(response(i, 'cama')));
|
load('cama'); expect(applied.every(r => r.cancelled)).toBe(true); expect(requests().every(r => r.request.url.startsWith('/cama/'))).toBe(true); flushAll('cama');
|
||||||
load('cacu'); const restored = requests(); expect(restored.every(r => r.request.params.get('periodos') === '2025-S1')).toBe(true);
|
// CaMa's last cards start after its first batch and are cancelled by the change of domain.
|
||||||
|
load('cacu'); const restored = requests().filter(r => !r.cancelled); expect(restored.every(r => r.request.params.get('periodos') === '2025-S1')).toBe(true);
|
||||||
expect(fixture.componentInstance.filters!.editors.semestre!.draft).toEqual({ mode: 'explicit', periodos: ['2025-S2'] }); restored.forEach((r,i) => r.flush(response(i)));
|
expect(fixture.componentInstance.filters!.editors.semestre!.draft).toEqual({ mode: 'explicit', periodos: ['2025-S2'] }); restored.forEach((r,i) => r.flush(response(i)));
|
||||||
});
|
});
|
||||||
it('el catálogo vigente retira los KPI que dejaron de publicarse', () => {
|
it('el catálogo vigente retira los KPI que dejaron de publicarse', () => {
|
||||||
@@ -175,24 +188,23 @@ describe('KPI integración con autoridad global', () => {
|
|||||||
expect(panels()).toHaveLength(2); expect(panels().every(p => p.result().state === 'Sin reportes disponibles')).toBe(true);
|
expect(panels()).toHaveLength(2); expect(panels().every(p => p.result().state === 'Sin reportes disponibles')).toBe(true);
|
||||||
http.expectNone(r => r.url.endsWith('/datos'));
|
http.expectNone(r => r.url.endsWith('/datos'));
|
||||||
});
|
});
|
||||||
it('las seis tarjetas conservan valores, unidades, periodo e información sin etiqueta estadística frontend', () => {
|
it('las tarjetas conservan valores, unidades, periodo e información sin etiqueta estadística frontend', () => {
|
||||||
for (const domain of ['cacu', 'cama'] as const) {
|
for (const domain of ['cacu', 'cama'] as const) {
|
||||||
load(domain);
|
load(domain);
|
||||||
const req = requests(); expect(req).toHaveLength(KPI_BY_DOMAIN[domain].length);
|
flushAll(domain, { notas: ['Nota del pie de la figura.'] });
|
||||||
req.forEach((r, i) => r.flush({ ...response(i, domain), notas: ['Nota del pie de la figura.'] }));
|
|
||||||
fixture.detectChanges();
|
|
||||||
const cards = [...fixture.nativeElement.querySelectorAll('app-indicador-kpi-card')];
|
const cards = [...fixture.nativeElement.querySelectorAll('app-indicador-kpi-card')];
|
||||||
expect(cards).toHaveLength(domain === 'cacu' ? 5 : 3);
|
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', '40.0', '7']);
|
expect(cards.map(card => card.querySelector('.value')?.firstChild?.textContent?.trim())).toEqual(domain === 'cacu' ? ['5', undefined, '7', undefined, undefined] : ['5', '40.0', '7', '7']);
|
||||||
expect(cards.map(card => card.querySelector('.value span')?.textContent.trim())).toEqual(domain === 'cacu' ? ['pacientes', undefined, 'días (mediana)', undefined, undefined] : ['pacientes', '%', 'días (mediana)']);
|
expect(cards.map(card => card.querySelector('.value span')?.textContent.trim())).toEqual(domain === 'cacu' ? ['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', 'Disponible', 'Disponible']);
|
: ['pacientes', '%', 'días (mediana)', 'días (mediana)']);
|
||||||
|
expect(cards.map(card => card.querySelector('.kpi-state')?.textContent.trim())).toEqual(domain === 'cacu' ? [undefined, 'Selección no consolidable', undefined, 'Indicador no disponible', 'Indicador no disponible'] : Array(4).fill(undefined));
|
||||||
expect(cards.map(card => card.textContent)).toEqual(expect.arrayContaining([
|
expect(cards.map(card => card.textContent)).toEqual(expect.arrayContaining([
|
||||||
expect.stringContaining('2025-S1'),
|
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.'),
|
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.'),
|
||||||
]));
|
]));
|
||||||
expect(fixture.nativeElement.textContent).not.toContain('Definición provisional');
|
expect(fixture.nativeElement.textContent).not.toContain('Definición provisional');
|
||||||
// CaCu cards say only their own line; the kit notes are the figure footer.
|
// CaCu and CaMa cards say only their own line; the kit notes are the figure footer.
|
||||||
expect(fixture.nativeElement.textContent.includes('Nota del pie de la figura.')).toBe(domain !== 'cacu');
|
expect(fixture.nativeElement.textContent).not.toContain('Nota del pie de la figura.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
it('Aplicar Todos después del periodo compartido conserva supresión del último sin retroceder', () => {
|
it('Aplicar Todos después del periodo compartido conserva supresión del último sin retroceder', () => {
|
||||||
@@ -212,7 +224,7 @@ describe('KPI integración con autoridad global', () => {
|
|||||||
it('primera entrada independiente y regreso inicial reutilizan datos, sin reiniciar filtros', () => {
|
it('primera entrada independiente y regreso inicial reutilizan datos, sin reiniciar filtros', () => {
|
||||||
for (const domain of ['cacu', 'cama'] as const) {
|
for (const domain of ['cacu', 'cama'] as const) {
|
||||||
load(domain, false, ['2025-S1'], true); requests()[0].flush(response(0, domain)); fixture.detectChanges();
|
load(domain, false, ['2025-S1'], true); requests()[0].flush(response(0, domain)); fixture.detectChanges();
|
||||||
requests().forEach((r, i) => r.flush(response(i + 1, domain))); fixture.detectChanges();
|
flushAll(domain);
|
||||||
expect(TestBed.inject(IndicadoresMemory).initialKpiPresentation(domain)).toBe(false);
|
expect(TestBed.inject(IndicadoresMemory).initialKpiPresentation(domain)).toBe(false);
|
||||||
}
|
}
|
||||||
load('cacu', false, ['2025-S1'], true);
|
load('cacu', false, ['2025-S1'], true);
|
||||||
@@ -224,7 +236,7 @@ describe('KPI integración con autoridad global', () => {
|
|||||||
const data = response(0, 'cacu', '2025-S2'); data.filas[0]['suprimido'] = 1; requests()[0].flush(data);
|
const data = response(0, 'cacu', '2025-S2'); data.filas[0]['suprimido'] = 1; requests()[0].flush(data);
|
||||||
const old = requests(); expect(old).toHaveLength(1);
|
const old = requests(); expect(old).toHaveLength(1);
|
||||||
load('cama'); expect(old.every(r => r.cancelled)).toBe(true);
|
load('cama'); expect(old.every(r => r.cancelled)).toBe(true);
|
||||||
requests().forEach((r, i) => r.flush(response(i, 'cama')));
|
flushAll('cama');
|
||||||
load('cacu', false, ['2025-S2', '2025-S1'], true); const resumed = requests(); expect(resumed).toHaveLength(1);
|
load('cacu', false, ['2025-S2', '2025-S1'], true); const resumed = requests(); expect(resumed).toHaveLength(1);
|
||||||
resumed[0].flush(response(0)); fixture.detectChanges();
|
resumed[0].flush(response(0)); fixture.detectChanges();
|
||||||
requests().forEach((r, i) => { expect(r.request.params.get('periodos')).toBe('2025-S1'); r.flush(response(i + 1)); });
|
requests().forEach((r, i) => { expect(r.request.params.get('periodos')).toBe('2025-S1'); r.flush(response(i + 1)); });
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ interface KpiDisplay extends KpiResult { period?: string; earlier?: boolean; ver
|
|||||||
imports: [IndicadorKpiCard, MatButtonModule],
|
imports: [IndicadorKpiCard, MatButtonModule],
|
||||||
template: `<app-indicador-kpi-card [title]="definition.title" [value]="result().value" [unit]="definition.unit"
|
template: `<app-indicador-kpi-card [title]="definition.title" [value]="result().value" [unit]="definition.unit"
|
||||||
[state]="result().state" [additionalInfo]="result().info" [temporalReference]="temporalReference"
|
[state]="result().state" [additionalInfo]="result().info" [temporalReference]="temporalReference"
|
||||||
[loading]="result().loading ?? false" [notes]="dominio === 'cacu' ? [] : result().notes ?? []" />
|
[loading]="result().loading ?? false" [notes]="dominio !== 'tea' ? [] : result().notes ?? []" [intervalo]="result().intervalo" />
|
||||||
@if (result().state === 'Error de consulta') {
|
@if (result().state === 'Error de consulta') {
|
||||||
<button type="button" mat-stroked-button (click)="retry()" [attr.aria-label]="'Reintentar ' + definition.title">Reintentar consulta</button>
|
<button type="button" mat-stroked-button (click)="retry()" [attr.aria-label]="'Reintentar ' + definition.title">Reintentar consulta</button>
|
||||||
}`,
|
}`,
|
||||||
|
|||||||
@@ -14,9 +14,11 @@
|
|||||||
@for (period of unavailableSelection; track period) { <mat-option [value]="period" disabled>{{ period }}, disponibilidad no confirmada</mat-option> }
|
@for (period of unavailableSelection; track period) { <mat-option [value]="period" disabled>{{ period }}, disponibilidad no confirmada</mat-option> }
|
||||||
}
|
}
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-hint>{{ availability ? 'Existe reporte en al menos un indicador del dominio; la cobertura puede variar.' : 'Disponibilidad desconocida hasta consultar.' }}</mat-hint>
|
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
<button class="apply-button" type="button" mat-flat-button [disabled]="!canApply || (!hasPending && !initialPresentation)" (click)="apply.emit()">Aplicar</button>
|
||||||
|
@if (hasPending) { <span class="pending" role="status">Hay cambios sin aplicar.</span> }
|
||||||
</div>
|
</div>
|
||||||
|
<p class="applied-summary">Filtro general aplicado: {{ appliedSummary }}. {{ availability ? 'Existe reporte en al menos un indicador del dominio.' : 'Disponibilidad desconocida hasta consultar.' }}</p>
|
||||||
@if (availability) {
|
@if (availability) {
|
||||||
@if (availability.status === 'loading') { <p role="status">Consultando periodos disponibles…</p> }
|
@if (availability.status === 'loading') { <p role="status">Consultando periodos disponibles…</p> }
|
||||||
@else if (availability.status === 'error') {
|
@else if (availability.status === 'error') {
|
||||||
@@ -43,10 +45,5 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@if (error) { <p class="error" role="alert">{{ error }}</p> }
|
@if (error) { <p class="error" role="alert">{{ error }}</p> }
|
||||||
<p class="draft-summary">Selección en edición: {{ summary }}</p>
|
|
||||||
@if (!canApply) { <p role="status">Selecciona un periodo válido para aplicar.</p> }
|
@if (!canApply) { <p role="status">Selecciona un periodo válido para aplicar.</p> }
|
||||||
@if (!hasPending) { <p class="pending">Sin cambios pendientes.</p> }
|
|
||||||
@if (hasPending) { <p class="pending" role="status">Hay cambios sin aplicar.</p> }
|
|
||||||
<button class="apply-button" type="button" mat-flat-button [disabled]="!canApply || (!hasPending && !initialPresentation)" (click)="apply.emit()">Aplicar</button>
|
|
||||||
<p class="applied-summary">Filtro general aplicado: {{ appliedSummary }}</p>
|
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
:host { display: block; min-width: 0; margin: var(--issste-space-4) 0; }
|
@use '@angular/material' as mat;
|
||||||
|
|
||||||
|
// One compact row, like the Seguimiento form: the two selectors, Aplicar and the pending notice.
|
||||||
|
:host { display: block; min-width: 0; @include mat.theme((density: -4)); }
|
||||||
section { min-width: 0; }
|
section { min-width: 0; }
|
||||||
.fields { display: flex; flex-wrap: wrap; align-items: start; gap: var(--issste-space-3); }
|
.fields { display: flex; flex-wrap: wrap; align-items: center; gap: var(--issste-space-3); }
|
||||||
mat-form-field { flex: 1 1 14rem; min-width: 0; max-width: 24rem; }
|
mat-form-field { flex: 0 1 14rem; min-width: 0; }
|
||||||
.period-builder mat-form-field { flex: 0 1 10rem; }
|
.period-builder mat-form-field { flex: 0 1 9rem; }
|
||||||
.period-builder button { margin-top: var(--issste-space-2); min-height: 44px; }
|
.period-builder button { min-height: 40px; }
|
||||||
p { overflow-wrap: anywhere; line-height: 1.5; margin: var(--issste-space-3) 0; }
|
p { overflow-wrap: anywhere; line-height: 1.4; margin: var(--issste-space-2) 0 0; font: var(--mat-sys-body-small); }
|
||||||
.select-value { white-space: normal; overflow-wrap: anywhere; line-height: 1.5; }
|
.select-value { white-space: normal; overflow-wrap: anywhere; line-height: 1.4; }
|
||||||
.filter-help, .applied-summary { color: var(--issste-text-secondary); font: var(--mat-sys-body-small); }
|
.filter-help, .applied-summary { color: var(--issste-text-secondary); }
|
||||||
.draft-summary { font-weight: 500; }
|
.pending { color: var(--issste-text); font: var(--mat-sys-body-small); border-left: 3px solid var(--issste-accent); padding-left: var(--issste-space-2); }
|
||||||
.pending { border-left: 3px solid var(--issste-text); padding-left: var(--issste-space-3); }
|
|
||||||
.error { color: var(--mat-sys-error); }
|
.error { color: var(--mat-sys-error); }
|
||||||
.remove { display: flex; flex-wrap: wrap; gap: var(--issste-space-2); }
|
.remove { display: flex; flex-wrap: wrap; gap: var(--issste-space-2); }
|
||||||
.remove button { min-height: 44px; }
|
.apply-button { min-height: 40px; }
|
||||||
.apply-button { min-height: 44px; margin-top: var(--issste-space-2); }
|
|
||||||
@media (max-width: 550px) {
|
@media (max-width: 550px) {
|
||||||
mat-form-field, .period-builder mat-form-field { flex: 1 1 100%; max-width: none; }
|
mat-form-field, .period-builder mat-form-field { flex: 1 1 100%; }
|
||||||
.period-builder button { margin-top: 0; }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
:host { display: block; min-width: 0; padding: var(--issste-space-4); overflow-wrap: anywhere;
|
:host { display: block; min-width: 0; padding: var(--issste-space-4); overflow-wrap: anywhere;
|
||||||
background: var(--issste-surface); border: 1px solid var(--issste-border); border-radius: var(--issste-radius); }
|
background: var(--issste-surface); border: 1px solid var(--issste-border); border-radius: var(--issste-radius); }
|
||||||
h2 { font-size: 1.5rem; margin-top: 0; }
|
h2 { font-size: 1.25rem; font-weight: 500; margin-top: 0; }
|
||||||
h3 { font-size: 1.25rem; }
|
h3 { font-size: 1.25rem; }
|
||||||
h4 { font-size: 1rem; margin-bottom: .5rem; }
|
h4 { font-size: 1rem; margin-bottom: .5rem; }
|
||||||
section + section { border-top: 1px solid var(--issste-border); margin-top: var(--issste-space-6); padding-top: var(--issste-space-4); }
|
section + section { border-top: 1px solid var(--issste-border); margin-top: var(--issste-space-6); padding-top: var(--issste-space-4); }
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export class IndicadoresDefinitions {
|
|||||||
@Input() loading = false;
|
@Input() loading = false;
|
||||||
@Input() error = '';
|
@Input() error = '';
|
||||||
readonly retry = output<void>();
|
readonly retry = output<void>();
|
||||||
readonly domainNames: Record<Dominio, string> = { tea: 'TEA', cacu: 'cáncer cervicouterino', cama: 'CaMa' };
|
readonly domainNames: Record<Dominio, string> = { tea: 'TEA', cacu: 'cáncer cervicouterino', cama: 'cáncer de mama' };
|
||||||
readonly periodNames: Record<TipoPeriodo, string> = { semestre: 'Semestral', mes: 'Mensual' };
|
readonly periodNames: Record<TipoPeriodo, string> = { semestre: 'Semestral', mes: 'Mensual' };
|
||||||
readonly figureDisplayName = figureDisplayName;
|
readonly figureDisplayName = figureDisplayName;
|
||||||
readonly periodInterpretation = PERIOD_INTERPRETATION;
|
readonly periodInterpretation = PERIOD_INTERPRETATION;
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
import { IndicadorDatos, PlotlyFigure, Tema } from './indicadores.models';
|
import { DimensionEstrato, Dominio, Indicador, IndicadorDatos, PlotlyFigure, Tema, VistaEscenario } from './indicadores.models';
|
||||||
import { c2Theme } from './indicadores-c2-palette';
|
import { c2Theme } from './indicadores-c2-palette';
|
||||||
import { percentNumber, shareText } from './indicadores-format';
|
import { percentNumber, shareText } from './indicadores-format';
|
||||||
|
|
||||||
// Adapted from entregable_eu7_dona_escenario/eu7-dona-escenario.ts.
|
// Adapted from entregable_eu7_dona_escenario/eu7-dona-escenario.ts.
|
||||||
// This boundary is intentionally specific to EU7. Unknown cells never become zero.
|
// A C2 distribution with category groups, next to the same categories by one stratum. Unknown cells never become zero.
|
||||||
export const ESTRATO = 'estatus_seguimiento';
|
export const ESTRATO = 'estatus_seguimiento';
|
||||||
const SIN_DATO = 'SIN_DATO';
|
const SIN_DATO = 'SIN_DATO';
|
||||||
|
// CaCu's EU7 predates the catalog's `escenario` field.
|
||||||
|
const EU7: VistaEscenario = { estrato: ESTRATO, etiqueta: 'escenario clínico' };
|
||||||
|
export function vistaEscenario(dominio: Dominio, indicador: Indicador): VistaEscenario | undefined {
|
||||||
|
if (indicador.escenario) return indicador.escenario;
|
||||||
|
return dominio === 'cacu' && indicador.id === 'cacu_eu7' ? EU7 : undefined;
|
||||||
|
}
|
||||||
|
export const esEu7 = (vista: VistaEscenario) => vista === EU7;
|
||||||
export interface Seleccion { grupo?: string; categoria?: string; }
|
export interface Seleccion { grupo?: string; categoria?: string; }
|
||||||
export interface Categoria { id: string; etiqueta: string; color: string; grupo: string; }
|
export interface Categoria { id: string; etiqueta: string; color: string; grupo: string; }
|
||||||
export interface Grupo { id: string; etiqueta: string; color: string; }
|
export interface Grupo { id: string; etiqueta: string; color: string; }
|
||||||
@@ -64,7 +71,7 @@ function catalogo(data: IndicadorDatos): Categoria[] {
|
|||||||
/** Validate the common temporal scope before exposing any period's figures. */
|
/** Validate the common temporal scope before exposing any period's figures. */
|
||||||
export function periodosCompatibles(general: IndicadorDatos, escenarios: IndicadorDatos, tipo: string, solicitados?: readonly string[]): string[] {
|
export function periodosCompatibles(general: IndicadorDatos, escenarios: IndicadorDatos, tipo: string, solicitados?: readonly string[]): string[] {
|
||||||
for (const d of [general, escenarios]) {
|
for (const d of [general, escenarios]) {
|
||||||
if (d.id !== 'cacu_eu7' || d.contrato !== 'C2' || d.tipo_periodo !== tipo || !Array.isArray(d.periodos)
|
if (d.id !== general.id || d.contrato !== 'C2' || d.tipo_periodo !== tipo || !Array.isArray(d.periodos)
|
||||||
|| new Set(d.periodos).size !== d.periodos.length || d.periodos.some(p => typeof p !== 'string'
|
|| new Set(d.periodos).size !== d.periodos.length || d.periodos.some(p => typeof p !== 'string'
|
||||||
|| !(tipo === 'semestre' ? /^[0-9]{4}-S[12]$/ : /^[0-9]{4}-(0[1-9]|1[0-2])$/).test(p))
|
|| !(tipo === 'semestre' ? /^[0-9]{4}-S[12]$/ : /^[0-9]{4}-(0[1-9]|1[0-2])$/).test(p))
|
||||||
|| !Array.isArray(d.filas) || d.filas.some(f => !registro(f) || !d.periodos.includes(f['periodo'] as string))) {
|
|| !Array.isArray(d.filas) || d.filas.some(f => !registro(f) || !d.periodos.includes(f['periodo'] as string))) {
|
||||||
@@ -80,10 +87,10 @@ export function periodosCompatibles(general: IndicadorDatos, escenarios: Indicad
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Two immutable /datos payloads -> one safe presentation model for a single period. */
|
/** Two immutable /datos payloads -> one safe presentation model for a single period. */
|
||||||
export function modelo(general: IndicadorDatos, porEscenario: IndicadorDatos, periodo: string): Modelo {
|
export function modelo(general: IndicadorDatos, porEscenario: IndicadorDatos, periodo: string, estrato: DimensionEstrato = ESTRATO): Modelo {
|
||||||
periodosCompatibles(general, porEscenario, general.tipo_periodo);
|
periodosCompatibles(general, porEscenario, general.tipo_periodo);
|
||||||
const valores = porEscenario['valores_estrato'], etiquetas = porEscenario['etiquetas_estrato'];
|
const valores = porEscenario['valores_estrato'], etiquetas = porEscenario['etiquetas_estrato'];
|
||||||
if ((general['estrato'] ?? null) !== null || porEscenario['estrato'] !== ESTRATO || !general.periodos.includes(periodo)
|
if ((general['estrato'] ?? null) !== null || porEscenario['estrato'] !== estrato || !general.periodos.includes(periodo)
|
||||||
|| !Array.isArray(valores) || !valores.every(v => typeof v === 'string') || new Set(valores).size !== valores.length
|
|| !Array.isArray(valores) || !valores.every(v => typeof v === 'string') || new Set(valores).size !== valores.length
|
||||||
|| !registro(etiquetas) || valores.some(v => typeof etiquetas[v] !== 'string')
|
|| !registro(etiquetas) || valores.some(v => typeof etiquetas[v] !== 'string')
|
||||||
|| [general, porEscenario].some(d => registro(d['filtros']) ? Object.keys(d['filtros']).length > 0 : d['filtros'] != null)) {
|
|| [general, porEscenario].some(d => registro(d['filtros']) ? Object.keys(d['filtros']).length > 0 : d['filtros'] != null)) {
|
||||||
@@ -212,7 +219,7 @@ export function dona(m: Modelo, sel: Seleccion, tema: Tema): PlotlyFigure {
|
|||||||
config: { displayModeBar: false } };
|
config: { displayModeBar: false } };
|
||||||
}
|
}
|
||||||
/** Selection never changes the original denominator or renormalizes a subset. */
|
/** Selection never changes the original denominator or renormalizes a subset. */
|
||||||
export function barras(m: Modelo, sel: Seleccion, tema: Tema): PlotlyFigure {
|
export function barras(m: Modelo, sel: Seleccion, tema: Tema, eje = '% de pacientes del escenario con resultado'): PlotlyFigure {
|
||||||
const p = c2Theme(tema);
|
const p = c2Theme(tema);
|
||||||
const visibles = sel.categoria ? [sel.categoria] : sel.grupo ? hijas(m, sel.grupo).map(c => c.id) : m.categorias.map(c => c.id);
|
const visibles = sel.categoria ? [sel.categoria] : sel.grupo ? hijas(m, sel.grupo).map(c => c.id) : m.categorias.map(c => c.id);
|
||||||
const y = m.escenarios.map(s => escapar(s.etiqueta));
|
const y = m.escenarios.map(s => escapar(s.etiqueta));
|
||||||
@@ -235,7 +242,7 @@ export function barras(m: Modelo, sel: Seleccion, tema: Tema): PlotlyFigure {
|
|||||||
paper_bgcolor: p.background, plot_bgcolor: p.background, font: { color: p.text },
|
paper_bgcolor: p.background, plot_bgcolor: p.background, font: { color: p.text },
|
||||||
margin: { t: 24, l: 150, r: 72, b: 64 }, showlegend: false,
|
margin: { t: 24, l: 150, r: 72, b: 64 }, showlegend: false,
|
||||||
yaxis: { type: 'category', autorange: 'reversed', categoryorder: 'array', categoryarray: y, automargin: true },
|
yaxis: { type: 'category', autorange: 'reversed', categoryorder: 'array', categoryarray: y, automargin: true },
|
||||||
xaxis: { title: { text: '% de pacientes del escenario con resultado' }, ticksuffix: ' %', gridcolor: p.grid,
|
xaxis: { title: { text: eje }, ticksuffix: ' %', gridcolor: p.grid,
|
||||||
range: sel.grupo || sel.categoria ? [0, Math.max(...sumas.filter((v): v is number => v !== null), 1) * 1.35] : [0, 112],
|
range: sel.grupo || sel.categoria ? [0, Math.max(...sumas.filter((v): v is number => v !== null), 1) * 1.35] : [0, 112],
|
||||||
tickvals: sel.grupo || sel.categoria ? undefined : [0, 20, 40, 60, 80, 100] },
|
tickvals: sel.grupo || sel.categoria ? undefined : [0, 20, 40, 60, 80, 100] },
|
||||||
annotations: m.escenarios.map((s, i) => ({ y: y[i], x: sumas[i] ?? 0, xanchor: 'left', xshift: 6, showarrow: false,
|
annotations: m.escenarios.map((s, i) => ({ y: y[i], x: sumas[i] ?? 0, xanchor: 'left', xshift: 6, showarrow: false,
|
||||||
|
|||||||
@@ -126,12 +126,12 @@ describe('Pestaña Histórico', () => {
|
|||||||
it('cada intervalo se consulta una vez y cambiar de tema no vuelve a consultar', () => {
|
it('cada intervalo se consulta una vez y cambiar de tema no vuelve a consultar', () => {
|
||||||
abrir();
|
abrir();
|
||||||
http.expectOne(r => r.url === datosUrl).flush(datos('mes', ['2024-01', '2024-02'])); render();
|
http.expectOne(r => r.url === datosUrl).flush(datos('mes', ['2024-01', '2024-02'])); render();
|
||||||
fixture.componentInstance.tipo.set('semestre'); render();
|
fixture.componentInstance.elegido.set('semestre'); render();
|
||||||
const semestre = http.expectOne(r => r.url === datosUrl);
|
const semestre = http.expectOne(r => r.url === datosUrl);
|
||||||
expect(semestre.request.params.get('periodos')).toBe('2024-S1');
|
expect(semestre.request.params.get('periodos')).toBe('2024-S1');
|
||||||
semestre.flush(datos('semestre', ['2024-S1'])); render();
|
semestre.flush(datos('semestre', ['2024-S1'])); render();
|
||||||
expect(fixture.nativeElement.querySelector('.rango').textContent).toBe('2024 S1 (1 semestre)');
|
expect(fixture.nativeElement.querySelector('.rango').textContent).toBe('2024 S1 (1 semestre)');
|
||||||
fixture.componentInstance.tipo.set('mes'); render();
|
fixture.componentInstance.elegido.set('mes'); render();
|
||||||
fixture.componentRef.setInput('tema', 'oscuro'); render();
|
fixture.componentRef.setInput('tema', 'oscuro'); render();
|
||||||
http.expectNone(() => true);
|
http.expectNone(() => true);
|
||||||
});
|
});
|
||||||
@@ -147,11 +147,11 @@ describe('Pestaña Histórico', () => {
|
|||||||
c.elegirVentana(5); render();
|
c.elegirVentana(5); render();
|
||||||
expect(fixture.nativeElement.querySelector('.rango').textContent).toBe('ago 2024 a dic 2024 (5 meses)');
|
expect(fixture.nativeElement.querySelector('.rango').textContent).toBe('ago 2024 a dic 2024 (5 meses)');
|
||||||
http.expectNone(() => true);
|
http.expectNone(() => true);
|
||||||
c.tipo.set('semestre'); render();
|
c.elegido.set('semestre'); render();
|
||||||
expect(c.ventana()).toBe(0);
|
expect(c.ventana()).toBe(0);
|
||||||
http.expectOne(r => r.url === datosUrl).flush(datos('semestre', semestres)); render();
|
http.expectOne(r => r.url === datosUrl).flush(datos('semestre', semestres)); render();
|
||||||
expect(c.opciones().map(o => o.etiqueta)).toEqual(['Últimos 5 semestres', 'Todos (6 semestres)', 'Personalizado…']);
|
expect(c.opciones().map(o => o.etiqueta)).toEqual(['Últimos 5 semestres', 'Todos (6 semestres)', 'Personalizado…']);
|
||||||
c.tipo.set('mes'); render();
|
c.elegido.set('mes'); render();
|
||||||
expect(c.ventana()).toBe(5);
|
expect(c.ventana()).toBe(5);
|
||||||
http.expectNone(() => true);
|
http.expectNone(() => true);
|
||||||
});
|
});
|
||||||
@@ -191,10 +191,10 @@ describe('Pestaña Histórico', () => {
|
|||||||
expect(c.opciones().at(-1)!.etiqueta).toBe('Personalizado (1 mes)');
|
expect(c.opciones().at(-1)!.etiqueta).toBe('Personalizado (1 mes)');
|
||||||
expect(fixture.nativeElement.querySelector('.rango').textContent).toBe('feb 2024 (1 mes, elegidos)');
|
expect(fixture.nativeElement.querySelector('.rango').textContent).toBe('feb 2024 (1 mes, elegidos)');
|
||||||
// The other granularity keeps its own choice.
|
// The other granularity keeps its own choice.
|
||||||
c.tipo.set('semestre'); render();
|
c.elegido.set('semestre'); render();
|
||||||
expect(c.ventana()).toBe(0);
|
expect(c.ventana()).toBe(0);
|
||||||
http.expectOne(r => r.url === datosUrl).flush(datos_('semestre', ['2024-S1'])); render();
|
http.expectOne(r => r.url === datosUrl).flush(datos_('semestre', ['2024-S1'])); render();
|
||||||
c.tipo.set('mes'); render();
|
c.elegido.set('mes'); render();
|
||||||
expect(c.ventana()).toBe(-1);
|
expect(c.ventana()).toBe(-1);
|
||||||
http.expectNone(() => true);
|
http.expectNone(() => true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -51,9 +51,9 @@ function agrupar(paneles: (Panel & { datos?: IndicadorDatos })[], tema: Tema): P
|
|||||||
template: `
|
template: `
|
||||||
<div class="controles">
|
<div class="controles">
|
||||||
<span id="historico-intervalo">Intervalo de análisis</span>
|
<span id="historico-intervalo">Intervalo de análisis</span>
|
||||||
<mat-button-toggle-group aria-labelledby="historico-intervalo" hideSingleSelectionIndicator [value]="tipo()" (change)="tipo.set($event.value)">
|
<mat-button-toggle-group aria-labelledby="historico-intervalo" hideSingleSelectionIndicator [value]="tipo()" (change)="elegido.set($event.value)">
|
||||||
<mat-button-toggle value="mes">Mensual</mat-button-toggle>
|
@if (tipos().includes('mes')) { <mat-button-toggle value="mes">Mensual</mat-button-toggle> }
|
||||||
<mat-button-toggle value="semestre">Semestral</mat-button-toggle>
|
@if (tipos().includes('semestre')) { <mat-button-toggle value="semestre">Semestral</mat-button-toggle> }
|
||||||
</mat-button-toggle-group>
|
</mat-button-toggle-group>
|
||||||
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
||||||
<mat-label>Periodos a mostrar</mat-label>
|
<mat-label>Periodos a mostrar</mat-label>
|
||||||
@@ -123,7 +123,13 @@ export class IndicadoresHistorico {
|
|||||||
readonly catalog = input.required<readonly Indicador[]>();
|
readonly catalog = input.required<readonly Indicador[]>();
|
||||||
readonly tema = input.required<Tema>();
|
readonly tema = input.required<Tema>();
|
||||||
readonly active = input(false);
|
readonly active = input(false);
|
||||||
readonly tipo = signal<TipoPeriodo>('mes');
|
// Only the granularities some indicator publishes; monthly first when there is one.
|
||||||
|
readonly tipos = computed(() => (['mes', 'semestre'] as const).filter(tipo => this.catalog().some(item => item.tipos_periodo.includes(tipo))));
|
||||||
|
readonly elegido = signal<TipoPeriodo | undefined>(undefined);
|
||||||
|
readonly tipo = computed<TipoPeriodo>(() => {
|
||||||
|
const elegido = this.elegido(), tipos = this.tipos();
|
||||||
|
return elegido && tipos.includes(elegido) ? elegido : tipos[0] ?? 'mes';
|
||||||
|
});
|
||||||
// How many of the latest periods to show, per granularity; 0 shows them all.
|
// How many of the latest periods to show, per granularity; 0 shows them all.
|
||||||
private readonly ventanas = signal<Partial<Record<TipoPeriodo, number>>>({});
|
private readonly ventanas = signal<Partial<Record<TipoPeriodo, number>>>({});
|
||||||
readonly ventana = computed(() => this.ventanas()[this.tipo()] ?? 0);
|
readonly ventana = computed(() => this.ventanas()[this.tipo()] ?? 0);
|
||||||
|
|||||||
@@ -16,10 +16,13 @@ import { Indicador } from './indicadores.models';
|
|||||||
|
|
||||||
@Component({ selector: 'app-plotly-chart', inputs: ['figure', 'label', 'showNotes'], template: '' })
|
@Component({ selector: 'app-plotly-chart', inputs: ['figure', 'label', 'showNotes'], template: '' })
|
||||||
class ChartStub {}
|
class ChartStub {}
|
||||||
|
// The period and anchor rules are pinned on CaMa's first three cards (C2, C1, C3r); the fourth follows the same
|
||||||
|
// rules (indicador-kpi-panel.spec.ts covers all four).
|
||||||
|
const KPIS = { ...KPI_BY_DOMAIN, cama: KPI_BY_DOMAIN.cama.slice(0, 3) };
|
||||||
describe.each(['tea', 'cacu', 'cama'] as const)('P0 autoridad temporal compartida de %s', domain => {
|
describe.each(['tea', 'cacu', 'cama'] as const)('P0 autoridad temporal compartida de %s', domain => {
|
||||||
let fixture: ReturnType<typeof TestBed.createComponent<IndicadoresPage>>, http: HttpTestingController, page: IndicadoresPage;
|
let fixture: ReturnType<typeof TestBed.createComponent<IndicadoresPage>>, http: HttpTestingController, page: IndicadoresPage;
|
||||||
const periods = ['2026-S2', '2026-S1', '2025-S2'];
|
const periods = ['2026-S2', '2026-S1', '2025-S2'];
|
||||||
const definitions = KPI_BY_DOMAIN[domain];
|
const definitions = KPIS[domain];
|
||||||
const otherDomain = domain === 'cacu' ? 'cama' : 'cacu';
|
const otherDomain = domain === 'cacu' ? 'cama' : 'cacu';
|
||||||
const items = [...definitions.map(d => ({ id: d.id, titulo: d.title, contrato: d.contrato, tipos_periodo: ['semestre'], figuras: ['f', 'g'] })),
|
const items = [...definitions.map(d => ({ id: d.id, titulo: d.title, contrato: d.contrato, tipos_periodo: ['semestre'], figuras: ['f', 'g'] })),
|
||||||
// Two figures, so every domain keeps an ordinary card whose representation can change.
|
// Two figures, so every domain keeps an ordinary card whose representation can change.
|
||||||
@@ -89,7 +92,7 @@ describe.each(['tea', 'cacu', 'cama'] as const)('P0 autoridad temporal compartid
|
|||||||
const ongoing = request(periods[0]);
|
const ongoing = request(periods[0]);
|
||||||
for (const section of ['seguimiento', 'datos', 'resumen', 'datos'] as const) {
|
for (const section of ['seguimiento', 'datos', 'resumen', 'datos'] as const) {
|
||||||
page.changeSection(section); fixture.detectChanges();
|
page.changeSection(section); fixture.detectChanges();
|
||||||
for (const req of http.match(r => r.url === '/cacu/seguimiento' || r.url === '/tea/seguimiento')) req.flush({}, { status: 404, statusText: 'Pending' });
|
for (const req of http.match(r => r.url.endsWith('/seguimiento'))) req.flush({}, { status: 404, statusText: 'Pending' });
|
||||||
expect(page.initialPeriodState()).toBe('loading');
|
expect(page.initialPeriodState()).toBe('loading');
|
||||||
expect(ongoing.cancelled).toBe(false);
|
expect(ongoing.cancelled).toBe(false);
|
||||||
http.expectNone(() => true);
|
http.expectNone(() => true);
|
||||||
@@ -109,7 +112,7 @@ describe.each(['tea', 'cacu', 'cama'] as const)('P0 autoridad temporal compartid
|
|||||||
editor().select([periods[2]]); fixture.detectChanges();
|
editor().select([periods[2]]); fixture.detectChanges();
|
||||||
for (let i = 0; i < 3; i++) for (const section of ['seguimiento', 'datos', 'resumen'] as const) {
|
for (let i = 0; i < 3; i++) for (const section of ['seguimiento', 'datos', 'resumen'] as const) {
|
||||||
page.changeSection(section); fixture.detectChanges();
|
page.changeSection(section); fixture.detectChanges();
|
||||||
for (const req of http.match(r => r.url === '/cacu/seguimiento' || r.url === '/tea/seguimiento')) req.flush({}, { status: 404, statusText: 'Pending' });
|
for (const req of http.match(r => r.url.endsWith('/seguimiento'))) req.flush({}, { status: 404, statusText: 'Pending' });
|
||||||
expect(page.filters).toBe(state); expect(page.filters!.applied).toBe(applied);
|
expect(page.filters).toBe(state); expect(page.filters!.applied).toBe(applied);
|
||||||
expect(editor().selectedPeriods).toEqual([periods[2]]);
|
expect(editor().selectedPeriods).toEqual([periods[2]]);
|
||||||
expect(cards()).toContain(card); expect(card.selectedFigure).toBe('g');
|
expect(cards()).toContain(card); expect(card.selectedFigure).toBe('g');
|
||||||
@@ -224,7 +227,7 @@ describe.each(['tea', 'cacu', 'cama'] as const)('P0 autoridad temporal compartid
|
|||||||
const catalogs = new Map<string, typeof items>([[domain, items]]);
|
const catalogs = new Map<string, typeof items>([[domain, items]]);
|
||||||
for (const target of ['tea', 'cacu', 'cama'] as const) {
|
for (const target of ['tea', 'cacu', 'cama'] as const) {
|
||||||
if (target === domain) continue;
|
if (target === domain) continue;
|
||||||
const definitions = KPI_BY_DOMAIN[target];
|
const definitions = KPIS[target];
|
||||||
const period = own.size === 1 ? '2024-S2' : '2025-S1';
|
const period = own.size === 1 ? '2024-S2' : '2025-S1';
|
||||||
own.set(target, period);
|
own.set(target, period);
|
||||||
const catalog = definitions.map(d => ({ id: d.id, titulo: d.title, contrato: d.contrato, tipos_periodo: ['semestre'], figuras: ['f'] }));
|
const catalog = definitions.map(d => ({ id: d.id, titulo: d.title, contrato: d.contrato, tipos_periodo: ['semestre'], figuras: ['f'] }));
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ describe.each(['cacu', 'cama'] as const)('P0 búsqueda del ancla C2 de %s', doma
|
|||||||
if (domain === 'cama') {
|
if (domain === 'cama') {
|
||||||
expect(anchor.id).toBe('cama_birads_456_paciente');
|
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 y 6');
|
||||||
expect(KPI_BY_DOMAIN.cama.map(d => d.id)).toEqual(['cama_birads_456_paciente', 'cama_confirmacion_birads45', 'cama_dias_toma_diagnostico']);
|
expect(KPI_BY_DOMAIN.cama.map(d => d.id)).toEqual(['cama_birads_456_paciente', 'cama_tasa_deteccion_histopatologica',
|
||||||
|
'cama_eu38a', 'cama_dias_resultado_diagnostico']);
|
||||||
} else expect(anchor.id).toBe('cacu_eu7');
|
} else expect(anchor.id).toBe('cacu_eu7');
|
||||||
const run = start(); inventory(); request(periods[0]).flush(data(periods[0]));
|
const run = start(); inventory(); request(periods[0]).flush(data(periods[0]));
|
||||||
expect(run.selected()?.periodo).toBe(periods[0]);
|
expect(run.selected()?.periodo).toBe(periods[0]);
|
||||||
|
|||||||
@@ -129,7 +129,15 @@ const DATOS_2025_S2: Record<string, IndicadorDatos> = {
|
|||||||
|
|
||||||
describe('KPI de CaMa con respuestas reales de WebApi', () => {
|
describe('KPI de CaMa con respuestas reales de WebApi', () => {
|
||||||
const applied = { tipo: 'semestre' as const, selection: { mode: 'explicit' as const, periodos: ['2025-S2'] as [string] }, revision: 0 };
|
const applied = { tipo: 'semestre' as const, selection: { mode: 'explicit' as const, periodos: ['2025-S2'] as [string] }, revision: 0 };
|
||||||
const result = (index: number) => kpiResult(DATOS_2025_S2[KPI_BY_DOMAIN.cama[index].id], KPI_BY_DOMAIN.cama[index], 'cama', applied);
|
// The card of each real answer; confirmación and tamizaje a diagnóstico are no longer cards, so theirs is
|
||||||
|
// built from the answer, to keep checking the C1 and C3r rules on real data.
|
||||||
|
const ids = Object.keys(DATOS_2025_S2);
|
||||||
|
const result = (index: number) => {
|
||||||
|
const data = DATOS_2025_S2[ids[index]];
|
||||||
|
const definition = KPI_BY_DOMAIN.cama.find(d => d.id === ids[index])
|
||||||
|
?? { id: data.id, title: data.id, contrato: data.contrato as 'C1' | 'C3r', unit: '' };
|
||||||
|
return kpiResult(data, definition, 'cama', applied);
|
||||||
|
};
|
||||||
|
|
||||||
it('pacientes evaluadas con BI-RADS 4, 5 y 6: la suma de sus categorías', () => {
|
it('pacientes evaluadas con BI-RADS 4, 5 y 6: la suma de sus categorías', () => {
|
||||||
expect(result(0)).toEqual(expect.objectContaining({ state: 'Disponible', value: 31 }));
|
expect(result(0)).toEqual(expect.objectContaining({ state: 'Disponible', value: 31 }));
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ const applied: GlobalApplied = { tipo: 'semestre', selection: { mode: 'explicit'
|
|||||||
const total = { periodo: '2025-S1', grupo: 'TOTAL', estrato: null, suprimido: 0 };
|
const total = { periodo: '2025-S1', grupo: 'TOTAL', estrato: null, suprimido: 0 };
|
||||||
// Keep C1 numerical-contract coverage even though CaCu no longer presents a C1 KPI.
|
// Keep C1 numerical-contract coverage even though CaCu no longer presents a C1 KPI.
|
||||||
const definitions = { ...KPI_BY_DOMAIN, cacu: [KPI_BY_DOMAIN.cacu[0],
|
const definitions = { ...KPI_BY_DOMAIN, cacu: [KPI_BY_DOMAIN.cacu[0],
|
||||||
{ id: 'cacu_eu13', title: 'Confirmación', contrato: 'C1', unit: '%' } as KpiDefinition, KPI_BY_DOMAIN.cacu[1]] };
|
{ id: 'cacu_eu13', title: 'Confirmación', contrato: 'C1', unit: '%' } as KpiDefinition, KPI_BY_DOMAIN.cacu[1]],
|
||||||
|
// One card of each contract, in the C2, C1, C3r order the tests index by.
|
||||||
|
cama: KPI_BY_DOMAIN.cama.slice(0, 3) };
|
||||||
function data(domain: Dominio, index: number, filas: Record<string, unknown>[]): IndicadorDatos {
|
function data(domain: Dominio, index: number, filas: Record<string, unknown>[]): IndicadorDatos {
|
||||||
const d = definitions[domain][index]; return { id: d.id, contrato: d.contrato, tipo_periodo: 'semestre', periodos: ['2025-S1'], categorias: Object.fromEntries(filas.filter(row => typeof row['categoria'] === 'string').map(row => [row['categoria'], {}])), filas };
|
const d = definitions[domain][index]; return { id: d.id, contrato: d.contrato, tipo_periodo: 'semestre', periodos: ['2025-S1'], categorias: Object.fromEntries(filas.filter(row => typeof row['categoria'] === 'string').map(row => [row['categoria'], {}])), filas };
|
||||||
}
|
}
|
||||||
@@ -67,3 +69,25 @@ it('TEA usa sus cinco indicadores destacados y su grupo C1 es TOTAL', () => {
|
|||||||
expect(kpiResult(data('tea', 1, [{ ...total, grupo: 'total', valor: 50, numerador: 3, denominador: 6 }]), KPI_BY_DOMAIN.tea[1], 'tea', applied).state)
|
expect(kpiResult(data('tea', 1, [{ ...total, grupo: 'total', valor: 50, numerador: 3, denominador: 6 }]), KPI_BY_DOMAIN.tea[1], 'tea', applied).state)
|
||||||
.toBe('Selección no consolidable');
|
.toBe('Selección no consolidable');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('KPI con intervalo de Wilson', () => {
|
||||||
|
const definition = KPI_BY_DOMAIN.cama.find(d => d.intervalo)!;
|
||||||
|
const run = (row: Record<string, unknown>) => kpiResult({ id: definition.id, contrato: 'C1', tipo_periodo: 'semestre', periodos: ['2025-S1'],
|
||||||
|
filas: [{ ...total, grupo: 'total', numerador: 129, denominador: 306, valor: 42.2, ...row }] }, definition, 'cama', applied);
|
||||||
|
it('lleva el intervalo publicado junto al valor', () => {
|
||||||
|
// Fails if the card stops receiving the published Wilson bounds, or recomputes them.
|
||||||
|
expect(run({ ic_bajo: 36.8, ic_alto: 47.8 }).intervalo).toEqual({ valor: 42.2, bajo: 36.8, alto: 47.8 });
|
||||||
|
});
|
||||||
|
it('no dibuja un intervalo ausente o que no contiene su valor', () => {
|
||||||
|
// Fails if missing or inconsistent bounds are drawn instead of omitted.
|
||||||
|
expect(run({}).intervalo).toBeUndefined();
|
||||||
|
expect(run({ ic_bajo: 45, ic_alto: 47.8 }).intervalo).toBeUndefined();
|
||||||
|
expect(run({ ic_bajo: 36.8, ic_alto: 47.8 }).value).toBe('42.2');
|
||||||
|
});
|
||||||
|
it('una tarjeta C1 que no lo pide no lo recibe', () => {
|
||||||
|
// Fails if the interval line leaks to cards that didn't ask for it.
|
||||||
|
const other: KpiDefinition = { id: 'cama_confirmacion_birads45', title: 'Confirmación', contrato: 'C1', unit: '%' };
|
||||||
|
expect(kpiResult({ id: other.id, contrato: 'C1', tipo_periodo: 'semestre', periodos: ['2025-S1'],
|
||||||
|
filas: [{ ...total, grupo: 'total', numerador: 1, denominador: 2, valor: 50, ic_bajo: 9, ic_alto: 91 }] }, other, 'cama', applied).intervalo).toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ export interface KpiDefinition {
|
|||||||
id: string; title: string; contrato: 'C1' | 'C2' | 'C3r'; unit: string; singleAppliedPeriod?: boolean;
|
id: string; title: string; contrato: 'C1' | 'C2' | 'C3r'; unit: string; singleAppliedPeriod?: boolean;
|
||||||
// C1 only: replaces the domain's explanatory line when the numerator is not the domain's usual one.
|
// C1 only: replaces the domain's explanatory line when the numerator is not the domain's usual one.
|
||||||
c1Info?: (numerador: number, denominador: number) => string;
|
c1Info?: (numerador: number, denominador: number) => string;
|
||||||
|
// C1 only: draw the published Wilson interval as a horizontal line under the value.
|
||||||
|
intervalo?: boolean;
|
||||||
}
|
}
|
||||||
// Same laboratory-result source used by PARES_TIEMPOS; diagnosis has its own ID.
|
// Same laboratory-result source used by PARES_TIEMPOS; diagnosis has its own ID.
|
||||||
export const CACU_RESULTADO_KPI: KpiDefinition = {
|
export const CACU_RESULTADO_KPI: KpiDefinition = {
|
||||||
@@ -37,8 +39,10 @@ export const KPI_BY_DOMAIN: Record<Dominio, KpiDefinition[]> = {
|
|||||||
],
|
],
|
||||||
cama: [
|
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 y 6', contrato: 'C2', unit: 'pacientes' },
|
||||||
{ id: 'cama_confirmacion_birads45', title: 'Tasa de confirmación histopatológica', contrato: 'C1', unit: '%' },
|
{ id: 'cama_tasa_deteccion_histopatologica', title: 'Tasa de detección histopatológica', contrato: 'C1', unit: '%', intervalo: true,
|
||||||
{ id: 'cama_dias_toma_diagnostico', title: 'Tiempo de tamizaje a diagnóstico', contrato: 'C3r', unit: 'días (mediana)' },
|
c1Info: (n, d) => `${n} de ${d} biopsias con resultado maligno.` },
|
||||||
|
{ id: 'cama_eu38a', title: 'Tiempo de tamizaje a resultado', contrato: 'C3r', unit: 'días (mediana)' },
|
||||||
|
{ id: 'cama_dias_resultado_diagnostico', title: 'Tiempo de resultado a diagnóstico', contrato: 'C3r', unit: 'días (mediana)' },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
// C1 rows of CaCu/CaMa carry the linkId `total`; TEA's ficha names its single group `TOTAL`.
|
// C1 rows of CaCu/CaMa carry the linkId `total`; TEA's ficha names its single group `TOTAL`.
|
||||||
@@ -48,12 +52,18 @@ const C1_INFO: Record<Dominio, (numerador: number, denominador: number) => strin
|
|||||||
cacu: (n, d) => `${n} de ${d} pacientes con lesión de alto grado o mayor en biopsia.`,
|
cacu: (n, d) => `${n} de ${d} pacientes con lesión de alto grado o mayor en biopsia.`,
|
||||||
cama: (n, d) => `${n} de ${d} mastografías BI-RADS 4 y 5 con reporte de biopsia.`,
|
cama: (n, d) => `${n} de ${d} mastografías BI-RADS 4 y 5 con reporte de biopsia.`,
|
||||||
};
|
};
|
||||||
|
const C2_INFO: Record<Dominio, string> = {
|
||||||
|
tea: 'Conteo de pacientes únicos en el periodo.',
|
||||||
|
cacu: 'Pacientes con citología tomada en el periodo.',
|
||||||
|
cama: 'Pacientes con mastografía BI-RADS 4, 5 o 6 en el periodo.',
|
||||||
|
};
|
||||||
const C3R_INFO: Record<Dominio, (n: number, q1: number, q3: number) => string> = {
|
const C3R_INFO: Record<Dominio, (n: number, q1: number, q3: number) => string> = {
|
||||||
tea: (n, q1, q3) => `${n} pacientes; Q1 a Q3: ${q1} a ${q3} días.`,
|
tea: (n, q1, q3) => `${n} pacientes; Q1 a Q3: ${q1} a ${q3} días.`,
|
||||||
cacu: (n, q1, q3) => `${n} citologías; primer cuartil: ${q1} días; tercer cuartil: ${q3} días.`,
|
cacu: (n, q1, q3) => `${n} citologías; primer cuartil: ${q1} días; tercer cuartil: ${q3} días.`,
|
||||||
cama: (n, q1, q3) => `${n} mastografías; Q1 a Q3: ${q1} a ${q3} días.`,
|
cama: (n, q1, q3) => `${n} mastografías; Q1 a Q3: ${q1} a ${q3} días.`,
|
||||||
};
|
};
|
||||||
export interface KpiResult { state: string; value?: string | number; info?: string; loading?: boolean; notes?: string[]; categorias?: Record<string, number>; }
|
export interface KpiIntervalo { valor: number; bajo: number; alto: number; }
|
||||||
|
export interface KpiResult { state: string; value?: string | number; info?: string; loading?: boolean; notes?: string[]; categorias?: Record<string, number>; intervalo?: KpiIntervalo; }
|
||||||
const finite = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v);
|
const finite = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v);
|
||||||
const count = (v: unknown): v is number => finite(v) && Number.isSafeInteger(v) && v >= 0;
|
const count = (v: unknown): v is number => finite(v) && Number.isSafeInteger(v) && v >= 0;
|
||||||
const unscoped = { state: 'Selección no consolidable', info: 'Elige un único periodo. No hay una regla aprobada para consolidar periodos, grupos o estratos.' };
|
const unscoped = { state: 'Selección no consolidable', info: 'Elige un único periodo. No hay una regla aprobada para consolidar periodos, grupos o estratos.' };
|
||||||
@@ -88,11 +98,16 @@ export function kpiResult(data: IndicadorDatos, definition: KpiDefinition, domai
|
|||||||
if (!rows.every(row => count(row['n']))) return empty;
|
if (!rows.every(row => count(row['n']))) return empty;
|
||||||
const value = rows.reduce((sum, row) => sum + (row['n'] as number), 0);
|
const value = rows.reduce((sum, row) => sum + (row['n'] as number), 0);
|
||||||
if (!count(value)) return empty;
|
if (!count(value)) return empty;
|
||||||
return { state: 'Disponible', value, categorias: Object.fromEntries(rows.map(row => [row['categoria'] as string, row['n'] as number])), info: domain === 'cacu' ? 'Pacientes con citología tomada en el periodo.' : 'Conteo de pacientes únicos en el periodo.' };
|
return { state: 'Disponible', value, categorias: Object.fromEntries(rows.map(row => [row['categoria'] as string, row['n'] as number])), info: C2_INFO[domain] };
|
||||||
}
|
}
|
||||||
if (definition.contrato === 'C1') {
|
if (definition.contrato === 'C1') {
|
||||||
if (!finite(row['valor']) || row['valor'] < 0 || row['valor'] > 100 || !count(row['numerador']) || !count(row['denominador']) || row['numerador'] > row['denominador']) return empty;
|
if (!finite(row['valor']) || row['valor'] < 0 || row['valor'] > 100 || !count(row['numerador']) || !count(row['denominador']) || row['numerador'] > row['denominador']) return empty;
|
||||||
return { state: 'Disponible', value: percentNumber(row['valor']), info: (definition.c1Info ?? C1_INFO[domain])(row['numerador'], row['denominador']) };
|
const info = (definition.c1Info ?? C1_INFO[domain])(row['numerador'], row['denominador']);
|
||||||
|
const [bajo, alto, valor] = [row['ic_bajo'], row['ic_alto'], row['valor']];
|
||||||
|
// An interval that doesn't contain its value is not drawn rather than drawn wrong.
|
||||||
|
const intervalo = definition.intervalo && finite(bajo) && finite(alto) && 0 <= bajo && bajo <= valor && valor <= alto && alto <= 100
|
||||||
|
? { valor, bajo, alto } : undefined;
|
||||||
|
return { state: 'Disponible', value: percentNumber(valor), info, ...(intervalo ? { intervalo } : {}) };
|
||||||
}
|
}
|
||||||
if (!finite(row['mediana']) || !count(row['n']) || (definition.id === CACU_RESULTADO_KPI.id && row['n'] === 0) || !finite(row['q1']) || !finite(row['q3']) || row['q1'] < 0 || row['q1'] > row['mediana'] || row['mediana'] > row['q3'] || row['unidad'] !== 'dias') return empty;
|
if (!finite(row['mediana']) || !count(row['n']) || (definition.id === CACU_RESULTADO_KPI.id && row['n'] === 0) || !finite(row['q1']) || !finite(row['q3']) || row['q1'] < 0 || row['q1'] > row['mediana'] || row['mediana'] > row['q3'] || row['unidad'] !== 'dias') return empty;
|
||||||
return { state: 'Disponible', value: row['mediana'], info: C3R_INFO[domain](row['n'], row['q1'], row['q3']) };
|
return { state: 'Disponible', value: row['mediana'], info: C3R_INFO[domain](row['n'], row['q1'], row['q3']) };
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ describe('UX-04 navegación Angular', () => {
|
|||||||
const harness = await setup();
|
const harness = await setup();
|
||||||
await harness.navigateByUrl('/indicadores/' + domain, IndicadoresPage);
|
await harness.navigateByUrl('/indicadores/' + domain, IndicadoresPage);
|
||||||
load(domain, harness); harness.detectChanges();
|
load(domain, harness); harness.detectChanges();
|
||||||
// Our shell keeps the domain nav on the page itself, see indicadores-page.html.
|
// Domain switching lives in the App header (app.spec.ts); the page must not add a second one.
|
||||||
expect(harness.routeNativeElement!.querySelectorAll('nav.domain-nav a')).toHaveLength(3);
|
expect(harness.routeNativeElement!.querySelectorAll('nav.domain-nav a')).toHaveLength(0);
|
||||||
http.expectNone(() => true);
|
http.expectNone(() => true);
|
||||||
});
|
});
|
||||||
it('mantiene la ruta, restaura borradores y reconsulta la aplicación entre TEA/CaCu/CaMa', async () => {
|
it('mantiene la ruta, restaura borradores y reconsulta la aplicación entre TEA/CaCu/CaMa', async () => {
|
||||||
|
|||||||
@@ -10,14 +10,6 @@
|
|||||||
}
|
}
|
||||||
</header>
|
</header>
|
||||||
@if (!fichaPacienteAbierta()) {
|
@if (!fichaPacienteAbierta()) {
|
||||||
<!-- Upstream moved domain switching into its own app shell's header (a
|
|
||||||
dropdown in app.ts/app.html); our shell is shared with other workspace
|
|
||||||
sections (Conectar, Gobernanza) so it stays here instead, same as before. -->
|
|
||||||
<nav aria-label="Dominios de indicadores" class="domain-nav">
|
|
||||||
@for (domain of dominios; track domain) {
|
|
||||||
<a mat-button [routerLink]="['/indicadores', domain]" [attr.aria-current]="dominio === domain ? 'page' : null">{{ domainNavLabels[domain] }}</a>
|
|
||||||
}
|
|
||||||
</nav>
|
|
||||||
<div class="section-tabs" [class.dark-theme]="tema === 'oscuro'" role="tablist" [attr.aria-label]="'Secciones de ' + domainLabels[dominio]" (keydown)="sectionKeydown($event)">
|
<div class="section-tabs" [class.dark-theme]="tema === 'oscuro'" role="tablist" [attr.aria-label]="'Secciones de ' + domainLabels[dominio]" (keydown)="sectionKeydown($event)">
|
||||||
@for (section of sections; track section.id) {
|
@for (section of sections; track section.id) {
|
||||||
<button type="button" role="tab" [id]="'tab-' + section.id" [attr.aria-controls]="'panel-' + section.id"
|
<button type="button" role="tab" [id]="'tab-' + section.id" [attr.aria-controls]="'panel-' + section.id"
|
||||||
@@ -31,7 +23,7 @@
|
|||||||
@if (!catalogLoading() && filters; as state) {
|
@if (!catalogLoading() && filters; as state) {
|
||||||
<section class="global-filters" aria-labelledby="global-filters-title" [attr.data-domain]="dominio">
|
<section class="global-filters" aria-labelledby="global-filters-title" [attr.data-domain]="dominio">
|
||||||
<h2 id="global-filters-title" class="section-title">Filtros generales de {{ domainLabels[dominio] }}</h2>
|
<h2 id="global-filters-title" class="section-title">Filtros generales de {{ domainLabels[dominio] }}</h2>
|
||||||
<p class="section-description">{{ dominio === 'cacu' ? 'La selección se aplica a los indicadores de oportunidad y las gráficas, salvo las que indican selección independiente: Todos con reporte.' : 'La selección aplicada se comparte entre las figuras y los indicadores destacados de este proyecto.' }}</p>
|
<p class="section-description">{{ dominio === 'tea' ? 'Se aplica a las figuras y los indicadores destacados.' : 'Se aplica a los indicadores de oportunidad y las gráficas, salvo las de selección independiente.' }}</p>
|
||||||
<app-indicador-period-filters [state]="state" [types]="filterTypes()" [availability]="availability()" [initialPresentation]="initialPeriodBlocked"
|
<app-indicador-period-filters [state]="state" [types]="filterTypes()" [availability]="availability()" [initialPresentation]="initialPeriodBlocked"
|
||||||
(retryAvailability)="retryAvailability()"
|
(retryAvailability)="retryAvailability()"
|
||||||
(edited)="editFilters()" (apply)="applyFilters()" />
|
(edited)="editFilters()" (apply)="applyFilters()" />
|
||||||
@@ -56,7 +48,7 @@
|
|||||||
@if (kpis.length && !initialPeriodBlocked) {
|
@if (kpis.length && !initialPeriodBlocked) {
|
||||||
<section class="kpi-section" aria-labelledby="kpi-section-title" [attr.data-domain]="dominio">
|
<section class="kpi-section" aria-labelledby="kpi-section-title" [attr.data-domain]="dominio">
|
||||||
@let resumen = teaResumenPeriodo;
|
@let resumen = teaResumenPeriodo;
|
||||||
<h2 id="kpi-section-title" class="section-title">{{ dominio === 'cacu' ? 'Indicadores de oportunidad' : resumen ? 'Resumen' : 'Indicadores destacados' }}</h2>
|
<h2 id="kpi-section-title" class="section-title">{{ dominio !== 'tea' ? 'Indicadores de oportunidad' : resumen ? 'Resumen' : 'Indicadores destacados' }}</h2>
|
||||||
@if (resumen) { <app-tea-resumen-periodo [periodo]="resumen" [paneles]="kpiPanels()" /> }
|
@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. -->
|
<!-- 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 : 0)">
|
||||||
@@ -74,7 +66,7 @@
|
|||||||
|
|
||||||
<section class="graphic-section" aria-labelledby="graphic-section-title">
|
<section class="graphic-section" aria-labelledby="graphic-section-title">
|
||||||
<div class="catalog-heading">
|
<div class="catalog-heading">
|
||||||
<h2 id="graphic-section-title" class="section-title">{{ dominio === 'cacu' ? 'Indicadores clínicos' : 'Indicadores gráficos' }}</h2>
|
<h2 id="graphic-section-title" class="section-title">{{ dominio !== 'tea' ? 'Indicadores clínicos' : 'Indicadores gráficos' }}</h2>
|
||||||
@if (!catalogLoading() && !catalogError() && catalog().length) {
|
@if (!catalogLoading() && !catalogError() && catalog().length) {
|
||||||
<p class="catalog-count" role="status">{{ catalogOrder().length }} indicadores publicados</p>
|
<p class="catalog-count" role="status">{{ catalogOrder().length }} indicadores publicados</p>
|
||||||
}
|
}
|
||||||
@@ -127,7 +119,7 @@
|
|||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (dominio === 'tea') {
|
@if (conHistorico) {
|
||||||
<section id="panel-historico" class="section-panel" [class.dark-theme]="tema === 'oscuro'" role="tabpanel" aria-labelledby="tab-historico" tabindex="0" [hidden]="activeSection() !== 'historico'">
|
<section id="panel-historico" class="section-panel" [class.dark-theme]="tema === 'oscuro'" role="tabpanel" aria-labelledby="tab-historico" tabindex="0" [hidden]="activeSection() !== 'historico'">
|
||||||
<app-indicadores-historico [dominio]="dominio" [catalog]="catalog()" [tema]="tema" [active]="activeSection() === 'historico'" />
|
<app-indicadores-historico [dominio]="dominio" [catalog]="catalog()" [tema]="tema" [active]="activeSection() === 'historico'" />
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -4,39 +4,11 @@
|
|||||||
// The workspace shell clips overflow, so the page scrolls itself.
|
// The workspace shell clips overflow, so the page scrolls itself.
|
||||||
:host { display: block; flex: 1; min-width: 0; min-height: 0; overflow-y: auto; padding: 0 var(--space-6) var(--space-7); }
|
:host { display: block; flex: 1; min-width: 0; min-height: 0; overflow-y: auto; padding: 0 var(--space-6) var(--space-7); }
|
||||||
.dashboard { max-width: 1440px; margin: 0 auto; min-width: 0; container: dashboard / inline-size; }
|
.dashboard { max-width: 1440px; margin: 0 auto; min-width: 0; container: dashboard / inline-size; }
|
||||||
h1 { font: var(--mat-sys-headline-large); font-family: var(--issste-font-heading); font-weight: 700; margin: .65rem 0; }
|
h1 { font-family: var(--issste-font-heading); font-size: 1.75rem; font-weight: 500; line-height: 1.25; letter-spacing: 0; margin: .5rem 0; }
|
||||||
header p { color: var(--mat-sys-on-surface-variant); margin-bottom: 1.5rem; }
|
header p { color: var(--mat-sys-on-surface-variant); margin-bottom: 1.5rem; }
|
||||||
.domain { color: var(--mat-sys-primary); font: var(--mat-sys-label-large); }
|
.domain { color: var(--mat-sys-primary); font: var(--mat-sys-label-large); }
|
||||||
// Kept here (not moved to our app shell, see the template comment above the
|
|
||||||
// nav) -- same rules as before upstream relocated its own copy into app.scss.
|
|
||||||
.domain-nav {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: var(--issste-space-2);
|
|
||||||
padding: var(--issste-space-2);
|
|
||||||
justify-content: center;
|
|
||||||
margin: var(--issste-space-4) 0;
|
|
||||||
border-radius: var(--issste-radius);
|
|
||||||
}
|
|
||||||
.domain-nav a {
|
|
||||||
flex: 0 1 6rem;
|
|
||||||
max-width: 10rem;
|
|
||||||
color: var(--issste-text);
|
|
||||||
border: 1px solid var(--issste-border);
|
|
||||||
background: var(--issste-surface);
|
|
||||||
min-height: 44px;
|
|
||||||
border-radius: var(--issste-radius);
|
|
||||||
}
|
|
||||||
.domain-nav a[aria-current='page'] {
|
|
||||||
background: var(--issste-accent);
|
|
||||||
font-weight: 700;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
@media (max-width: 550px) {
|
|
||||||
.domain-nav { gap: var(--issste-space-2); padding-inline: 0; }
|
|
||||||
}
|
|
||||||
.state { padding: 1.25rem; margin: 0; }
|
.state { padding: 1.25rem; margin: 0; }
|
||||||
.section-title { font-family: var(--issste-font-heading); font-size: 1.5rem; line-height: 1.3; margin: 0; overflow-wrap: anywhere; }
|
.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; }
|
.section-description { color: var(--issste-text-secondary); margin: var(--issste-space-2) 0 var(--issste-space-4); overflow-wrap: anywhere; }
|
||||||
.kpi-section, .graphic-section { min-width: 0; }
|
.kpi-section, .graphic-section { min-width: 0; }
|
||||||
.graphic-section { margin-top: var(--issste-space-6); padding-top: var(--issste-space-6); border-top: 1px solid var(--issste-border); }
|
.graphic-section { margin-top: var(--issste-space-6); padding-top: var(--issste-space-6); border-top: 1px solid var(--issste-border); }
|
||||||
@@ -57,15 +29,17 @@ header p { color: var(--mat-sys-on-surface-variant); margin-bottom: 1.5rem; }
|
|||||||
@container dashboard (min-width: 1304px) { .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
@container dashboard (min-width: 1304px) { .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
||||||
|
|
||||||
@media (max-width: 550px) {
|
@media (max-width: 550px) {
|
||||||
h1 { font-size: var(--mat-sys-headline-medium-size); line-height: var(--mat-sys-headline-medium-line-height); }
|
h1 { font-size: 1.5rem; }
|
||||||
}
|
}
|
||||||
|
|
||||||
.global-filters { margin-block: var(--issste-space-6); padding: clamp(.75rem, 2vw, 1.5rem); border: 1px solid var(--issste-border); border-radius: var(--issste-radius); background: var(--issste-surface); min-width: 0; }
|
.global-filters { margin-block: var(--issste-space-4); padding: var(--issste-space-3) var(--issste-space-4); border: 1px solid var(--issste-border); border-radius: var(--issste-radius); background: var(--issste-surface); min-width: 0; }
|
||||||
|
.global-filters .section-title { font-size: 1rem; }
|
||||||
|
.global-filters .section-description { margin: var(--issste-space-1) 0 var(--issste-space-2); font: var(--mat-sys-body-small); }
|
||||||
|
|
||||||
@container dashboard (min-width: 1000px) { .kpi-grid { grid-template-columns: repeat(min(3, var(--kpi-count)), minmax(0, 1fr)); } }
|
@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.
|
// Five opportunity cards: at least ~280px per card; retain existing TEA/CaMa grids.
|
||||||
.kpi-section[data-domain='cacu'] .kpi-grid {
|
.kpi-section[data-domain='cacu'] .kpi-grid, .kpi-section[data-domain='cama'] .kpi-grid {
|
||||||
grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,13 +136,9 @@ describe('UX-06E.D.3.A catálogo permanentemente desplegado', () => {
|
|||||||
http.expectNone(() => true);
|
http.expectNone(() => true);
|
||||||
});
|
});
|
||||||
it('UX-06B mantiene una sola navegación entre dominios, sin duplicar botones', () => {
|
it('UX-06B mantiene una sola navegación entre dominios, sin duplicar botones', () => {
|
||||||
// Our shell has no domain selector of its own (unlike upstream's App),
|
// The App header owns the domain menu (app.spec.ts); fails if the page brings back its own links.
|
||||||
// so the page keeps exactly the one it always had -- not duplicated.
|
|
||||||
// (Needs a render pass first: unlike upstream's trivial "absent" check,
|
|
||||||
// confirming presence requires the template to have actually painted.)
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(fixture.nativeElement.querySelectorAll('nav.domain-nav')).toHaveLength(1);
|
expect(fixture.nativeElement.querySelectorAll('nav.domain-nav')).toHaveLength(0);
|
||||||
expect(fixture.nativeElement.querySelectorAll('nav.domain-nav a')).toHaveLength(3);
|
|
||||||
expect(cards()).toHaveLength(0);
|
expect(cards()).toHaveLength(0);
|
||||||
// Constructing the page legitimately initializes its domain catalog.
|
// Constructing the page legitimately initializes its domain catalog.
|
||||||
const catalogRequest = http.expectOne('/tea/indicadores');
|
const catalogRequest = http.expectOne('/tea/indicadores');
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { DOCUMENT } from '@angular/common';
|
import { DOCUMENT } from '@angular/common';
|
||||||
import { afterEveryRender, afterNextRender, ChangeDetectorRef, Component, DestroyRef, ElementRef, Injector, inject, computed, signal, viewChild, viewChildren } from '@angular/core';
|
import { afterEveryRender, afterNextRender, ChangeDetectorRef, Component, DestroyRef, ElementRef, Injector, inject, computed, signal, viewChild, viewChildren } from '@angular/core';
|
||||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||||
import { ActivatedRoute, RouterLink } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { MatCardModule } from '@angular/material/card';
|
import { MatCardModule } from '@angular/material/card';
|
||||||
@@ -11,7 +11,8 @@ import { MatIconModule } from '@angular/material/icon';
|
|||||||
import { MatSelect, MatSelectModule } from '@angular/material/select';
|
import { MatSelect, MatSelectModule } from '@angular/material/select';
|
||||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||||
import { catchError, first, map, of, startWith, Subject, switchMap, takeUntil } from 'rxjs';
|
import { catchError, first, map, of, startWith, Subject, switchMap, takeUntil } from 'rxjs';
|
||||||
import { Dominio, DOMINIOS, isDominio, Indicador, Tema } from './indicadores.models';
|
import { Dominio, isDominio, Indicador, Tema } from './indicadores.models';
|
||||||
|
import { vistaEscenario } from './indicadores-eu7-escenario';
|
||||||
import { IndicadoresService } from './indicadores.service';
|
import { IndicadoresService } from './indicadores.service';
|
||||||
import { applyGlobal, domainTypes, GlobalFilterState, IndicadoresMemory, pending, validDraft } from './indicadores-memory';
|
import { applyGlobal, domainTypes, GlobalFilterState, IndicadoresMemory, pending, validDraft } from './indicadores-memory';
|
||||||
import { IndicadorPeriodFilters } from './indicador-period-filters';
|
import { IndicadorPeriodFilters } from './indicador-period-filters';
|
||||||
@@ -35,17 +36,19 @@ const SECTIONS: readonly { id: DashboardSection; label: string }[] = [
|
|||||||
{ id: 'seguimiento', label: 'Seguimiento' },
|
{ id: 'seguimiento', label: 'Seguimiento' },
|
||||||
{ id: 'datos', label: 'Datos y definiciones' },
|
{ id: 'datos', label: 'Datos y definiciones' },
|
||||||
];
|
];
|
||||||
// Only TEA has enough periods for its history to say anything.
|
// Domains with enough periods for their history to say anything.
|
||||||
const TEA_SECTIONS: readonly { id: DashboardSection; label: string }[] = [SECTIONS[0], { id: 'historico', label: 'Histórico' }, SECTIONS[1], SECTIONS[2]];
|
const CON_HISTORICO: readonly Dominio[] = ['tea', 'cama'];
|
||||||
|
const HISTORICO_SECTIONS: readonly { id: DashboardSection; label: string }[] = [SECTIONS[0], { id: 'historico', label: 'Histórico' }, SECTIONS[1], SECTIONS[2]];
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-indicadores-page',
|
selector: 'app-indicadores-page',
|
||||||
imports: [RouterLink, FormsModule, MatButtonModule, MatCardModule, MatFormFieldModule, MatInputModule, MatIconModule, MatSelectModule, MatProgressBarModule, IndicadorCatalogCard, IndicadorKpiPanel, IndicadorKpiCard, IndicadorPeriodFilters, IndicadoresDefinitions, IndicadoresTracking, IndicadoresHistorico, TeaResumenPeriodo],
|
imports: [FormsModule, MatButtonModule, MatCardModule, MatFormFieldModule, MatInputModule, MatIconModule, MatSelectModule, MatProgressBarModule, IndicadorCatalogCard, IndicadorKpiPanel, IndicadorKpiCard, IndicadorPeriodFilters, IndicadoresDefinitions, IndicadoresTracking, IndicadoresHistorico, TeaResumenPeriodo],
|
||||||
templateUrl: './indicadores-page.html',
|
templateUrl: './indicadores-page.html',
|
||||||
styleUrl: './indicadores-page.scss',
|
styleUrl: './indicadores-page.scss',
|
||||||
})
|
})
|
||||||
export class IndicadoresPage {
|
export class IndicadoresPage {
|
||||||
get sections() { return this.dominio === 'tea' ? TEA_SECTIONS : SECTIONS; }
|
get sections() { return this.conHistorico ? HISTORICO_SECTIONS : SECTIONS; }
|
||||||
|
get conHistorico() { return CON_HISTORICO.includes(this.dominio); }
|
||||||
readonly activeSection = signal<DashboardSection>('resumen');
|
readonly activeSection = signal<DashboardSection>('resumen');
|
||||||
readonly fichaPacienteAbierta = signal(false);
|
readonly fichaPacienteAbierta = signal(false);
|
||||||
setFichaPacienteAbierta(open: boolean) {
|
setFichaPacienteAbierta(open: boolean) {
|
||||||
@@ -265,14 +268,12 @@ export class IndicadoresPage {
|
|||||||
private readonly memory = inject(IndicadoresMemory);
|
private readonly memory = inject(IndicadoresMemory);
|
||||||
private readonly destroyRef = inject(DestroyRef);
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
private readonly route = inject(ActivatedRoute, { optional: true });
|
private readonly route = inject(ActivatedRoute, { optional: true });
|
||||||
readonly dominios = DOMINIOS;
|
|
||||||
dominio: Dominio = 'tea';
|
dominio: Dominio = 'tea';
|
||||||
readonly domainLabels: Record<Dominio, string> = { tea: 'TEA', cacu: 'cáncer cervicouterino', cama: 'CaMa' };
|
readonly domainLabels: Record<Dominio, string> = { tea: 'TEA', cacu: 'cáncer cervicouterino', cama: 'cáncer de mama' };
|
||||||
// At the start of the header line.
|
// At the start of the header line.
|
||||||
readonly domainTitles: Record<Dominio, string> = { ...this.domainLabels, cacu: 'Cáncer cervicouterino' };
|
readonly domainTitles: Record<Dominio, string> = { ...this.domainLabels, cacu: 'Cáncer cervicouterino', cama: 'Cáncer de mama' };
|
||||||
// Short form for the domain-switcher buttons (our shell's own nav, see the
|
// Short form for the domain-switcher buttons (our shell's own nav, see the
|
||||||
// template comment above it) -- `domainLabels`/`domainTitles` are prose-length.
|
// template comment above it) -- `domainLabels`/`domainTitles` are prose-length.
|
||||||
readonly domainNavLabels: Record<Dominio, string> = { tea: 'TEA', cacu: 'CaCu', cama: 'CaMa' };
|
|
||||||
readonly kpisByDomain = { ...KPI_BY_DOMAIN, tea: [...KPI_BY_DOMAIN.tea, ...KPI_RESUMEN_TEA] };
|
readonly kpisByDomain = { ...KPI_BY_DOMAIN, tea: [...KPI_BY_DOMAIN.tea, ...KPI_RESUMEN_TEA] };
|
||||||
figureApplied(item: Indicador) { return figureApplied(this.dominio, item.id, this.filters!.applied); }
|
figureApplied(item: Indicador) { return figureApplied(this.dominio, item.id, this.filters!.applied); }
|
||||||
independentPeriods(item: Indicador) { return independentFigurePeriods(this.dominio, item.id); }
|
independentPeriods(item: Indicador) { return independentFigurePeriods(this.dominio, item.id); }
|
||||||
@@ -310,9 +311,10 @@ export class IndicadoresPage {
|
|||||||
// Stable presentation priority; pins still take precedence in the grid.
|
// Stable presentation priority; pins still take precedence in the grid.
|
||||||
readonly catalogOrder = computed(() => {
|
readonly catalogOrder = computed(() => {
|
||||||
const catalog = this.catalog();
|
const catalog = this.catalog();
|
||||||
return this.dominio === 'cacu'
|
// The interactive views go first.
|
||||||
? [...catalog.filter(item => item.id === 'cacu_eu7'), ...catalog.filter(item => item.id !== 'cacu_eu7')]
|
const resumen = catalog.filter(item => !item.vistas || item.vistas.includes('resumen'));
|
||||||
: catalog.filter(item => !item.vistas || item.vistas.includes('resumen'));
|
const primero = (item: Indicador) => !!vistaEscenario(this.dominio, item);
|
||||||
|
return [...resumen.filter(primero), ...resumen.filter(item => !primero(item))];
|
||||||
});
|
});
|
||||||
readonly selectedIndicators = computed(() => this.indicatorSelection() ?? this.catalog().map(item => item.id));
|
readonly selectedIndicators = computed(() => this.indicatorSelection() ?? this.catalog().map(item => item.id));
|
||||||
readonly selectionSummary = computed(() => {
|
readonly selectionSummary = computed(() => {
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import { IndicadorPeriodFilters } from './indicador-period-filters';
|
|||||||
import { CACU_RESULTADO_KPI, KPI_BY_DOMAIN } from './indicadores-kpi';
|
import { CACU_RESULTADO_KPI, KPI_BY_DOMAIN } from './indicadores-kpi';
|
||||||
import { Dominio, IndicadorDatos } from './indicadores.models';
|
import { Dominio, IndicadorDatos } from './indicadores.models';
|
||||||
|
|
||||||
|
// The period and anchor rules are pinned on CaMa's first three cards (C2, C1, C3r); the fourth follows the same
|
||||||
|
// rules (indicador-kpi-panel.spec.ts covers all four).
|
||||||
|
const KPIS = { ...KPI_BY_DOMAIN, cama: KPI_BY_DOMAIN.cama.slice(0, 3) };
|
||||||
describe('P0.1 selección publicada y último periodo por KPI', () => {
|
describe('P0.1 selección publicada y último periodo por KPI', () => {
|
||||||
let fixture: ReturnType<typeof TestBed.createComponent<IndicadoresPage>>, http: HttpTestingController;
|
let fixture: ReturnType<typeof TestBed.createComponent<IndicadoresPage>>, http: HttpTestingController;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -21,12 +24,12 @@ describe('P0.1 selección publicada y último periodo por KPI', () => {
|
|||||||
const payload = (id: string, periods: string[]) => ({ id, periodos: periods.map(periodo => ({ periodo, tipo: periodo.includes('-S') ? 'semestre' : 'mes' })) });
|
const payload = (id: string, periods: string[]) => ({ id, periodos: periods.map(periodo => ({ periodo, tipo: periodo.includes('-S') ? 'semestre' : 'mes' })) });
|
||||||
function catalog(domain: Dominio) {
|
function catalog(domain: Dominio) {
|
||||||
fixture.componentInstance.changeDominio(domain); fixture.detectChanges();
|
fixture.componentInstance.changeDominio(domain); fixture.detectChanges();
|
||||||
http.expectOne('/' + domain + '/indicadores').flush(KPI_BY_DOMAIN[domain].map(d => ({ id: d.id, titulo: d.title, contrato: d.contrato, figuras: [], tipos_periodo: ['semestre', 'mes'] })));
|
http.expectOne('/' + domain + '/indicadores').flush(KPIS[domain].map(d => ({ id: d.id, titulo: d.title, contrato: d.contrato, figuras: [], tipos_periodo: ['semestre', 'mes'] })));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
return http.match(r => r.url.endsWith('/periodos'));
|
return http.match(r => r.url.endsWith('/periodos'));
|
||||||
}
|
}
|
||||||
function load(domain: Dominio, periods: string[][]) {
|
function load(domain: Dominio, periods: string[][]) {
|
||||||
catalog(domain).forEach((r, i) => r.flush(payload(KPI_BY_DOMAIN[domain][i].id, periods[i])));
|
catalog(domain).forEach((r, i) => r.flush(payload(KPIS[domain][i].id, periods[i])));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
}
|
}
|
||||||
// Regression assertions below target the original KPI contracts. The added lab
|
// Regression assertions below target the original KPI contracts. The added lab
|
||||||
@@ -43,7 +46,7 @@ describe('P0.1 selección publicada y último periodo por KPI', () => {
|
|||||||
function panels() { return fixture.debugElement.queryAll(By.directive(IndicadorKpiPanel)).map(e => e.componentInstance as IndicadorKpiPanel).filter(panel => panel.definition.id !== CACU_RESULTADO_KPI.id); }
|
function panels() { return fixture.debugElement.queryAll(By.directive(IndicadorKpiPanel)).map(e => e.componentInstance as IndicadorKpiPanel).filter(panel => panel.definition.id !== CACU_RESULTADO_KPI.id); }
|
||||||
function editor() { return fixture.debugElement.query(By.directive(IndicadorPeriodFilters)).componentInstance as IndicadorPeriodFilters; }
|
function editor() { return fixture.debugElement.query(By.directive(IndicadorPeriodFilters)).componentInstance as IndicadorPeriodFilters; }
|
||||||
function data(index: number, domain: Dominio, period: string, suppressed = false): IndicadorDatos {
|
function data(index: number, domain: Dominio, period: string, suppressed = false): IndicadorDatos {
|
||||||
const d = KPI_BY_DOMAIN[domain][index];
|
const d = KPIS[domain][index];
|
||||||
return { id: d.id, contrato: d.contrato, tipo_periodo: period.includes('-S') ? 'semestre' : 'mes', periodos: [period], categorias: { A: {} }, filas: [{
|
return { id: d.id, contrato: d.contrato, tipo_periodo: period.includes('-S') ? 'semestre' : 'mes', periodos: [period], categorias: { A: {} }, filas: [{
|
||||||
periodo: period, grupo: d.contrato === 'C1' ? 'total' : 'TOTAL', estrato: null, categoria: 'A',
|
periodo: period, grupo: d.contrato === 'C1' ? 'total' : 'TOTAL', estrato: null, categoria: 'A',
|
||||||
n: 0, valor: 0, numerador: 0, denominador: 5, mediana: 0, q1: 0, q3: 0, unidad: 'dias', suprimido: suppressed ? 1 : 0,
|
n: 0, valor: 0, numerador: 0, denominador: 5, mediana: 0, q1: 0, q3: 0, unidad: 'dias', suprimido: suppressed ? 1 : 0,
|
||||||
@@ -56,7 +59,7 @@ describe('P0.1 selección publicada y último periodo por KPI', () => {
|
|||||||
if (!requests.length) return resolved;
|
if (!requests.length) return resolved;
|
||||||
resolved.push(...requests);
|
resolved.push(...requests);
|
||||||
requests.forEach(r => {
|
requests.forEach(r => {
|
||||||
const index = KPI_BY_DOMAIN[domain].findIndex(d => r.request.url.endsWith('/' + d.id + '/datos'));
|
const index = KPIS[domain].findIndex(d => r.request.url.endsWith('/' + d.id + '/datos'));
|
||||||
r.flush(data(index, domain, r.request.params.get('periodos')!, suppressed));
|
r.flush(data(index, domain, r.request.params.get('periodos')!, suppressed));
|
||||||
});
|
});
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@@ -64,11 +67,11 @@ describe('P0.1 selección publicada y último periodo por KPI', () => {
|
|||||||
}
|
}
|
||||||
it.each(['cacu', 'cama'] as const)('%s comparte el periodo del ancla aunque otros inventarios difieran y conserva sus ceros', domain => {
|
it.each(['cacu', 'cama'] as const)('%s comparte el periodo del ancla aunque otros inventarios difieran y conserva sus ceros', domain => {
|
||||||
load(domain, [['2026-S1', '2024-S2', '2025-S2'], ['2025-S1', '2026-S2', '2025-12'], ['2025-S2', '2024-S1']]);
|
load(domain, [['2026-S1', '2024-S2', '2025-S2'], ['2025-S1', '2026-S2', '2025-12'], ['2025-S2', '2024-S1']]);
|
||||||
const anchor = http.expectOne(r => r.url.endsWith('/' + KPI_BY_DOMAIN[domain][0].id + '/datos'));
|
const anchor = http.expectOne(r => r.url.endsWith('/' + KPIS[domain][0].id + '/datos'));
|
||||||
const positive = data(0, domain, '2026-S1'); positive.filas[0]['n'] = 4; anchor.flush(positive); fixture.detectChanges();
|
const positive = data(0, domain, '2026-S1'); positive.filas[0]['n'] = 4; anchor.flush(positive); fixture.detectChanges();
|
||||||
const requests = flushDatos(domain);
|
const requests = flushDatos(domain);
|
||||||
expect(requests.map(r => r.request.params.get('periodos'))).toEqual(KPI_BY_DOMAIN[domain].slice(1).map(() => '2026-S1'));
|
expect(requests.map(r => r.request.params.get('periodos'))).toEqual(KPIS[domain].slice(1).map(() => '2026-S1'));
|
||||||
expect(panels().map(p => p.temporalReference)).toEqual(KPI_BY_DOMAIN[domain].map(() => '2026-S1'));
|
expect(panels().map(p => p.temporalReference)).toEqual(KPIS[domain].map(() => '2026-S1'));
|
||||||
expect(panels().map(p => p.result().value)).toEqual(domain === 'cacu' ? [4, 0] : [4, '0.0', 0]);
|
expect(panels().map(p => p.result().value)).toEqual(domain === 'cacu' ? [4, 0] : [4, '0.0', 0]);
|
||||||
expect(fixture.componentInstance.filters!.applied.selection).toEqual({ mode: 'explicit', periodos: ['2026-S1'] });
|
expect(fixture.componentInstance.filters!.applied.selection).toEqual({ mode: 'explicit', periodos: ['2026-S1'] });
|
||||||
expect(fixture.componentInstance.filters!.applied.revision).toBe(1);
|
expect(fixture.componentInstance.filters!.applied.revision).toBe(1);
|
||||||
@@ -112,7 +115,7 @@ describe('P0.1 selección publicada y último periodo por KPI', () => {
|
|||||||
it('error de disponibilidad ofrece reintento sin sustituir la selección y conserva éxitos en caché', () => {
|
it('error de disponibilidad ofrece reintento sin sustituir la selección y conserva éxitos en caché', () => {
|
||||||
const requests = catalog('cacu');
|
const requests = catalog('cacu');
|
||||||
requests[0].flush('private', { status: 503, statusText: 'Unavailable' });
|
requests[0].flush('private', { status: 503, statusText: 'Unavailable' });
|
||||||
requests.slice(1).forEach((r, i) => r.flush(payload(KPI_BY_DOMAIN.cacu[i + 1].id, ['2025-S2'])));
|
requests.slice(1).forEach((r, i) => r.flush(payload(KPIS.cacu[i + 1].id, ['2025-S2'])));
|
||||||
fixture.detectChanges(); flushDatos('cacu');
|
fixture.detectChanges(); flushDatos('cacu');
|
||||||
expect(fixture.componentInstance.initialPeriodState()).toBe('error');
|
expect(fixture.componentInstance.initialPeriodState()).toBe('error');
|
||||||
expect(panels()).toHaveLength(0);
|
expect(panels()).toHaveLength(0);
|
||||||
@@ -130,7 +133,7 @@ describe('P0.1 selección publicada y último periodo por KPI', () => {
|
|||||||
const outgoing = catalog('cacu'); const incoming = catalog('cama');
|
const outgoing = catalog('cacu'); const incoming = catalog('cama');
|
||||||
expect(outgoing.every(r => r.cancelled)).toBe(true);
|
expect(outgoing.every(r => r.cancelled)).toBe(true);
|
||||||
expect(() => outgoing[0].flush(payload('cacu_eu7', ['2099-S2']))).toThrow();
|
expect(() => outgoing[0].flush(payload('cacu_eu7', ['2099-S2']))).toThrow();
|
||||||
incoming.forEach((r, i) => r.flush(payload(KPI_BY_DOMAIN.cama[i].id, ['2025-S1'])));
|
incoming.forEach((r, i) => r.flush(payload(KPIS.cama[i].id, ['2025-S1'])));
|
||||||
fixture.detectChanges(); const requests = flushDatos('cama');
|
fixture.detectChanges(); const requests = flushDatos('cama');
|
||||||
expect(requests.every(r => r.request.url.startsWith('/cama/') && r.request.params.get('periodos') === '2025-S1')).toBe(true);
|
expect(requests.every(r => r.request.url.startsWith('/cama/') && r.request.params.get('periodos') === '2025-S1')).toBe(true);
|
||||||
expect(editor().options).toEqual(['2025-S1']);
|
expect(editor().options).toEqual(['2025-S1']);
|
||||||
|
|||||||
@@ -37,15 +37,13 @@ describe('Secciones compartidas por dominio', () => {
|
|||||||
http.expectOne('/' + domain + '/indicadores').flush(catalog); harness.detectChanges();
|
http.expectOne('/' + domain + '/indicadores').flush(catalog); harness.detectChanges();
|
||||||
const root = harness.routeNativeElement!;
|
const root = harness.routeNativeElement!;
|
||||||
const tabs = Array.from(root.querySelectorAll<HTMLButtonElement>('[role="tab"]'));
|
const tabs = Array.from(root.querySelectorAll<HTMLButtonElement>('[role="tab"]'));
|
||||||
expect(tabs.map(t => t.textContent?.trim())).toEqual(domain === 'tea'
|
expect(tabs.map(t => t.textContent?.trim())).toEqual(domain === 'tea' || domain === 'cama'
|
||||||
? ['Resumen', 'Histórico', 'Seguimiento', 'Datos y definiciones'] : ['Resumen', 'Seguimiento', 'Datos y definiciones']);
|
? ['Resumen', 'Histórico', 'Seguimiento', 'Datos y definiciones'] : ['Resumen', 'Seguimiento', 'Datos y definiciones']);
|
||||||
expect(tabs.map(t => t.getAttribute('aria-selected'))).toEqual(tabs.map((_, i) => String(i === 0)));
|
expect(tabs.map(t => t.getAttribute('aria-selected'))).toEqual(tabs.map((_, i) => String(i === 0)));
|
||||||
const tab = (id: string) => tabs.find(t => t.id === 'tab-' + id)!;
|
const tab = (id: string) => tabs.find(t => t.id === 'tab-' + id)!;
|
||||||
expect(root.querySelector('[role="tablist"]')?.getAttribute('aria-label')).toContain(page.domainLabels[domain]);
|
expect(root.querySelector('[role="tablist"]')?.getAttribute('aria-label')).toContain(page.domainLabels[domain]);
|
||||||
// Upstream moved domain selection to its own App shell; ours keeps it on
|
// The App header switches domains (see app.html); the page has no switcher of its own.
|
||||||
// the page itself (see indicadores-page.html), since our shell is shared
|
expect(root.querySelector('nav.domain-nav')).toBeNull();
|
||||||
// with other workspace sections.
|
|
||||||
expect(root.querySelector('nav.domain-nav')).not.toBeNull();
|
|
||||||
for (const tab of tabs) {
|
for (const tab of tabs) {
|
||||||
const panel = root.querySelector<HTMLElement>('#' + tab.getAttribute('aria-controls'))!;
|
const panel = root.querySelector<HTMLElement>('#' + tab.getAttribute('aria-controls'))!;
|
||||||
expect(panel.getAttribute('aria-labelledby')).toBe(tab.id);
|
expect(panel.getAttribute('aria-labelledby')).toBe(tab.id);
|
||||||
@@ -53,25 +51,14 @@ describe('Secciones compartidas por dominio', () => {
|
|||||||
}
|
}
|
||||||
const cards = harness.routeDebugElement!.queryAll(By.directive(IndicadorCatalogCard)).map(e => e.componentInstance);
|
const cards = harness.routeDebugElement!.queryAll(By.directive(IndicadorCatalogCard)).map(e => e.componentInstance);
|
||||||
tab('seguimiento').click(); harness.detectChanges();
|
tab('seguimiento').click(); harness.detectChanges();
|
||||||
if (domain === 'cacu' || domain === 'tea') {
|
http.expectOne(r => r.url === '/' + domain + '/seguimiento').flush({}, { status: 404, statusText: 'Pending' });
|
||||||
http.expectOne(r => r.url === '/' + domain + '/seguimiento').flush({}, { status: 404, statusText: 'Pending' });
|
harness.detectChanges();
|
||||||
harness.detectChanges();
|
|
||||||
}
|
|
||||||
const tracking = root.querySelector<HTMLElement>('#panel-seguimiento')!;
|
const tracking = root.querySelector<HTMLElement>('#panel-seguimiento')!;
|
||||||
expect(tracking.hidden).toBe(false);
|
expect(tracking.hidden).toBe(false);
|
||||||
expect(tracking.textContent).toContain('El seguimiento aún no está disponible');
|
expect(tracking.textContent).toContain('El seguimiento aún no está disponible');
|
||||||
if (domain === 'cacu') {
|
// Every domain queries its list; until it is published there is no table, only the form.
|
||||||
expect(tracking.querySelector('tbody')).toBeNull();
|
expect(tracking.querySelector('tbody')).toBeNull();
|
||||||
expect(tracking.querySelector('input[type=date]')).not.toBeNull();
|
expect(tracking.querySelector('input[type=date]')).not.toBeNull();
|
||||||
} else if (domain === 'tea') {
|
|
||||||
expect(tracking.querySelector('tbody')).toBeNull();
|
|
||||||
expect(tracking.querySelector('input[type=date]')).not.toBeNull();
|
|
||||||
} else {
|
|
||||||
expect(tracking.querySelectorAll('thead th')).toHaveLength(6);
|
|
||||||
expect(tracking.querySelectorAll('tbody tr')).toHaveLength(1);
|
|
||||||
expect(tracking.querySelector('tbody td')?.getAttribute('colspan')).toBe('6');
|
|
||||||
expect(tracking.querySelectorAll('input,button,select')).toHaveLength(0);
|
|
||||||
}
|
|
||||||
tab('datos').click(); harness.detectChanges();
|
tab('datos').click(); harness.detectChanges();
|
||||||
expect(root.querySelector<HTMLElement>('#panel-datos')!.hidden).toBe(false);
|
expect(root.querySelector<HTMLElement>('#panel-datos')!.hidden).toBe(false);
|
||||||
tab('resumen').click(); harness.detectChanges();
|
tab('resumen').click(); harness.detectChanges();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const record = (v: unknown): v is Record<string, unknown> => !!v && typeof v ===
|
|||||||
const escape = (v: string) => v.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
const escape = (v: string) => v.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||||
export function stratifiedCapabilities(item: Indicador): DimensionEstrato[] {
|
export function stratifiedCapabilities(item: Indicador): DimensionEstrato[] {
|
||||||
return item.contrato === 'C2' && Array.isArray(item.filtros)
|
return item.contrato === 'C2' && Array.isArray(item.filtros)
|
||||||
? (['grupo_edad', 'estatus_seguimiento'] as const).filter(d => item.filtros!.some(f => f?.estrato === d
|
? (['grupo_edad', 'estatus_seguimiento', 'birads'] as const).filter(d => item.filtros!.some(f => f?.estrato === d
|
||||||
&& typeof f.etiqueta === 'string' && Array.isArray(f.valores) && f.valores.length > 0
|
&& typeof f.etiqueta === 'string' && Array.isArray(f.valores) && f.valores.length > 0
|
||||||
&& f.valores.every(v => typeof v?.valor === 'string' && typeof v.etiqueta === 'string'))) : [];
|
&& f.valores.every(v => typeof v?.valor === 'string' && typeof v.etiqueta === 'string'))) : [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,24 +5,23 @@
|
|||||||
}
|
}
|
||||||
<div [hidden]="pacienteDetalle.estado().tipo !== 'cerrado'">
|
<div [hidden]="pacienteDetalle.estado().tipo !== 'cerrado'">
|
||||||
<h2>Seguimiento de {{ domainLabel }}</h2>
|
<h2>Seguimiento de {{ domainLabel }}</h2>
|
||||||
@if (dominio !== 'cacu' && dominio !== 'tea') {
|
|
||||||
<p>El seguimiento aún no está disponible.</p>
|
|
||||||
<div class="tracking-table" role="region" aria-label="Estructura prevista de seguimiento" tabindex="0">
|
|
||||||
<table>
|
|
||||||
<thead><tr><th scope="col">Paciente / identificación</th><th scope="col">Proceso o etapa</th><th scope="col">Estado</th><th scope="col">Fecha de referencia</th><th scope="col">Responsable</th><th scope="col">Acciones</th></tr></thead>
|
|
||||||
<tbody><tr><td colspan="6">No hay registros de seguimiento disponibles.</td></tr></tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
} @else {
|
|
||||||
<form (ngSubmit)="apply()">
|
<form (ngSubmit)="apply()">
|
||||||
<label>Fecha de corte <input name="corte" type="date" [(ngModel)]="draft.corte" /></label>
|
<label>Fecha de corte <input name="corte" type="date" [(ngModel)]="draft.corte" /></label>
|
||||||
<label>Ventana de meses <select name="meses" [(ngModel)]="draft.meses">
|
<label>Ventana de meses <select name="meses" [(ngModel)]="draft.meses">
|
||||||
@for (m of [1,3,6,12]; track m) { <option [ngValue]="m">{{ m }} {{ m === 1 ? 'mes' : 'meses' }}</option> }
|
@for (m of [1,3,6,12]; track m) { <option [ngValue]="m">{{ m }} {{ m === 1 ? 'mes' : 'meses' }}</option> }
|
||||||
</select></label>
|
</select></label>
|
||||||
|
@if (propio) {
|
||||||
<label>{{ dominio === 'tea' ? 'Alteraciones EEG' : 'Estatus de seguimiento' }} <select name="estatus" [(ngModel)]="draft.estatus">
|
<label>{{ dominio === 'tea' ? 'Alteraciones EEG' : 'Estatus de seguimiento' }} <select name="estatus" [(ngModel)]="draft.estatus">
|
||||||
<option [ngValue]="undefined">{{ dominio === 'tea' ? 'Todas' : 'Todos' }}</option>
|
<option [ngValue]="undefined">{{ dominio === 'tea' ? 'Todas' : 'Todos' }}</option>
|
||||||
@for (s of statuses; track s.codigo) { <option [value]="s.codigo">{{ s.etiqueta }}</option> }
|
@for (s of statuses; track s.codigo) { <option [value]="s.codigo">{{ s.etiqueta }}</option> }
|
||||||
</select></label>
|
</select></label>
|
||||||
|
}
|
||||||
|
@for (f of filtrosTabla; track f.clave) {
|
||||||
|
<label>{{ f.etiqueta }} <select [name]="'filtro-' + f.clave" [attr.name]="'filtro-' + f.clave" [(ngModel)]="filtrosDraft[f.clave]">
|
||||||
|
<option [ngValue]="undefined">Todos</option>
|
||||||
|
@for (o of f.opciones; track o.codigo) { <option [value]="o.codigo">{{ o.etiqueta }}</option> }
|
||||||
|
</select></label>
|
||||||
|
}
|
||||||
@if (dominio === 'tea') {
|
@if (dominio === 'tea') {
|
||||||
<label>Grupo de edad <select name="grupo_edad" [(ngModel)]="draft.grupo_edad">
|
<label>Grupo de edad <select name="grupo_edad" [(ngModel)]="draft.grupo_edad">
|
||||||
<option [ngValue]="undefined">Todos</option>
|
<option [ngValue]="undefined">Todos</option>
|
||||||
@@ -92,6 +91,22 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
} @else if (tablaData; as response) {
|
||||||
|
<div class="tracking-table" role="region" aria-label="Lista de seguimiento de demostración" tabindex="0">
|
||||||
|
<table>
|
||||||
|
<caption>Resultados disponibles por paciente</caption>
|
||||||
|
<thead><tr>@for (c of response.columnas; track c.clave) { <th scope="col">{{ c.etiqueta }}</th> }</tr></thead>
|
||||||
|
<tbody>
|
||||||
|
@for (item of response.items; track item['id_seudonimo']) {
|
||||||
|
<tr [attr.data-paciente]="item['id_seudonimo']">
|
||||||
|
@for (c of response.columnas; track c.clave) {
|
||||||
|
<td>{{ valorTabla(item[c.clave]) }}@for (d of detallesTabla(c); track d.clave) { @if (item[d.clave] !== null && item[d.clave] !== undefined) { <small>{{ d.etiqueta }}: {{ valorTabla(item[d.clave]) }}</small> } }</td>
|
||||||
|
}
|
||||||
|
</tr>
|
||||||
|
} @empty { <tr><td [attr.colspan]="response.columnas.length">No hay registros para los filtros aplicados.</td></tr> }
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
} @else if (data; as response) {
|
} @else if (data; as response) {
|
||||||
<div class="tracking-table" role="region" aria-label="Lista de seguimiento de demostración" tabindex="0">
|
<div class="tracking-table" role="region" aria-label="Lista de seguimiento de demostración" tabindex="0">
|
||||||
<table>
|
<table>
|
||||||
@@ -117,5 +132,4 @@
|
|||||||
<button type="button" [disabled]="response.paginacion.page >= response.paginacion.total_pages" (click)="navigate(response.paginacion.page + 1)">Siguiente</button>
|
<button type="button" [disabled]="response.paginacion.page >= response.paginacion.total_pages" (click)="navigate(response.paginacion.page + 1)">Siguiente</button>
|
||||||
</nav>
|
</nav>
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
:host { display: block; min-width: 0; padding: var(--issste-space-4); overflow-wrap: anywhere;
|
:host { display: block; min-width: 0; padding: var(--issste-space-4); overflow-wrap: anywhere;
|
||||||
background: var(--issste-surface); color: var(--issste-text); border: 1px solid var(--issste-border); border-radius: var(--issste-radius); }
|
background: var(--issste-surface); color: var(--issste-text); border: 1px solid var(--issste-border); border-radius: var(--issste-radius); }
|
||||||
h2 { font-size: 1.5rem; margin-top: 0; }
|
h2 { font-size: 1.25rem; font-weight: 500; margin-top: 0; }
|
||||||
p { color: var(--issste-text-secondary); }
|
p { color: var(--issste-text-secondary); }
|
||||||
form { display: flex; flex-wrap: wrap; align-items: end; gap: 1rem; margin-bottom: 1rem; }
|
form { display: flex; flex-wrap: wrap; align-items: end; gap: 1rem; margin-bottom: 1rem; }
|
||||||
label { display: flex; flex-direction: column; gap: .5rem; max-width: 100%; }
|
label { display: flex; flex-direction: column; gap: .5rem; max-width: 100%; }
|
||||||
@@ -31,7 +31,7 @@ tbody tr[data-paciente]:hover { background-color: color-mix(in srgb, var(--issst
|
|||||||
tbody tr[data-paciente]:focus-within { outline: 2px solid var(--issste-accent); outline-offset: -2px; }
|
tbody tr[data-paciente]:focus-within { outline: 2px solid var(--issste-accent); outline-offset: -2px; }
|
||||||
.patient-link { min-height: 44px; padding: .35rem .5rem; border: 0; border-radius: var(--issste-radius); background: transparent; color: var(--issste-accent); font: inherit; font-weight: 600; text-align: left; text-decoration: underline; text-underline-offset: .15em; cursor: pointer; }
|
.patient-link { min-height: 44px; padding: .35rem .5rem; border: 0; border-radius: var(--issste-radius); background: transparent; color: var(--issste-accent); font: inherit; font-weight: 600; text-align: left; text-decoration: underline; text-underline-offset: .15em; cursor: pointer; }
|
||||||
.patient-link:focus-visible { outline: 2px solid var(--issste-accent); outline-offset: 2px; }
|
.patient-link:focus-visible { outline: 2px solid var(--issste-accent); outline-offset: 2px; }
|
||||||
.eeg { display: inline-block; padding: .15rem .6rem; border-radius: 999px; border: 1px solid var(--issste-border); font-weight: 600; }
|
.eeg { display: inline-block; padding: .15rem .6rem; border-radius: var(--issste-radius); border: 1px solid var(--issste-border); font-weight: 600; }
|
||||||
.eeg-anormal { border-color: var(--issste-accent); color: var(--issste-accent); }
|
.eeg-anormal { border-color: var(--issste-accent); color: var(--issste-accent); }
|
||||||
tbody tr.tea-row { cursor: pointer; transition: background-color 120ms ease; }
|
tbody tr.tea-row { cursor: pointer; transition: background-color 120ms ease; }
|
||||||
tbody tr.tea-row:hover, tbody tr.tea-row.abierta { background-color: color-mix(in srgb, var(--issste-accent) 7%, transparent); }
|
tbody tr.tea-row:hover, tbody tr.tea-row.abierta { background-color: color-mix(in srgb, var(--issste-accent) 7%, transparent); }
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { Dominio } from './indicadores.models';
|
|||||||
import { IndicadoresService } from './indicadores.service';
|
import { IndicadoresService } from './indicadores.service';
|
||||||
import { ALTERACIONES_EEG, ESTADOS_CASO, GRUPOS_EDAD_TEA, RANGOS_CSS, RANGOS_MCHAT, TeaSeguimientoPaciente, TeaSeguimientoResponse, TeaSeguimientoService } from './tea-seguimiento.service';
|
import { ALTERACIONES_EEG, ESTADOS_CASO, GRUPOS_EDAD_TEA, RANGOS_CSS, RANGOS_MCHAT, TeaSeguimientoPaciente, TeaSeguimientoResponse, TeaSeguimientoService } from './tea-seguimiento.service';
|
||||||
import { TeaPacienteResumen } from './tea-paciente-resumen';
|
import { TeaPacienteResumen } from './tea-paciente-resumen';
|
||||||
|
import { SeguimientoColumna, SeguimientoFiltro, SeguimientoTablaResponse, SeguimientoTablaService, SeguimientoValor } from './seguimiento-tabla.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-indicadores-tracking',
|
selector: 'app-indicadores-tracking',
|
||||||
@@ -27,6 +28,7 @@ export class IndicadoresTracking implements OnChanges {
|
|||||||
private readonly service = inject(CacuSeguimientoService);
|
private readonly service = inject(CacuSeguimientoService);
|
||||||
private readonly indicators = inject(IndicadoresService);
|
private readonly indicators = inject(IndicadoresService);
|
||||||
private readonly teaService = inject(TeaSeguimientoService);
|
private readonly teaService = inject(TeaSeguimientoService);
|
||||||
|
private readonly tablaService = inject(SeguimientoTablaService);
|
||||||
private readonly destroy = inject(DestroyRef);
|
private readonly destroy = inject(DestroyRef);
|
||||||
private readonly changeDetector = inject(ChangeDetectorRef);
|
private readonly changeDetector = inject(ChangeDetectorRef);
|
||||||
private readonly injector = inject(Injector);
|
private readonly injector = inject(Injector);
|
||||||
@@ -35,18 +37,22 @@ export class IndicadoresTracking implements OnChanges {
|
|||||||
private controlPaciente?: HTMLElement;
|
private controlPaciente?: HTMLElement;
|
||||||
private readonly requests = new Subject<SeguimientoQuery | null>();
|
private readonly requests = new Subject<SeguimientoQuery | null>();
|
||||||
private readonly teaRequests = new Subject<SeguimientoQuery | null>();
|
private readonly teaRequests = new Subject<SeguimientoQuery | null>();
|
||||||
|
private readonly tablaRequests = new Subject<{ dominio: Dominio; q: SeguimientoQuery } | null>();
|
||||||
private initialized = false;
|
private initialized = false;
|
||||||
private previousDomain?: Dominio;
|
private previousDomain?: Dominio;
|
||||||
status: 'idle' | 'loading' | 'ready' | 'pending' | 'error' = 'idle';
|
status: 'idle' | 'loading' | 'ready' | 'pending' | 'error' = 'idle';
|
||||||
message = '';
|
message = '';
|
||||||
data?: SeguimientoResponse;
|
data?: SeguimientoResponse;
|
||||||
teaData?: TeaSeguimientoResponse;
|
teaData?: TeaSeguimientoResponse;
|
||||||
|
// Domains whose list announces its own filters and columns.
|
||||||
|
tablaData?: SeguimientoTablaResponse;
|
||||||
|
filtrosTabla: SeguimientoFiltro[] = [];
|
||||||
// One open summary at a time, like an accordion.
|
// One open summary at a time, like an accordion.
|
||||||
teaAbierto?: string;
|
teaAbierto?: string;
|
||||||
statuses: SeguimientoStatus[] = [];
|
statuses: SeguimientoStatus[] = [];
|
||||||
private metadataLoaded = false;
|
private metadataLoaded = false;
|
||||||
categories: Record<string, { etiqueta: string; color?: string | null }> = {};
|
categories: Record<string, { etiqueta: string; color?: string | null }> = {};
|
||||||
draft: SeguimientoQuery = { meses: 3, page: 1, page_size: 50 };
|
draft: SeguimientoQuery = { meses: 3, page: 1, page_size: 50, filtros: {} };
|
||||||
private applied: SeguimientoQuery = { ...this.draft };
|
private applied: SeguimientoQuery = { ...this.draft };
|
||||||
readonly latestStudy = latestStudy;
|
readonly latestStudy = latestStudy;
|
||||||
readonly gruposEdad = GRUPOS_EDAD_TEA;
|
readonly gruposEdad = GRUPOS_EDAD_TEA;
|
||||||
@@ -57,7 +63,8 @@ export class IndicadoresTracking implements OnChanges {
|
|||||||
// Kept from the last answer, so the filter doesn't empty while a query is running.
|
// Kept from the last answer, so the filter doesn't empty while a query is running.
|
||||||
tiposAlteracion: { codigo: string; etiqueta: string }[] = [];
|
tiposAlteracion: { codigo: string; etiqueta: string }[] = [];
|
||||||
get provisional() { return this.data?.reglas.some(r => r.estado === 'provisional'); }
|
get provisional() { return this.data?.reglas.some(r => r.estado === 'provisional'); }
|
||||||
get response() { return this.dominio === 'tea' ? this.teaData : this.data; }
|
get response() { return this.dominio === 'tea' ? this.teaData : this.dominio === 'cacu' ? this.data : this.tablaData; }
|
||||||
|
get propio() { return this.dominio === 'cacu' || this.dominio === 'tea'; }
|
||||||
constructor() {
|
constructor() {
|
||||||
const failure = (error: unknown, q: SeguimientoQuery) => of({ data: undefined, status: error instanceof HttpErrorResponse && error.status === 404 && q.page === 1 ? 'pending' as const : 'error' as const,
|
const failure = (error: unknown, q: SeguimientoQuery) => of({ data: undefined, status: error instanceof HttpErrorResponse && error.status === 404 && q.page === 1 ? 'pending' as const : 'error' as const,
|
||||||
message: error instanceof HttpErrorResponse && error.status === 400 ? 'Revisa la fecha, la ventana y los filtros seleccionados.'
|
message: error instanceof HttpErrorResponse && error.status === 400 ? 'Revisa la fecha, la ventana y los filtros seleccionados.'
|
||||||
@@ -93,24 +100,43 @@ export class IndicadoresTracking implements OnChanges {
|
|||||||
this.draft = { ...this.applied };
|
this.draft = { ...this.applied };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.tablaRequests.pipe(switchMap(r => r ? defer(() => this.tablaService.consultar(r.dominio, r.q)).pipe(
|
||||||
|
map(data => ({ data, message: '', status: 'ready' as const })), catchError(error => failure(error, r.q))) : of(null)), takeUntilDestroyed(this.destroy)).subscribe(result => {
|
||||||
|
if (!result) return;
|
||||||
|
this.changeDetector.markForCheck();
|
||||||
|
this.status = result.status; this.tablaData = result.data; this.message = result.message;
|
||||||
|
if (result.data) {
|
||||||
|
const data = result.data;
|
||||||
|
this.filtrosTabla = data.filtros_disponibles;
|
||||||
|
const filtros = Object.fromEntries(Object.entries(data.filtros).filter((e): e is [string, string] => e[1] !== null));
|
||||||
|
this.applied = { corte: data.corte, meses: data.ventana.meses, filtros, page: data.paginacion.page, page_size: data.paginacion.page_size };
|
||||||
|
this.draft = { ...this.applied, filtros: { ...filtros } };
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
ngOnChanges() {
|
ngOnChanges() {
|
||||||
if (this.previousDomain !== this.dominio) {
|
if (this.previousDomain !== this.dominio) {
|
||||||
if (this.pacienteDetalle.estado().tipo !== 'cerrado') this.fichaPacienteAbierta.emit(false);
|
if (this.pacienteDetalle.estado().tipo !== 'cerrado') this.fichaPacienteAbierta.emit(false);
|
||||||
this.pacienteDetalle.cerrar(); this.controlPaciente = undefined;
|
this.pacienteDetalle.cerrar(); this.controlPaciente = undefined;
|
||||||
this.previousDomain = this.dominio; this.requests.next(null); this.teaRequests.next(null); this.data = undefined; this.teaData = undefined;
|
this.previousDomain = this.dominio; this.requests.next(null); this.teaRequests.next(null); this.tablaRequests.next(null);
|
||||||
this.status = 'idle'; this.statuses = []; this.initialized = false; this.draft = { meses: 3, page: 1, page_size: 50 }; this.applied = { ...this.draft };
|
this.data = undefined; this.teaData = undefined; this.tablaData = undefined; this.filtrosTabla = [];
|
||||||
|
this.status = 'idle'; this.statuses = []; this.initialized = false; this.draft = { meses: 3, page: 1, page_size: 50, filtros: {} }; this.applied = { ...this.draft };
|
||||||
}
|
}
|
||||||
if (this.dominio === 'cacu' && this.active && !this.initialized) { this.initialized = true; this.load(this.applied); }
|
if (this.dominio === 'cacu' && this.active && !this.initialized) { this.initialized = true; this.load(this.applied); }
|
||||||
if (this.dominio === 'tea' && this.active && !this.initialized) { this.initialized = true; this.statuses = ALTERACIONES_EEG; this.load(this.applied); }
|
if (this.dominio === 'tea' && this.active && !this.initialized) { this.initialized = true; this.statuses = ALTERACIONES_EEG; this.load(this.applied); }
|
||||||
|
if (!this.propio && this.active && !this.initialized) { this.initialized = true; this.load(this.applied); }
|
||||||
}
|
}
|
||||||
private load(q: SeguimientoQuery) {
|
private load(q: SeguimientoQuery) {
|
||||||
if (this.dominio !== 'cacu' && this.dominio !== 'tea') return;
|
|
||||||
if (!validSeguimientoQuery(q)) { this.message = 'Revisa la fecha, la ventana y el tamaño de página (1 a 200).'; return; }
|
if (!validSeguimientoQuery(q)) { this.message = 'Revisa la fecha, la ventana y el tamaño de página (1 a 200).'; return; }
|
||||||
this.status = 'loading'; this.message = ''; this.data = undefined; this.teaData = undefined; this.applied = { ...q };
|
this.status = 'loading'; this.message = ''; this.data = undefined; this.teaData = undefined; this.tablaData = undefined; this.applied = { ...q };
|
||||||
(this.dominio === 'tea' ? this.teaRequests : this.requests).next(q);
|
if (this.dominio === 'tea') this.teaRequests.next(q);
|
||||||
|
else if (this.dominio === 'cacu') this.requests.next(q);
|
||||||
|
else this.tablaRequests.next({ dominio: this.dominio, q });
|
||||||
}
|
}
|
||||||
apply() { this.load({ ...this.draft, page: 1 }); }
|
apply() { this.load({ ...this.draft, filtros: Object.fromEntries(Object.entries(this.draft.filtros ?? {}).filter(([, v]) => v)), page: 1 }); }
|
||||||
|
valorTabla(v: SeguimientoValor | undefined) { return v === null || v === undefined || v === '' ? 'No disponible' : typeof v === 'number' ? v.toLocaleString('es-MX') : v; }
|
||||||
|
detallesTabla(c: SeguimientoColumna) { return c.detalles ?? []; }
|
||||||
|
get filtrosDraft() { return this.draft.filtros ??= {}; }
|
||||||
retry() { this.load(this.applied); }
|
retry() { this.load(this.applied); }
|
||||||
navigate(page: number) {
|
navigate(page: number) {
|
||||||
if (!this.response || page < 1 || page > this.response.paginacion.total_pages) return;
|
if (!this.response || page < 1 || page > this.response.paginacion.total_pages) return;
|
||||||
|
|||||||
@@ -18,8 +18,13 @@ export interface Indicador {
|
|||||||
filtros?: IndicadorFiltro[];
|
filtros?: IndicadorFiltro[];
|
||||||
// Tabs that show it; without this field, all of them.
|
// Tabs that show it; without this field, all of them.
|
||||||
vistas?: string[];
|
vistas?: string[];
|
||||||
|
// Interactive donut and bars by one stratum, like CaCu's EU7.
|
||||||
|
escenario?: VistaEscenario;
|
||||||
}
|
}
|
||||||
export type DimensionEstrato = 'grupo_edad' | 'estatus_seguimiento' | 'citologia_alto_grado';
|
export type DimensionEstrato = 'grupo_edad' | 'estatus_seguimiento' | 'citologia_alto_grado' | 'birads';
|
||||||
|
export const DIMENSIONES_ESTRATO: readonly DimensionEstrato[] = ['grupo_edad', 'estatus_seguimiento', 'citologia_alto_grado', 'birads'];
|
||||||
|
// `etiqueta` names one value of the stratum in lower case, as in «por escenario clínico».
|
||||||
|
export interface VistaEscenario { estrato: DimensionEstrato; etiqueta: string; }
|
||||||
export interface IndicadorFiltro { estrato: string; etiqueta: string; valores: { valor: string; etiqueta: string }[]; }
|
export interface IndicadorFiltro { estrato: string; etiqueta: string; valores: { valor: string; etiqueta: string }[]; }
|
||||||
export interface DatosScope { estrato?: DimensionEstrato; filtros?: readonly string[]; }
|
export interface DatosScope { estrato?: DimensionEstrato; filtros?: readonly string[]; }
|
||||||
export interface EstratoTotal { periodo: string; grupo: string; estrato: string; n: number | null; suprimido: 0 | 1; }
|
export interface EstratoTotal { periodo: string; grupo: string; estrato: string; n: number | null; suprimido: 0 | 1; }
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { inject, Injectable } from '@angular/core';
|
import { inject, Injectable } from '@angular/core';
|
||||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||||
import { map } from 'rxjs';
|
import { map } from 'rxjs';
|
||||||
import { DatosScope, Dominio, IndicadorDatos, IndicadorMetadatos, FigureSelection, Indicador, parsePeriodos, PlotlyFigure, requireDominio } from './indicadores.models';
|
import { DatosScope, DIMENSIONES_ESTRATO, DimensionEstrato, Dominio, IndicadorDatos, IndicadorMetadatos, FigureSelection, Indicador, parsePeriodos, PlotlyFigure, requireDominio } from './indicadores.models';
|
||||||
|
|
||||||
function record(value: unknown): value is Record<string, unknown> {
|
function record(value: unknown): value is Record<string, unknown> {
|
||||||
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
||||||
@@ -20,7 +20,9 @@ export class IndicadoresService {
|
|||||||
&& new Set(item['figuras']).size === item['figuras'].length
|
&& new Set(item['figuras']).size === item['figuras'].length
|
||||||
&& Array.isArray(item['tipos_periodo']) && item['tipos_periodo'].length > 0
|
&& Array.isArray(item['tipos_periodo']) && item['tipos_periodo'].length > 0
|
||||||
&& item['tipos_periodo'].every((tipo: unknown) => tipo === 'semestre' || tipo === 'mes')
|
&& item['tipos_periodo'].every((tipo: unknown) => tipo === 'semestre' || tipo === 'mes')
|
||||||
&& new Set(item['tipos_periodo']).size === item['tipos_periodo'].length)) {
|
&& new Set(item['tipos_periodo']).size === item['tipos_periodo'].length
|
||||||
|
&& (item['escenario'] === undefined || record(item['escenario']) && typeof item['escenario']['etiqueta'] === 'string'
|
||||||
|
&& DIMENSIONES_ESTRATO.includes(item['escenario']['estrato'] as DimensionEstrato)))) {
|
||||||
throw new Error('Respuesta de catálogo inválida');
|
throw new Error('Respuesta de catálogo inválida');
|
||||||
}
|
}
|
||||||
if (new Set(value.map(item => item['id'])).size !== value.length) throw new Error('IDs de catálogo duplicados');
|
if (new Set(value.map(item => item['id'])).size !== value.length) throw new Error('IDs de catálogo duplicados');
|
||||||
@@ -66,7 +68,7 @@ export class IndicadoresService {
|
|||||||
}
|
}
|
||||||
let params = new HttpParams();
|
let params = new HttpParams();
|
||||||
if (scope.estrato) {
|
if (scope.estrato) {
|
||||||
if (!['grupo_edad', 'estatus_seguimiento', 'citologia_alto_grado'].includes(scope.estrato)) throw new Error('Dimensión no admitida');
|
if (!DIMENSIONES_ESTRATO.includes(scope.estrato)) throw new Error('Dimensión no admitida');
|
||||||
params = params.set('estrato', scope.estrato);
|
params = params.set('estrato', scope.estrato);
|
||||||
}
|
}
|
||||||
if (scope.filtros?.length) params = params.set('filtro', scope.filtros.join(','));
|
if (scope.filtros?.length) params = params.set('filtro', scope.filtros.join(','));
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import { inject, Injectable } from '@angular/core';
|
||||||
|
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||||
|
import { map } from 'rxjs';
|
||||||
|
import { isoDate, SeguimientoQuery, SeguimientoResponse, SeguimientoStatus } from './cacu-seguimiento.models';
|
||||||
|
import { validSeguimientoQuery } from './cacu-seguimiento.service';
|
||||||
|
import { Dominio, requireDominio } from './indicadores.models';
|
||||||
|
|
||||||
|
// Follow-up list whose filters and columns come with the answer, so a domain needs no code of its own.
|
||||||
|
export type SeguimientoValor = string | number | null;
|
||||||
|
// `detalles` are shown under the value, each with its label (for example the date of a result).
|
||||||
|
export interface SeguimientoColumna { clave: string; etiqueta: string; detalles?: { clave: string; etiqueta: string }[] }
|
||||||
|
export interface SeguimientoFiltro { clave: string; etiqueta: string; opciones: SeguimientoStatus[] }
|
||||||
|
export interface SeguimientoTablaResponse extends Pick<SeguimientoResponse, 'simulado' | 'corte' | 'ventana' | 'paginacion'> {
|
||||||
|
filtros: Record<string, string | null>;
|
||||||
|
filtros_disponibles: SeguimientoFiltro[];
|
||||||
|
columnas: SeguimientoColumna[];
|
||||||
|
// Every item has `id_seudonimo`; the rest are the columns' keys and their details.
|
||||||
|
items: Record<string, SeguimientoValor>[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const record = (v: unknown): v is Record<string, unknown> => !!v && typeof v === 'object' && !Array.isArray(v);
|
||||||
|
const integer = (v: unknown, min = 0) => typeof v === 'number' && Number.isSafeInteger(v) && v >= min;
|
||||||
|
const text = (v: unknown): v is string => typeof v === 'string' && v.length > 0;
|
||||||
|
const valor = (v: unknown) => v === null || typeof v === 'string' || typeof v === 'number' && Number.isFinite(v);
|
||||||
|
// Keys travel as query parameters, so they are restricted to what can't collide with the shared ones.
|
||||||
|
const clave = (v: unknown) => text(v) && /^[a-z][a-z0-9_]*$/.test(v) && !['meses', 'page', 'page_size', 'corte'].includes(v);
|
||||||
|
const opcion = (v: unknown) => record(v) && text(v['codigo']) && text(v['etiqueta']);
|
||||||
|
|
||||||
|
export function seguimientoTablaResponse(v: unknown): SeguimientoTablaResponse {
|
||||||
|
// Same rule as CaCu and TEA: demonstration records only.
|
||||||
|
if (!record(v) || v['simulado'] !== true) throw new Error('Esta vista solo admite datos de demostración.');
|
||||||
|
const p = v['paginacion'], window = v['ventana'], filters = v['filtros'], available = v['filtros_disponibles'], columns = v['columnas'];
|
||||||
|
if (!isoDate(v['corte']) || !record(window) || ![1, 3, 6, 12].includes(window['meses'] as number) || !isoDate(window['desde']) || !isoDate(window['hasta'])
|
||||||
|
|| !record(p) || !integer(p['page'], 1) || !integer(p['page_size'], 1) || (p['page_size'] as number) > 200 || !integer(p['total_items']) || !integer(p['total_pages'])
|
||||||
|
|| !Array.isArray(available) || !available.every(f => record(f) && clave(f['clave']) && text(f['etiqueta']) && Array.isArray(f['opciones']) && f['opciones'].every(opcion))
|
||||||
|
|| new Set(available.map(f => f['clave'])).size !== available.length
|
||||||
|
|| !record(filters) || !Object.entries(filters).every(([k, f]) => f === null || typeof f === 'string' && available.some(a => a['clave'] === k))
|
||||||
|
|| !Array.isArray(columns) || !columns.length || !columns.every(c => record(c) && text(c['clave']) && text(c['etiqueta'])
|
||||||
|
&& (c['detalles'] === undefined || Array.isArray(c['detalles']) && c['detalles'].every(d => record(d) && text(d['clave']) && text(d['etiqueta']))))
|
||||||
|
|| !Array.isArray(v['items']) || v['items'].length > (p['page_size'] as number)
|
||||||
|
|| !v['items'].every(item => record(item) && text(item['id_seudonimo']) && Object.values(item).every(valor)))
|
||||||
|
throw new Error('Respuesta de seguimiento inválida');
|
||||||
|
return v as unknown as SeguimientoTablaResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class SeguimientoTablaService {
|
||||||
|
private readonly http = inject(HttpClient);
|
||||||
|
consultar(dominio: Dominio, query: SeguimientoQuery) {
|
||||||
|
if (!validSeguimientoQuery(query) || !Object.keys(query.filtros ?? {}).every(clave)) throw new Error('Parámetros de seguimiento inválidos');
|
||||||
|
let params = new HttpParams().set('meses', query.meses).set('page', query.page).set('page_size', query.page_size);
|
||||||
|
if (query.corte) params = params.set('corte', query.corte);
|
||||||
|
for (const [k, v] of Object.entries(query.filtros ?? {})) if (v) params = params.set(k, v);
|
||||||
|
return this.http.get<unknown>(`/${requireDominio(dominio)}/seguimiento`, { params }).pipe(map(seguimientoTablaResponse));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { provideHttpClient } from '@angular/common/http';
|
||||||
|
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
|
||||||
|
import eu7 from './fixtures/eu7-c2-ejemplos.json';
|
||||||
|
import { Indicador, IndicadorDatos } from './indicadores.models';
|
||||||
|
import { modelo, vistaEscenario } from './indicadores-eu7-escenario';
|
||||||
|
import { IndicadoresTracking } from './indicadores-tracking';
|
||||||
|
import { seguimientoTablaResponse } from './seguimiento-tabla.service';
|
||||||
|
|
||||||
|
// Covers what lets a domain reuse CaCu's views without code of its own: the interactive donut and bars
|
||||||
|
// chosen by the catalog's `escenario`, and the follow-up list whose filters and columns come in the answer.
|
||||||
|
// Fixtures: `eu7-c2-ejemplos.json` (CaCu's EU7 answers, relabelled here as another stratum) and `lista`,
|
||||||
|
// a two-patient CaMa list built below.
|
||||||
|
|
||||||
|
// Two CaMa patients, one without a biopsy, with the filters and columns the list announces.
|
||||||
|
const lista = () => ({
|
||||||
|
simulado: true, corte: '2026-10-20', ventana: { meses: 3, desde: '2026-07-21', hasta: '2026-10-20' },
|
||||||
|
filtros: { birads: null }, filtros_disponibles: [{ clave: 'birads', etiqueta: 'Categoría BI-RADS', opciones: [{ codigo: 'BIRADS_5', etiqueta: 'BI-RADS 5' }] }],
|
||||||
|
columnas: [{ clave: 'id_seudonimo', etiqueta: 'Identificador seudónimo' },
|
||||||
|
{ clave: 'birads', etiqueta: 'Última mastografía', detalles: [{ clave: 'mastografia_fecha', etiqueta: 'Fecha' }] },
|
||||||
|
{ clave: 'biopsia', etiqueta: 'Resultado histopatológico' }],
|
||||||
|
paginacion: { page: 1, page_size: 50, total_items: 2, total_pages: 1 },
|
||||||
|
items: [{ id_seudonimo: 'M-0001', birads: 'BI-RADS 5', mastografia_fecha: '2026-09-01', biopsia: 'Carcinoma invasor' },
|
||||||
|
{ id_seudonimo: 'M-0002', birads: 'BI-RADS 4A', mastografia_fecha: '2026-08-15', biopsia: null }],
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Vista de dona y barras por estrato', () => {
|
||||||
|
const item = (extra: Partial<Indicador> = {}): Indicador => ({ id: 'x', titulo: 'X', contrato: 'C2', figuras: [], tipos_periodo: ['semestre'], ...extra });
|
||||||
|
it('la elige el campo escenario del catálogo, y CaCu EU7 la conserva sin él', () => {
|
||||||
|
// Fails if the view goes back to being recognised by CaCu's indicator id only.
|
||||||
|
expect(vistaEscenario('cama', item({ escenario: { estrato: 'birads', etiqueta: 'categoría BI-RADS' } }))?.estrato).toBe('birads');
|
||||||
|
expect(vistaEscenario('cacu', item({ id: 'cacu_eu7' }))?.estrato).toBe('estatus_seguimiento');
|
||||||
|
expect(vistaEscenario('cama', item())).toBeUndefined();
|
||||||
|
});
|
||||||
|
it('arma el modelo con otro indicador y otro estrato', () => {
|
||||||
|
// Fails if `modelo` checks CaCu's id or its stratum instead of the ones it is given.
|
||||||
|
const relabel = (d: unknown, estrato: string | null) => ({ ...structuredClone(d) as IndicadorDatos, id: 'cama_histopatologia_birads', ...(estrato ? { estrato } : {}) });
|
||||||
|
const general = relabel(eu7.general, null), porBirads = relabel(eu7.estatus_seguimiento, 'birads');
|
||||||
|
expect(modelo(general, porBirads, '2025-S2', 'birads').total).toBe(946);
|
||||||
|
expect(() => modelo(general, porBirads, '2025-S2')).toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Seguimiento con filtros y columnas anunciados', () => {
|
||||||
|
let fixture: ReturnType<typeof TestBed.createComponent<IndicadoresTracking>>, http: HttpTestingController;
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({ providers: [provideHttpClient(), provideHttpClientTesting()] });
|
||||||
|
fixture = TestBed.createComponent(IndicadoresTracking); http = TestBed.inject(HttpTestingController);
|
||||||
|
fixture.componentRef.setInput('dominio', 'cama'); fixture.componentRef.setInput('domainLabel', 'cáncer de mama');
|
||||||
|
fixture.componentRef.setInput('active', true); fixture.detectChanges();
|
||||||
|
});
|
||||||
|
afterEach(() => { fixture.destroy(); http.verify(); });
|
||||||
|
const text = () => fixture.nativeElement.textContent as string;
|
||||||
|
|
||||||
|
it('pinta las columnas, los detalles y los valores ausentes de la respuesta', () => {
|
||||||
|
// Fails if CaMa stops querying its own list or the table stops following `columnas`.
|
||||||
|
http.expectOne(r => r.url === '/cama/seguimiento').flush(lista()); fixture.detectChanges();
|
||||||
|
const headers = Array.from(fixture.nativeElement.querySelectorAll('thead th')).map(e => (e as HTMLElement).textContent?.trim());
|
||||||
|
expect(headers).toEqual(['Identificador seudónimo', 'Última mastografía', 'Resultado histopatológico']);
|
||||||
|
expect(text()).toContain('Fecha: 2026-09-01');
|
||||||
|
expect(fixture.nativeElement.querySelectorAll('tbody tr')[1].textContent).toContain('No disponible');
|
||||||
|
});
|
||||||
|
it('envía cada filtro anunciado con su clave y sin los vacíos', () => {
|
||||||
|
// Fails if the announced filters stop reaching the query, or an empty choice is sent as a value.
|
||||||
|
http.expectOne(r => r.url === '/cama/seguimiento').flush(lista()); fixture.detectChanges();
|
||||||
|
expect(fixture.nativeElement.querySelector('select[name="filtro-birads"]')).not.toBeNull();
|
||||||
|
expect(fixture.nativeElement.querySelector('select[name="estatus"]')).toBeNull();
|
||||||
|
fixture.componentInstance.filtrosDraft['birads'] = 'BIRADS_5'; fixture.componentInstance.apply();
|
||||||
|
let req = http.expectOne(r => r.url === '/cama/seguimiento');
|
||||||
|
expect(req.request.params.get('birads')).toBe('BIRADS_5');
|
||||||
|
req.flush({ ...lista(), filtros: { birads: 'BIRADS_5' } });
|
||||||
|
fixture.componentInstance.filtrosDraft['birads'] = ''; fixture.componentInstance.apply();
|
||||||
|
req = http.expectOne(r => r.url === '/cama/seguimiento');
|
||||||
|
expect(req.request.params.has('birads')).toBe(false);
|
||||||
|
req.flush(lista());
|
||||||
|
});
|
||||||
|
it('sin lista publicada queda pendiente', () => {
|
||||||
|
// Fails if a 404 on the first page is shown as an error instead of a list not yet published.
|
||||||
|
http.expectOne(r => r.url === '/cama/seguimiento').flush({}, { status: 404, statusText: 'Not found' }); fixture.detectChanges();
|
||||||
|
expect(text()).toContain('Funcionalidad pendiente de publicación');
|
||||||
|
});
|
||||||
|
it('solo admite datos de demostración y respuestas coherentes', () => {
|
||||||
|
// Fails if the validation stops guarding the table from real records or from filters it didn't announce.
|
||||||
|
expect(() => seguimientoTablaResponse({ ...lista(), simulado: false })).toThrow();
|
||||||
|
expect(() => seguimientoTablaResponse({ ...lista(), filtros: { edad: '40-49' } })).toThrow();
|
||||||
|
expect(() => seguimientoTablaResponse({ ...lista(), filtros_disponibles: [{ clave: 'page', etiqueta: 'X', opciones: [] }] })).toThrow();
|
||||||
|
expect(() => seguimientoTablaResponse({ ...lista(), items: [{ birads: 'BI-RADS 5' }] })).toThrow();
|
||||||
|
http.expectOne(r => r.url === '/cama/seguimiento').flush(lista());
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -25,7 +25,7 @@ button.nombre:focus-visible::after { outline: 2px solid var(--issste-text); outl
|
|||||||
.leyenda-mapa .rojo { margin-inline-start: .5rem; background: #B2182B; }
|
.leyenda-mapa .rojo { margin-inline-start: .5rem; background: #B2182B; }
|
||||||
dd[data-calidad=aceptable] { color: #B26A00; }
|
dd[data-calidad=aceptable] { color: #B26A00; }
|
||||||
.dominio { display: grid; grid-template-columns: 1fr auto; gap: .15rem 1rem; margin-bottom: .4rem; font-size: .85rem; }
|
.dominio { display: grid; grid-template-columns: 1fr auto; gap: .15rem 1rem; margin-bottom: .4rem; font-size: .85rem; }
|
||||||
.bar { grid-column: 1 / -1; height: .375rem; border-radius: 999px; background: var(--issste-border); overflow: hidden; }
|
.bar { grid-column: 1 / -1; height: .375rem; border-radius: var(--issste-radius); background: var(--issste-border); overflow: hidden; }
|
||||||
.bar span { display: block; height: 100%; background: var(--issste-text); }
|
.bar span { display: block; height: 100%; background: var(--issste-text); }
|
||||||
details { margin-top: .5rem; }
|
details { margin-top: .5rem; }
|
||||||
summary { cursor: pointer; font-weight: 600; font-size: .9rem; min-height: 44px; display: flex; align-items: center; gap: .5rem; list-style: none; }
|
summary { cursor: pointer; font-weight: 600; font-size: .9rem; min-height: 44px; display: flex; align-items: center; gap: .5rem; list-style: none; }
|
||||||
@@ -44,7 +44,7 @@ dt { color: var(--issste-text-secondary); } dd { margin: 0; text-align: end; fon
|
|||||||
.regiones li { padding: .1rem 0; }
|
.regiones li { padding: .1rem 0; }
|
||||||
.regiones li span:last-child { float: inline-end; font-variant-numeric: tabular-nums; }
|
.regiones li span:last-child { float: inline-end; font-variant-numeric: tabular-nums; }
|
||||||
.regiones .destacada { font-weight: 700; }
|
.regiones .destacada { font-weight: 700; }
|
||||||
h3 .mock { display: inline-block; white-space: nowrap; margin-inline-start: .5rem; padding: .1rem .5rem; border: 1px dashed var(--issste-border); border-radius: 999px;
|
h3 .mock { display: inline-block; white-space: nowrap; margin-inline-start: .5rem; padding: .1rem .5rem; border: 1px dashed var(--issste-border); border-radius: var(--issste-radius);
|
||||||
font-size: .75rem; font-weight: 400; color: var(--issste-text-secondary); vertical-align: middle; }
|
font-size: .75rem; font-weight: 400; color: var(--issste-text-secondary); vertical-align: middle; }
|
||||||
.sin-alteraciones { margin: 0 0 .75rem; font-weight: 600; }
|
.sin-alteraciones { margin: 0 0 .75rem; font-weight: 600; }
|
||||||
.metricas, .efectos { margin: 0; padding: 0; list-style: none; }
|
.metricas, .efectos { margin: 0; padding: 0; list-style: none; }
|
||||||
|
|||||||
+9
-2
@@ -10,7 +10,7 @@
|
|||||||
--color-border: #e3e7df;
|
--color-border: #e3e7df;
|
||||||
--color-step: #f0f3e8;
|
--color-step: #f0f3e8;
|
||||||
--font-body: 'Roboto', sans-serif;
|
--font-body: 'Roboto', sans-serif;
|
||||||
--font-heading: 'Rajdhani', 'Roboto Condensed', 'Arial Narrow', sans-serif;
|
--font-heading: 'Roboto', 'Helvetica Neue', Arial, sans-serif;
|
||||||
--site-header-height: 72px;
|
--site-header-height: 72px;
|
||||||
|
|
||||||
/* Spacing scale on a 4px grid. Use these for padding, margins and gaps
|
/* Spacing scale on a 4px grid. Use these for padding, margins and gaps
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
--issste-space-3: var(--space-3);
|
--issste-space-3: var(--space-3);
|
||||||
--issste-space-4: var(--space-4);
|
--issste-space-4: var(--space-4);
|
||||||
--issste-space-6: var(--space-6);
|
--issste-space-6: var(--space-6);
|
||||||
--issste-radius: var(--mat-sys-corner-medium);
|
--issste-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
html {
|
html {
|
||||||
@@ -60,6 +60,13 @@ html {
|
|||||||
density: 0,
|
density: 0,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
// Institutional shapes: square corners with a slight rounding, including buttons (no pills).
|
||||||
|
--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;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
|||||||
Reference in New Issue
Block a user