Clarify CaCu and CaMa chart labels

This commit is contained in:
Angel Capetillo Zavala
2026-12-03 15:18:22 -06:00
parent d38c795c8a
commit 63f6e16d19
13 changed files with 122 additions and 51 deletions
+7 -7
View File
@@ -30,7 +30,7 @@ test('indicadores cacu: its sections in order, each card read one mode at a time
.evaluateAll((els) => els.map((e) => (e as HTMLElement).innerText.trim())); .evaluateAll((els) => els.map((e) => (e as HTMLElement).innerText.trim()));
expect(headings.slice(headings.indexOf('Indicadores de oportunidad'))).toEqual([ expect(headings.slice(headings.indexOf('Indicadores de oportunidad'))).toEqual([
'Indicadores de oportunidad', 'Indicadores de oportunidad',
'Días de la ruta del tamizaje', 'Tiempos de tamizaje',
'Indicadores clínicos', 'Indicadores clínicos',
'Resultados de citología, VPH y biopsia', 'Resultados de citología, VPH y biopsia',
'Distribución de resultados citológicos', 'Distribución de resultados citológicos',
@@ -40,7 +40,7 @@ test('indicadores cacu: its sections in order, each card read one mode at a time
'Tasa de confirmación histopatológica de referencia a colposcopía', 'Tasa de confirmación histopatológica de referencia a colposcopía',
]); ]);
const route = tab.locator('app-readings').first(); const route = tab.locator('app-readings').first();
for (const mode of ['Por pasos', 'Primer diagnóstico', 'Diagnóstico tras biopsia', 'Acumulado desde la toma']) { for (const mode of ['Por ventana de tiempo', 'Primer diagnóstico', 'Diagnóstico tras biopsia', 'Acumulado desde la toma']) {
await route.getByRole('radio', { name: mode }).click(); await route.getByRole('radio', { name: mode }).click();
await expect( await expect(
route.getByRole('table', { name: mode }).or(route.getByText('Sin datos en el periodo.')), route.getByRole('table', { name: mode }).or(route.getByText('Sin datos en el periodo.')),
@@ -112,7 +112,7 @@ test('indicadores cacu: its sections in order, each card read one mode at a time
test('riesgos cacu: ages filter the whole list and a row opens its stages', async ({ page }) => { test('riesgos cacu: ages filter the whole list and a row opens its stages', async ({ page }) => {
await page.goto('/indicadores/cacu'); await page.goto('/indicadores/cacu');
await page.getByRole('tab', { name: 'Seguimiento' }).click(); await page.getByRole('tab', { name: 'Análisis de Riesgo' }).click();
const list = page.locator('table.worklist tbody tr'); const list = page.locator('table.worklist tbody tr');
await expect(list.first().locator('app-stages li')).toHaveCount(5); await expect(list.first().locator('app-stages li')).toHaveCount(5);
await list.first().getByRole('button', { name: 'Detalle' }).click(); await list.first().getByRole('button', { name: 'Detalle' }).click();
@@ -187,7 +187,7 @@ async function withRounds(page: Page, how: Simulation) {
} }
/** The first group of independent bars of a card (the cytology and genotype breakdowns). */ /** The first group of independent bars of a card (the cytology and genotype breakdowns). */
const plotOf = (readings: Locator) => readings.locator('.group').first(); const plotOf = (readings: Locator) => readings.locator('.group').first();
/** The groups of a card as the page draws them: "label<br>n = N", the width of the first bar and the colour of /** The groups of a card as the page draws them: "label<br>unit: N", the width of the first bar and the colour of
* each category (the first group's rows), in hex. */ * each category (the first group's rows), in hex. */
const traces = (readings: Locator) => const traces = (readings: Locator) =>
readings.evaluate((el) => { readings.evaluate((el) => {
@@ -202,7 +202,7 @@ const traces = (readings: Locator) =>
return { return {
y: groups.map( y: groups.map(
(g) => (g) =>
`${g.querySelector('h4')!.childNodes[0].textContent!.trim()}<br>n = ${g.querySelector('.n')!.textContent!.replace('n = ', '').trim()}`, `${g.querySelector('h4')!.childNodes[0].textContent!.trim()}<br>${g.querySelector('.n')!.textContent!.trim()}`,
), ),
x: groups.map((g) => parseFloat((g.querySelector('.fill') as HTMLElement).style.width)), x: groups.map((g) => parseFloat((g.querySelector('.fill') as HTMLElement).style.width)),
colours: Object.fromEntries( colours: Object.fromEntries(
@@ -277,7 +277,7 @@ for (const card of ['cytology', 'genotype'] as const) {
const { card: of, view } = await withRounds(page, 'no-initial'); const { card: of, view } = await withRounds(page, 'no-initial');
await view(ROUND.name); await view(ROUND.name);
const found = await traces(of(TITLES[card])); const found = await traces(of(TITLES[card]));
expect(found.y[0]).toBe('Detección inicial<br>n = 0'); expect(found.y[0]).toBe('Detección inicial<br>Pacientes: 0');
expect(found.x[0]).toBe(0); expect(found.x[0]).toBe(0);
}); });
@@ -307,7 +307,7 @@ test('rondas (simulado): the genotype card never shows the incomplete positives,
'VPH 16', 'VPH 16',
'VPH 18', 'VPH 18',
'VPH 16 y 18', 'VPH 16 y 18',
'Positivo', 'Positivo sin genotipo',
]); ]);
for (const name of VIEWS.slice(1)) { for (const name of VIEWS.slice(1)) {
await view(name); await view(name);
+1 -1
View File
@@ -25,7 +25,7 @@ const isXlsx = (b: Buffer) => b.subarray(0, 2).toString() === 'PK'; // a zip con
async function followUp(page: Page, domain: 'cama' | 'cacu') { async function followUp(page: Page, domain: 'cama' | 'cacu') {
await page.goto(`/indicadores/${domain}`); await page.goto(`/indicadores/${domain}`);
await page.getByRole('tab', { name: 'Seguimiento' }).click(); await page.getByRole('tab', { name: 'Análisis de Riesgo' }).click();
await page.locator('table.worklist tbody tr').first().waitFor({ timeout: 120_000 }); await page.locator('table.worklist tbody tr').first().waitFor({ timeout: 120_000 });
} }
+2 -2
View File
@@ -14,7 +14,7 @@ test.beforeEach(async ({ page }) => {
/** The record of the first patient of the risk list, as an address. */ /** The record of the first patient of the risk list, as an address. */
async function firstRecord(page: Page): Promise<{ url: string; sample: string }> { async function firstRecord(page: Page): Promise<{ url: string; sample: string }> {
await page.goto('/indicadores/cacu'); await page.goto('/indicadores/cacu');
await page.getByRole('tab', { name: 'Seguimiento' }).click(); await page.getByRole('tab', { name: 'Análisis de Riesgo' }).click();
const link = page.locator('table.worklist tbody tr a').first(); const link = page.locator('table.worklist tbody tr a').first();
await link.waitFor({ timeout: 120_000 }); await link.waitFor({ timeout: 120_000 });
const url = (await link.getAttribute('href'))!; const url = (await link.getAttribute('href'))!;
@@ -1587,7 +1587,7 @@ test('elegibilidad (simulado): a new patient never inherits the previous risk ex
await open(page, firstUrl); await open(page, firstUrl);
await expect(reason).toBeVisible(); await expect(reason).toBeVisible();
await page.getByRole('link', { name: 'Regresar' }).click(); await page.getByRole('link', { name: 'Regresar' }).click();
await page.getByRole('tab', { name: 'Seguimiento' }).click(); await page.getByRole('tab', { name: 'Análisis de Riesgo' }).click();
await page.locator(`a[href*="/pacientes/${secondId}?"]`).first().click(); await page.locator(`a[href*="/pacientes/${secondId}?"]`).first().click();
await expect(historial(page)).toBeVisible({ timeout: 120_000 }); await expect(historial(page)).toBeVisible({ timeout: 120_000 });
await expect(riskBox(page).locator('app-risk-scales')).toBeVisible(); await expect(riskBox(page).locator('app-risk-scales')).toBeVisible();
+8 -8
View File
@@ -58,14 +58,14 @@ test("indicators: the KPIs are the API's MeasureReports, every tab and the patie
); );
await expect(page.locator('app-tab-indicadores app-plot').first()).toBeVisible(); await expect(page.locator('app-tab-indicadores app-plot').first()).toBeVisible();
await page.getByRole('tab', { name: 'Histórico' }).click(); await page.getByRole('tab', { name: 'Trazabilidad' }).click();
await expect(page.locator('app-tab-trazabilidad section.panel')).toHaveCount(9); await expect(page.locator('app-tab-trazabilidad section.panel')).toHaveCount(9);
await page.getByRole('tab', { name: 'Datos y definiciones' }).click(); await page.getByRole('tab', { name: 'Datos y definiciones' }).click();
await expect(page.locator('app-tab-definiciones details')).toHaveCount(21); await expect(page.locator('app-tab-definiciones details')).toHaveCount(21);
const list = page.waitForResponse((r) => r.url().includes('/fhir/Patient?')); const list = page.waitForResponse((r) => r.url().includes('/fhir/Patient?'));
await page.getByRole('tab', { name: 'Seguimiento' }).click(); await page.getByRole('tab', { name: 'Análisis de Riesgo' }).click();
const bundle = await (await list).json(); const bundle = await (await list).json();
const patient = bundle.entry.find((e: any) => e.search.mode === 'match').resource; const patient = bundle.entry.find((e: any) => e.search.mode === 'match').resource;
const first = patient.name?.[0]?.text ?? patient.id.slice(0, 10); const first = patient.name?.[0]?.text ?? patient.id.slice(0, 10);
@@ -84,14 +84,14 @@ test("indicators: the KPIs are the API's MeasureReports, every tab and the patie
).not.toContainText('Sin estudios'); ).not.toContainText('Sin estudios');
await page.goto('/indicadores/cama'); await page.goto('/indicadores/cama');
await expect(page.getByRole('tab', { name: 'Resumen' })).toBeVisible(); await expect(page.getByRole('tab', { name: 'Indicadores' })).toBeVisible();
await page.getByRole('tab', { name: 'Seguimiento' }).click(); await page.getByRole('tab', { name: 'Análisis de Riesgo' }).click();
await page.locator('mat-form-field', { hasText: 'Ventana' }).click(); await page.locator('mat-form-field', { hasText: 'Ventana' }).click();
await page.getByRole('option', { name: '12 meses' }).click(); await page.getByRole('option', { name: '12 meses' }).click();
const camaRows = page.locator('table.worklist tbody tr'); const camaRows = page.locator('table.worklist tbody tr');
await expect(camaRows.first()).toContainText('BI-RADS'); await expect(camaRows.first()).toContainText('BI-RADS');
await page.goto('/indicadores/tea'); await page.goto('/indicadores/tea');
await expect(page.getByRole('tab', { name: 'Resumen' })).toBeVisible(); await expect(page.getByRole('tab', { name: 'Indicadores' })).toBeVisible();
expect(problems).toEqual([]); expect(problems).toEqual([]);
}); });
@@ -208,8 +208,8 @@ const kindOf = (types: string[]) => [...new Set(types)].sort().join('+');
for (const domain of ['cacu', 'cama', 'tea']) { for (const domain of ['cacu', 'cama', 'tea']) {
test(`pestañas de indicadores ${domain} tienen nombres únicos`, async ({ page }) => { test(`pestañas de indicadores ${domain} tienen nombres únicos`, async ({ page }) => {
await page.goto(`/indicadores/${domain}`); await page.goto(`/indicadores/${domain}`);
await expect(page.getByRole('tab', { name: 'Seguimiento', exact: true })).toHaveCount(1); await expect(page.getByRole('tab', { name: 'Análisis de Riesgo', exact: true })).toHaveCount(1);
await expect(page.getByRole('tab', { name: 'Histórico', exact: true })).toHaveCount(1); await expect(page.getByRole('tab', { name: 'Trazabilidad', exact: true })).toHaveCount(1);
const labels = await page.getByRole('tab').allTextContents(); const labels = await page.getByRole('tab').allTextContents();
expect(new Set(labels.map((s) => s.trim())).size).toBe(labels.length); expect(new Set(labels.map((s) => s.trim())).size).toBe(labels.length);
}); });
@@ -278,7 +278,7 @@ for (const domain of ['cacu', 'cama', 'tea']) {
['h2', 'h3', 'plot'].includes(i.kind), ['h2', 'h3', 'plot'].includes(i.kind),
); );
await page.goto(`/indicadores/${domain}`); await page.goto(`/indicadores/${domain}`);
await page.getByRole('tab', { name: 'Histórico' }).click(); await page.getByRole('tab', { name: 'Trazabilidad' }).click();
const tab = page.locator('app-tab-trazabilidad'); const tab = page.locator('app-tab-trazabilidad');
await expect(tab.getByRole('heading', { name: 'Filtros' })).toBeVisible(); await expect(tab.getByRole('heading', { name: 'Filtros' })).toBeVisible();
await expect(tab.locator('app-loading')).toHaveCount(0, { timeout: 5 * 60_000 }); await expect(tab.locator('app-loading')).toHaveCount(0, { timeout: 5 * 60_000 });
+7 -7
View File
@@ -157,15 +157,15 @@ describe('bars', () => {
); );
const y = (f.data[0] as any).y; const y = (f.data[0] as any).y;
expect(y).toEqual([ expect(y).toEqual([
'Detección inicial<br>n = 0', 'Detección inicial<br>Pacientes: 0',
'Detección subsecuente<br>n = 8', 'Detección subsecuente<br>Pacientes: 8',
'Sin dato<br>n = 2', 'Sin dato<br>Pacientes: 2',
]); ]);
expect((f.data[0] as any).x).toEqual([0, 75, 100]); expect((f.data[0] as any).x).toEqual([0, 75, 100]);
}); });
it('leaves out a group that does not reconcile', () => { it('leaves out a group that does not reconcile', () => {
const f = draw(reading({ 'subsequent|NILM': 6 }, 10)); const f = draw(reading({ 'subsequent|NILM': 6 }, 10));
expect((f.data[0] as any).y).toEqual(['Detección subsecuente<br>n = 6']); expect((f.data[0] as any).y).toEqual(['Detección subsecuente<br>Pacientes: 6']);
}); });
}); });
}); });
@@ -173,7 +173,7 @@ describe('bars', () => {
describe('shared views of cytology and HPV by genotype', () => { describe('shared views of cytology and HPV by genotype', () => {
const HPV = [ const HPV = [
{ code: 'negative', label: 'Negativo', color: '#42A77E', group: '' }, { code: 'negative', label: 'Negativo', color: '#42A77E', group: '' },
{ code: 'positive_other', label: 'Positivo', color: '#A8C243', group: '' }, { code: 'positive_other', label: 'Positivo sin genotipo', color: '#A8C243', group: '' },
]; ];
const reading = (cells: Record<string, number>): Reading => ({ const reading = (cells: Record<string, number>): Reading => ({
populations: { 'initial-population': Object.values(cells).reduce((a, b) => a + b, 0) }, populations: { 'initial-population': Object.values(cells).reduce((a, b) => a + b, 0) },
@@ -198,7 +198,7 @@ describe('shared views of cytology and HPV by genotype', () => {
it('does not list a hidden category but keeps it in the total and the percentages', () => { it('does not list a hidden category but keeps it in the total and the percentages', () => {
const t = bars(counts, () => reading({}))!; const t = bars(counts, () => reading({}))!;
expect(t.rows.map((x) => x.label)).toEqual(['Negativo', 'Positivo']); expect(t.rows.map((x) => x.label)).toEqual(['Negativo', 'Positivo sin genotipo']);
expect(t.rows.map((x) => x.cells)).toEqual([ expect(t.rows.map((x) => x.cells)).toEqual([
['5', '50.0 %'], ['5', '50.0 %'],
['2', '20.0 %'], ['2', '20.0 %'],
@@ -247,7 +247,7 @@ describe('shared views of cytology and HPV by genotype', () => {
}); });
expect((own.data[0] as any).x).toEqual([80]); // 4 of the 5 the catalog draws expect((own.data[0] as any).x).toEqual([80]); // 4 of the 5 the catalog draws
expect((all.data[0] as any).x).toEqual([40]); // 4 of the group's 10 reports expect((all.data[0] as any).x).toEqual([40]); // 4 of the group's 10 reports
expect((all.data[0] as any).y).toEqual(['25-34<br>n = 10']); expect((all.data[0] as any).y).toEqual(['25-34<br>Reportes: 10']);
}); });
}); });
+41 -10
View File
@@ -16,6 +16,10 @@ export type Mode = {
kind: 'counts'; kind: 'counts';
measure: string; measure: string;
catalog: Category[]; catalog: Category[];
/** The records counted in the category distribution. */
unit?: string;
/** What the share in the second column is a share of. */
percentLabel?: string;
hidden?: Hidden; hidden?: Hidden;
/** every bar on a fixed scale of 0 to 100 %, so its length is the share shown */ /** every bar on a fixed scale of 0 to 100 %, so its length is the share shown */
percent?: boolean; percent?: boolean;
@@ -27,6 +31,7 @@ export type Mode = {
order: string[]; order: string[];
complete?: boolean; complete?: boolean;
colors?: Colors; colors?: Colors;
percentLabel?: string;
} }
| { | {
kind: 'positives'; kind: 'positives';
@@ -35,8 +40,15 @@ export type Mode = {
order: string[]; order: string[];
complete?: boolean; complete?: boolean;
colors?: Colors; colors?: Colors;
percentLabel?: string;
}
| {
kind: 'signs';
measure: string;
strata: string[];
colors?: Colors;
percentLabel?: string;
} }
| { kind: 'signs'; measure: string; strata: string[]; colors?: Colors }
| { | {
kind: 'grouped'; kind: 'grouped';
measure: string; measure: string;
@@ -47,6 +59,8 @@ export type Mode = {
order: string[]; order: string[];
/** what the records are called ("pacientes", "reportes") */ /** what the records are called ("pacientes", "reportes") */
unit: string; unit: string;
/** The denominator of the percentage shown with each grouped result. */
percentLabel?: string;
/** draw an empty group of `order` when the counts reconcile (see `reconciles`) */ /** draw an empty group of `order` when the counts reconcile (see `reconciles`) */
complete?: boolean; complete?: boolean;
/** each group's denominator is all its records, not only those of the catalog's categories */ /** each group's denominator is all its records, not only those of the catalog's categories */
@@ -55,10 +69,18 @@ export type Mode = {
} }
| { kind: 'days'; steps: { label: string; measure: string }[]; tint?: Tint } | { kind: 'days'; steps: { label: string; measure: string }[]; tint?: Tint }
/** A proportion as one bar of 0 to 100 %, its 95 % interval as the two marks on it */ /** A proportion as one bar of 0 to 100 %, its 95 % interval as the two marks on it */
| { kind: 'ratio'; measure: string; colors?: Colors } | { kind: 'ratio'; measure: string; colors?: Colors; percentLabel?: string }
| { kind: 'days-by'; measure: string; stratum: string; tint?: Tint } | { kind: 'days-by'; measure: string; stratum: string; tint?: Tint }
/** A proportion as its two parts (what counted and what did not), in units, with the shares */ /** A proportion as its two parts (what counted and what did not), in units, with the shares */
| { kind: 'split'; measure: string; yes: string; no: string; colors?: [string, string] } | {
kind: 'split';
measure: string;
yes: string;
no: string;
colors?: [string, string];
unit?: string;
percentLabel?: string;
}
/** Each row's units by result (a bar in segments), and the share of the row's units with a /** Each row's units by result (a bar in segments), and the share of the row's units with a
* result that are `malignant`; a row with units and no result is not a row with none */ * result that are `malignant`; a row with units and no result is not a row with none */
| { | {
@@ -213,7 +235,7 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
if (r?.score === undefined || !total) return undefined; if (r?.score === undefined || !total) return undefined;
const ends = r.low !== undefined && r.high !== undefined ? [r.low, r.high] : []; const ends = r.low !== undefined && r.high !== undefined ? [r.low, r.high] : [];
return { return {
head: ['n/N', '%', 'IC 95 %'], head: ['n/N', mode.percentLabel ?? 'Porcentaje', 'IC 95 %'],
rows: [ rows: [
{ {
label: 'Total', label: 'Total',
@@ -239,7 +261,7 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
]; ];
const most = mode.percent ? total : Math.max(...Object.values(cells).map(size)); const most = mode.percent ? total : Math.max(...Object.values(cells).map(size));
return { return {
head: ['n', '%'], head: [mode.unit ?? 'n', mode.percentLabel ?? 'Porcentaje'],
rows: all.map(({ code, label, color }) => { rows: all.map(({ code, label, color }) => {
const n = size(cells[code]); const n = size(cells[code]);
const cols = [`${n}`, pct(n, total)]; const cols = [`${n}`, pct(n, total)];
@@ -261,6 +283,7 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
cells[c]['denominator'] ?? 0, cells[c]['denominator'] ?? 0,
mode.colors?.[c], mode.colors?.[c],
]), ]),
mode.percentLabel,
); );
if (!patients(r) || !Object.keys(cells).length) return undefined; if (!patients(r) || !Object.keys(cells).length) return undefined;
const sound = (c: string) => const sound = (c: string) =>
@@ -277,6 +300,7 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
ok, ok,
(c) => (sound(c) ? [cells[c]['numerator'], cells[c]['denominator']] : undefined), (c) => (sound(c) ? [cells[c]['numerator'], cells[c]['denominator']] : undefined),
mode.colors, mode.colors,
mode.percentLabel,
); );
} }
case 'positives': { case 'positives': {
@@ -291,6 +315,7 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
const positive = size(cells[`${c}|positive`]); const positive = size(cells[`${c}|positive`]);
return [name(c), positive, positive + size(cells[`${c}|negative`]), mode.colors?.[c]]; return [name(c), positive, positive + size(cells[`${c}|negative`]), mode.colors?.[c]];
}), }),
mode.percentLabel,
); );
if (!patients(r) || !found.size) return undefined; if (!patients(r) || !found.size) return undefined;
const ok = reconciles( const ok = reconciles(
@@ -306,6 +331,7 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
return [positive, positive + size(cells[`${c}|negative`])]; return [positive, positive + size(cells[`${c}|negative`])];
}, },
mode.colors, mode.colors,
mode.percentLabel,
); );
} }
case 'signs': { case 'signs': {
@@ -317,6 +343,7 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
const positive = size(strata[s]['positive']); const positive = size(strata[s]['positive']);
return [name(s), positive, positive + size(strata[s]['negative']), mode.colors?.[s]]; return [name(s), positive, positive + size(strata[s]['negative']), mode.colors?.[s]];
}), }),
mode.percentLabel,
); );
} }
case 'days': case 'days':
@@ -349,7 +376,7 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
[mode.no, denominator - numerator], [mode.no, denominator - numerator],
]; ];
return { return {
head: ['n', '%'], head: [mode.unit ?? 'n', mode.percentLabel ?? 'Porcentaje'],
rows: parts.map(([label, n], i) => ({ rows: parts.map(([label, n], i) => ({
label, label,
color: mode.colors?.[i], color: mode.colors?.[i],
@@ -480,6 +507,7 @@ function complete(
reconciled: boolean, reconciled: boolean,
counts: (code: string) => [number, number] | undefined, counts: (code: string) => [number, number] | undefined,
colors: Colors = {}, colors: Colors = {},
percentLabel = 'Porcentaje',
): Bars { ): Bars {
const extra = listed.filter((c) => !order.includes(c)); const extra = listed.filter((c) => !order.includes(c));
const rows: Bar[] = [...order, ...extra].map((code) => { const rows: Bar[] = [...order, ...extra].map((code) => {
@@ -507,7 +535,7 @@ function complete(
const none = empty.length === classified.length; const none = empty.length === classified.length;
const unclassified = counts('no_data')?.[1] ?? 0; const unclassified = counts('no_data')?.[1] ?? 0;
return { return {
head: ['n/N', '%'], head: ['n/N', percentLabel],
rows, rows,
note: !reconciled note: !reconciled
? 'Los conteos del informe no concilian con el total de pacientes: los grupos ausentes no se muestran como cero.' ? 'Los conteos del informe no concilian con el total de pacientes: los grupos ausentes no se muestran como cero.'
@@ -520,10 +548,13 @@ function complete(
}; };
} }
function ratios(rows: [string, number, number, string?][]): Bars | undefined { function ratios(
rows: [string, number, number, string?][],
percentLabel = 'Porcentaje',
): Bars | undefined {
if (!rows.length) return undefined; if (!rows.length) return undefined;
return { return {
head: ['n/N', '%'], head: ['n/N', percentLabel],
rows: rows.map(([label, n, total, color]) => ({ rows: rows.map(([label, n, total, color]) => ({
label, label,
color, color,
@@ -543,7 +574,7 @@ function medians(
const top = Math.max(...rows.flatMap((r) => [r.score?.score ?? 0, r.score?.high ?? 0])) || 1; const top = Math.max(...rows.flatMap((r) => [r.score?.score ?? 0, r.score?.high ?? 0])) || 1;
const at = (v: number) => (100 * v) / top; const at = (v: number) => (100 * v) / top;
return { return {
head: ['Mediana', 'n', 'Q1–Q3'], head: ['Mediana', 'Observaciones', 'Q1–Q3'],
markColor: tint?.mark, markColor: tint?.mark,
rows: rows.map(({ label, n, score: s }) => { rows: rows.map(({ label, n, score: s }) => {
if (s?.score === undefined) return { label, width: 0, marks: [], cells: ['—', `${n}`, '—'] }; if (s?.score === undefined) return { label, width: 0, marks: [], cells: ['—', `${n}`, '—'] };
+5 -3
View File
@@ -125,7 +125,7 @@ export function scenarioBars(
: catalog.categories.reduce((t, c) => t + n(s, c.code), 0), : catalog.categories.reduce((t, c) => t + n(s, c.code), 0),
); );
const y = order const y = order
? scenarios.map((s, i) => `${label(s)}<br>n = ${totals[i]}`) ? scenarios.map((s, i) => `${label(s)}<br>${options.ofAll ? 'Reportes' : 'Pacientes'}: ${totals[i]}`)
: scenarios.map(label); : scenarios.map(label);
return { return {
data: catalog.categories.map((c) => ({ data: catalog.categories.map((c) => ({
@@ -304,9 +304,11 @@ export function shareDonut(r: Reading, catalog: Catalog, center: string): Figure
line: { color: '#FFFFFF', width: 2 }, line: { color: '#FFFFFF', width: 2 },
}, },
// an empty slice says nothing (its label would sit on its neighbours') // an empty slice says nothing (its label would sit on its neighbours')
texttemplate: values.map((v) => (v ? '%{label}<br>%{percent}' : '')), texttemplate: values.map((v) =>
v ? `%{label}<br>%{percent} del total de ${center}` : '',
),
textposition: 'outside', textposition: 'outside',
hovertemplate: '%{label}<br>%{value} (%{percent})<extra></extra>', hovertemplate: `%{label}<br>%{value} (%{percent} del total de ${center})<extra></extra>`,
} as Partial<Plotly.Data>, } as Partial<Plotly.Data>,
], ],
layout: { layout: {
+5 -5
View File
@@ -36,28 +36,28 @@ import { Loading } from '../loading';
<p class="muted empty">Este dominio todavía no tiene indicadores publicados.</p> <p class="muted empty">Este dominio todavía no tiene indicadores publicados.</p>
} @else { } @else {
<mat-tab-group mat-stretch-tabs="false" mat-align-tabs="center" animationDuration="0ms"> <mat-tab-group mat-stretch-tabs="false" mat-align-tabs="center" animationDuration="0ms">
<mat-tab label="Resumen"> <mat-tab label="Indicadores">
<app-tab-indicadores [domain]="domain()" [measures]="measures.value()!" /> <app-tab-indicadores [domain]="domain()" [measures]="measures.value()!" />
</mat-tab> </mat-tab>
<mat-tab label="Histórico"> <mat-tab label="Trazabilidad">
<ng-template matTabContent> <ng-template matTabContent>
<app-tab-trazabilidad [domain]="domain()" [measures]="measures.value()!" /> <app-tab-trazabilidad [domain]="domain()" [measures]="measures.value()!" />
</ng-template> </ng-template>
</mat-tab> </mat-tab>
@if (domain() === 'cacu') { @if (domain() === 'cacu') {
<mat-tab label="Seguimiento"> <mat-tab label="Análisis de Riesgo">
<ng-template matTabContent> <ng-template matTabContent>
<app-tab-riesgos [domain]="domain()" /> <app-tab-riesgos [domain]="domain()" />
</ng-template> </ng-template>
</mat-tab> </mat-tab>
} @else if (domain() === 'tea') { } @else if (domain() === 'tea') {
<mat-tab label="Seguimiento"> <mat-tab label="Análisis de Riesgo">
<ng-template matTabContent> <ng-template matTabContent>
<app-tab-riesgos-tea [domain]="domain()" /> <app-tab-riesgos-tea [domain]="domain()" />
</ng-template> </ng-template>
</mat-tab> </mat-tab>
} @else if (domain() === 'cama') { } @else if (domain() === 'cama') {
<mat-tab label="Seguimiento"> <mat-tab label="Análisis de Riesgo">
<ng-template matTabContent> <ng-template matTabContent>
<app-tab-seguimiento [domain]="domain()" /> <app-tab-seguimiento [domain]="domain()" />
</ng-template> </ng-template>
+1
View File
@@ -106,6 +106,7 @@ export const LABELS: Record<string, string> = {
normal: 'Normal', normal: 'Normal',
carcinoma: 'Carcinoma', carcinoma: 'Carcinoma',
no_data: 'Sin dato', no_data: 'Sin dato',
'<25': '<25 años (sin límite inferior)',
no_biopsy: 'Sin biopsia', no_biopsy: 'Sin biopsia',
pre_colposcopy: 'Pre colposcopia', pre_colposcopy: 'Pre colposcopia',
post_colposcopy: 'Post colposcopia', post_colposcopy: 'Post colposcopia',
+34 -6
View File
@@ -59,7 +59,7 @@ const HPV = [
{ code: 'positive_16', label: 'VPH 16', color: HPV_COLORS['positive_16'] }, { code: 'positive_16', label: 'VPH 16', color: HPV_COLORS['positive_16'] },
{ code: 'positive_18', label: 'VPH 18', color: HPV_COLORS['positive_18'] }, { code: 'positive_18', label: 'VPH 18', color: HPV_COLORS['positive_18'] },
{ code: 'positive_16_18', label: 'VPH 16 y 18', color: HPV_COLORS['positive_16_18'] }, { code: 'positive_16_18', label: 'VPH 16 y 18', color: HPV_COLORS['positive_16_18'] },
{ code: 'positive_other', label: 'Positivo', color: HPV_COLORS['positive_other'] }, { code: 'positive_other', label: 'Positivo sin genotipo', color: HPV_COLORS['positive_other'] },
]; ];
const REQUESTS = [ const REQUESTS = [
{ code: 'high_grade', label: 'LIEAG o más', color: REQUEST_COLORS['high_grade'] }, { code: 'high_grade', label: 'LIEAG o más', color: REQUEST_COLORS['high_grade'] },
@@ -107,19 +107,28 @@ const groupViews = (
measure, measure,
catalog, catalog,
unit, unit,
caption: more.ofAll
? 'Porcentaje de reportes de VPH del grupo por genotipo.'
: 'Porcentaje de pacientes del grupo por resultado citológico.',
...v, ...v,
...more, ...more,
})); }));
/** A PPV's card: the whole, and by each of its stratifiers. */ /** A PPV's card: the whole, and by each of its stratifiers. */
const ppv = (measure: string, title: string, note: string, ...more: Mode[]): ReadingsCard => ({ const ppv = (
measure: string,
title: string,
note: string,
percentLabel: string,
...more: Mode[]
): ReadingsCard => ({
kind: 'readings', kind: 'readings',
title, title,
headline: measure, headline: measure,
footnote: true, footnote: true,
note: `${note} Confirma la histología LIEBG o mayor.`, note: `${note} Confirma la histología LIEBG o mayor.`,
modes: [ modes: [
{ kind: 'ratio', label: 'Total', measure, colors: PPV_DONUT }, { kind: 'ratio', label: 'Total', measure, colors: PPV_DONUT, percentLabel },
{ {
kind: 'shares', kind: 'shares',
label: 'Citología previa', label: 'Citología previa',
@@ -128,6 +137,7 @@ const ppv = (measure: string, title: string, note: string, ...more: Mode[]): Rea
stratum: 'cytology', stratum: 'cytology',
colors: PPV_CYTOLOGY_COLORS, colors: PPV_CYTOLOGY_COLORS,
order: ['ascus_plus', 'lsil_plus', 'hsil_plus', 'no_data'], order: ['ascus_plus', 'lsil_plus', 'hsil_plus', 'no_data'],
percentLabel: 'Porcentaje de pacientes con esta citología previa',
}, },
{ {
kind: 'shares', kind: 'shares',
@@ -137,6 +147,7 @@ const ppv = (measure: string, title: string, note: string, ...more: Mode[]): Rea
stratum: 'hpv', stratum: 'hpv',
colors: HPV_COLORS, colors: HPV_COLORS,
order: ['negative', 'positive', 'hpv_16', 'hpv_18', 'no_data'], order: ['negative', 'positive', 'hpv_16', 'hpv_18', 'no_data'],
percentLabel: 'Porcentaje de pacientes de cada grupo de VPH previo',
}, },
{ {
kind: 'shares', kind: 'shares',
@@ -145,6 +156,7 @@ const ppv = (measure: string, title: string, note: string, ...more: Mode[]): Rea
stratum: 'level', stratum: 'level',
colors: PPV_LEVEL_COLORS, colors: PPV_LEVEL_COLORS,
order: ['cin1_plus', 'cin2_plus', 'carcinoma'], order: ['cin1_plus', 'cin2_plus', 'carcinoma'],
percentLabel: 'Porcentaje de pacientes de cada nivel de histología',
}, },
{ {
kind: 'shares', kind: 'shares',
@@ -155,6 +167,7 @@ const ppv = (measure: string, title: string, note: string, ...more: Mode[]): Rea
colors: ROUND_COLORS, colors: ROUND_COLORS,
order: ROUNDS, order: ROUNDS,
complete: true, complete: true,
percentLabel: 'Porcentaje de pacientes de cada ronda',
}, },
...more, ...more,
], ],
@@ -197,7 +210,7 @@ export const CACU: Page = {
opportunity: [ opportunity: [
{ {
kind: 'readings', kind: 'readings',
title: 'Días de la ruta del tamizaje', title: 'Tiempos de tamizaje',
note: 'Mediana en días; las marcas son el primer y el tercer cuartil.', note: 'Mediana en días; las marcas son el primer y el tercer cuartil.',
modes: [ modes: [
{ {
@@ -217,7 +230,7 @@ export const CACU: Page = {
{ {
kind: 'days', kind: 'days',
tint: TINT, tint: TINT,
label: 'Por pasos', label: 'Por ventana de tiempo',
caption: 'Cada paso mide a sus propias pacientes: las medianas no se suman.', caption: 'Cada paso mide a sus propias pacientes: las medianas no se suman.',
steps: [ steps: [
{ {
@@ -262,7 +275,14 @@ export const CACU: Page = {
title: 'Distribución de resultados citológicos', title: 'Distribución de resultados citológicos',
note: 'Pacientes, por su última muestra válida del periodo.', note: 'Pacientes, por su última muestra válida del periodo.',
modes: [ modes: [
{ kind: 'counts', label: GENERAL, measure: 'CACU_EU7', catalog: CYTOLOGY.categories }, {
kind: 'counts',
label: GENERAL,
measure: 'CACU_EU7',
catalog: CYTOLOGY.categories,
unit: 'Pacientes',
percentLabel: 'Porcentaje de pacientes',
},
...groupViews('CACU_EU7', CYTOLOGY.categories, 'pacientes'), ...groupViews('CACU_EU7', CYTOLOGY.categories, 'pacientes'),
], ],
}, },
@@ -277,6 +297,8 @@ export const CACU: Page = {
label: GENERAL, label: GENERAL,
measure: 'CACU_VPH_GENOTIPO', measure: 'CACU_VPH_GENOTIPO',
catalog: HPV, catalog: HPV,
unit: 'Reportes',
percentLabel: 'Porcentaje de reportes de VPH',
hidden: HPV_HIDDEN, hidden: HPV_HIDDEN,
}, },
...groupViews('CACU_VPH_GENOTIPO', HPV, 'reportes', { ...groupViews('CACU_VPH_GENOTIPO', HPV, 'reportes', {
@@ -295,6 +317,8 @@ export const CACU: Page = {
label: 'General', label: 'General',
measure: 'CACU_BIOPSIA_RESULTADOS', measure: 'CACU_BIOPSIA_RESULTADOS',
catalog: BIOPSY.categories, catalog: BIOPSY.categories,
unit: 'Reportes',
percentLabel: 'Porcentaje de reportes de biopsia',
}, },
], ],
}, },
@@ -310,6 +334,7 @@ export const CACU: Page = {
'CACU_VPP_COLPOSCOPIA', 'CACU_VPP_COLPOSCOPIA',
'Tasa de confirmación histopatológica de referencia a colposcopía', 'Tasa de confirmación histopatológica de referencia a colposcopía',
'Pacientes con colposcopía en el periodo; biopsia solicitada en los 60 días siguientes.', 'Pacientes con colposcopía en el periodo; biopsia solicitada en los 60 días siguientes.',
'Porcentaje de pacientes',
), ),
}, },
{ {
@@ -318,12 +343,15 @@ export const CACU: Page = {
'CACU_VPP_BIOPSIA', 'CACU_VPP_BIOPSIA',
'Tasa de confirmación histopatológica de referencia a biopsia', 'Tasa de confirmación histopatológica de referencia a biopsia',
'Pacientes con biopsia reportada, por fecha de solicitud.', 'Pacientes con biopsia reportada, por fecha de solicitud.',
'Porcentaje de biopsias reportadas',
{ {
kind: 'counts', kind: 'counts',
label: 'Solicitudes', label: 'Solicitudes',
caption: 'Solicitudes de biopsia registradas, según su resultado.', caption: 'Solicitudes de biopsia registradas, según su resultado.',
measure: 'CACU_BIOPSIA_SOLICITUD_CONFIRMACION', measure: 'CACU_BIOPSIA_SOLICITUD_CONFIRMACION',
catalog: REQUESTS, catalog: REQUESTS,
unit: 'Solicitudes',
percentLabel: 'Porcentaje de solicitudes',
}, },
), ),
}, },
+4
View File
@@ -342,6 +342,7 @@ export const PAGES: Record<string, Page> = {
measure: 'CAMA_HISTOPATOLOGIA_BIRADS', measure: 'CAMA_HISTOPATOLOGIA_BIRADS',
catalog: [...BIOPSY_GRADES, ...NO_RESULT], catalog: [...BIOPSY_GRADES, ...NO_RESULT],
percent: true, percent: true,
percentLabel: 'Porcentaje de pacientes',
}, },
], ],
}, },
@@ -366,6 +367,7 @@ export const PAGES: Record<string, Page> = {
measure: 'CAMA_BIOPSIAS', measure: 'CAMA_BIOPSIAS',
catalog: [...BIOPSY_GRADES, NO_RESULT[1]], catalog: [...BIOPSY_GRADES, NO_RESULT[1]],
percent: true, percent: true,
percentLabel: 'Porcentaje de reportes de biopsia',
}, },
], ],
}, },
@@ -386,6 +388,8 @@ export const PAGES: Record<string, Page> = {
yes: 'Con reporte de biopsia', yes: 'Con reporte de biopsia',
no: 'Sin reporte de biopsia', no: 'Sin reporte de biopsia',
colors: [INSTITUTIONAL, NEUTRAL], colors: [INSTITUTIONAL, NEUTRAL],
unit: 'Mastografías',
percentLabel: 'Porcentaje de mastografías',
}, },
], ],
}, },
+6 -1
View File
@@ -54,7 +54,7 @@ import { Reading } from './measures';
@for (group of g.groups; track group.code) { @for (group of g.groups; track group.code) {
<section class="group" [attr.data-group]="group.code" [attr.aria-label]="group.label"> <section class="group" [attr.data-group]="group.code" [attr.aria-label]="group.label">
<h4> <h4>
{{ group.label }} <span class="n">n = {{ group.total }}</span> {{ group.label }} <span class="n">{{ countUnit() }}: {{ group.total }}</span>
@if (group.hint) { @if (group.hint) {
<span class="hint">{{ group.hint }}</span> <span class="hint">{{ group.hint }}</span>
} }
@@ -364,6 +364,11 @@ export class Readings {
readonly draw = input.required<(mode: Mode) => Figure | undefined>(); readonly draw = input.required<(mode: Mode) => Figure | undefined>();
protected readonly chosen = signal(''); protected readonly chosen = signal('');
protected readonly countUnit = computed(() => {
const mode = this.mode();
const unit = mode.kind === 'grouped' ? mode.unit : 'pacientes';
return unit[0].toUpperCase() + unit.slice(1);
});
protected readonly mode = computed( protected readonly mode = computed(
() => this.modes().find((m) => m.label === (this.view() || this.chosen())) ?? this.modes()[0], () => this.modes().find((m) => m.label === (this.view() || this.chosen())) ?? this.modes()[0],
); );
+1 -1
View File
@@ -142,7 +142,7 @@
</td> </td>
<td> <td>
{{ row.age ?? 'No disponible' }} {{ row.age ?? 'No disponible' }}
<small>Grupo: {{ row.ageGroup }}</small> <small>Grupo: {{ name(row.ageGroup) }}</small>
</td> </td>
<td>{{ name(row.status) }}</td> <td>{{ name(row.status) }}</td>
<td> <td>