Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e5aa205662 | |||
| 89f3d41e0c | |||
| 2e9dd39cf1 |
@@ -384,7 +384,7 @@
|
||||
"estrato": null,
|
||||
"valores_estrato": [],
|
||||
"grupos": {
|
||||
"principal": "principal"
|
||||
"total": "Total"
|
||||
},
|
||||
"categorias": {},
|
||||
"grupos_de_categoria": {},
|
||||
@@ -410,7 +410,7 @@
|
||||
"filas": [
|
||||
{
|
||||
"periodo": "2021-S1",
|
||||
"grupo": "principal",
|
||||
"grupo": "total",
|
||||
"estrato": null,
|
||||
"suprimido": 0,
|
||||
"numerador": 0,
|
||||
@@ -423,7 +423,7 @@
|
||||
},
|
||||
{
|
||||
"periodo": "2025-S2",
|
||||
"grupo": "principal",
|
||||
"grupo": "total",
|
||||
"estrato": null,
|
||||
"suprimido": 0,
|
||||
"numerador": 1,
|
||||
@@ -463,7 +463,7 @@
|
||||
"<25": "<25"
|
||||
},
|
||||
"grupos": {
|
||||
"principal": "principal"
|
||||
"total": "Total"
|
||||
},
|
||||
"categorias": {},
|
||||
"grupos_de_categoria": {},
|
||||
@@ -489,7 +489,7 @@
|
||||
"filas": [
|
||||
{
|
||||
"periodo": "2025-S2",
|
||||
"grupo": "principal",
|
||||
"grupo": "total",
|
||||
"estrato": "25-34",
|
||||
"suprimido": 0,
|
||||
"numerador": 0,
|
||||
@@ -502,7 +502,7 @@
|
||||
},
|
||||
{
|
||||
"periodo": "2025-S2",
|
||||
"grupo": "principal",
|
||||
"grupo": "total",
|
||||
"estrato": "35-44",
|
||||
"suprimido": 0,
|
||||
"numerador": 0,
|
||||
@@ -515,7 +515,7 @@
|
||||
},
|
||||
{
|
||||
"periodo": "2025-S2",
|
||||
"grupo": "principal",
|
||||
"grupo": "total",
|
||||
"estrato": "45-54",
|
||||
"suprimido": 0,
|
||||
"numerador": 1,
|
||||
@@ -528,7 +528,7 @@
|
||||
},
|
||||
{
|
||||
"periodo": "2025-S2",
|
||||
"grupo": "principal",
|
||||
"grupo": "total",
|
||||
"estrato": "55-64",
|
||||
"suprimido": 0,
|
||||
"numerador": 0,
|
||||
@@ -541,7 +541,7 @@
|
||||
},
|
||||
{
|
||||
"periodo": "2025-S2",
|
||||
"grupo": "principal",
|
||||
"grupo": "total",
|
||||
"estrato": "<25",
|
||||
"suprimido": 0,
|
||||
"numerador": 0,
|
||||
@@ -573,7 +573,7 @@
|
||||
"PRE_COLPOSCOPIA": "PRE_COLPOSCOPIA"
|
||||
},
|
||||
"grupos": {
|
||||
"principal": "principal"
|
||||
"total": "Total"
|
||||
},
|
||||
"categorias": {},
|
||||
"grupos_de_categoria": {},
|
||||
@@ -599,7 +599,7 @@
|
||||
"filas": [
|
||||
{
|
||||
"periodo": "2025-S2",
|
||||
"grupo": "principal",
|
||||
"grupo": "total",
|
||||
"estrato": "PRE_COLPOSCOPIA",
|
||||
"suprimido": 0,
|
||||
"numerador": 1,
|
||||
@@ -845,7 +845,7 @@
|
||||
"estrato": null,
|
||||
"valores_estrato": [],
|
||||
"grupos": {
|
||||
"principal": "principal"
|
||||
"total": "Total"
|
||||
},
|
||||
"categorias": {},
|
||||
"grupos_de_categoria": {},
|
||||
@@ -871,7 +871,7 @@
|
||||
"filas": [
|
||||
{
|
||||
"periodo": "2021-S1",
|
||||
"grupo": "principal",
|
||||
"grupo": "total",
|
||||
"estrato": null,
|
||||
"suprimido": 0,
|
||||
"numerador": 0,
|
||||
@@ -884,7 +884,7 @@
|
||||
},
|
||||
{
|
||||
"periodo": "2025-S2",
|
||||
"grupo": "principal",
|
||||
"grupo": "total",
|
||||
"estrato": null,
|
||||
"suprimido": 0,
|
||||
"numerador": 19,
|
||||
|
||||
@@ -10,6 +10,7 @@ import { CACU_MEASURE_IDS } from './indicadores-cacu-fhir';
|
||||
import { ID_CONFIRMACION } from './indicadores-confirmacion-citologia';
|
||||
import { CACU_RESULTADO_KPI, KPI_BY_DOMAIN, kpiResult } from './indicadores-kpi';
|
||||
import { GlobalApplied } from './indicadores-memory';
|
||||
import { historicoFigura } from './indicadores-historico-figures';
|
||||
|
||||
const STRUCTURE = 'https://isssteleon.org/fhir/StructureDefinition';
|
||||
const ENDPOINT = ['CACU-CONFIRMACION-CITOLOGIA', 'CACU-DIAS-TOMA-DIAGNOSTICO', 'CACU-EU-TIEMPO-REPORTE', 'CACU-EU13', 'CACU-EU7',
|
||||
@@ -130,4 +131,37 @@ describe('Las medidas de CaCu como las publica el WebApi con figuras y etiquetas
|
||||
expect(dibujo.status).toBe('supported');
|
||||
}
|
||||
});
|
||||
|
||||
it('un C1 publicado con su intervalo de Wilson llena la banda del histórico, en porcentaje', () => {
|
||||
// Pins down: the `ic-bajo` and `ic-alto` of a proportion's score (proportions) reach the rows as percentages and
|
||||
// the history trend draws them as its band. Fails if the bounds are read unconverted or dropped.
|
||||
const eu13 = medida('CACU-EU13');
|
||||
const cuenta = (code: string, count: number) => ({ code: { coding: [{ code }] }, count });
|
||||
const reporte13 = { resourceType: 'MeasureReport', id: 'CACU-EU13-1', period: { start: '2025-01-01', end: '2025-06-30' },
|
||||
group: [{ code: { coding: [{ code: 'principal' }] }, population: [cuenta('initial-population', 4), cuenta('denominator', 4), cuenta('numerator', 1)],
|
||||
measureScore: { value: 0.25, extension: [{ url: `${STRUCTURE}/ic-bajo`, valueDecimal: 0.0456 }, { url: `${STRUCTURE}/ic-alto`, valueDecimal: 0.6994 }] } }] } as unknown as Report;
|
||||
const datos = datosDeReportes(eu13, [reporte13], 'semestre');
|
||||
expect(datos.filas[0]).toMatchObject({ valor: 25, ic_bajo: 4.6, ic_alto: 69.9 });
|
||||
const banda = (historicoFigura(datos, 'claro').figure as unknown as { data: { name: string; y: number[] }[] }).data[0];
|
||||
expect(banda.name).toBe('Intervalo de confianza');
|
||||
expect(banda.y).toEqual([69.9, 4.6]);
|
||||
});
|
||||
|
||||
it('un C1 de CaCu cuyo grupo se llama principal dibuja su tendencia en el histórico', () => {
|
||||
// Pins down: the WebApi names the group of a proportion `principal`; the page reads it as `total`, the group the
|
||||
// history trend draws, for CaCu as for CaMa. Fails if the rows keep the group `principal` and the trend comes out
|
||||
// empty, with its period listed as having no data.
|
||||
const cuenta = (code: string, count: number) => ({ code: { coding: [{ code }] }, count });
|
||||
for (const id of ['CACU-EU13', 'IND1']) {
|
||||
const medida13 = medida(id);
|
||||
const reporte = { resourceType: 'MeasureReport', id: id + '-1', period: { start: '2025-01-01', end: '2025-06-30' },
|
||||
group: [{ code: { coding: [{ code: 'principal' }] }, population: [cuenta('initial-population', 4), cuenta('denominator', 4), cuenta('numerator', 1)],
|
||||
measureScore: { value: 0.25 } }] } as unknown as Report;
|
||||
const datos = datosDeReportes(medida13, [reporte], 'semestre');
|
||||
expect(datos.filas[0]['grupo']).toBe('total');
|
||||
const figura = historicoFigura(datos, 'claro');
|
||||
expect((figura.figure as unknown as { data: { y: number[] }[] }).data[1].y).toEqual([25]);
|
||||
expect(figura.sinDato).toEqual([]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -56,6 +56,8 @@ function decimal(score: Score | undefined, name: string): number | null {
|
||||
return typeof value === 'number' ? value : null;
|
||||
}
|
||||
const round1 = (value: number) => Math.round(value * 10) / 10;
|
||||
// A proportion's bounds travel as proportions; the rows hold percentages, like `valor`.
|
||||
const percent = (value: number | null) => value === null ? null : round1(value * 100);
|
||||
|
||||
// A category's group is optional (`grupo` inside its `categoria`): a Measure that declares none, like CaMa's and TEA's,
|
||||
// keeps every category ungrouped.
|
||||
@@ -146,7 +148,7 @@ function proporcion(populations: Population[] | undefined, score: Score | undefi
|
||||
return {
|
||||
suprimido: 0, numerador, denominador,
|
||||
valor: typeof score?.value === 'number' ? round1(score.value * 100) : null,
|
||||
ic_bajo: decimal(score, 'ic-bajo'), ic_alto: decimal(score, 'ic-alto'),
|
||||
ic_bajo: percent(decimal(score, 'ic-bajo')), ic_alto: percent(decimal(score, 'ic-alto')),
|
||||
n_sin_evento: numerador !== null && denominador !== null ? denominador - numerador : null,
|
||||
n_excluido: count(populations, 'denominator-exclusion') ?? 0,
|
||||
};
|
||||
@@ -251,10 +253,10 @@ export function datosDeReportes(measure: Measure, reports: Report[], tipo: TipoP
|
||||
: { ...declaradas,
|
||||
...Object.fromEntries([...extras].map(([categoria, etiqueta]) => [categoria, { etiqueta, color: null, grupo: null }])) };
|
||||
const totales: Record<string, unknown>[] = [];
|
||||
// CaMa's page names the primary group of a proportion `total`; the WebApi names it `principal`.
|
||||
// The page names the primary group of a proportion `total`; the WebApi names it `principal`.
|
||||
const nombre = (codigo: string | undefined) => {
|
||||
const grupo = codigo ?? 'TOTAL';
|
||||
return cama && kind === 'C1' && grupo === GRUPO_PRINCIPAL_FHIR ? GRUPO_PRINCIPAL_PAGINA : grupo;
|
||||
return kind === 'C1' && grupo === GRUPO_PRINCIPAL_FHIR ? GRUPO_PRINCIPAL_PAGINA : grupo;
|
||||
};
|
||||
const grupos = Object.fromEntries((measure.group ?? []).map(g => {
|
||||
const id = nombre(code(g.code));
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// Covers CaCu's history tab: its fixed list of indicators, in order, with a pending panel for each one the catalog
|
||||
// does not publish. Catalogs are synthetic, shaped like /cacu/indicadores; the tab stays inactive, so nothing is
|
||||
// requested.
|
||||
import { Component } from '@angular/core';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { provideHttpClient } from '@angular/common/http';
|
||||
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { PlotlyChart } from '../../shared/plotly/plotly-chart';
|
||||
import { HISTORICO_CACU, IndicadoresHistorico } from './indicadores-historico';
|
||||
import { Indicador } from './indicadores.models';
|
||||
|
||||
@Component({ selector: 'app-plotly-chart', inputs: ['figure', 'label', 'showNotes'], template: '' })
|
||||
class ChartStub {}
|
||||
|
||||
const item = (id: string, contrato: string): Indicador => ({ id, titulo: id, contrato, figuras: [], tipos_periodo: ['semestre', 'mes'] }) as unknown as Indicador;
|
||||
|
||||
describe('Histórico de CaCu', () => {
|
||||
let fixture: ReturnType<typeof TestBed.createComponent<IndicadoresHistorico>>, http: HttpTestingController;
|
||||
function montar(catalog: Indicador[]) {
|
||||
TestBed.configureTestingModule({ imports: [IndicadoresHistorico], providers: [provideHttpClient(), provideHttpClientTesting(), { provide: MatDialog, useValue: { open: vi.fn() } }] });
|
||||
TestBed.overrideComponent(IndicadoresHistorico, { remove: { imports: [PlotlyChart] }, add: { imports: [ChartStub] } });
|
||||
fixture = TestBed.createComponent(IndicadoresHistorico); http = TestBed.inject(HttpTestingController);
|
||||
fixture.componentRef.setInput('dominio', 'cacu'); fixture.componentRef.setInput('catalog', catalog);
|
||||
fixture.componentRef.setInput('tema', 'claro'); fixture.componentRef.setInput('active', false);
|
||||
fixture.detectChanges();
|
||||
}
|
||||
afterEach(() => { fixture?.destroy(); http.match(() => true); http.verify(); });
|
||||
const paneles = () => [...(fixture.nativeElement as HTMLElement).querySelectorAll('article.panel')] as HTMLElement[];
|
||||
|
||||
it('lista los seis indicadores en orden y deja pendientes los que el catálogo no publica', () => {
|
||||
// Pins down: the tab shows the fixed list, not the whole catalog, so the risk bands stay out and an indicator
|
||||
// the catalog lacks keeps its place as a pending panel. Fails if the list changes, or the catalog's order or
|
||||
// extra measures leak into the tab.
|
||||
montar([item('cacu_riesgo_banda', 'C2'), item('ind1', 'C1'), item('cacu_eu13', 'C1')]);
|
||||
expect(paneles().map(p => p.querySelector('h2')?.textContent)).toEqual(HISTORICO_CACU.map(e => e.titulo));
|
||||
const pendientes = paneles().filter(p => p.textContent!.includes('Integración pendiente')).map(p => p.querySelector('h2')!.textContent);
|
||||
expect(pendientes).toEqual(['Distribución de resultados citológicos', 'Tasa de confirmación histopatológica',
|
||||
'Días de la toma de la citología a su resultado', 'Tiempo de tamizaje a diagnóstico']);
|
||||
http.expectNone(() => true);
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
// Covers the history tab in the page: it exists for CaMa only, sits between Resumen and Seguimiento, and its
|
||||
// Covers the history tab in the page: it exists for TEA, CaMa and CaCu, sits between Resumen and Seguimiento, and its
|
||||
// panel loads nothing until it is opened. Catalogs are synthetic, shaped like /<dominio>/indicadores.
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { provideHttpClient } from '@angular/common/http';
|
||||
@@ -38,12 +38,13 @@ describe('Pestaña Histórico', () => {
|
||||
expect(root().querySelector('#panel-analisis')).toBeNull();
|
||||
http.expectNone(request => request.url.startsWith('/cama/analisis'));
|
||||
});
|
||||
it('cacu no tiene la pestaña Histórico', () => {
|
||||
// Fails if the history tab of TEA or CaMa leaks into CaCu.
|
||||
it('cacu tiene Histórico pero no Análisis epidemiológico', () => {
|
||||
// Fails if CaCu loses its history tab or gains CaMa's analysis tab.
|
||||
abrir('cama', []);
|
||||
abrir('cacu', [item('cacu_x', 'C2')]);
|
||||
expect(tabs()).toEqual(['Resumen', 'Seguimiento', 'Datos y definiciones']);
|
||||
expect(root().querySelector('#panel-historico')).toBeNull();
|
||||
expect(tabs()).toEqual(['Resumen', 'Histórico', 'Seguimiento', 'Datos y definiciones']);
|
||||
expect(root().querySelector('#panel-historico')).not.toBeNull();
|
||||
expect(root().querySelector('#panel-analisis')).toBeNull();
|
||||
});
|
||||
it('tea tiene Histórico pero no Análisis epidemiológico', () => {
|
||||
abrir('cama', []);
|
||||
|
||||
@@ -36,6 +36,18 @@ export const HISTORICO_CAMA: readonly { id: string; titulo: string }[] = [
|
||||
{ id: 'cama_dias_resultado_diagnostico', titulo: 'Días del resultado de la mastografía al diagnóstico' },
|
||||
];
|
||||
|
||||
// CaCu's history, built like CaMa's: a fixed list, with the same pending panel for what the catalog does not publish.
|
||||
// The risk bands are left out until their batches are readable.
|
||||
export const HISTORICO_CACU: readonly { id: string; titulo: string }[] = [
|
||||
{ id: 'cacu_eu7', titulo: 'Distribución de resultados citológicos' },
|
||||
{ id: 'ind1', titulo: 'Pacientes con citología anómala' },
|
||||
{ id: 'cacu_eu13', titulo: 'Tasa de detección histopatológica' },
|
||||
{ id: 'cacu_confirmacion_citologia', titulo: 'Tasa de confirmación histopatológica' },
|
||||
{ id: 'cacu_eu_tiempo_reporte', titulo: 'Días de la toma de la citología a su resultado' },
|
||||
{ id: 'cacu_dias_toma_diagnostico', titulo: 'Tiempo de tamizaje a diagnóstico' },
|
||||
];
|
||||
const HISTORICO_FIJO: Readonly<Partial<Record<string, readonly { id: string; titulo: string }[]>>> = { cama: HISTORICO_CAMA, cacu: HISTORICO_CACU };
|
||||
|
||||
// The screening steps go together as small charts, and the case counts are followed by their in-process share.
|
||||
function agrupar(paneles: (Panel & { datos?: IndicadorDatos })[], tema: Tema): Panel[] {
|
||||
const pasos = TIEMPOS.map(id => paneles.find(p => p.item.id === id));
|
||||
@@ -171,9 +183,11 @@ export class IndicadoresHistorico {
|
||||
readonly catalog = input.required<readonly Indicador[]>();
|
||||
readonly tema = input.required<Tema>();
|
||||
readonly active = input(false);
|
||||
// The indicators the tab draws: CaMa's fixed list, where the catalog publishes it; the whole catalog elsewhere.
|
||||
private readonly publicados = computed(() => this.dominio() === 'cama'
|
||||
? HISTORICO_CAMA.flatMap(entrada => this.catalog().filter(item => item.id === entrada.id)) : this.catalog());
|
||||
// The indicators the tab draws: a domain's fixed list, where the catalog publishes it; the whole catalog elsewhere.
|
||||
private readonly publicados = computed(() => {
|
||||
const fijo = HISTORICO_FIJO[this.dominio()];
|
||||
return fijo ? fijo.flatMap(entrada => this.catalog().filter(item => item.id === entrada.id)) : this.catalog();
|
||||
});
|
||||
// Only the granularities some indicator publishes; monthly first when there is one.
|
||||
readonly tipos = computed(() => (['mes', 'semestre'] as const).filter(tipo => this.publicados().some(item => item.tipos_periodo.includes(tipo))));
|
||||
readonly elegido = signal<TipoPeriodo | undefined>(undefined);
|
||||
@@ -241,9 +255,10 @@ export class IndicadoresHistorico {
|
||||
return { item, rango, estado: 'error', mensaje: error instanceof Error ? error.message : 'Datos de histórico inválidos' };
|
||||
}
|
||||
};
|
||||
if (this.dominio() === 'cama') {
|
||||
const fijo = HISTORICO_FIJO[this.dominio()];
|
||||
if (fijo) {
|
||||
if (!this.publicados().length) return [];
|
||||
return HISTORICO_CAMA.map((entrada): Panel => {
|
||||
return fijo.map((entrada): Panel => {
|
||||
const item = this.catalog().find(i => i.id === entrada.id);
|
||||
return item ? { ...panelDe(item), item: { ...entrada, contrato: item.contrato } } : { item: entrada, estado: 'pendiente' };
|
||||
});
|
||||
|
||||
@@ -58,7 +58,7 @@ const SECTIONS_CAMA: readonly { id: DashboardSection; label: string }[] = [
|
||||
})
|
||||
export class IndicadoresPage {
|
||||
get sections(): readonly { id: DashboardSection; label: string }[] { return this.dominio === 'cama' ? SECTIONS_CAMA : this.conHistorico ? SECTIONS_WITH_HISTORY : SECTIONS; }
|
||||
get conHistorico() { return this.dominio === 'tea' || this.dominio === 'cama'; }
|
||||
get conHistorico() { return this.dominio === 'tea' || this.dominio === 'cama' || this.dominio === 'cacu'; }
|
||||
get conAnalisis() { return CAMA_ANALYSIS_ENABLED && this.dominio === 'cama'; }
|
||||
readonly activeSection = signal<DashboardSection>('resumen');
|
||||
readonly fichaPacienteAbierta = signal(false);
|
||||
|
||||
@@ -163,7 +163,7 @@ describe('Recorrido de cáncer de mama: análisis, lista, ficha y regreso', () =
|
||||
http.expectOne('/' + dominio + '/indicadores').flush([]); await e.asentar();
|
||||
expect(e.page.seleccionSeguimiento()).toBeUndefined();
|
||||
expect(Array.from(e.root.querySelectorAll('[role="tab"]')).map(t => t.textContent?.trim())).toEqual(
|
||||
dominio === 'tea' ? ['Resumen', 'Histórico', 'Seguimiento', 'Datos y definiciones'] : ['Resumen', 'Seguimiento', 'Datos y definiciones']);
|
||||
['Resumen', 'Histórico', 'Seguimiento', 'Datos y definiciones']);
|
||||
expect(e.root.querySelector('#panel-analisis')).toBeNull();
|
||||
}
|
||||
e.page.changeDominio('cama'); e.harness.detectChanges();
|
||||
|
||||
@@ -11,7 +11,7 @@ describe('Regresión del mapeo FHIR en CaCu y TEA', () => {
|
||||
it('las 16 medidas se mapean igual que antes: ids, catálogo, ficha y filas de datos', () => {
|
||||
// Pins down: ids, catalog entries, sheets and data rows of CaCu's seven and TEA's nine measures, over real reports,
|
||||
// equal the recorded ones; an error counts as a result too. Fails if a change meant for CaMa (its id table, its
|
||||
// group name, its undeclared categories, its sheet code) reaches another domain. If the new result is the right one,
|
||||
// undeclared categories, its sheet code) reaches another domain. If the new result is the right one,
|
||||
// regenerate the recorded mapping and say why in the change.
|
||||
const actual = mapeoDeCacuYTea({ indicadorId, indicadorDeMeasure, metadatosDeMeasure, datosDeReportes });
|
||||
expect(Object.keys(actual)).toEqual(Object.keys(esperado));
|
||||
|
||||
@@ -39,9 +39,9 @@ describe('Secciones compartidas por dominio', () => {
|
||||
http.expectOne('/' + domain + '/indicadores').flush(catalog); harness.detectChanges();
|
||||
const root = harness.routeNativeElement!;
|
||||
const tabs = Array.from(root.querySelectorAll<HTMLButtonElement>('[role="tab"]'));
|
||||
// TEA and CaMa also have Histórico; CaMa labels Seguimiento as Análisis de Riesgos; CaCu keeps its three.
|
||||
// TEA, CaMa and CaCu have Histórico; CaMa labels Seguimiento as Análisis de Riesgos.
|
||||
const esperadas = domain === 'cama' ? ['Resumen', 'Histórico', 'Análisis de Riesgos', 'Datos y definiciones']
|
||||
: domain === 'tea' ? ['Resumen', 'Histórico', 'Seguimiento', 'Datos y definiciones'] : ['Resumen', 'Seguimiento', 'Datos y definiciones'];
|
||||
: ['Resumen', 'Histórico', 'Seguimiento', 'Datos y definiciones'];
|
||||
expect(tabs.map(t => t.textContent?.trim())).toEqual(esperadas);
|
||||
expect(tabs.map(t => t.getAttribute('aria-selected'))).toEqual(esperadas.map((_, i) => String(i === 0)));
|
||||
const tab = (id: string) => tabs.find(t => t.id === 'tab-' + id)!;
|
||||
|
||||
Reference in New Issue
Block a user