diff --git a/src/app/features/indicadores/indicador-conteos-pareados.html b/src/app/features/indicadores/indicador-conteos-pareados.html
index 22e0deb..18eb9ea 100644
--- a/src/app/features/indicadores/indicador-conteos-pareados.html
+++ b/src/app/features/indicadores/indicador-conteos-pareados.html
@@ -34,7 +34,7 @@
{{ m.periodo }}, selección: {{ selectionLabel }}. {{ reading }}
@for (note of m.notas; track $index) { Valores publicados
diff --git a/src/app/features/indicadores/indicadores-conteos-pareados.spec.ts b/src/app/features/indicadores/indicadores-conteos-pareados.spec.ts
index a7da565..c4bd04f 100644
--- a/src/app/features/indicadores/indicadores-conteos-pareados.spec.ts
+++ b/src/app/features/indicadores/indicadores-conteos-pareados.spec.ts
@@ -93,19 +93,17 @@ describe('Conteos pareados de CaMa: lo que se puede sumar', () => {
describe('Conteos pareados de CaMa: etiquetas de la dona', () => {
type Figura = { data: Record[]; layout: { annotations: Record[]; margin: Record; showlegend: boolean } };
- const dona = (compacta = false) => donaConteos(modelo(examenes(LAB_E), pacientes(LAB_P)), PAR, 'claro', compacta) as unknown as Figura;
+ const dona = () => donaConteos(modelo(examenes(LAB_E), pacientes(LAB_P)), PAR, 'claro') as unknown as Figura;
- it('mantiene las etiquetas con porcentaje fuera del sector en ambos tamaños', () => {
- for (const compacta of [false, true]) {
- const f = dona(compacta), t = f.data[0];
- expect(t['textposition']).toBe('outside');
- expect(t['text'][0]).toBe('BI-RADS 4
(sin subcategoría)
45.5 %');
- expect(t['text'][1]).toBe('');
- expect(t['text'][4]).toMatch(/^BI-RADS 5
54[.,]5 %$/);
- expect(t['values']).toEqual([15, 0, 0, 0, 18, 0]);
- expect(f.layout.showlegend).toBe(false);
- expect(f.layout.annotations[0]['text']).toBe('33
mastografías');
- }
+ it('mantiene las etiquetas con porcentaje fuera del sector', () => {
+ const f = dona(), t = f.data[0];
+ expect(t['textinfo']).toBe('none');
+ expect(f.layout.annotations.slice(1).map(a => a['text']).sort()).toEqual([
+ 'BI-RADS 4
(sin
subcategoría)
45.5 %', 'BI-RADS 5
54.5 %',
+ ]);
+ expect(t['values']).toEqual([15, 0, 0, 0, 18, 0]);
+ expect(f.layout.showlegend).toBe(false);
+ expect(f.layout.annotations[0]['text']).toBe('33
mastografías');
});
});
diff --git a/src/app/features/indicadores/indicadores-conteos-pareados.ts b/src/app/features/indicadores/indicadores-conteos-pareados.ts
index 0c697e9..4a6484a 100644
--- a/src/app/features/indicadores/indicadores-conteos-pareados.ts
+++ b/src/app/features/indicadores/indicadores-conteos-pareados.ts
@@ -46,7 +46,6 @@ const ETIQUETA_RESPALDO: Readonly> = { B4: 'BI-RADS 4 (si
const OPCIONALES: ReadonlySet = new Set(Object.keys(ETIQUETA_RESPALDO));
const COLOR_RESPALDO: Readonly> = { B4: '#E9C08C' };
const COLOR_NEUTRO = '#8A9199';
-// Labels longer than «BI-RADS 4A» do not fit inside the ring.
export interface CategoriaConteo { id: string; etiqueta: string; color: string; n: number | null; }
export interface FilaConteo { id: string; etiqueta: string; pacientes: number | null; examenes: number | null; }
@@ -108,24 +107,51 @@ export function modelosConteos(par: ParConteos, examenes: IndicadorDatos, pacien
}
export const totalExamenes = (m: ModeloConteos) => sumar(m.examenes.map(c => c.n));
-const ALTO_DONA = 400, MARGEN_VERTICAL = 30, MARGEN_ROTULO = 120;
+const ALTO_DONA = 400, MARGEN_DONA = 8;
+const RADIO_DONA = (ALTO_DONA - 2 * MARGEN_DONA) * .2;
-export function donaConteos(m: ModeloConteos, par: ParConteos, tema: Tema, compacta = false): PlotlyFigure {
+export function donaConteos(m: ModeloConteos, par: ParConteos, tema: Tema): PlotlyFigure {
const total = totalExamenes(m);
if (!total) return { data: [], layout: {} };
const p = c2Theme(tema), n = m.examenes.map(c => c.n!);
- const porcentaje = (i: number) => percentNumber(100 * n[i] / total) + ' %';
- return { data: [{ type: 'pie', hole: .6, sort: false, direction: 'clockwise', values: n, labels: m.examenes.map(c => escapar(c.etiqueta)),
- marker: { colors: m.examenes.map(c => c.color), line: { color: p.background, width: 2 } }, textinfo: 'text', textposition: 'outside',
- text: n.map((v, i) => v > 0 ? escapar(m.examenes[i].etiqueta).replace(' (', '
(') + '
' + porcentaje(i) : ''),
- domain: { x: [0, 1], y: [.05, .95] },
- customdata: n.map(v => [miles(v), percentNumber(100 * v / total)]),
+ const etiquetas = m.examenes.map(c => escapar(c.etiqueta));
+ const porcentajes = n.map(v => percentNumber(100 * v / total));
+ const centro = { x: .5, y: .5, xref: 'paper', yref: 'paper', showarrow: false };
+ // The pie starts at noon. Keep each callout on its slice's side and order the rows vertically,
+ // so even several adjacent slivers get separate labels and their guide lines keep the same order.
+ let acumulado = 0;
+ const puntos = n.flatMap((valor, i) => {
+ const angulo = 2 * Math.PI * (acumulado + valor / 2) / total;
+ acumulado += valor;
+ if (!valor) return [];
+ const x = RADIO_DONA * Math.sin(angulo), y = RADIO_DONA * Math.cos(angulo);
+ return [{ i, x, y }];
+ });
+ const llamadas = [-1, 1].flatMap(lado => {
+ const columna = puntos.filter(punto => (punto.x < 0 ? -1 : 1) === lado).sort((a, b) => b.y - a.y);
+ return columna.map(({ i, x, y }, fila) => {
+ const altura = (columna.length - 1 - 2 * fila) * 24;
+ const texto = etiquetas[i].replace(' (sin subcategoría)', '
(sin
subcategoría)');
+ return {
+ annotation: { ...centro, xshift: lado * 105, yshift: altura,
+ xanchor: lado < 0 ? 'right' : 'left', align: lado < 0 ? 'right' : 'left',
+ font: { size: 11, color: p.text }, text: texto + '
' + porcentajes[i] + ' %' },
+ shape: { type: 'path', xref: 'paper', yref: 'paper', xsizemode: 'pixel', ysizemode: 'pixel',
+ xanchor: .5, yanchor: .5, line: { color: p.text, width: 1 },
+ path: 'M ' + Math.round(x) + ',' + Math.round(y) + ' L ' + lado * 86 + ',' + y + ' L ' + lado * 101 + ',' + altura },
+ };
+ });
+ });
+ return { data: [{ type: 'pie', hole: .6, sort: false, direction: 'clockwise', values: n, labels: etiquetas,
+ marker: { colors: m.examenes.map(c => c.color), line: { color: p.background, width: 2 } }, textinfo: 'none',
+ domain: { x: [0, 1], y: [.3, .7] },
+ customdata: n.map((v, i) => [miles(v), porcentajes[i]]),
hovertemplate: `%{label}
%{customdata[0]} ${par.unidades.examenes}, %{customdata[1]} %` }],
- layout: { autosize: true, height: compacta ? ALTO_DONA + 40 : ALTO_DONA, showlegend: false, paper_bgcolor: p.background, font: { color: p.text },
- margin: { t: MARGEN_VERTICAL, b: MARGEN_VERTICAL, l: MARGEN_ROTULO, r: MARGEN_ROTULO },
- ...(compacta ? { legend: { orientation: 'h', x: .5, xanchor: 'center', y: -.02, yanchor: 'top', font: { size: 12 } } } : {}),
- annotations: [{ x: .5, y: .5, xref: 'paper', yref: 'paper', showarrow: false, font: { size: 18, color: p.text },
- text: `${miles(total)}
${par.unidades.examenes}` }] }, config: { displayModeBar: false } };
+ layout: { autosize: true, height: ALTO_DONA, showlegend: false, paper_bgcolor: p.background, font: { color: p.text },
+ margin: { t: MARGEN_DONA, b: MARGEN_DONA, l: MARGEN_DONA, r: MARGEN_DONA },
+ shapes: llamadas.map(({ shape }) => shape),
+ annotations: [{ ...centro, font: { size: 16, color: p.text },
+ text: `${miles(total)}
${par.unidades.examenes}` }, ...llamadas.map(({ annotation }) => annotation)] }, config: { displayModeBar: false } };
}
/** Per BI-RADS family: patients (in their most severe category) next to exams. No ratio between them is drawn. */
diff --git a/src/app/features/indicadores/indicadores-histopatologia-cama.spec.ts b/src/app/features/indicadores/indicadores-histopatologia-cama.spec.ts
index c767e64..268a5a3 100644
--- a/src/app/features/indicadores/indicadores-histopatologia-cama.spec.ts
+++ b/src/app/features/indicadores/indicadores-histopatologia-cama.spec.ts
@@ -242,7 +242,11 @@ describe('Histopatología por BI-RADS: componente', () => {
expect(figures.map(s => s.classList.contains('rates') ? 'tasas' : 'dona')).toEqual(['tasas', 'dona']);
expect([...f.nativeElement.querySelectorAll('.keys button')].map((b: Element) => b.textContent!.trim()))
.toEqual(['No maligno', 'Maligno', 'Benigno', 'Lesión de riesgo (B3)', 'Carcinoma in situ', 'Carcinoma invasor']);
- expect(f.nativeElement.querySelector('.selection-status').textContent).toContain('selección: Maligno');
+ const grafica = f.nativeElement.querySelector('.figures') as HTMLElement;
+ const seleccion = f.nativeElement.querySelector('.selection-status') as HTMLElement;
+ expect(grafica.nextElementSibling?.classList.contains('legend')).toBe(true);
+ expect(grafica.nextElementSibling?.nextElementSibling).toBe(seleccion);
+ expect(seleccion.textContent).toContain('selección: Maligno');
const table = f.nativeElement.querySelector('table') as HTMLTableElement;
expect([...table.querySelectorAll('thead th')].map(th => th.textContent)).toEqual(
['Categoría BI-RADS', 'Benigno', 'Lesión de riesgo (B3)', 'Carcinoma in situ', 'Carcinoma invasor', 'Con resultado', 'Sin biopsia reportada', 'Sin dato', 'Total de pacientes']);
diff --git a/src/app/features/indicadores/indicadores-historico-cama.spec.ts b/src/app/features/indicadores/indicadores-historico-cama.spec.ts
index f8b051c..15219fc 100644
--- a/src/app/features/indicadores/indicadores-historico-cama.spec.ts
+++ b/src/app/features/indicadores/indicadores-historico-cama.spec.ts
@@ -83,7 +83,7 @@ describe('Histórico de CaMa', () => {
montar(CATALOGO, true); responder();
expect(paneles().map(p => p.querySelector('h2')?.textContent)).toEqual(HISTORICO_CAMA.map(e => e.titulo));
const pendientes = paneles().filter(p => p.textContent!.includes('Integración pendiente')).map(p => p.querySelector('h2')!.textContent);
- expect(pendientes).toEqual(['Resultado histopatológico por categoría BI-RADS', 'Días del resultado de la mastografía al diagnóstico', 'Tasa de detección histopatológica']);
+ expect(pendientes).toEqual(['Resultado histopatológico', 'Días del resultado de la mastografía al diagnóstico', 'Tasa de detección histopatológica']);
expect(graficas()).toHaveLength(5);
expect(paneles().filter(p => p.textContent!.includes('Integración pendiente') && p.querySelector('app-plotly-chart')).length).toBe(0);
});
diff --git a/src/app/features/indicadores/indicadores-historico-pestana.spec.ts b/src/app/features/indicadores/indicadores-historico-pestana.spec.ts
index ae6fd5d..444c173 100644
--- a/src/app/features/indicadores/indicadores-historico-pestana.spec.ts
+++ b/src/app/features/indicadores/indicadores-historico-pestana.spec.ts
@@ -28,10 +28,16 @@ describe('Pestaña Histórico', () => {
http.match(() => true);
}
- it('CaMa: Resumen, Histórico, Análisis epidemiológico, Seguimiento y Datos y definiciones, en ese orden', () => {
+ it('CaMa: Resumen, Histórico, Análisis, Análisis de Riesgos y Datos y definiciones, en ese orden', () => {
abrir('cama', [item('cama_eu38a', 'C3r')]);
- expect(tabs()).toEqual(['Resumen', 'Histórico', 'Análisis', 'Seguimiento', 'Datos y definiciones']);
+ expect(tabs()).toEqual(['Resumen', 'Histórico', 'Análisis', 'Análisis de Riesgos', 'Datos y definiciones']);
expect(root().querySelector('#panel-historico')).not.toBeNull();
+ root().querySelector('#tab-analisis')!.click();
+ fixture.detectChanges();
+ const panel = root().querySelector('#panel-analisis')!;
+ expect(panel.hidden).toBe(false);
+ expect(panel.textContent?.trim()).toBe('En desarrollo');
+ 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.
diff --git a/src/app/features/indicadores/indicadores-historico.ts b/src/app/features/indicadores/indicadores-historico.ts
index a84dbc7..ad494d2 100644
--- a/src/app/features/indicadores/indicadores-historico.ts
+++ b/src/app/features/indicadores/indicadores-historico.ts
@@ -26,7 +26,7 @@ const PERSONALIZADO = -1;
// CaMa's history, in the order of the mockup. The titles are the mockup's; an indicator the catalog does not
// publish is drawn as a pending panel instead of being left out, so what is missing stays visible.
export const HISTORICO_CAMA: readonly { id: string; titulo: string }[] = [
- { id: 'cama_histopatologia_birads', titulo: 'Resultado histopatológico por categoría BI-RADS' },
+ { id: 'cama_histopatologia_birads', titulo: 'Resultado histopatológico' },
{ id: 'cama_birads_456_paciente', titulo: 'Pacientes evaluadas con BI-RADS 4, 5 y 6' },
{ id: 'cama_birads_456_mastografia', titulo: 'Porcentaje individual de mastografías con resultado en la clasificación de BI-RADS 4, 5 y 6' },
{ id: 'cama_confirmacion_birads45', titulo: 'Tasa de confirmación histopatológica' },
diff --git a/src/app/features/indicadores/indicadores-page.ts b/src/app/features/indicadores/indicadores-page.ts
index f8826bd..8cb772a 100644
--- a/src/app/features/indicadores/indicadores-page.ts
+++ b/src/app/features/indicadores/indicadores-page.ts
@@ -43,7 +43,7 @@ const SECTIONS: readonly { id: DashboardSection; label: string }[] = [
// between its history and its follow-up list.
const SECTIONS_WITH_HISTORY: readonly { id: DashboardSection; label: string }[] = [SECTIONS[0], { id: 'historico', label: 'Histórico' }, SECTIONS[1], SECTIONS[2]];
const SECTIONS_WITH_ANALYSIS: readonly { id: DashboardSection; label: string }[] = [
- SECTIONS_WITH_HISTORY[0], SECTIONS_WITH_HISTORY[1], { id: 'analisis', label: 'Análisis' }, SECTIONS_WITH_HISTORY[2], SECTIONS_WITH_HISTORY[3]];
+ SECTIONS_WITH_HISTORY[0], SECTIONS_WITH_HISTORY[1], { id: 'analisis', label: 'Análisis' }, { id: 'seguimiento', label: 'Análisis de Riesgos' }, SECTIONS_WITH_HISTORY[3]];
@Component({
selector: 'app-indicadores-page',
diff --git a/src/app/features/indicadores/indicadores-sections.spec.ts b/src/app/features/indicadores/indicadores-sections.spec.ts
index 19d0fd0..1f3c97f 100644
--- a/src/app/features/indicadores/indicadores-sections.spec.ts
+++ b/src/app/features/indicadores/indicadores-sections.spec.ts
@@ -38,7 +38,7 @@ describe('Secciones compartidas por dominio', () => {
const root = harness.routeNativeElement!;
const tabs = Array.from(root.querySelectorAll('[role="tab"]'));
// TEA and CaMa also have Histórico; CaMa adds Análisis epidemiológico before Seguimiento; CaCu keeps its three.
- const esperadas = domain === 'cama' ? ['Resumen', 'Histórico', 'Análisis', 'Seguimiento', 'Datos y definiciones']
+ const esperadas = domain === 'cama' ? ['Resumen', 'Histórico', 'Análisis', 'Análisis de Riesgos', 'Datos y definiciones']
: domain === 'tea' ? ['Resumen', 'Histórico', 'Seguimiento', 'Datos y definiciones'] : ['Resumen', '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)));