fix(cama): ajustar resumen y ocultar análisis
This commit is contained in:
@@ -33,19 +33,6 @@
|
||||
<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="legend" role="group" aria-label="Seleccionar resultado de biopsia">
|
||||
<button type="button" (click)="select('centro')" [disabled]="isBase" aria-label="Volver a la vista general de la histopatología">Volver</button>
|
||||
<div class="keys" role="group" aria-label="Grupos del anillo interior">
|
||||
@for (g of m.grupos; track g.id; let i = $index) {
|
||||
<button type="button" [attr.aria-pressed]="!selection?.categoria && selection?.grupo === g.id" (click)="select('grupos', i)"><span class="swatch" [style.background]="g.color" aria-hidden="true"></span>{{ g.etiqueta }}</button>
|
||||
}
|
||||
</div>
|
||||
<div class="keys" role="group" aria-label="Categorías del anillo exterior">
|
||||
@for (c of m.categorias; track c.id; let i = $index) {
|
||||
<button type="button" [attr.aria-pressed]="selection?.categoria === c.id" (click)="select('categorias', i)"><span class="swatch" [style.background]="c.color" aria-hidden="true"></span>{{ c.etiqueta }}</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="figures">
|
||||
<section class="figure rates"><h3>Por categoría BI-RADS, {{ m.periodo }}</h3>
|
||||
@if (ratesFigure) {
|
||||
@@ -61,6 +48,19 @@
|
||||
} @else { <p role="status">{{ m.conResultado === null ? 'Dona no disponible: hay celdas suprimidas o datos incompletos. No se calcula un total parcial.' : 'Sin pacientes con resultado de biopsia en el periodo.' }}</p> }
|
||||
</section>
|
||||
</div>
|
||||
<div class="legend" role="group" aria-label="Seleccionar resultado de biopsia">
|
||||
<button type="button" (click)="select('centro')" [disabled]="isBase" aria-label="Volver a la vista general de la histopatología">Volver</button>
|
||||
<div class="keys" role="group" aria-label="Grupos del anillo interior">
|
||||
@for (g of m.grupos; track g.id; let i = $index) {
|
||||
<button type="button" [attr.aria-pressed]="!selection?.categoria && selection?.grupo === g.id" (click)="select('grupos', i)"><span class="swatch" [style.background]="g.color" aria-hidden="true"></span>{{ g.etiqueta }}</button>
|
||||
}
|
||||
</div>
|
||||
<div class="keys" role="group" aria-label="Categorías del anillo exterior">
|
||||
@for (c of m.categorias; track c.id; let i = $index) {
|
||||
<button type="button" [attr.aria-pressed]="selection?.categoria === c.id" (click)="select('categorias', i)"><span class="swatch" [style.background]="c.color" aria-hidden="true"></span>{{ c.etiqueta }}</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@for (note of m.notas; track $index) { <p class="note">{{ note }}</p> }
|
||||
<details class="published-values"><summary>Valores publicados</summary>
|
||||
|
||||
@@ -44,4 +44,4 @@ export const CATEGORIA_HISTOPATOLOGIA_PAGINA: Readonly<Record<string, { id: stri
|
||||
SIN_BIOPSIA: { id: 'SIN_BIOPSIA', grupo: null, gravedad: null },
|
||||
SIN_DATO: { id: 'SIN_DATO', grupo: 'SIN_DATO', gravedad: null },
|
||||
};
|
||||
export const GRUPOS_HISTOPATOLOGIA_PAGINA: Readonly<Record<string, string>> = { NO_MALIGNO: 'No metástasis', MALIGNO: 'Metástasis', SIN_DATO: 'Sin dato' };
|
||||
export const GRUPOS_HISTOPATOLOGIA_PAGINA: Readonly<Record<string, string>> = { NO_MALIGNO: 'No maligno', MALIGNO: 'Maligno', SIN_DATO: 'Sin dato' };
|
||||
|
||||
@@ -95,35 +95,17 @@ 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;
|
||||
|
||||
// Fails if the 4 without subcategory goes back outside the ring with a guide line instead of inside its slice on two
|
||||
// lines like BI-RADS 5, loses its percentage, or if the short labels or the centre total change.
|
||||
it('2025-S2: la etiqueta del 4 sin subcategoría va dentro de su segmento, en dos líneas; las cortas y el total se conservan', () => {
|
||||
const f = dona(), t = f.data[0];
|
||||
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['textposition']).toBe('inside');
|
||||
expect(t['values']).toEqual([15, 0, 0, 0, 18, 0]);
|
||||
expect(f.layout.annotations).toHaveLength(1);
|
||||
expect(f.layout.annotations[0]['text']).toBe('<b>33</b><br>mastografías');
|
||||
});
|
||||
|
||||
// Fails if an inside label still reserves side margins, as a callout would.
|
||||
it('sin llamada exterior no se reservan márgenes laterales', () => {
|
||||
const f = dona();
|
||||
expect(f.layout.margin['r']).toBeLessThan(20);
|
||||
expect(f.layout.margin['l']).toBeLessThan(20);
|
||||
expect(f.layout.showlegend).toBe(false);
|
||||
});
|
||||
|
||||
// Fails if a narrow screen keeps a label that needs side room instead of moving to a legend under the donut.
|
||||
it('en pantalla estrecha no hay llamada: la dona usa una leyenda debajo', () => {
|
||||
const f = dona(true);
|
||||
expect(f.layout.annotations).toHaveLength(1);
|
||||
expect(f.layout.showlegend).toBe(true);
|
||||
expect((f.layout as Record<string, any>)['legend']['orientation']).toBe('h');
|
||||
expect(f.layout.margin['r']).toBeLessThan(20);
|
||||
expect(f.data[0]['values']).toEqual([15, 0, 0, 0, 18, 0]);
|
||||
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');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ 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.
|
||||
const LARGO_ETIQUETA_INTERIOR = 12;
|
||||
|
||||
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; }
|
||||
@@ -109,51 +108,24 @@ export function modelosConteos(par: ParConteos, examenes: IndicadorDatos, pacien
|
||||
}
|
||||
export const totalExamenes = (m: ModeloConteos) => sumar(m.examenes.map(c => c.n));
|
||||
|
||||
// Geometry the callouts rely on. The ring is height-bound (a 400 px figure with a 10 px margin above and below and
|
||||
// the pie over 90 % of that height), so its radius does not depend on the width of the card.
|
||||
const ALTO_DONA = 400, MARGEN_VERTICAL = 10, RADIO_DONA = Math.round((ALTO_DONA - 2 * MARGEN_VERTICAL) * .9 / 2);
|
||||
const MARGEN_ROTULO = 120, SALIDA_ROTULO = 28;
|
||||
const ALTO_DONA = 400, MARGEN_VERTICAL = 30, MARGEN_ROTULO = 120;
|
||||
|
||||
/**
|
||||
* Exams by category around their total; nothing is drawn when a cell is unknown. A long label does not fit in the
|
||||
* ring: it is drawn outside, horizontal and on two lines, joined to its slice by a guide line, on the side of the
|
||||
* slice with room reserved for it so it never reaches the neighbouring chart. On a narrow card (`compacta`) the
|
||||
* callouts give way to a legend under the donut.
|
||||
*/
|
||||
export function donaConteos(m: ModeloConteos, par: ParConteos, tema: Tema, compacta = false): PlotlyFigure {
|
||||
const total = totalExamenes(m);
|
||||
if (!total) return { data: [], layout: {} };
|
||||
const p = c2Theme(tema), n = m.examenes.map(c => c.n!);
|
||||
// «BI-RADS 4 (sin subcategoría)» is long but is drawn inside its slice on two lines, like the short labels.
|
||||
const sinSubcategoria = (i: number) => m.examenes[i].etiqueta.endsWith(' (sin subcategoría)');
|
||||
const larga = (i: number) => m.examenes[i].etiqueta.length > LARGO_ETIQUETA_INTERIOR && n[i] > 0 && !sinSubcategoria(i);
|
||||
const porcentaje = (i: number) => percentNumber(100 * n[i] / total) + ' %';
|
||||
const dibujadas = (i: number) => !larga(i) && n[i] / total >= .05;
|
||||
// Each long label is a callout whose guide line ends inside its slice.
|
||||
let antes = 0;
|
||||
const llamadas = n.flatMap((v, i) => {
|
||||
const angulo = 2 * Math.PI * (antes + v / 2) / total;
|
||||
antes += v;
|
||||
if (compacta || !larga(i)) return [];
|
||||
const seno = Math.sin(angulo), coseno = Math.cos(angulo), dentro = Math.round(RADIO_DONA * .8), fuera = RADIO_DONA + SALIDA_ROTULO - dentro;
|
||||
const etiqueta = escapar(m.examenes[i].etiqueta), corte = etiqueta.indexOf(' (');
|
||||
return [{ x: .5, y: .5, xref: 'paper', yref: 'paper', xshift: Math.round(dentro * seno), yshift: Math.round(dentro * coseno),
|
||||
ax: Math.round(fuera * seno), ay: Math.round(-fuera * coseno), axref: 'pixel', ayref: 'pixel', showarrow: true, arrowhead: 0, arrowwidth: 1, arrowcolor: p.text,
|
||||
text: (corte > 0 ? etiqueta.slice(0, corte) + '<br>' + etiqueta.slice(corte + 1) : etiqueta) + '<br>' + porcentaje(i),
|
||||
align: seno >= 0 ? 'left' : 'right', xanchor: seno >= 0 ? 'left' : 'right', yanchor: 'middle', font: { size: 12, color: p.text }, lado: seno >= 0 ? 'r' : 'l' }];
|
||||
});
|
||||
const lado = (l: string) => llamadas.some(a => a.lado === l) ? MARGEN_ROTULO : 10;
|
||||
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: 'inside',
|
||||
text: n.map((_, i) => dibujadas(i) ? (sinSubcategoria(i) ? escapar(m.examenes[i].etiqueta).replace(' (', '<br>(') : escapar(m.examenes[i].etiqueta)) + '<br>' + porcentaje(i) : ''),
|
||||
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)]),
|
||||
hovertemplate: `%{label}<br>%{customdata[0]} ${par.unidades.examenes}, %{customdata[1]} %<extra></extra>` }],
|
||||
layout: { autosize: true, height: compacta ? ALTO_DONA + 40 : ALTO_DONA, showlegend: compacta, paper_bgcolor: p.background, font: { color: p.text },
|
||||
margin: { t: MARGEN_VERTICAL, b: compacta ? 70 : MARGEN_VERTICAL, l: lado('l'), r: lado('r') },
|
||||
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}` }, ...llamadas.map(({ lado: _lado, ...a }) => a)] }, config: { displayModeBar: false } };
|
||||
text: `<b>${miles(total)}</b><br>${par.unidades.examenes}` }] }, config: { displayModeBar: false } };
|
||||
}
|
||||
|
||||
/** Per BI-RADS family: patients (in their most severe category) next to exams. No ratio between them is drawn. */
|
||||
|
||||
@@ -138,14 +138,14 @@ describe('Histopatología por BI-RADS: tasas, selección y figuras', () => {
|
||||
expect(tasas(m, sel).map(t => [t.k, t.fila.den])).toEqual([[2, 4], [3, 5], [2, 4], [2, 4], [2, 4], [2, 4]]);
|
||||
const [bajo, alto] = wilson(3, 5);
|
||||
expect(tasas(m, sel)[1]).toMatchObject({ valor: 60, bajo, alto });
|
||||
expect(lectura(m, sel)).toBe('Pacientes con resultado metástasis entre las que tienen resultado de biopsia');
|
||||
expect(lectura(m, sel)).toBe('Pacientes con resultado maligno entre las que tienen resultado de biopsia');
|
||||
});
|
||||
it('grupo, categoría, segundo clic al grupo y centro a la base', () => {
|
||||
const m = base(), sel = seleccionBase(m);
|
||||
const noMaligno = clicHistopatologia(m, sel, 'grupos', 0);
|
||||
expect(noMaligno).toEqual({ grupo: 'NO_MALIGNO' });
|
||||
expect(tasas(m, noMaligno).map(t => t.k)).toEqual([2, 2, 2, 2, 2, 2]);
|
||||
expect(lectura(m, noMaligno)).toBe('Pacientes con resultado no metástasis entre las que tienen resultado de biopsia');
|
||||
expect(lectura(m, noMaligno)).toBe('Pacientes con resultado no maligno entre las que tienen resultado de biopsia');
|
||||
const b3 = clicHistopatologia(m, noMaligno, 'categorias', 1);
|
||||
expect(b3).toEqual({ grupo: 'NO_MALIGNO', categoria: 'RIESGO_B3' });
|
||||
expect(tasas(m, b3).map(t => t.k)).toEqual([0, 1, 1, 1, 1, 1]);
|
||||
|
||||
@@ -113,7 +113,7 @@ export function modeloHistopatologia(datos: IndicadorDatos, periodo: string): Mo
|
||||
});
|
||||
const grupos: GrupoCategorias[] = [...new Set(categorias.map(c => c.grupo))].map(id => {
|
||||
const propias = categorias.filter(c => c.grupo === id);
|
||||
return { id, etiqueta: etiquetaGrupo(nombres[id])!, color: promedio(propias.map(c => c.color)), categorias: propias.map(c => c.id) };
|
||||
return { id, etiqueta: id === 'MALIGNO' ? 'Maligno' : id === 'NO_MALIGNO' ? 'No maligno' : etiquetaGrupo(nombres[id])!, color: promedio(propias.map(c => c.color)), categorias: propias.map(c => c.id) };
|
||||
});
|
||||
if (grupos.length !== 2) return fail('Se esperaban dos grupos de resultados.');
|
||||
const base = categorias.find(c => c.id === CATEGORIA_BASE)!.grupo;
|
||||
@@ -181,8 +181,8 @@ export function clicHistopatologia(m: ModeloHistopatologia, sel: SeleccionHistop
|
||||
}
|
||||
/** The axis title says what the rate reads. */
|
||||
export function lectura(m: ModeloHistopatologia, sel: SeleccionHistopatologia): string {
|
||||
if (!sel.categoria && sel.grupo === m.base) return 'Pacientes con resultado metástasis entre las que tienen resultado de biopsia';
|
||||
if (!sel.categoria) return 'Pacientes con resultado no metástasis entre las que tienen resultado de biopsia';
|
||||
if (!sel.categoria && sel.grupo === m.base) return 'Pacientes con resultado maligno entre las que tienen resultado de biopsia';
|
||||
if (!sel.categoria) return 'Pacientes con resultado no maligno entre las que tienen resultado de biopsia';
|
||||
return 'Proporción con resultado ' + enFrase(seleccionEtiqueta(m, sel));
|
||||
}
|
||||
/** Per BI-RADS stratum: the selected categories over the patients with a biopsy result. No biopsy and no data never enter. */
|
||||
|
||||
@@ -30,7 +30,7 @@ describe('Pestaña Histórico', () => {
|
||||
|
||||
it('CaMa: Resumen, Histórico, Análisis epidemiológico, Seguimiento y Datos y definiciones, en ese orden', () => {
|
||||
abrir('cama', [item('cama_eu38a', 'C3r')]);
|
||||
expect(tabs()).toEqual(['Resumen', 'Histórico', 'Análisis epidemiológico', 'Seguimiento', 'Datos y definiciones']);
|
||||
expect(tabs()).toEqual(['Resumen', 'Histórico', 'Análisis', 'Seguimiento', 'Datos y definiciones']);
|
||||
expect(root().querySelector('#panel-historico')).not.toBeNull();
|
||||
});
|
||||
it('cacu no tiene la pestaña Histórico', () => {
|
||||
|
||||
@@ -135,7 +135,7 @@
|
||||
|
||||
@if (conAnalisis) {
|
||||
<section id="panel-analisis" class="section-panel" [class.dark-theme]="tema === 'oscuro'" role="tabpanel" aria-labelledby="tab-analisis" tabindex="0" [hidden]="activeSection() !== 'analisis'">
|
||||
<app-indicadores-analisis [dominio]="dominio" [tema]="tema" [active]="activeSection() === 'analisis'" (verPacientes)="verPacientes($event)" />
|
||||
<p>En desarrollo</p>
|
||||
</section>
|
||||
}
|
||||
|
||||
|
||||
@@ -43,11 +43,11 @@ 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 epidemiológico' }, SECTIONS_WITH_HISTORY[2], SECTIONS_WITH_HISTORY[3]];
|
||||
SECTIONS_WITH_HISTORY[0], SECTIONS_WITH_HISTORY[1], { id: 'analisis', label: 'Análisis' }, SECTIONS_WITH_HISTORY[2], SECTIONS_WITH_HISTORY[3]];
|
||||
|
||||
@Component({
|
||||
selector: 'app-indicadores-page',
|
||||
imports: [FormsModule, MatButtonModule, MatCardModule, MatFormFieldModule, MatInputModule, MatIconModule, MatSelectModule, MatProgressBarModule, IndicadorCatalogCard, IndicadorKpiPanel, IndicadorKpiCard, IndicadorHistopatologiaPendiente, IndicadorPeriodFilters, IndicadoresDefinitions, IndicadoresTracking, IndicadoresHistorico, IndicadoresAnalisis, TeaResumenPeriodo],
|
||||
imports: [FormsModule, MatButtonModule, MatCardModule, MatFormFieldModule, MatInputModule, MatIconModule, MatSelectModule, MatProgressBarModule, IndicadorCatalogCard, IndicadorKpiPanel, IndicadorKpiCard, IndicadorHistopatologiaPendiente, IndicadorPeriodFilters, IndicadoresDefinitions, IndicadoresTracking, IndicadoresHistorico, TeaResumenPeriodo],
|
||||
templateUrl: './indicadores-page.html',
|
||||
styleUrl: './indicadores-page.scss',
|
||||
})
|
||||
|
||||
@@ -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 epidemiológico', 'Seguimiento', 'Datos y definiciones']
|
||||
const esperadas = domain === 'cama' ? ['Resumen', 'Histórico', 'Análisis', 'Seguimiento', '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