fix(cama): completar ajustes visuales de indicadores
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
<div class="figures">
|
||||
<section class="figure"><h3>{{ par.unidades.examenes | titlecase }} por categoría, {{ m.periodo }}</h3>
|
||||
@if (total) {
|
||||
<app-plotly-chart [figure]="donutFigure!" [showNotes]="false" [label]="indicador.titulo + ', dona, ' + m.periodo" />
|
||||
<app-plotly-chart [figure]="donutFigure!" class="donut-chart" [showNotes]="false" [label]="indicador.titulo + ', dona, ' + m.periodo" />
|
||||
} @else { <p role="status">{{ total === null ? 'Dona no disponible: hay celdas suprimidas o sin dato.' : 'Sin ' + par.unidades.examenes + ' en el periodo.' }}</p> }
|
||||
@if (m.sinDato) { <p class="note">Fuera de la dona: {{ texto(m.sinDato) }} {{ par.unidades.examenes }} sin categoría.</p> }
|
||||
</section>
|
||||
|
||||
@@ -14,6 +14,8 @@ h3 { font-size: 1rem; font-weight: 500; line-height: 1.5; }
|
||||
.figures { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--issste-space-6); }
|
||||
@media (min-width: 1100px) { .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
||||
app-plotly-chart { --plot-height: 400px; }
|
||||
// Keep space for the outside labels and let the existing plot viewport scroll on very narrow cards.
|
||||
.donut-chart { --plot-min-width: 390px; }
|
||||
summary { cursor: pointer; padding-block: .75rem; }
|
||||
summary:focus-visible, .table-scroll:focus-visible { outline: 2px solid var(--issste-text); outline-offset: 3px; }
|
||||
.table-scroll { overflow: auto; }
|
||||
|
||||
@@ -38,10 +38,6 @@ export class IndicadorConteosPareados implements OnChanges, OnDestroy {
|
||||
private subscription?: Subscription;
|
||||
private key = '';
|
||||
private loaded = false;
|
||||
// On a narrow screen the donut's long label gives way to a legend under it.
|
||||
private readonly estrecha = typeof matchMedia === 'function' ? matchMedia('(max-width: 520px)') : undefined;
|
||||
private readonly alCambiarAncho = () => { if (this.model) this.draw(); };
|
||||
constructor() { this.estrecha?.addEventListener('change', this.alCambiarAncho); }
|
||||
|
||||
get model(): ModeloConteos | undefined { return this.pages[this.periodIndex]; }
|
||||
get total() { return this.model ? totalExamenes(this.model) : null; }
|
||||
@@ -111,9 +107,9 @@ export class IndicadorConteosPareados implements OnChanges, OnDestroy {
|
||||
private draw() {
|
||||
const m = this.model;
|
||||
if (!m) return;
|
||||
this.donutFigure = donaConteos(m, this.par, this.tema, this.estrecha?.matches ?? false);
|
||||
this.donutFigure = donaConteos(m, this.par, this.tema);
|
||||
this.barsFigure = barrasConteos(m, this.par, this.tema);
|
||||
this.changeDetector.markForCheck();
|
||||
}
|
||||
ngOnDestroy() { this.subscription?.unsubscribe(); this.estrecha?.removeEventListener('change', this.alCambiarAncho); }
|
||||
ngOnDestroy() { this.subscription?.unsubscribe(); }
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
</nav>
|
||||
}
|
||||
@if (model; as m) {
|
||||
<p class="selection-status" role="status" aria-live="polite">{{ m.periodo }}, selección: {{ selectionLabel }}. {{ reading }}</p>
|
||||
@if (status() === 'empty') { <p role="status">No hay pacientes con resultado de mastografía BI-RADS 4, 5 o 6 publicadas para este periodo.</p> }
|
||||
@else {
|
||||
<div class="figures">
|
||||
@@ -62,6 +61,7 @@
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<p class="selection-status" role="status" aria-live="polite">{{ m.periodo }}, selección: {{ selectionLabel }}. {{ reading }}</p>
|
||||
@for (note of m.notas; track $index) { <p class="note">{{ note }}</p> }
|
||||
<details class="published-values"><summary>Valores publicados</summary>
|
||||
<div class="table-scroll" role="region" aria-label="Tabla de pacientes por categoría BI-RADS y resultado de biopsia" tabindex="0">
|
||||
|
||||
@@ -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<string, any>[]; layout: { annotations: Record<string, any>[]; margin: Record<string, number>; 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<br>(sin subcategoría)<br>45.5 %');
|
||||
expect(t['text'][1]).toBe('');
|
||||
expect(t['text'][4]).toMatch(/^BI-RADS 5<br>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('<b>33</b><br>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<br>(sin<br>subcategoría)<br>45.5 %', 'BI-RADS 5<br>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('<b>33</b><br>mastografías');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ const ETIQUETA_RESPALDO: Readonly<Record<string, string>> = { B4: 'BI-RADS 4 (si
|
||||
const OPCIONALES: ReadonlySet<string> = new Set(Object.keys(ETIQUETA_RESPALDO));
|
||||
const COLOR_RESPALDO: Readonly<Record<string, string>> = { 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(' (', '<br>(') + '<br>' + 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)', '<br>(sin<br>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 + '<br>' + 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}<br>%{customdata[0]} ${par.unidades.examenes}, %{customdata[1]} %<extra></extra>` }],
|
||||
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: `<b>${miles(total)}</b><br>${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: `<b>${miles(total)}</b><br>${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. */
|
||||
|
||||
@@ -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']);
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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<HTMLButtonElement>('#tab-analisis')!.click();
|
||||
fixture.detectChanges();
|
||||
const panel = root().querySelector<HTMLElement>('#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.
|
||||
|
||||
@@ -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' },
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('Secciones compartidas por dominio', () => {
|
||||
const root = harness.routeNativeElement!;
|
||||
const tabs = Array.from(root.querySelectorAll<HTMLButtonElement>('[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)));
|
||||
|
||||
Reference in New Issue
Block a user