feat(indicadores): CaMa labels, single-period filters and the four-card strip
CaMa reads «cáncer de mama» everywhere on the indicators page and uses the compact filter: interval, one period and Aplicar on one row, without the mode selector, the multiple selection or the editing summaries. The opportunity strip is the four cards only, and the biopsy distribution card is no longer drawn in the summary (it stays in Datos y definiciones). Other domains keep their filter and strip. (cherry picked from commit 7c9dcf634e5870fec35ab96347b0863b2e3bb86e)
This commit is contained in:
@@ -168,7 +168,7 @@ describe('KPI integración con autoridad global', () => {
|
||||
expect(panels()).toHaveLength(2); expect(panels().every(p => p.result().state === 'Sin reportes disponibles')).toBe(true);
|
||||
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) {
|
||||
load(domain);
|
||||
const req = requests(); expect(req).toHaveLength(KPI_BY_DOMAIN[domain].length);
|
||||
@@ -176,10 +176,10 @@ describe('KPI integración con autoridad global', () => {
|
||||
req.forEach(r => r.flush({ ...response(KPI_BY_DOMAIN[domain].findIndex(d => r.request.url.endsWith('/' + d.id + '/datos')), domain), notas: ['Nota del pie de la figura.'] }));
|
||||
fixture.detectChanges();
|
||||
const cards = [...fixture.nativeElement.querySelectorAll('app-indicador-kpi-card')];
|
||||
expect(cards).toHaveLength(domain === 'cacu' ? 5 : 6);
|
||||
expect(cards.map(card => card.querySelector('.value')?.firstChild?.textContent?.trim())).toEqual(domain === 'cacu' ? ['5', undefined, '7', undefined, undefined] : ['5', undefined, '7', undefined, '40.0', '7']);
|
||||
expect(cards.map(card => card.querySelector('.value span')?.textContent.trim())).toEqual(domain === 'cacu' ? ['pacientes', undefined, 'días (mediana)', undefined, undefined] : ['pacientes', undefined, 'días (mediana)', undefined, '%', 'días (mediana)']);
|
||||
expect(cards.map(card => card.querySelector('.kpi-state')?.textContent.trim())).toEqual(domain === 'cacu' ? ['Disponible', 'Selección no consolidable', 'Disponible', 'Indicador no disponible', 'Indicador no disponible'] : ['Disponible', 'Integración pendiente', 'Disponible', 'Integración pendiente', 'Disponible', 'Disponible']);
|
||||
expect(cards).toHaveLength(domain === 'cacu' ? 5 : 4);
|
||||
expect(cards.map(card => card.querySelector('.value')?.firstChild?.textContent?.trim())).toEqual(domain === 'cacu' ? ['5', undefined, '7', undefined, undefined] : ['5', undefined, '7', undefined]);
|
||||
expect(cards.map(card => card.querySelector('.value span')?.textContent.trim())).toEqual(domain === 'cacu' ? ['pacientes', undefined, 'días (mediana)', undefined, undefined] : ['pacientes', undefined, 'días (mediana)', undefined]);
|
||||
expect(cards.map(card => card.querySelector('.kpi-state')?.textContent.trim())).toEqual(domain === 'cacu' ? ['Disponible', 'Selección no consolidable', 'Disponible', 'Indicador no disponible', 'Indicador no disponible'] : ['Disponible', 'Integración pendiente', 'Disponible', 'Integración pendiente']);
|
||||
expect(cards.map(card => card.textContent)).toEqual(expect.arrayContaining([
|
||||
expect.stringContaining('2025-S1'),
|
||||
expect.stringContaining(domain === 'cacu' ? '5 citologías; primer cuartil: 3 días; tercer cuartil: 9 días.' : '5 mastografías; Q1 a Q3: 3 a 9 días.'),
|
||||
|
||||
@@ -1,3 +1,54 @@
|
||||
@if (compact) {
|
||||
<section aria-label="Editor de filtros generales del proyecto">
|
||||
@if (!types.includes(state.tipo)) { <p role="status">El intervalo de análisis del borrador ya no está publicado para este proyecto. Elige un intervalo de análisis disponible.</p> }
|
||||
<div class="fields compact">
|
||||
<mat-form-field appearance="outline" subscriptSizing="dynamic"><mat-label>Intervalo de análisis</mat-label>
|
||||
<mat-select [ngModel]="state.tipo" (ngModelChange)="changeTipo($event)">
|
||||
@for (tipo of types; track tipo) { <mat-option [value]="tipo">{{ tipo === 'mes' ? 'Mensual' : 'Semestral' }}</mat-option> }
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline" subscriptSizing="dynamic"><mat-label>Periodo seleccionado</mat-label>
|
||||
<mat-select [ngModel]="selectedPeriods[0] ?? null" (ngModelChange)="select($event ? [$event] : [])">
|
||||
<mat-select-trigger><span class="select-value">{{ selectedPeriods[0] }}</span></mat-select-trigger>
|
||||
@for (period of options; track period) { <mat-option [value]="period">{{ period }}</mat-option> }
|
||||
@if (availability) {
|
||||
@for (period of unavailableSelection; track period) { <mat-option [value]="period" disabled>{{ period }}, disponibilidad no confirmada</mat-option> }
|
||||
}
|
||||
</mat-select>
|
||||
</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>
|
||||
<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.status === 'loading') { <p role="status">Consultando periodos disponibles…</p> }
|
||||
@else if (availability.status === 'error') {
|
||||
<p role="alert">No se pudo completar la consulta de periodos disponibles.</p>
|
||||
<button type="button" mat-stroked-button (click)="retryAvailability.emit()">Reintentar disponibilidad</button>
|
||||
} @else if (!options.length) { <p role="status">Sin reportes disponibles para este intervalo de análisis.</p> }
|
||||
@if (entry.draft.mode === 'explicit' && unavailableSelection.length) { <p role="status">La selección conservada contiene periodos cuya disponibilidad no está confirmada. Elige periodos disponibles antes de aplicar.</p> }
|
||||
}
|
||||
@if (!availability) {
|
||||
<p class="filter-help">Periodos agregados por ti. Su disponibilidad se desconoce hasta consultar; esta lista no es un inventario de reportes.</p>
|
||||
<div class="fields period-builder">
|
||||
<mat-form-field appearance="outline" subscriptSizing="dynamic"><mat-label>Año</mat-label><input matInput [(ngModel)]="year" inputmode="numeric" maxlength="4" /></mat-form-field>
|
||||
<mat-form-field appearance="outline" subscriptSizing="dynamic"><mat-label>{{ state.tipo === 'mes' ? 'Mes' : 'Semestre' }}</mat-label>
|
||||
<mat-select [(ngModel)]="unit">
|
||||
@for (value of state.tipo === 'mes' ? months : ['S1', 'S2']; track value) { <mat-option [value]="value">{{ value }}</mat-option> }
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<button type="button" mat-stroked-button (click)="add()">Agregar periodo</button>
|
||||
</div>
|
||||
<div class="remove" aria-label="Eliminar periodos agregados">
|
||||
@for (period of entry.added; track period) {
|
||||
<button type="button" mat-button (click)="remove(period)" [attr.aria-label]="'Eliminar periodo ' + period">Eliminar {{ period }}</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@if (error) { <p class="error" role="alert">{{ error }}</p> }
|
||||
@if (!canApply) { <p role="status">Selecciona un periodo válido para aplicar.</p> }
|
||||
</section>
|
||||
} @else {
|
||||
<section aria-label="Editor de filtros generales del proyecto">
|
||||
@if (state.tipo === 'mes') { <p class="filter-help">Para consultar meses debes elegir periodos explícitos. Todos con reporte utiliza semestres.</p> }
|
||||
@if (!types.includes(state.tipo)) { <p role="status">El intervalo de tiempo del borrador ya no está publicado para este proyecto. Elige un intervalo de tiempo disponible.</p> }
|
||||
@@ -64,3 +115,4 @@
|
||||
<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>
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ p { overflow-wrap: anywhere; line-height: 1.5; margin: var(--issste-space-3) 0;
|
||||
.remove { display: flex; flex-wrap: wrap; gap: var(--issste-space-2); }
|
||||
.remove button { min-height: 44px; }
|
||||
.apply-button { min-height: 44px; margin-top: var(--issste-space-2); }
|
||||
.fields.compact { align-items: center; }
|
||||
.fields.compact mat-form-field { flex: 0 1 14rem; }
|
||||
.fields.compact .apply-button { margin-top: 0; }
|
||||
@media (max-width: 550px) {
|
||||
mat-form-field, .period-builder mat-form-field { flex: 1 1 100%; max-width: none; }
|
||||
.period-builder button { margin-top: 0; }
|
||||
|
||||
@@ -19,6 +19,8 @@ export class IndicadorPeriodFilters implements OnChanges {
|
||||
@Input({ required: true }) types!: TipoPeriodo[];
|
||||
@Input() availability?: PeriodAvailability;
|
||||
@Input() initialPresentation = false;
|
||||
// One period at a time, with the interval and Aplicar on one row.
|
||||
@Input() compact = false;
|
||||
@Output() retryAvailability = new EventEmitter<void>();
|
||||
@Output() edited = new EventEmitter<void>();
|
||||
@Output() apply = new EventEmitter<void>();
|
||||
|
||||
@@ -9,6 +9,8 @@ import { By } from '@angular/platform-browser';
|
||||
import { IndicadoresPage } from './indicadores-page';
|
||||
import { IndicadorKpiPanel } from './indicador-kpi-panel';
|
||||
import { IndicadorKpiCard } from './indicador-kpi-card';
|
||||
import { IndicadorPeriodFilters } from './indicador-period-filters';
|
||||
import { emptyAvailability } from './indicadores-periodos';
|
||||
import {
|
||||
CAMA_OPORTUNIDAD_KPIS, CAMA_RESULTADO_DIAGNOSTICO_KPI, CAMA_TAMIZAJE_RESULTADO_KPI, CAMA_TASA_DETECCION_KPI,
|
||||
KPI_BY_DOMAIN, KpiDefinition, camaKpiCards, kpiResult,
|
||||
@@ -37,9 +39,8 @@ describe('Tarjetas de oportunidad de CaMa: definiciones', () => {
|
||||
expect(KPI_BY_DOMAIN.cama[0]).toBe(CAMA_OPORTUNIDAD_KPIS[0]);
|
||||
});
|
||||
it('solo las tarjetas con indicador en el catálogo entran en KPI_BY_DOMAIN, que es lo que se consulta sin pedirlo', () => {
|
||||
// Fails if an indicator the catalog does not publish is queried by default.
|
||||
expect(KPI_BY_DOMAIN.cama.map(d => d.id)).toEqual([
|
||||
'cama_birads_456_paciente', 'cama_confirmacion_birads45', 'cama_dias_toma_diagnostico', 'cama_eu38a']);
|
||||
// Fails if an indicator the catalog does not publish is queried by default, or if a card the summary retired comes back.
|
||||
expect(KPI_BY_DOMAIN.cama.map(d => d.id)).toEqual(['cama_birads_456_paciente', 'cama_eu38a']);
|
||||
expect(KPI_BY_DOMAIN.cama).not.toContain(CAMA_TASA_DETECCION_KPI);
|
||||
expect(KPI_BY_DOMAIN.cama).not.toContain(CAMA_RESULTADO_DIAGNOSTICO_KPI);
|
||||
});
|
||||
@@ -132,18 +133,18 @@ describe('Tarjetas de oportunidad de CaMa: valores', () => {
|
||||
|
||||
describe('Tarjetas de oportunidad de CaMa: cuáles se dibujan', () => {
|
||||
const only = (...ids: string[]) => (id: string) => ids.includes(id);
|
||||
it('sin ningún indicador publicado no hay tarjetas, ni siquiera pendientes', () => {
|
||||
// Fails if "Integración pendiente" is shown while the catalog is empty, loading or failed.
|
||||
it('sin ningún indicador de oportunidad publicado no hay tarjetas, ni siquiera pendientes', () => {
|
||||
// Fails if "Integración pendiente" is shown while the catalog is empty, loading or failed, or because of other CaMa indicators.
|
||||
expect(camaKpiCards(only())).toEqual([]);
|
||||
expect(camaKpiCards(only('cama_confirmacion_birads45', 'cama_dias_toma_diagnostico')).filter(c => !c.pending).length).toBe(2);
|
||||
expect(camaKpiCards(only('cama_confirmacion_birads45', 'cama_dias_toma_diagnostico', 'cama_biopsias'))).toEqual([]);
|
||||
expect(camaKpiCards(only('cama_tasa_deteccion_histopatologica')).filter(c => !c.pending).length).toBe(1);
|
||||
});
|
||||
it('con el catálogo actual del laboratorio hay dos tarjetas vivas y dos pendientes, y las existentes de DEV siguen después', () => {
|
||||
it('con el catálogo actual del laboratorio hay dos tarjetas vivas y dos pendientes, y nada más', () => {
|
||||
// Fails if the confirmation and screening-to-diagnosis cards, retired from the strip, are drawn again.
|
||||
const cards = camaKpiCards(only('cama_birads_456_paciente', 'cama_confirmacion_birads45', 'cama_dias_toma_diagnostico', 'cama_eu38a'));
|
||||
expect(cards.map(c => [c.definition.id, c.pending])).toEqual([
|
||||
['cama_birads_456_paciente', false], ['cama_tasa_deteccion_histopatologica', true],
|
||||
['cama_eu38a', false], ['cama_dias_resultado_diagnostico', true],
|
||||
['cama_confirmacion_birads45', false], ['cama_dias_toma_diagnostico', false]]);
|
||||
['cama_eu38a', false], ['cama_dias_resultado_diagnostico', true]]);
|
||||
});
|
||||
it('una tarjeta pendiente pasa a viva cuando el catálogo publica su indicador, sin tocar código', () => {
|
||||
const cards = camaKpiCards(only(...CAMA_OPORTUNIDAD_KPIS.map(d => d.id)));
|
||||
@@ -166,6 +167,12 @@ describe('Tarjetas de oportunidad de CaMa en la página', () => {
|
||||
});
|
||||
afterEach(() => { fixture.destroy(); http.verify(); vi.unstubAllGlobals(); });
|
||||
const catalog = (definitions: KpiDefinition[]) => definitions.map(d => ({ id: d.id, titulo: d.title, contrato: d.contrato, figuras: [], tipos_periodo: ['semestre', 'mes'] }));
|
||||
// What 18080 publishes besides the opportunity indicators: none of them has a card in the strip.
|
||||
const otros = (): KpiDefinition[] => [
|
||||
{ id: 'cama_confirmacion_birads45', title: 'Tasa de confirmación histopatológica', contrato: 'C1', unit: '%' },
|
||||
{ id: 'cama_dias_toma_diagnostico', title: 'Tiempo de tamizaje a diagnóstico', contrato: 'C3r', unit: 'días (mediana)' },
|
||||
{ id: 'cama_biopsias', title: 'Distribución de resultados de biopsia', contrato: 'C2', unit: 'biopsias' },
|
||||
{ id: 'cama_birads_456_mastografia', title: 'Porcentaje individual de mastografías', contrato: 'C2', unit: 'mastografías' }];
|
||||
const dataFor = (definition: KpiDefinition): IndicadorDatos => {
|
||||
if (definition.contrato === 'C2') return datos(definition, [{ ...row, grupo: 'TOTAL', categoria: 'A', n: 5 }]);
|
||||
if (definition.contrato === 'C1') return datos(definition, [{ ...row, grupo: 'total', valor: 40, numerador: 2, denominador: 5 }]);
|
||||
@@ -200,22 +207,24 @@ describe('Tarjetas de oportunidad de CaMa en la página', () => {
|
||||
|
||||
it('con el catálogo actual: dos tarjetas con datos, dos pendientes y ninguna consulta a indicadores sin publicar', () => {
|
||||
// Fails if a pending indicator is requested, or if a pending card is drawn with a number.
|
||||
const urls = load(KPI_BY_DOMAIN.cama);
|
||||
const urls = load(KPI_BY_DOMAIN.cama, { listed: catalog([...KPI_BY_DOMAIN.cama, ...otros()]) });
|
||||
expect(urls.some(url => url.includes('cama_tasa_deteccion_histopatologica') || url.includes('cama_dias_resultado_diagnostico'))).toBe(false);
|
||||
expect(urls.some(url => url.includes('cama_confirmacion_birads45') || url.includes('cama_dias_toma_diagnostico'))).toBe(false);
|
||||
expect(fixture.nativeElement.querySelector('#kpi-section-title').textContent).toBe('Indicadores de oportunidad');
|
||||
expect(cards().map(card => text(card, 'h3'))).toEqual([
|
||||
'Pacientes evaluadas con BI-RADS 4, 5 y 6', 'Tasa de detección histopatológica', 'Tiempo de tamizaje a resultado',
|
||||
'Tiempo de resultado a diagnóstico', 'Tasa de confirmación histopatológica', 'Tiempo de tamizaje a diagnóstico']);
|
||||
expect(cards().map(card => text(card, '.value'))).toEqual(['5pacientes', undefined, '7días (mediana)', undefined, '40.0%', '7días (mediana)']);
|
||||
expect(cards().map(card => text(card, '.kpi-state'))).toEqual(['Disponible', 'Integración pendiente', 'Disponible', 'Integración pendiente', 'Disponible', 'Disponible']);
|
||||
'Pacientes evaluadas con BI-RADS 4, 5 y 6', 'Tasa de detección histopatológica', 'Tiempo de tamizaje a resultado', 'Tiempo de resultado a diagnóstico']);
|
||||
expect(cards().map(card => text(card, '.value'))).toEqual(['5pacientes', undefined, '7días (mediana)', undefined]);
|
||||
expect(cards().map(card => text(card, '.kpi-state'))).toEqual(['Disponible', 'Integración pendiente', 'Disponible', 'Integración pendiente']);
|
||||
expect(cards()[1].textContent).toContain('aún no está publicado');
|
||||
expect(cards()[1].textContent).not.toMatch(/\d/);
|
||||
});
|
||||
it('si el catálogo publica los cuatro indicadores no queda ninguna tarjeta pendiente', () => {
|
||||
// Fails if a published opportunity indicator is not queried and drawn.
|
||||
const urls = load([...KPI_BY_DOMAIN.cama, CAMA_TASA_DETECCION_KPI, CAMA_RESULTADO_DIAGNOSTICO_KPI]);
|
||||
expect(cards()).toHaveLength(4);
|
||||
expect(urls.some(url => url.includes('cama_tasa_deteccion_histopatologica'))).toBe(true);
|
||||
expect(urls.some(url => url.includes('cama_dias_resultado_diagnostico'))).toBe(true);
|
||||
expect(cards().map(card => text(card, 'h3')).slice(0, 4)).toEqual(CAMA_OPORTUNIDAD_KPIS.map(d => d.title));
|
||||
expect(cards().map(card => text(card, 'h3'))).toEqual(CAMA_OPORTUNIDAD_KPIS.map(d => d.title));
|
||||
expect(cards().some(card => card.textContent?.includes('Integración pendiente'))).toBe(false);
|
||||
expect(cards()[1].textContent).toContain('2 de 5 biopsias con resultado maligno.');
|
||||
});
|
||||
@@ -239,6 +248,22 @@ describe('Tarjetas de oportunidad de CaMa en la página', () => {
|
||||
expect(fixture.nativeElement.textContent).not.toContain('private');
|
||||
expect(fixture.nativeElement.querySelector('button[aria-label="Reintentar Tiempo de tamizaje a resultado"]')).not.toBeNull();
|
||||
});
|
||||
it('la tarjeta de distribución de biopsias no se dibuja en el resumen de CaMa y el resto de las figuras sigue', () => {
|
||||
// Fails if cama_biopsias comes back to the summary, or if the filter also hides other indicators.
|
||||
load(KPI_BY_DOMAIN.cama, { listed: catalog([...KPI_BY_DOMAIN.cama, ...otros()]) });
|
||||
const ids = fixture.componentInstance.searchResults().items.map(item => item.id);
|
||||
expect(ids).not.toContain('cama_biopsias');
|
||||
expect(ids).toContain('cama_birads_456_mastografia');
|
||||
expect(fixture.nativeElement.querySelector('.catalog-grid').textContent).not.toContain('Distribución de resultados de biopsia');
|
||||
});
|
||||
it('los rótulos de CaMa dicen «cáncer de mama»', () => {
|
||||
load(KPI_BY_DOMAIN.cama);
|
||||
const text = fixture.nativeElement.textContent as string;
|
||||
expect(text).toContain('Cáncer de mama, investigación');
|
||||
expect(text).toContain('Explora los indicadores de cáncer de mama.');
|
||||
expect(text).toContain('Filtros generales de cáncer de mama');
|
||||
expect(text).toContain('Se aplica a los indicadores de oportunidad y las gráficas, salvo las de selección independiente.');
|
||||
});
|
||||
it('Disponible queda visualmente oculto y sigue en un único estado accesible en CaMa', () => {
|
||||
const card = TestBed.createComponent(IndicadorKpiCard);
|
||||
card.componentRef.setInput('title', 'Indicador'); card.componentRef.setInput('state', 'Disponible'); card.detectChanges();
|
||||
@@ -258,3 +283,61 @@ describe('Tarjetas de oportunidad de CaMa en la página', () => {
|
||||
card.destroy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Filtros generales de CaMa: periodo único', () => {
|
||||
let fixture: ReturnType<typeof TestBed.createComponent<IndicadorPeriodFilters>>;
|
||||
const availability = () => ({ ...emptyAvailability('ready'), options: { semestre: ['2025-S2', '2025-S1'], mes: ['2025-12', '2025-11'] } });
|
||||
function mount(compact: boolean, draft: unknown = { mode: 'explicit', periodos: ['2025-S2'] }, applied: unknown = { mode: 'explicit', periodos: ['2025-S2'] }) {
|
||||
TestBed.configureTestingModule({ imports: [IndicadorPeriodFilters] });
|
||||
fixture = TestBed.createComponent(IndicadorPeriodFilters);
|
||||
fixture.componentRef.setInput('types', ['semestre', 'mes']);
|
||||
fixture.componentRef.setInput('compact', compact);
|
||||
fixture.componentRef.setInput('availability', availability());
|
||||
fixture.componentRef.setInput('state', { tipo: 'semestre', editors: { semestre: { added: [], draft }, mes: { added: [], draft: { mode: 'empty' } } },
|
||||
applied: { tipo: 'semestre', selection: applied } });
|
||||
fixture.detectChanges();
|
||||
return fixture.componentInstance;
|
||||
}
|
||||
afterEach(() => fixture.destroy());
|
||||
const labels = () => [...fixture.nativeElement.querySelectorAll('mat-label')].map(e => (e as HTMLElement).textContent?.trim());
|
||||
|
||||
it('muestra Intervalo de análisis, Periodo seleccionado y Aplicar en una fila, sin modalidad ni resúmenes de edición', () => {
|
||||
// Fails if the multi-period controls or the editing summaries come back to CaMa.
|
||||
mount(true);
|
||||
expect(labels()).toEqual(['Intervalo de análisis', 'Periodo seleccionado']);
|
||||
expect(fixture.nativeElement.querySelector('.fields.compact .apply-button')).not.toBeNull();
|
||||
const text = fixture.nativeElement.textContent as string;
|
||||
expect(text).not.toContain('Modalidad');
|
||||
expect(text).not.toContain('Selección en edición');
|
||||
expect(text).not.toContain('Sin cambios pendientes');
|
||||
expect(text).toContain('Filtro general aplicado: 2025-S2. Existe reporte en al menos un indicador del dominio.');
|
||||
});
|
||||
it('elegir otro periodo deja un solo periodo en el borrador y avisa que hay cambios sin aplicar', () => {
|
||||
// Fails if the control keeps more than one period, or if the pending notice is lost.
|
||||
const control = mount(true);
|
||||
expect(fixture.nativeElement.textContent).not.toContain('Hay cambios sin aplicar.');
|
||||
control.select(['2025-S1']); fixture.componentRef.setInput('state', { ...control.state }); fixture.detectChanges();
|
||||
expect(control.state.editors.semestre!.draft).toEqual({ mode: 'explicit', periodos: ['2025-S1'] });
|
||||
expect(fixture.nativeElement.textContent).toContain('Hay cambios sin aplicar.');
|
||||
let applied = 0; control.apply.subscribe(() => applied++);
|
||||
(fixture.nativeElement.querySelector('.apply-button') as HTMLButtonElement).click();
|
||||
expect(applied).toBe(1);
|
||||
});
|
||||
it('Aplicar no se puede pulsar sin cambios pendientes', () => {
|
||||
mount(true);
|
||||
expect((fixture.nativeElement.querySelector('.apply-button') as HTMLButtonElement).disabled).toBe(true);
|
||||
});
|
||||
it('sin periodo elegido no hay nada que aplicar', () => {
|
||||
const control = mount(true, { mode: 'empty' });
|
||||
expect(control.canApply).toBe(false);
|
||||
expect(fixture.nativeElement.textContent).toContain('Selecciona un periodo válido para aplicar.');
|
||||
});
|
||||
it('los demás dominios conservan Modalidad, la selección múltiple y sus resúmenes', () => {
|
||||
// Fails if the single-period layout leaks to CaCu or TEA.
|
||||
mount(false, { mode: 'todos' }, { mode: 'todos' });
|
||||
expect(labels()).toEqual(['Intervalo de tiempo', 'Modalidad']);
|
||||
const text = fixture.nativeElement.textContent as string;
|
||||
expect(text).toContain('Selección en edición: Todos con reporte');
|
||||
expect(text).toContain('Sin cambios pendientes.');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ export class IndicadoresDefinitions {
|
||||
@Input() loading = false;
|
||||
@Input() error = '';
|
||||
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 figureDisplayName = figureDisplayName;
|
||||
readonly periodInterpretation = PERIOD_INTERPRETATION;
|
||||
|
||||
@@ -48,7 +48,7 @@ describe.each(['cacu', 'cama'] as const)('P0 búsqueda del ancla C2 de %s', doma
|
||||
if (domain === 'cama') {
|
||||
expect(anchor.id).toBe('cama_birads_456_paciente');
|
||||
expect(anchor.title).toBe('Pacientes evaluadas con BI-RADS 4, 5 y 6');
|
||||
expect(KPI_BY_DOMAIN.cama.map(d => d.id)).toEqual(['cama_birads_456_paciente', 'cama_confirmacion_birads45', 'cama_dias_toma_diagnostico', 'cama_eu38a']);
|
||||
expect(KPI_BY_DOMAIN.cama.map(d => d.id)).toEqual(['cama_birads_456_paciente', 'cama_eu38a']);
|
||||
} else expect(anchor.id).toBe('cacu_eu7');
|
||||
const run = start(); inventory(); request(periods[0]).flush(data(periods[0]));
|
||||
expect(run.selected()?.periodo).toBe(periods[0]);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { KPI_BY_DOMAIN, kpiResult } from './indicadores-kpi';
|
||||
import { KPI_BY_DOMAIN, KpiDefinition, kpiResult } from './indicadores-kpi';
|
||||
import { IndicadorDatos } from './indicadores.models';
|
||||
|
||||
// /cama/indicadores/<id>/datos?periodos=2025-S2 as WebApi served it (oct 2026) over a CaMa base
|
||||
@@ -129,7 +129,11 @@ const DATOS_2025_S2: Record<string, IndicadorDatos> = {
|
||||
|
||||
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 result = (index: number) => kpiResult(DATOS_2025_S2[KPI_BY_DOMAIN.cama[index].id], KPI_BY_DOMAIN.cama[index], 'cama', applied);
|
||||
// The two cards CaMa's summary no longer draws; their real responses still have to read correctly (the history charts use them).
|
||||
const confirmacion: KpiDefinition = { id: 'cama_confirmacion_birads45', title: 'Tasa de confirmación histopatológica', contrato: 'C1', unit: '%' };
|
||||
const tomaDiagnostico: KpiDefinition = { id: 'cama_dias_toma_diagnostico', title: 'Tiempo de tamizaje a diagnóstico', contrato: 'C3r', unit: 'días (mediana)' };
|
||||
const definitions = [KPI_BY_DOMAIN.cama[0], confirmacion, tomaDiagnostico];
|
||||
const result = (index: number) => kpiResult(DATOS_2025_S2[definitions[index].id], definitions[index], 'cama', applied);
|
||||
|
||||
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 }));
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { KPI_BY_DOMAIN, KpiDefinition, kpiResult } from './indicadores-kpi';
|
||||
import { CAMA_TAMIZAJE_RESULTADO_KPI, CAMA_TASA_DETECCION_KPI, KPI_BY_DOMAIN, KpiDefinition, kpiResult } from './indicadores-kpi';
|
||||
import { GlobalApplied } from './indicadores-memory';
|
||||
import { Dominio, IndicadorDatos } from './indicadores.models';
|
||||
const applied: GlobalApplied = { tipo: 'semestre', selection: { mode: 'explicit', periodos: ['2025-S1'] }, revision: 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.
|
||||
// CaMa's C1 and C3r cards are the opportunity ones the catalog may not publish yet; the contract rules are the same.
|
||||
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]],
|
||||
cama: [KPI_BY_DOMAIN.cama[0], CAMA_TASA_DETECCION_KPI, CAMA_TAMIZAJE_RESULTADO_KPI] };
|
||||
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 };
|
||||
}
|
||||
|
||||
@@ -39,8 +39,6 @@ export const KPI_BY_DOMAIN: Record<Dominio, KpiDefinition[]> = {
|
||||
],
|
||||
cama: [
|
||||
{ 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_dias_toma_diagnostico', title: 'Tiempo de tamizaje a diagnóstico', contrato: 'C3r', unit: 'días (mediana)' },
|
||||
CAMA_TAMIZAJE_RESULTADO_KPI,
|
||||
],
|
||||
};
|
||||
@@ -55,16 +53,14 @@ export const CAMA_OPORTUNIDAD_KPIS: KpiDefinition[] = [
|
||||
CAMA_RESULTADO_DIAGNOSTICO_KPI,
|
||||
];
|
||||
export interface KpiCardSlot { definition: KpiDefinition; pending: boolean; }
|
||||
// The four opportunity cards first, each pending while its indicator is not in the catalog, then the
|
||||
// other published CaMa cards. Nothing at all (not even pending cards) until the catalog publishes one of them.
|
||||
// The four opportunity cards, each pending while its indicator is not in the catalog. Nothing at all
|
||||
// (not even pending cards) until the catalog publishes one of them.
|
||||
export function camaKpiCards(published: (id: string) => boolean): KpiCardSlot[] {
|
||||
const cards = [
|
||||
...CAMA_OPORTUNIDAD_KPIS.map(definition => ({ definition, pending: !published(definition.id) })),
|
||||
...KPI_BY_DOMAIN.cama.filter(definition => !CAMA_OPORTUNIDAD_KPIS.includes(definition) && published(definition.id))
|
||||
.map(definition => ({ definition, pending: false })),
|
||||
];
|
||||
const cards = CAMA_OPORTUNIDAD_KPIS.map(definition => ({ definition, pending: !published(definition.id) }));
|
||||
return cards.some(card => !card.pending) ? cards : [];
|
||||
}
|
||||
// Published CaMa indicators whose card the summary does not draw.
|
||||
export const CAMA_FUERA_DEL_RESUMEN: readonly string[] = ['cama_biopsias'];
|
||||
// C1 rows of CaCu/CaMa carry the linkId `total`; TEA's ficha names its single group `TOTAL`.
|
||||
const C1_GROUP: Record<Dominio, string> = { tea: 'TOTAL', cacu: 'total', cama: 'total' };
|
||||
const C1_INFO: Record<Dominio, (numerador: number, denominador: number) => string> = {
|
||||
|
||||
@@ -52,8 +52,8 @@
|
||||
@if (!catalogLoading() && filters; as state) {
|
||||
<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>
|
||||
<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>
|
||||
<app-indicador-period-filters [state]="state" [types]="filterTypes()" [availability]="availability()" [initialPresentation]="initialPeriodBlocked"
|
||||
<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.' : dominio === 'cama' ? 'Se aplica a los indicadores de oportunidad y las gráficas, salvo las de selección independiente.' : 'La selección aplicada se comparte entre las figuras y los indicadores destacados de este proyecto.' }}</p>
|
||||
<app-indicador-period-filters [state]="state" [compact]="dominio === 'cama'" [types]="filterTypes()" [availability]="availability()" [initialPresentation]="initialPeriodBlocked"
|
||||
(retryAvailability)="retryAvailability()"
|
||||
(edited)="editFilters()" (apply)="applyFilters()" />
|
||||
</section>
|
||||
@@ -76,7 +76,7 @@
|
||||
@let kpis = kpiCards;
|
||||
@if (kpis.length && !initialPeriodBlocked) {
|
||||
<section class="kpi-section" aria-labelledby="kpi-section-title" [attr.data-domain]="dominio">
|
||||
<h2 id="kpi-section-title" class="section-title">{{ dominio === 'cacu' ? 'Indicadores de oportunidad' : 'Indicadores destacados' }}</h2>
|
||||
<h2 id="kpi-section-title" class="section-title">{{ dominio === 'cacu' || dominio === 'cama' ? 'Indicadores de oportunidad' : 'Indicadores destacados' }}</h2>
|
||||
<div class="kpi-grid" [style.--kpi-count]="kpis.length + (dominio === 'cacu' ? 2 : 0)">
|
||||
@for (card of kpis; track dominio + ':' + card.definition.id) {
|
||||
@if (card.pending) {
|
||||
|
||||
@@ -17,7 +17,7 @@ import { IndicadoresService } from './indicadores.service';
|
||||
import { applyGlobal, domainTypes, GlobalFilterState, IndicadoresMemory, pending, validDraft } from './indicadores-memory';
|
||||
import { IndicadorPeriodFilters } from './indicador-period-filters';
|
||||
import { IndicadorCatalogCard } from './indicador-catalog-card';
|
||||
import { CACU_RESULTADO_KPI, KPI_BY_DOMAIN, KpiCardSlot, camaKpiCards } from './indicadores-kpi';
|
||||
import { CACU_RESULTADO_KPI, CAMA_FUERA_DEL_RESUMEN, KPI_BY_DOMAIN, KpiCardSlot, camaKpiCards } from './indicadores-kpi';
|
||||
import { IndicadorKpiPanel } from './indicador-kpi-panel';
|
||||
import { IndicadorKpiCard } from './indicador-kpi-card';
|
||||
import { figureApplied, independentFigurePeriods } from './indicadores-figure-selection';
|
||||
@@ -268,9 +268,9 @@ export class IndicadoresPage {
|
||||
private readonly route = inject(ActivatedRoute, { optional: true });
|
||||
readonly dominios = DOMINIOS;
|
||||
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.
|
||||
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
|
||||
// template comment above it) -- `domainLabels`/`domainTitles` are prose-length.
|
||||
readonly domainNavLabels: Record<Dominio, string> = { tea: 'TEA', cacu: 'CaCu', cama: 'CaMa' };
|
||||
@@ -312,7 +312,7 @@ export class IndicadoresPage {
|
||||
// Stable presentation priority; search matches and pins still take precedence.
|
||||
const items = this.dominio === 'cacu'
|
||||
? [...catalog.filter(item => item.id === 'cacu_eu7'), ...catalog.filter(item => item.id !== 'cacu_eu7')]
|
||||
: catalog;
|
||||
: this.dominio === 'cama' ? catalog.filter(item => !CAMA_FUERA_DEL_RESUMEN.includes(item.id)) : catalog;
|
||||
const query = this.normalizeSearch(this.searchQuery());
|
||||
const prioritize = (group: Indicador[]) => [
|
||||
...group.filter(item => this.isPinned(item)),
|
||||
|
||||
@@ -63,13 +63,13 @@ 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 => {
|
||||
load(domain, [['2026-S1', '2024-S2', '2025-S2'], ['2025-S1', '2026-S2', '2025-12'], ['2025-S2', '2024-S1'], ['2026-S1', '2025-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 positive = data(0, domain, '2026-S1'); positive.filas[0]['n'] = 4; anchor.flush(positive); fixture.detectChanges();
|
||||
const requests = flushDatos(domain);
|
||||
expect(requests.map(r => r.request.params.get('periodos'))).toEqual(KPI_BY_DOMAIN[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.result().value)).toEqual(domain === 'cacu' ? [4, 0] : [4, undefined, '0.0', 0]); // Display order; the second card is the new median over n = 0, which is no value
|
||||
expect(panels().map(p => p.result().value)).toEqual(domain === 'cacu' ? [4, 0] : [4, undefined]); // CaMa's second card is a median over n = 0, which is no value
|
||||
expect(fixture.componentInstance.filters!.applied.selection).toEqual({ mode: 'explicit', periodos: ['2026-S1'] });
|
||||
expect(fixture.componentInstance.filters!.applied.revision).toBe(1);
|
||||
fixture.componentInstance.applyFilters(); fixture.detectChanges(); http.expectNone(() => true);
|
||||
@@ -85,11 +85,11 @@ describe('P0.1 selección publicada y último periodo por KPI', () => {
|
||||
expect(panels().every(p => p.temporalReference === '2026-S2')).toBe(true); http.expectNone(() => true);
|
||||
});
|
||||
it('sin reportes en una tarjeta no consulta datos y no impide las otras', () => {
|
||||
load('cama', [[], ['2025-S2'], ['2025-S1'], ['2025-S2']]);
|
||||
load('cama', [[], ['2025-S2']]);
|
||||
expect(fixture.componentInstance.initialPeriodState()).toBe('empty'); expect(panels()).toHaveLength(0);
|
||||
http.expectNone(r => r.url.endsWith('/datos'));
|
||||
fixture.componentInstance.applyFilters(); fixture.detectChanges(); const requests = flushDatos('cama');
|
||||
expect(requests).toHaveLength(3); expect(panels()[0].result().state).toBe('Sin reportes disponibles');
|
||||
expect(requests).toHaveLength(1); expect(panels()[0].result().state).toBe('Sin reportes disponibles');
|
||||
expect(panels()[0].result().value).toBeUndefined();
|
||||
});
|
||||
it('multiselección mensual edita sin HTTP; un periodo consulta y varios no consolidan', async () => {
|
||||
|
||||
Reference in New Issue
Block a user