diff --git a/src/app/features/indicadores/indicador-screening-route.html b/src/app/features/indicadores/indicador-screening-route.html
index fef2e09..72d1bec 100644
--- a/src/app/features/indicadores/indicador-screening-route.html
+++ b/src/app/features/indicadores/indicador-screening-route.html
@@ -8,12 +8,7 @@
}
@if (model(); as m) {
-
- Periodo
-
- @for (period of m.periods; track period) { {{ periodLabel(period) }} }
-
-
+ @if (m.period) {
Periodo: {{ periodLabel(m.period) }}
}
Acumulado desde la toma
Por pasos
diff --git a/src/app/features/indicadores/indicador-screening-route.spec.ts b/src/app/features/indicadores/indicador-screening-route.spec.ts
index 7a804b5..3b38cf7 100644
--- a/src/app/features/indicadores/indicador-screening-route.spec.ts
+++ b/src/app/features/indicadores/indicador-screening-route.spec.ts
@@ -64,8 +64,10 @@ describe('Ruta del tamizaje: componente', () => {
expect((f.componentInstance.figure()!.data[0] as Record)['base']).toBeUndefined();
f.componentInstance.selectView('steps'); f.detectChanges();
expect((f.componentInstance.figure()!.data[0] as Record)['base']).toBeDefined();
- f.componentInstance.selectPeriod('2025-S1'); f.detectChanges();
+ // the period follows the page's filter, with no request of its own
+ f.componentRef.setInput('periodos', ['2025-S1']); f.detectChanges();
expect(f.componentInstance.model()!.period).toBe('2025-S1');
+ expect(f.nativeElement.querySelector('mat-select')).toBeNull();
f.componentRef.setInput('tema', 'oscuro'); f.detectChanges();
expect(f.componentInstance.figure()!.layout['paper_bgcolor']).toBe('#081839');
http.expectNone(() => true);
diff --git a/src/app/features/indicadores/indicador-screening-route.ts b/src/app/features/indicadores/indicador-screening-route.ts
index c1d66fe..e2752a2 100644
--- a/src/app/features/indicadores/indicador-screening-route.ts
+++ b/src/app/features/indicadores/indicador-screening-route.ts
@@ -3,9 +3,7 @@ import { HttpErrorResponse } from '@angular/common/http';
import { forkJoin, Subscription, timeout, TimeoutError } from 'rxjs';
import { MatButtonModule } from '@angular/material/button';
import { MatButtonToggleModule } from '@angular/material/button-toggle';
-import { MatFormFieldModule } from '@angular/material/form-field';
import { MatProgressBarModule } from '@angular/material/progress-bar';
-import { MatSelectModule } from '@angular/material/select';
import { PlotlyChart } from '../../shared/plotly/plotly-chart';
import { Dominio, IndicadorDatos, Tema, TipoPeriodo } from './indicadores.models';
import { etiquetaPeriodo } from './indicadores-historico-figures';
@@ -16,7 +14,7 @@ import { ROUTE_IDS, RouteIncompatible, RouteView, routeCellText, routeFigure, ro
/** Days along the screening route, from the sample to each event, as horizontal bars: cumulative or step by step. */
@Component({
selector: 'app-indicador-screening-route',
- imports: [MatButtonModule, MatButtonToggleModule, MatFormFieldModule, MatProgressBarModule, MatSelectModule, PlotlyChart],
+ imports: [MatButtonModule, MatButtonToggleModule, MatProgressBarModule, PlotlyChart],
templateUrl: './indicador-screening-route.html',
styleUrl: './indicador-screening-route.scss',
})
@@ -24,17 +22,18 @@ export class IndicadorScreeningRoute {
readonly dominio = input.required();
readonly tema = input.required();
readonly tipo = input('semestre');
+ /** The periods of the page's filter: the chart shows the newest of them with data, and has no period filter of its own. */
+ readonly periodos = input(undefined);
/** The measures load once the region is visible. */
readonly visible = input(true);
readonly status = signal<'deferred' | 'loading' | 'ready' | 'empty' | 'error' | 'incompatible'>('deferred');
readonly message = signal('');
readonly view = signal('cumulative');
- readonly requestedPeriod = signal(undefined);
private readonly payloads = signal | undefined>(undefined);
readonly model = computed(() => {
const data = this.payloads();
- return data ? routeModel(data, this.tipo(), this.requestedPeriod()) : undefined;
+ return data ? routeModel(data, this.tipo(), this.periodos()) : undefined;
});
readonly figure = computed(() => {
const model = this.model();
@@ -56,7 +55,6 @@ export class IndicadorScreeningRoute {
}
retry() { this.load(this.dominio(), this.tipo()); }
- selectPeriod(period: string) { this.requestedPeriod.set(period); }
selectView(view: RouteView) { this.view.set(view); }
private load(dominio: Dominio, tipo: TipoPeriodo) {
@@ -67,7 +65,7 @@ export class IndicadorScreeningRoute {
this.subscription = forkJoin(requests).pipe(timeout({ first: 40000 })).subscribe({
next: data => {
try {
- const model = routeModel(data, tipo, this.requestedPeriod());
+ const model = routeModel(data, tipo, this.periodos());
this.payloads.set(data);
this.status.set(routeHasData(model) ? 'ready' : 'empty');
} catch (error) { this.failure(error); }
diff --git a/src/app/features/indicadores/indicadores-page.html b/src/app/features/indicadores/indicadores-page.html
index fed9daa..5b80202 100644
--- a/src/app/features/indicadores/indicadores-page.html
+++ b/src/app/features/indicadores/indicadores-page.html
@@ -126,7 +126,7 @@
Incluye el periodo y los indicadores seleccionados. Elige «Guardar como PDF» en el cuadro de impresión.
}
- @if (screeningRouteAvailable) { }
+ @if (screeningRouteAvailable) { }
@for (item of clinicosItems(); track cardIdentity(item)) {
0
&& !this.catalog().some(item => item.id === ID_HISTOPATOLOGIA_CAMA);
}
+ /** The periods the page's filter applies, for the charts that follow it with no filter of their own (the screening
+ * route); `undefined` when it applies every period. */
+ periodosDelFiltro(): readonly string[] | undefined {
+ const seleccion = this.filters?.applied.selection;
+ return seleccion?.mode === 'explicit' ? seleccion.periodos : undefined;
+ }
// CaCu's screening route chart, once the catalog publishes every measure it reads.
get screeningRouteAvailable() {
return this.dominio === 'cacu' && ROUTE_IDS.every(id => this.catalog().some(item => item.id === id));
diff --git a/src/app/features/indicadores/screening-route.spec.ts b/src/app/features/indicadores/screening-route.spec.ts
index bd397c0..69f781e 100644
--- a/src/app/features/indicadores/screening-route.spec.ts
+++ b/src/app/features/indicadores/screening-route.spec.ts
@@ -49,6 +49,17 @@ describe('Ruta del tamizaje: modelo', () => {
expect(routeModel(data, 'semestre').period).toBe('2025-S2');
expect(routeModel(data, 'semestre', '2026-S1').period).toBe('2026-S1');
});
+ it('con los periodos del filtro de la página se usa el más reciente de ellos con cajas publicadas', () => {
+ // Fails if the chart, which has no period filter of its own, ignores the page's periods or opens on an empty one of
+ // them while an earlier one it was given has data.
+ const vacio = (id: string) => payload(id, [row('2025-S1', [10, 1, 2, 3]), row('2025-S2', S2[id]),
+ row('2026-S1', [0, null as never, null as never, null as never], { suprimido: 1 })], ['2025-S1', '2025-S2', '2026-S1']);
+ const data = Object.fromEntries(ROUTE_IDS.map(id => [id, vacio(id)]));
+ expect(routeModel(data, 'semestre', ['2025-S1', '2026-S1', '2025-S2']).period).toBe('2025-S2');
+ expect(routeModel(data, 'semestre', ['2025-S1']).period).toBe('2025-S1');
+ expect(routeModel(data, 'semestre', ['2026-S1']).period).toBe('2026-S1');
+ expect(routeModel(data, 'semestre', ['2023-S1']).period).toBe('2025-S2');
+ });
it('un paso suprimido o sin datos no se dibuja y la cadena sigue desde el último publicado', () => {
// Pins down: nothing is drawn as zero and the next step starts at the last published end. Fails if a suppressed box
// becomes a bar or leaves a gap in the chain.
diff --git a/src/app/features/indicadores/screening-route.ts b/src/app/features/indicadores/screening-route.ts
index 0f8f768..77fd39e 100644
--- a/src/app/features/indicadores/screening-route.ts
+++ b/src/app/features/indicadores/screening-route.ts
@@ -47,7 +47,8 @@ const fail = (message: string): never => { throw new RouteIncompatible(message);
const NOT_AVAILABLE: Caja = { estado: 'No disponible' };
/** The seven C3r /datos payloads -> one row per event for a period, newest period first when none is requested. */
-export function routeModel(data: Record, tipo: TipoPeriodo, requested?: string): RouteModel {
+export function routeModel(data: Record, tipo: TipoPeriodo,
+ requested?: string | readonly string[]): RouteModel {
const boxes: Record> = {};
for (const id of ROUTE_IDS) {
const d = data[id];
@@ -66,9 +67,12 @@ export function routeModel(data: Record, tipo: TipoPerio
}
}
const periods = [...new Set(ROUTE_IDS.flatMap(id => data[id].periodos))].sort().reverse();
- // Without a valid request the newest period that has a published box: a semester that has just begun is empty.
+ // The newest of the requested periods (the page's filter) that has a published box, else the newest requested one;
+ // without a valid request, the newest period that has a published box: a semester that has just begun is empty.
const hasData = (p: string) => ROUTE_IDS.some(id => boxes[id][p]?.estado === 'Publicado');
- const period = requested && periods.includes(requested) ? requested : periods.find(hasData) ?? periods[0];
+ const pedidos = (typeof requested === 'string' ? [requested] : [...(requested ?? [])])
+ .filter(p => periods.includes(p)).sort().reverse();
+ const period = pedidos.length ? pedidos.find(hasData) ?? pedidos[0] : periods.find(hasData) ?? periods[0];
let cursor = 0;
const rows = ROUTE_STEPS.map((step): RouteRow => {
const fromSample = period ? boxes[step.sinceSample][period] ?? NOT_AVAILABLE : NOT_AVAILABLE;