Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f92bcd80b9 | |||
| 4789282e17 | |||
| 22edb0bf42 | |||
| c128448317 | |||
| c28cf31e2a | |||
| f6dffb6dc2 | |||
| 1820b8ce2b | |||
| 1abfc27013 | |||
| e31c128991 | |||
| 972bdf0d8a | |||
| 7167426283 | |||
| cbc41ca365 | |||
| 94c3bb6d82 | |||
| 72aa91af04 | |||
| 2a84eb56ca |
@@ -1467,9 +1467,7 @@ test('elegibilidad: the risk section shows the published post-treatment exclusio
|
|||||||
expect(patientId, 'a synthetic patient with a published post-treatment exclusion').toBeDefined();
|
expect(patientId, 'a synthetic patient with a published post-treatment exclusion').toBeDefined();
|
||||||
await open(page, `/indicadores/cacu/pacientes/${patientId}`);
|
await open(page, `/indicadores/cacu/pacientes/${patientId}`);
|
||||||
const box = riskBox(page);
|
const box = riskBox(page);
|
||||||
await expect(box.getByRole('status')).toHaveText(
|
await expect(box.getByRole('status')).toHaveText(/paciente ya tratada\.$/);
|
||||||
'No disponible por: Sin biopsia previa al tratamiento en el periodo requerido.',
|
|
||||||
);
|
|
||||||
await expect(box.locator('app-risk-scales')).toHaveCount(0);
|
await expect(box.locator('app-risk-scales')).toHaveCount(0);
|
||||||
await expect(page.locator('[data-section=elegibilidad]')).toHaveCount(0);
|
await expect(page.locator('[data-section=elegibilidad]')).toHaveCount(0);
|
||||||
});
|
});
|
||||||
|
|||||||
+8
-12
@@ -226,22 +226,17 @@ for (const domain of ['cama', 'tea']) {
|
|||||||
(i) => i.kind === 'h3' && i.text === 'Tiempo de tamizaje a diagnóstico',
|
(i) => i.kind === 'h3' && i.text === 'Tiempo de tamizaje a diagnóstico',
|
||||||
);
|
);
|
||||||
const clinical = all.findIndex((i) => i.text === 'Indicadores clínicos');
|
const clinical = all.findIndex((i) => i.text === 'Indicadores clínicos');
|
||||||
// Lote 2: the detection rate has its own title, and the histopathology figures are two
|
// The histopathology figures are two cards: the result by BI-RADS and the confirmation.
|
||||||
// cards (the result by BI-RADS; the confirmation in two readings).
|
|
||||||
const detection = (i: { text?: string }) =>
|
|
||||||
i.text === 'Tasa de confirmación histopatológica'
|
|
||||||
? { ...i, text: 'Tasa de detección histopatológica' }
|
|
||||||
: i;
|
|
||||||
const results = all.findIndex(
|
const results = all.findIndex(
|
||||||
(i) => i.text === 'Resultado histopatológico por categoría BI-RADS',
|
(i) => i.text === 'Tipo histológico por categoría BI-RADS',
|
||||||
);
|
);
|
||||||
const cards = [
|
const cards = [
|
||||||
{ kind: 'h3', text: 'Resultado histopatológico por categoría BI-RADS' },
|
{ kind: 'h3', text: 'Tipo histológico por categoría BI-RADS' },
|
||||||
{ kind: 'h3', text: 'Confirmación histopatológica' }, // one card: title, tabs and reading
|
{ kind: 'h3', text: 'Confirmación histopatológica' }, // one card: title, tabs and reading
|
||||||
];
|
];
|
||||||
const old =
|
const old =
|
||||||
domain === 'cama'
|
domain === 'cama'
|
||||||
? [...all.slice(0, route + 1).map(detection), ...all.slice(clinical, results), ...cards]
|
? [...all.slice(0, route + 1), ...all.slice(clinical, results), ...cards]
|
||||||
: all;
|
: all;
|
||||||
await page.goto(`/indicadores/${domain}`);
|
await page.goto(`/indicadores/${domain}`);
|
||||||
const tab = page.locator('app-tab-indicadores');
|
const tab = page.locator('app-tab-indicadores');
|
||||||
@@ -253,14 +248,15 @@ for (const domain of ['cama', 'tea']) {
|
|||||||
const from = headings.indexOf('Indicadores de oportunidad');
|
const from = headings.indexOf('Indicadores de oportunidad');
|
||||||
if (domain === 'cama') {
|
if (domain === 'cama') {
|
||||||
const ordered = [
|
const ordered = [
|
||||||
|
'Pacientes evaluadas con BI-RADS 4, 5 o 6',
|
||||||
'Tiempo de toma de mastografía a interpretación radiológica',
|
'Tiempo de toma de mastografía a interpretación radiológica',
|
||||||
'Tiempo de interpretación radiológica a diagnóstico',
|
'Tiempo de interpretación radiológica a diagnóstico',
|
||||||
|
'Tiempo de interpretación radiológica a resultado de biopsia',
|
||||||
|
'Tiempo de diagnóstico a tratamiento',
|
||||||
'Tiempo de tamizaje a diagnóstico',
|
'Tiempo de tamizaje a diagnóstico',
|
||||||
'Porcentaje de mastografías con resultado BI-RADS 4, 5 ó 6',
|
'Porcentaje de mastografías con resultado BI-RADS 4, 5 ó 6',
|
||||||
'Pacientes evaluadas con BI-RADS 4, 5 o 6',
|
'Tipo histológico por categoría BI-RADS',
|
||||||
'Resultado histopatológico por categoría BI-RADS',
|
|
||||||
'Confirmación histopatológica',
|
'Confirmación histopatológica',
|
||||||
'Tasa de detección histopatológica',
|
|
||||||
];
|
];
|
||||||
let last = -1;
|
let last = -1;
|
||||||
for (const title of ordered) {
|
for (const title of ordered) {
|
||||||
|
|||||||
@@ -1,8 +1,66 @@
|
|||||||
import { bars, grouped, hiddenNote, Mode, subsequentHistory, unavailable } from './bars';
|
import { bars, grouped, hiddenNote, Mode, unavailable } from './bars';
|
||||||
import { scenarioBars } from './figures';
|
import { scenarioBars } from './figures';
|
||||||
import { Reading } from './measures';
|
import { Reading } from './measures';
|
||||||
|
|
||||||
describe('bars', () => {
|
describe('bars', () => {
|
||||||
|
it('shows histologic types by BI-RADS while deriving malignancy from biopsy classification', () => {
|
||||||
|
const type: Reading = {
|
||||||
|
populations: {},
|
||||||
|
strata: {
|
||||||
|
category: { '8500/3': { 'initial-population': 1 }, no_data: { 'initial-population': 1 } },
|
||||||
|
birads: { '4A': { 'initial-population': 2 } },
|
||||||
|
'birads-category': {
|
||||||
|
'4A|8500/3': { 'initial-population': 1 },
|
||||||
|
'4A|no_data': { 'initial-population': 1 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const classification: Reading = {
|
||||||
|
populations: {},
|
||||||
|
strata: {
|
||||||
|
'birads-category': {
|
||||||
|
'4A|benign': { 'initial-population': 1 },
|
||||||
|
'4A|invasive': { 'initial-population': 1 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const mode: Mode = {
|
||||||
|
kind: 'outcomes',
|
||||||
|
label: 'Por categoría BI-RADS',
|
||||||
|
measure: 'types',
|
||||||
|
stratum: 'birads',
|
||||||
|
rows: [{ code: '4A', label: '4A', color: '#000' }],
|
||||||
|
results: [
|
||||||
|
{ code: 'no_biopsy', label: 'Sin biopsia', color: '#aaa' },
|
||||||
|
{ code: 'no_data', label: 'Sin dato', color: '#bbb' },
|
||||||
|
],
|
||||||
|
malignant: ['in_situ', 'invasive'],
|
||||||
|
dynamicResults: true,
|
||||||
|
malignancyMeasure: 'grades',
|
||||||
|
};
|
||||||
|
const table = bars(mode, (key) => (key === 'types' ? type : classification))!;
|
||||||
|
expect(table.head).toEqual(['Pacientes', 'Carcinoma ductal infiltrante', 'Sin biopsia', 'Sin dato', '% maligno']);
|
||||||
|
expect(table.rows[0].cells).toEqual(['2', '1', '0', '1', '1/2 (50.0 %)']);
|
||||||
|
expect(bars(mode, (key) => (key === 'types' ? type : undefined))!.rows[0].cells.at(-1)).toBe(
|
||||||
|
'No disponible',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('lists histologic codes from gold and preserves missing types in the denominator', () => {
|
||||||
|
const r: Reading = {
|
||||||
|
populations: { 'initial-population': 4 },
|
||||||
|
strata: {
|
||||||
|
category: { '8500/3': { 'initial-population': 1 }, no_data: { 'initial-population': 3 } },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const table = bars(
|
||||||
|
{ kind: 'counts', label: 'Tipos histológicos', measure: 'M', catalog: [], unit: 'Biopsias' },
|
||||||
|
() => r,
|
||||||
|
)!;
|
||||||
|
expect(table.rows.map((row) => [row.label, ...row.cells])).toEqual([
|
||||||
|
['Carcinoma ductal infiltrante', '1', '25.0 %'],
|
||||||
|
['Sin dato', '3', '75.0 %'],
|
||||||
|
]);
|
||||||
|
});
|
||||||
it('list every category, so the shares add up', () => {
|
it('list every category, so the shares add up', () => {
|
||||||
const r: Reading = {
|
const r: Reading = {
|
||||||
populations: {},
|
populations: {},
|
||||||
@@ -35,6 +93,7 @@ describe('bars', () => {
|
|||||||
const aggregate = { label: 'Anormal', color: '#f00', codes: ['LSIL', 'HSIL'] };
|
const aggregate = { label: 'Anormal', color: '#f00', codes: ['LSIL', 'HSIL'] };
|
||||||
const t = bars({ kind: 'counts', label: 'x', measure: 'M', catalog, aggregate }, () => r)!;
|
const t = bars({ kind: 'counts', label: 'x', measure: 'M', catalog, aggregate }, () => r)!;
|
||||||
expect(t.rows[1].cells).toEqual(['3', '30.0 %']);
|
expect(t.rows[1].cells).toEqual(['3', '30.0 %']);
|
||||||
|
expect(t.rows.map((row) => !!row.sub)).toEqual([false, false, true, true, false].slice(0, t.rows.length));
|
||||||
const g = grouped(
|
const g = grouped(
|
||||||
{
|
{
|
||||||
kind: 'grouped',
|
kind: 'grouped',
|
||||||
@@ -51,25 +110,6 @@ describe('bars', () => {
|
|||||||
)!;
|
)!;
|
||||||
expect(g.groups[0].rows[1].text).toBe('3/10 · 30.0 %');
|
expect(g.groups[0].rows[1].text).toBe('3/10 · 30.0 %');
|
||||||
});
|
});
|
||||||
it('shows the form history within subsequent screening without treating missing answers as a category', () => {
|
|
||||||
const r: Reading = {
|
|
||||||
populations: {},
|
|
||||||
strata: {
|
|
||||||
round: { subsequent: { 'initial-population': 5 } },
|
|
||||||
subsequent_history: {
|
|
||||||
within_1_year: { 'initial-population': 1 },
|
|
||||||
'3_or_more_years': { 'initial-population': 2 },
|
|
||||||
no_data: { 'initial-population': 2 },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
expect(subsequentHistory(r)).toEqual([
|
|
||||||
{ label: 'Un año o menos', text: '1/5 · 20.0 %' },
|
|
||||||
{ label: 'Dos años', text: '0/5 · 0.0 %' },
|
|
||||||
{ label: 'Tres o más años', text: '2/5 · 40.0 %' },
|
|
||||||
]);
|
|
||||||
expect(subsequentHistory({ populations: {}, strata: {} })).toBeUndefined();
|
|
||||||
});
|
|
||||||
it('a group with no patients has no rate', () => {
|
it('a group with no patients has no rate', () => {
|
||||||
const r: Reading = {
|
const r: Reading = {
|
||||||
populations: {},
|
populations: {},
|
||||||
@@ -100,7 +140,7 @@ describe('bars', () => {
|
|||||||
const t = bars(mode, () => r)!;
|
const t = bars(mode, () => r)!;
|
||||||
expect(t.rows.map((x) => x.label)).toEqual([
|
expect(t.rows.map((x) => x.label)).toEqual([
|
||||||
'Detección inicial',
|
'Detección inicial',
|
||||||
'Detección subsecuente',
|
'Con detección anterior',
|
||||||
'Sin dato',
|
'Sin dato',
|
||||||
]);
|
]);
|
||||||
expect(t.rows.map((x) => x.cells)).toEqual([
|
expect(t.rows.map((x) => x.cells)).toEqual([
|
||||||
@@ -198,7 +238,7 @@ describe('bars', () => {
|
|||||||
c === 'initial'
|
c === 'initial'
|
||||||
? 'Detección inicial'
|
? 'Detección inicial'
|
||||||
: c === 'subsequent'
|
: c === 'subsequent'
|
||||||
? 'Detección subsecuente'
|
? 'Con detección anterior'
|
||||||
: 'Sin dato',
|
: 'Sin dato',
|
||||||
['initial', 'subsequent', 'no_data'],
|
['initial', 'subsequent', 'no_data'],
|
||||||
{ fill: true },
|
{ fill: true },
|
||||||
@@ -211,14 +251,14 @@ 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>Pacientes: 0',
|
'Detección inicial<br>Pacientes: 0',
|
||||||
'Detección subsecuente<br>Pacientes: 8',
|
'Con detección anterior<br>Pacientes: 8',
|
||||||
'Sin dato<br>Pacientes: 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>Pacientes: 6']);
|
expect((f.data[0] as any).y).toEqual(['Con detección anterior<br>Pacientes: 6']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -335,7 +375,7 @@ describe('independent bars by group', () => {
|
|||||||
)!;
|
)!;
|
||||||
expect(g.groups.map((x) => [x.label, x.total])).toEqual([
|
expect(g.groups.map((x) => [x.label, x.total])).toEqual([
|
||||||
['Detección inicial', 4],
|
['Detección inicial', 4],
|
||||||
['Detección subsecuente', 6],
|
['Con detección anterior', 6],
|
||||||
]);
|
]);
|
||||||
expect(g.groups[0].rows.map((r) => [r.label, r.text, r.percent, r.color])).toEqual([
|
expect(g.groups[0].rows.map((r) => [r.label, r.text, r.percent, r.color])).toEqual([
|
||||||
['Normal', '3/4 · 75.0 %', 75, '#408651'],
|
['Normal', '3/4 · 75.0 %', 75, '#408651'],
|
||||||
@@ -353,7 +393,7 @@ describe('independent bars by group', () => {
|
|||||||
['0/0 · —', undefined],
|
['0/0 · —', undefined],
|
||||||
['0/0 · —', undefined],
|
['0/0 · —', undefined],
|
||||||
]);
|
]);
|
||||||
expect(empty.note).toContain('una categoría en cero significa');
|
expect(empty.note).toBeUndefined();
|
||||||
const unreconciled = grouped(mode({ complete: true }), () =>
|
const unreconciled = grouped(mode({ complete: true }), () =>
|
||||||
reading({ 'subsequent|NILM': 2 }, 5),
|
reading({ 'subsequent|NILM': 2 }, 5),
|
||||||
)!;
|
)!;
|
||||||
@@ -468,3 +508,52 @@ describe('independent bars by group', () => {
|
|||||||
expect(bars(mode as any, () => r)!.rows.map((x) => x.color)).toEqual(['#a', '#b']);
|
expect(bars(mode as any, () => r)!.rows.map((x) => x.color)).toEqual(['#a', '#b']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('the subsequent round by last screening', () => {
|
||||||
|
it('chains the steps of a time window, quartiles moving with their bar', () => {
|
||||||
|
const median = (score: number, low: number, high: number): Reading => ({
|
||||||
|
populations: { 'measure-observation': 1 },
|
||||||
|
strata: {},
|
||||||
|
score,
|
||||||
|
low,
|
||||||
|
high,
|
||||||
|
});
|
||||||
|
const steps = [
|
||||||
|
{ label: 'a', measure: 'A' },
|
||||||
|
{ label: 'b', measure: 'B' },
|
||||||
|
];
|
||||||
|
const table = bars({ kind: 'days', label: 'x', steps, staggered: true }, (m) =>
|
||||||
|
m === 'A' ? median(10, 5, 10) : median(20, 10, 30),
|
||||||
|
)!;
|
||||||
|
expect(table.rows.map((r) => [r.offset, r.width, r.marks])).toEqual([
|
||||||
|
[0, 25, [12.5, 25]],
|
||||||
|
[25, 50, [50, 100]],
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
it('splits the subsequent round by last screening, drawing only those with an answer', () => {
|
||||||
|
const one = { 'initial-population': 1 };
|
||||||
|
const r: Reading = {
|
||||||
|
populations: { 'initial-population': 3 },
|
||||||
|
strata: {
|
||||||
|
'round-category': { 'initial|a': one, 'subsequent|a': { 'initial-population': 2 } },
|
||||||
|
'subsequent_history-category': { 'within_1_year|a': one, 'no_data|a': one },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const mode: Mode = {
|
||||||
|
kind: 'grouped',
|
||||||
|
label: 'x',
|
||||||
|
measure: 'M',
|
||||||
|
stratum: 'round',
|
||||||
|
order: ['initial', 'subsequent'],
|
||||||
|
unit: 'pacientes',
|
||||||
|
catalog: [{ code: 'a', label: 'A', color: '#000' }],
|
||||||
|
};
|
||||||
|
const { groups } = grouped(mode, () => r)!;
|
||||||
|
expect(groups.map((g) => [g.code, g.total])).toEqual([
|
||||||
|
['initial', 1],
|
||||||
|
['within_1_year', 1],
|
||||||
|
['2_years', 0],
|
||||||
|
['3_or_more_years', 0],
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
+92
-54
@@ -1,4 +1,5 @@
|
|||||||
import { CIE10 } from './cie10';
|
import { CIE10 } from './cie10';
|
||||||
|
import { chainStarts } from './durations';
|
||||||
import { NEUTRAL_DARK } from './cacu-palette';
|
import { NEUTRAL_DARK } from './cacu-palette';
|
||||||
import { name, Reading } from './measures';
|
import { name, Reading } from './measures';
|
||||||
|
|
||||||
@@ -69,7 +70,13 @@ export type Mode = {
|
|||||||
ofAll?: boolean;
|
ofAll?: boolean;
|
||||||
hidden?: Hidden;
|
hidden?: Hidden;
|
||||||
}
|
}
|
||||||
| { kind: 'days'; steps: { label: string; measure: string }[]; tint?: Tint }
|
| {
|
||||||
|
kind: 'days';
|
||||||
|
steps: { label: string; measure: string }[];
|
||||||
|
tint?: Tint;
|
||||||
|
/** each bar starts where the previous one ends (a schematic sequence, as a Gantt chart) */
|
||||||
|
staggered?: boolean;
|
||||||
|
}
|
||||||
/** 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; percentLabel?: string }
|
| { 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 }
|
||||||
@@ -92,6 +99,8 @@ export type Mode = {
|
|||||||
rows: Category[];
|
rows: Category[];
|
||||||
results: Category[];
|
results: Category[];
|
||||||
malignant: string[];
|
malignant: string[];
|
||||||
|
dynamicResults?: boolean;
|
||||||
|
malignancyMeasure?: string;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
kind: 'figure';
|
kind: 'figure';
|
||||||
@@ -121,6 +130,7 @@ export type Tint = { bar: string; mark: string };
|
|||||||
|
|
||||||
/** One category of a group as an independent bar of 0 to 100 %: its records over the group's. */
|
/** One category of a group as an independent bar of 0 to 100 %: its records over the group's. */
|
||||||
export interface GroupRow {
|
export interface GroupRow {
|
||||||
|
sub?: boolean;
|
||||||
label: string;
|
label: string;
|
||||||
color: string;
|
color: string;
|
||||||
count: number;
|
count: number;
|
||||||
@@ -147,10 +157,14 @@ export interface Groups {
|
|||||||
|
|
||||||
/** One bar: its length and quartile marks in % of the scale, and its cells of text. */
|
/** One bar: its length and quartile marks in % of the scale, and its cells of text. */
|
||||||
export interface Bar {
|
export interface Bar {
|
||||||
|
/** one of the categories the aggregate row above adds up */
|
||||||
|
sub?: boolean;
|
||||||
label: string;
|
label: string;
|
||||||
/** why the row has no figures: no patients in the group, or not available */
|
/** why the row has no figures: no patients in the group, or not available */
|
||||||
hint?: string;
|
hint?: string;
|
||||||
color?: string;
|
color?: string;
|
||||||
|
/** where the bar starts, in % of the scale */
|
||||||
|
offset?: number;
|
||||||
width: number;
|
width: number;
|
||||||
marks: number[];
|
marks: number[];
|
||||||
cells: string[];
|
cells: string[];
|
||||||
@@ -172,10 +186,8 @@ export interface Bars {
|
|||||||
|
|
||||||
export const NOT_AVAILABLE = 'No disponible';
|
export const NOT_AVAILABLE = 'No disponible';
|
||||||
export const NO_PATIENTS = 'Sin pacientes en el periodo';
|
export const NO_PATIENTS = 'Sin pacientes en el periodo';
|
||||||
const EMPTY_ROUND =
|
|
||||||
'Hay pacientes sin clasificación de ronda («Sin dato»): una categoría en cero significa que no hay pacientes clasificadas en esa ronda según la información disponible.';
|
|
||||||
const NO_ROUND =
|
const NO_ROUND =
|
||||||
'Ninguna paciente del periodo tiene clasificación de detección inicial o subsecuente: los grupos en cero reflejan información no registrada, no ausencia de pacientes.';
|
'Ninguna paciente del periodo tiene clasificación de detección inicial o anterior: los grupos en cero reflejan información no registrada, no ausencia de pacientes.';
|
||||||
|
|
||||||
const whole = (n: unknown): n is number => typeof n === 'number' && Number.isInteger(n) && n >= 0;
|
const whole = (n: unknown): n is number => typeof n === 'number' && Number.isInteger(n) && n >= 0;
|
||||||
|
|
||||||
@@ -267,7 +279,8 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
|
|||||||
rows: all.flatMap(({ code, label, color }, index) => {
|
rows: all.flatMap(({ code, label, color }, index) => {
|
||||||
const n = size(cells[code]);
|
const n = size(cells[code]);
|
||||||
const cols = [`${n}`, pct(n, total)];
|
const cols = [`${n}`, pct(n, total)];
|
||||||
const row = { label, color, width: (100 * n) / most, marks: [], cells: cols };
|
const part = !!mode.aggregate?.codes.includes(code);
|
||||||
|
const row = { label, color, width: (100 * n) / most, marks: [], cells: cols, sub: part };
|
||||||
if (index !== 0 || !mode.aggregate) return [row];
|
if (index !== 0 || !mode.aggregate) return [row];
|
||||||
const a = mode.aggregate;
|
const a = mode.aggregate;
|
||||||
const sum = a.codes.reduce((total, key) => total + size(cells[key]), 0);
|
const sum = a.codes.reduce((total, key) => total + size(cells[key]), 0);
|
||||||
@@ -368,6 +381,7 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
|
|||||||
return { label, n: r?.populations['measure-observation'] ?? 0, score: r };
|
return { label, n: r?.populations['measure-observation'] ?? 0, score: r };
|
||||||
}),
|
}),
|
||||||
mode.tint,
|
mode.tint,
|
||||||
|
mode.staggered,
|
||||||
);
|
);
|
||||||
case 'days-by': {
|
case 'days-by': {
|
||||||
const r = of(mode.measure);
|
const r = of(mode.measure);
|
||||||
@@ -406,16 +420,33 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
|
|||||||
const units = r?.strata[mode.stratum] ?? {};
|
const units = r?.strata[mode.stratum] ?? {};
|
||||||
const cells = r?.strata[`${mode.stratum}-category`] ?? {};
|
const cells = r?.strata[`${mode.stratum}-category`] ?? {};
|
||||||
if (!Object.keys(units).length) return undefined;
|
if (!Object.keys(units).length) return undefined;
|
||||||
const graded = (i: number) => !['no_biopsy', 'no_data'].includes(mode.results[i].code);
|
const colors = ['#5C42C2', '#C24269', '#9C42C2', '#A8C243', '#2778B8', '#B19525'];
|
||||||
|
const actual = Object.keys(r?.strata['category'] ?? {})
|
||||||
|
.filter((code) => !['no_biopsy', 'no_data'].includes(code))
|
||||||
|
.sort();
|
||||||
|
const results = mode.dynamicResults
|
||||||
|
? [
|
||||||
|
...actual.map((code, i) => ({
|
||||||
|
code,
|
||||||
|
label: name(code),
|
||||||
|
color: colors[i % colors.length],
|
||||||
|
})),
|
||||||
|
...mode.results,
|
||||||
|
]
|
||||||
|
: mode.results;
|
||||||
|
const malignancy = mode.malignancyMeasure ? of(mode.malignancyMeasure) : r;
|
||||||
|
const hasMalignancy = !!malignancy?.strata[`${mode.stratum}-category`];
|
||||||
|
const malignancyCells = malignancy?.strata[`${mode.stratum}-category`] ?? {};
|
||||||
|
const grades = ['benign', 'in_situ', 'invasive'];
|
||||||
return {
|
return {
|
||||||
head: ['Pacientes', ...mode.results.map((x) => x.label), '% maligno'],
|
head: ['Pacientes', ...results.map((x) => x.label), '% maligno'],
|
||||||
legend: mode.results.map(({ label, color }) => ({ label, color })),
|
legend: results.map(({ label, color }) => ({ label, color })),
|
||||||
rows: mode.rows.map(({ code, label }) => {
|
rows: mode.rows.map(({ code, label }) => {
|
||||||
const n = size(units[code]);
|
const n = size(units[code]);
|
||||||
const by = mode.results.map((x) => size(cells[`${code}|${x.code}`]));
|
const by = results.map((x) => size(cells[`${code}|${x.code}`]));
|
||||||
const den = by.reduce((t, k, i) => t + (graded(i) ? k : 0), 0);
|
const den = grades.reduce((t, grade) => t + size(malignancyCells[`${code}|${grade}`]), 0);
|
||||||
const bad = by.reduce(
|
const bad = mode.malignant.reduce(
|
||||||
(t, k, i) => t + (mode.malignant.includes(mode.results[i].code) ? k : 0),
|
(t, grade) => t + size(malignancyCells[`${code}|${grade}`]),
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
@@ -423,7 +454,7 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
|
|||||||
width: 100,
|
width: 100,
|
||||||
marks: [],
|
marks: [],
|
||||||
none: n ? undefined : 'Sin pacientes en el periodo',
|
none: n ? undefined : 'Sin pacientes en el periodo',
|
||||||
segments: mode.results.map((x, i) => ({
|
segments: results.map((x, i) => ({
|
||||||
width: n ? (100 * by[i]) / n : 0,
|
width: n ? (100 * by[i]) / n : 0,
|
||||||
color: x.color,
|
color: x.color,
|
||||||
title: `${x.label}: ${by[i]} de ${n} (${pct(by[i], n)})`,
|
title: `${x.label}: ${by[i]} de ${n} (${pct(by[i], n)})`,
|
||||||
@@ -432,11 +463,13 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
|
|||||||
`${n}`,
|
`${n}`,
|
||||||
...by.map((k) => (n ? `${k}` : '—')),
|
...by.map((k) => (n ? `${k}` : '—')),
|
||||||
n
|
n
|
||||||
? den
|
? !hasMalignancy
|
||||||
? `${bad}/${den} (${pct(bad, den)})`
|
? 'No disponible'
|
||||||
: by[mode.results.findIndex((x) => x.code === 'no_data')]
|
: den
|
||||||
? 'Sin biopsias clasificables'
|
? `${bad}/${den} (${pct(bad, den)})`
|
||||||
: 'Sin biopsias'
|
: size(malignancyCells[`${code}|no_data`])
|
||||||
|
? 'Sin biopsias clasificables'
|
||||||
|
: 'Sin biopsias'
|
||||||
: '—',
|
: '—',
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
@@ -448,23 +481,12 @@ export function bars(mode: Mode, of: (measure: string) => Reading | undefined):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Reported form answers within the subsequent round, over that round's own total. */
|
/** The subsequent round split by the form's last screening, drawn in place of that round's group. */
|
||||||
export function subsequentHistory(reading?: Reading) {
|
const LAST_SCREENING: [string, string][] = [
|
||||||
const values = reading?.strata['subsequent_history'];
|
['within_1_year', 'Detección anterior hace un año o menos'],
|
||||||
const den = reading?.strata['round']?.['subsequent']?.['initial-population'] ?? 0;
|
['2_years', 'Detección anterior hace dos años'],
|
||||||
if (!values) return undefined;
|
['3_or_more_years', 'Detección anterior hace tres años o más'],
|
||||||
return [
|
];
|
||||||
['within_1_year', 'Un año o menos'],
|
|
||||||
['2_years', 'Dos años'],
|
|
||||||
['3_or_more_years', 'Tres o más años'],
|
|
||||||
].map(([code, label]) => {
|
|
||||||
const count = values[code]?.['initial-population'] ?? 0;
|
|
||||||
return {
|
|
||||||
label,
|
|
||||||
text: `${count}/${den} · ${den ? ((100 * count) / den).toFixed(1) + ' %' : '—'}`,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The groups of a grouped mode: each group (an age group, a follow-up status, a screening round) with
|
/** The groups of a grouped mode: each group (an age group, a follow-up status, a screening round) with
|
||||||
* one independent bar per category over the group's own records. A group the report leaves out is
|
* one independent bar per category over the group's own records. A group the report leaves out is
|
||||||
@@ -478,7 +500,16 @@ export function grouped(
|
|||||||
const cells = r?.strata[`${mode.stratum}-category`] ?? {};
|
const cells = r?.strata[`${mode.stratum}-category`] ?? {};
|
||||||
const found = [...new Set(Object.keys(cells).map((k) => k.split('|')[0]))];
|
const found = [...new Set(Object.keys(cells).map((k) => k.split('|')[0]))];
|
||||||
if (!patients(r) || !found.length) return undefined;
|
if (!patients(r) || !found.length) return undefined;
|
||||||
const n = (g: string, c: string) => size(cells[`${g}|${c}`]);
|
const history =
|
||||||
|
mode.stratum === 'round' ? (r?.strata['subsequent_history-category'] ?? {}) : {};
|
||||||
|
const answers = LAST_SCREENING.map(([code]) => code);
|
||||||
|
/** the cells that make up a group, with their category */
|
||||||
|
const cellsOf = (g: string): [string, Record<string, number>][] =>
|
||||||
|
Object.entries(answers.includes(g) ? history : cells)
|
||||||
|
.filter(([k]) => k.split('|')[0] === g)
|
||||||
|
.map(([k, c]) => [k.split('|')[1], c]);
|
||||||
|
const n = (g: string, c: string) =>
|
||||||
|
cellsOf(g).reduce((t, [category, cell]) => (category === c ? t + size(cell) : t), 0);
|
||||||
const reconciled = reconciles(
|
const reconciled = reconciles(
|
||||||
Object.values(cells).map((c) => c['initial-population']),
|
Object.values(cells).map((c) => c['initial-population']),
|
||||||
patients(r),
|
patients(r),
|
||||||
@@ -489,20 +520,24 @@ export function grouped(
|
|||||||
];
|
];
|
||||||
const total = (g: string) =>
|
const total = (g: string) =>
|
||||||
mode.ofAll
|
mode.ofAll
|
||||||
? Object.entries(cells)
|
? cellsOf(g).reduce((t, [, c]) => t + size(c), 0)
|
||||||
.filter(([k]) => k.split('|')[0] === g)
|
|
||||||
.reduce((t, [, c]) => t + size(c), 0)
|
|
||||||
: mode.catalog.reduce((t, c) => t + n(g, c.code), 0);
|
: mode.catalog.reduce((t, c) => t + n(g, c.code), 0);
|
||||||
const groups: Group[] = codes.map((code) => {
|
const at = codes.indexOf('subsequent');
|
||||||
|
const drawn =
|
||||||
|
mode.stratum === 'round' && at >= 0 && r?.strata['subsequent_history-category']
|
||||||
|
? [...codes.slice(0, at), ...answers, ...codes.slice(at + 1)]
|
||||||
|
: codes;
|
||||||
|
const groups: Group[] = drawn.map((code) => {
|
||||||
const den = total(code);
|
const den = total(code);
|
||||||
return {
|
return {
|
||||||
code,
|
code,
|
||||||
label:
|
label:
|
||||||
mode.stratum === 'age_group' &&
|
LAST_SCREENING.find(([answer]) => answer === code)?.[1] ??
|
||||||
|
(mode.stratum === 'age_group' &&
|
||||||
code === '<25' &&
|
code === '<25' &&
|
||||||
['CACU_EU7', 'CACU_VPH_GENOTIPO'].includes(mode.measure)
|
['CACU_EU7', 'CACU_VPH_GENOTIPO'].includes(mode.measure)
|
||||||
? '14 años y 10 meses a menos de 25 años'
|
? '15-24'
|
||||||
: name(code),
|
: name(code)),
|
||||||
total: den,
|
total: den,
|
||||||
hint: den ? undefined : `Sin ${mode.unit} en el grupo`,
|
hint: den ? undefined : `Sin ${mode.unit} en el grupo`,
|
||||||
rows: mode.catalog.flatMap((c, index) => {
|
rows: mode.catalog.flatMap((c, index) => {
|
||||||
@@ -514,6 +549,7 @@ export function grouped(
|
|||||||
count,
|
count,
|
||||||
of: den,
|
of: den,
|
||||||
percent,
|
percent,
|
||||||
|
sub: !!mode.aggregate?.codes.includes(c.code),
|
||||||
text: `${count}/${den} · ${percent === undefined ? '—' : percent.toFixed(1) + ' %'}`,
|
text: `${count}/${den} · ${percent === undefined ? '—' : percent.toFixed(1) + ' %'}`,
|
||||||
};
|
};
|
||||||
if (index !== 0 || !mode.aggregate) return [row];
|
if (index !== 0 || !mode.aggregate) return [row];
|
||||||
@@ -543,9 +579,7 @@ export function grouped(
|
|||||||
? 'Los conteos del informe no concilian con el total: los grupos ausentes no se muestran como cero.'
|
? 'Los conteos del informe no concilian con el total: los grupos ausentes no se muestran como cero.'
|
||||||
: none && unclassified
|
: none && unclassified
|
||||||
? NO_ROUND
|
? NO_ROUND
|
||||||
: unclassified && classified.some((g) => !g.total)
|
: undefined;
|
||||||
? EMPTY_ROUND
|
|
||||||
: undefined;
|
|
||||||
note = [sentence, note].filter(Boolean).join(' ') || undefined;
|
note = [sentence, note].filter(Boolean).join(' ') || undefined;
|
||||||
}
|
}
|
||||||
return { groups, note };
|
return { groups, note };
|
||||||
@@ -586,7 +620,6 @@ function complete(
|
|||||||
const classified = order.filter((c) => c !== 'no_data' && listed.includes(c));
|
const classified = order.filter((c) => c !== 'no_data' && listed.includes(c));
|
||||||
const empty = classified.filter((c) => !(counts(c)?.[1] ?? 0));
|
const empty = classified.filter((c) => !(counts(c)?.[1] ?? 0));
|
||||||
const none = empty.length === classified.length;
|
const none = empty.length === classified.length;
|
||||||
const unclassified = counts('no_data')?.[1] ?? 0;
|
|
||||||
return {
|
return {
|
||||||
head: ['n/N', percentLabel],
|
head: ['n/N', percentLabel],
|
||||||
rows,
|
rows,
|
||||||
@@ -594,10 +627,7 @@ function complete(
|
|||||||
? '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.'
|
||||||
: none && listed.includes('no_data')
|
: none && listed.includes('no_data')
|
||||||
? NO_ROUND
|
? NO_ROUND
|
||||||
: unclassified &&
|
: undefined,
|
||||||
(empty.length || order.some((c) => !listed.includes(c) && c !== 'no_data'))
|
|
||||||
? EMPTY_ROUND
|
|
||||||
: undefined,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -622,21 +652,29 @@ type Score = { score?: number; low?: number; high?: number };
|
|||||||
function medians(
|
function medians(
|
||||||
rows: { label: string; n: number; score?: Score }[],
|
rows: { label: string; n: number; score?: Score }[],
|
||||||
tint?: Tint,
|
tint?: Tint,
|
||||||
|
staggered?: boolean,
|
||||||
): Bars | undefined {
|
): Bars | undefined {
|
||||||
if (!rows.some((r) => r.score?.score !== undefined)) return undefined;
|
if (!rows.some((r) => r.score?.score !== undefined)) return undefined;
|
||||||
const top = Math.max(...rows.flatMap((r) => [r.score?.score ?? 0, r.score?.high ?? 0])) || 1;
|
const starts = staggered
|
||||||
|
? chainStarts(rows.map((r) => ({ median: r.score?.score })))
|
||||||
|
: rows.map(() => 0);
|
||||||
|
const ends = rows.map(
|
||||||
|
(r, i) => starts[i] + Math.max(r.score?.score ?? 0, r.score?.high ?? 0),
|
||||||
|
);
|
||||||
|
const top = Math.max(...ends) || 1;
|
||||||
const at = (v: number) => (100 * v) / top;
|
const at = (v: number) => (100 * v) / top;
|
||||||
return {
|
return {
|
||||||
head: ['Mediana', 'Observaciones', '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 }, i) => {
|
||||||
if (s?.score === undefined) return { label, width: 0, marks: [], cells: ['—', `${n}`, '—'] };
|
if (s?.score === undefined) return { label, width: 0, marks: [], cells: ['—', `${n}`, '—'] };
|
||||||
const spread = s.low !== undefined && s.high !== undefined ? [s.low, s.high] : [];
|
const spread = s.low !== undefined && s.high !== undefined ? [s.low, s.high] : [];
|
||||||
return {
|
return {
|
||||||
label,
|
label,
|
||||||
color: tint?.bar,
|
color: tint?.bar,
|
||||||
|
offset: staggered ? at(starts[i]) : undefined,
|
||||||
width: at(s.score),
|
width: at(s.score),
|
||||||
marks: spread.map(at),
|
marks: spread.map((v) => at(starts[i] + v)),
|
||||||
cells: [`${days(s.score)} días`, `${n}`, spread.map(days).join('–') || '—'],
|
cells: [`${days(s.score)} días`, `${n}`, spread.map(days).join('–') || '—'],
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ export const CYTOLOGY_COLORS: Record<string, string> = {
|
|||||||
'ASC-US': '#2778B8',
|
'ASC-US': '#2778B8',
|
||||||
LSIL: '#B19525',
|
LSIL: '#B19525',
|
||||||
'ASC-H': '#7955B1',
|
'ASC-H': '#7955B1',
|
||||||
|
CIN2: '#E07A9C',
|
||||||
HSIL: '#CE4778',
|
HSIL: '#CE4778',
|
||||||
|
CIN3: '#BC4163',
|
||||||
CIS: '#AA394D',
|
CIS: '#AA394D',
|
||||||
no_data: NEUTRAL,
|
no_data: NEUTRAL,
|
||||||
};
|
};
|
||||||
@@ -43,7 +45,9 @@ export const HPV_COLORS: Record<string, string> = {
|
|||||||
export const BIOPSY_COLORS: Record<string, string> = {
|
export const BIOPSY_COLORS: Record<string, string> = {
|
||||||
normal: '#408651',
|
normal: '#408651',
|
||||||
LSIL: '#B19525',
|
LSIL: '#B19525',
|
||||||
|
CIN2: '#E07A9C',
|
||||||
HSIL: '#CE4778',
|
HSIL: '#CE4778',
|
||||||
|
CIN3: '#BC4163',
|
||||||
CIS: '#AA394D',
|
CIS: '#AA394D',
|
||||||
carcinoma: '#8D4C79',
|
carcinoma: '#8D4C79',
|
||||||
cin1_plus: '#B19525',
|
cin1_plus: '#B19525',
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { HISTORY, PAGES } from './pages';
|
||||||
|
|
||||||
|
describe('tiempo de diagnóstico tras biopsia a tratamiento en CaMa', () => {
|
||||||
|
it('conecta la tarjeta y el histórico con la medida', () => {
|
||||||
|
const measure = 'CAMA_DIAS_DIAGNOSTICO_TRATAMIENTO';
|
||||||
|
expect(PAGES['cama'].kpis.some((card) => card.measure === measure)).toBe(true);
|
||||||
|
expect(HISTORY['cama'].panels.some((panel) => panel.measure === measure)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { durationMax, durationRows } from './durations';
|
import { chainStarts, durationMax, durationRows } from './durations';
|
||||||
import { Reading } from './measures';
|
import { Reading } from './measures';
|
||||||
|
|
||||||
const reading = (score?: number, n = 0, low?: number, high?: number): Reading => ({
|
const reading = (score?: number, n = 0, low?: number, high?: number): Reading => ({
|
||||||
@@ -53,3 +53,10 @@ describe('durationRows', () => {
|
|||||||
expect(durationMax([])).toBe(0);
|
expect(durationMax([])).toBe(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('chainStarts', () => {
|
||||||
|
it('starts each step where the one it follows ends, two of them sharing a start', () => {
|
||||||
|
expect(chainStarts([{ median: 4 }, { median: 6 }, { median: 2, after: 0 }])).toEqual([0, 4, 4]);
|
||||||
|
expect(chainStarts([{ median: 4 }, {}, { median: 2 }])).toEqual([0, 4, 4]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import { Reading } from './measures';
|
|||||||
export interface RouteStep {
|
export interface RouteStep {
|
||||||
label: string;
|
label: string;
|
||||||
measure?: string;
|
measure?: string;
|
||||||
|
/** the step (its position) this one starts after; the previous one by default */
|
||||||
|
after?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** One row of a duration table: the median days, how many measurements and the quartiles.
|
/** One row of a duration table: the median days, how many measurements and the quartiles.
|
||||||
@@ -17,6 +19,25 @@ export interface DurationRow {
|
|||||||
observations?: number;
|
observations?: number;
|
||||||
low?: number;
|
low?: number;
|
||||||
high?: number;
|
high?: number;
|
||||||
|
after?: number;
|
||||||
|
/** where its bar starts, in days, when the steps are chained */
|
||||||
|
start?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Where each step's bar starts when drawn as a schematic sequence (a Gantt chart): where the
|
||||||
|
* step it follows ends. A step without a median moves nothing after it. */
|
||||||
|
export function chainStarts(steps: { median?: number; after?: number }[]): number[] {
|
||||||
|
const starts: number[] = [];
|
||||||
|
steps.forEach(({ after }, i) => {
|
||||||
|
const j = after ?? i - 1;
|
||||||
|
starts.push(j < 0 ? 0 : starts[j] + (steps[j].median ?? 0));
|
||||||
|
});
|
||||||
|
return starts;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function chained(rows: DurationRow[]): DurationRow[] {
|
||||||
|
const starts = chainStarts(rows);
|
||||||
|
return rows.map((row, i) => ({ ...row, start: starts[i] }));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The rows of a route in one reading; every step keeps its row. `published` says which
|
/** The rows of a route in one reading; every step keeps its row. `published` says which
|
||||||
@@ -26,12 +47,13 @@ export function durationRows(
|
|||||||
read: (measure: string) => Reading | undefined,
|
read: (measure: string) => Reading | undefined,
|
||||||
published: (measure: string) => boolean,
|
published: (measure: string) => boolean,
|
||||||
): DurationRow[] {
|
): DurationRow[] {
|
||||||
return steps.map(({ label, measure }) => {
|
return steps.map(({ label, measure, after }) => {
|
||||||
if (!measure || !published(measure)) return { label, status: 'unpublished' };
|
if (!measure || !published(measure)) return { label, after, status: 'unpublished' };
|
||||||
const r = read(measure);
|
const r = read(measure);
|
||||||
if (r?.score === undefined) return { label, status: 'empty' };
|
if (r?.score === undefined) return { label, after, status: 'empty' };
|
||||||
return {
|
return {
|
||||||
label,
|
label,
|
||||||
|
after,
|
||||||
status: 'value',
|
status: 'value',
|
||||||
median: r.score,
|
median: r.score,
|
||||||
observations: r.populations['measure-observation'],
|
observations: r.populations['measure-observation'],
|
||||||
@@ -41,6 +63,6 @@ export function durationRows(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The scale of a table of durations, from zero: the largest median or third quartile shown. */
|
/** The scale of a table of durations, from zero: the farthest median or third quartile shown. */
|
||||||
export const durationMax = (rows: DurationRow[]): number =>
|
export const durationMax = (rows: DurationRow[]): number =>
|
||||||
Math.max(0, ...rows.map((r) => Math.max(r.median ?? 0, r.high ?? 0)));
|
Math.max(0, ...rows.map((r) => (r.start ?? 0) + Math.max(r.median ?? 0, r.high ?? 0)));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { RiskAssessment } from 'fhir/r4';
|
import type { RiskAssessment } from 'fhir/r4';
|
||||||
import { ageGroup, currentRisk, windowStart, ageAt, bornFor } from './follow-up';
|
import { ageGroup, currentRisk, windowStart, ageAt, bornFor } from './follow-up';
|
||||||
import { periods } from './measures';
|
import { historyPeriods, periods } from './measures';
|
||||||
|
|
||||||
describe('follow-up list', () => {
|
describe('follow-up list', () => {
|
||||||
it('starts the window the day after the same day months before (core.follow_up)', () => {
|
it('starts the window the day after the same day months before (core.follow_up)', () => {
|
||||||
@@ -36,6 +36,16 @@ describe('follow-up list', () => {
|
|||||||
expect(currentRisk(risks, 'cin2', 3)).toBeUndefined();
|
expect(currentRisk(risks, 'cin2', 3)).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('ends history at the selected complete period for months and semesters', () => {
|
||||||
|
const monthly = historyPeriods('month', '2025-03');
|
||||||
|
expect(monthly.slice(-3)).toEqual(['2025-01', '2025-02', '2025-03']);
|
||||||
|
expect(monthly).toHaveLength(72);
|
||||||
|
const firstSemester = historyPeriods('semester', '2025-S1');
|
||||||
|
expect(firstSemester.slice(-3)).toEqual(['2024-S1', '2024-S2', '2025-S1']);
|
||||||
|
const secondSemester = historyPeriods('semester', '2025-S2');
|
||||||
|
expect(secondSemester.slice(-2)).toEqual(['2025-S1', '2025-S2']);
|
||||||
|
});
|
||||||
|
|
||||||
it('lists periods most recent first', () => {
|
it('lists periods most recent first', () => {
|
||||||
expect(periods('semester', 1, new Date(2026, 10, 25))).toEqual(['2026-S2', '2026-S1']);
|
expect(periods('semester', 1, new Date(2026, 10, 25))).toEqual(['2026-S2', '2026-S1']);
|
||||||
expect(periods('month', 1, new Date(2026, 1, 3)).slice(0, 3)).toEqual([
|
expect(periods('month', 1, new Date(2026, 1, 3)).slice(0, 3)).toEqual([
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ export const LAYOUTS: Record<string, Layout> = {
|
|||||||
'CAMA_EU38A',
|
'CAMA_EU38A',
|
||||||
'CAMA_DIAS_TOMA_DIAGNOSTICO',
|
'CAMA_DIAS_TOMA_DIAGNOSTICO',
|
||||||
'CAMA_CONFIRMACION_BIRADS45',
|
'CAMA_CONFIRMACION_BIRADS45',
|
||||||
'CAMA_TASA_DETECCION_HISTOPATOLOGICA',
|
|
||||||
],
|
],
|
||||||
route: [
|
route: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,6 +23,13 @@ export function periods(type: PeriodType, years = 6, today = new Date()): string
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Historical periods ending in the selected month or semester, oldest first. */
|
||||||
|
export function historyPeriods(type: PeriodType, selected: string): string[] {
|
||||||
|
const [year, part] = selected.split('-');
|
||||||
|
const month = type === 'semester' ? (part === 'S1' ? 0 : 6) : Number(part) - 1;
|
||||||
|
return periods(type, 6, new Date(Number(year), month, 1)).reverse();
|
||||||
|
}
|
||||||
|
|
||||||
export function periodLabel(period: string): string {
|
export function periodLabel(period: string): string {
|
||||||
const [year, part] = period.split('-');
|
const [year, part] = period.split('-');
|
||||||
if (part.startsWith('S')) return `${part === 'S1' ? 'Ene–Jun' : 'Jul–Dic'} ${year}`;
|
if (part.startsWith('S')) return `${part === 'S1' ? 'Ene–Jun' : 'Jul–Dic'} ${year}`;
|
||||||
@@ -103,6 +110,8 @@ export const LABELS: Record<string, string> = {
|
|||||||
NILM: 'Normal (NILM)',
|
NILM: 'Normal (NILM)',
|
||||||
LSIL: 'LIEBG',
|
LSIL: 'LIEBG',
|
||||||
HSIL: 'LIEAG',
|
HSIL: 'LIEAG',
|
||||||
|
CIN2: 'CIN 2',
|
||||||
|
CIN3: 'CIN 3',
|
||||||
normal: 'Normal',
|
normal: 'Normal',
|
||||||
carcinoma: 'Carcinoma',
|
carcinoma: 'Carcinoma',
|
||||||
no_data: 'Sin dato',
|
no_data: 'Sin dato',
|
||||||
@@ -135,7 +144,7 @@ export const LABELS: Record<string, string> = {
|
|||||||
bad: 'Malo',
|
bad: 'Malo',
|
||||||
not_analyzed: 'Sin analizar',
|
not_analyzed: 'Sin analizar',
|
||||||
initial: 'Detección inicial',
|
initial: 'Detección inicial',
|
||||||
subsequent: 'Detección subsecuente',
|
subsequent: 'Con detección anterior',
|
||||||
positive: 'Positivo',
|
positive: 'Positivo',
|
||||||
negative: 'Negativo',
|
negative: 'Negativo',
|
||||||
hpv_16: 'VPH 16',
|
hpv_16: 'VPH 16',
|
||||||
@@ -154,6 +163,21 @@ export const LABELS: Record<string, string> = {
|
|||||||
['0', '1', '2', '3', '4', '4A', '4B', '4C', '5', '6'].map((c) => [c, `BI-RADS ${c}`]),
|
['0', '1', '2', '3', '4', '4A', '4B', '4C', '5', '6'].map((c) => [c, `BI-RADS ${c}`]),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
/** Breast histologic types (ICD-O-3 morphology); a code not listed is shown as it is. */
|
||||||
|
const HISTOLOGIC_TYPES: Record<string, string> = {
|
||||||
|
'8500/2': 'Carcinoma ductal in situ',
|
||||||
|
'8500/3': 'Carcinoma ductal infiltrante',
|
||||||
|
'8520/2': 'Carcinoma lobulillar in situ',
|
||||||
|
'8520/3': 'Carcinoma lobulillar infiltrante',
|
||||||
|
'8522/3': 'Carcinoma ductal y lobulillar infiltrante',
|
||||||
|
'8480/3': 'Adenocarcinoma mucinoso',
|
||||||
|
'8211/3': 'Carcinoma tubular',
|
||||||
|
'8510/3': 'Carcinoma medular',
|
||||||
|
'8530/3': 'Carcinoma inflamatorio',
|
||||||
|
'8540/3': 'Enfermedad de Paget de la mama',
|
||||||
|
'9010/0': 'Fibroadenoma',
|
||||||
|
'9016/0': 'Fibroadenoma gigante',
|
||||||
|
};
|
||||||
/** A follow-up priority's label. */
|
/** A follow-up priority's label. */
|
||||||
export const PRIORITY: Record<string, string> = { high: 'Alta', medium: 'Media', low: 'Baja' };
|
export const PRIORITY: Record<string, string> = { high: 'Alta', medium: 'Media', low: 'Baja' };
|
||||||
export const STRATA: Record<string, string> = {
|
export const STRATA: Record<string, string> = {
|
||||||
@@ -166,11 +190,11 @@ export const STRATA: Record<string, string> = {
|
|||||||
cytology: 'Citología previa',
|
cytology: 'Citología previa',
|
||||||
hpv: 'VPH de la citología previa',
|
hpv: 'VPH de la citología previa',
|
||||||
level: 'Histología confirmada',
|
level: 'Histología confirmada',
|
||||||
round: 'Tamizaje inicial o subsecuente',
|
round: 'Detección inicial o anterior',
|
||||||
hpv_16: 'VPH 16',
|
hpv_16: 'VPH 16',
|
||||||
hpv_18: 'VPH 18',
|
hpv_18: 'VPH 18',
|
||||||
};
|
};
|
||||||
export const name = (value: string) => LABELS[value] ?? value;
|
export const name = (value: string) => LABELS[value] ?? HISTOLOGIC_TYPES[value] ?? value;
|
||||||
|
|
||||||
export function formatScore(measure: Measure, r: Reading | undefined): string {
|
export function formatScore(measure: Measure, r: Reading | undefined): string {
|
||||||
if (!r || r.score === undefined) return 'Sin dato';
|
if (!r || r.score === undefined) return 'Sin dato';
|
||||||
|
|||||||
@@ -47,7 +47,9 @@ const BIOPSY: Catalog = {
|
|||||||
categories: [
|
categories: [
|
||||||
{ code: 'normal', label: 'Normal', color: BIOPSY_COLORS['normal'], group: 'low' },
|
{ code: 'normal', label: 'Normal', color: BIOPSY_COLORS['normal'], group: 'low' },
|
||||||
{ code: 'LSIL', label: 'LIEBG (CIN 1)', color: BIOPSY_COLORS['LSIL'], group: 'low' },
|
{ code: 'LSIL', label: 'LIEBG (CIN 1)', color: BIOPSY_COLORS['LSIL'], group: 'low' },
|
||||||
|
{ code: 'CIN2', label: 'CIN 2', color: BIOPSY_COLORS['CIN2'], group: 'high' },
|
||||||
{ code: 'HSIL', label: 'LIEAG (CIN 2 y 3)', color: BIOPSY_COLORS['HSIL'], group: 'high' },
|
{ code: 'HSIL', label: 'LIEAG (CIN 2 y 3)', color: BIOPSY_COLORS['HSIL'], group: 'high' },
|
||||||
|
{ code: 'CIN3', label: 'CIN 3', color: BIOPSY_COLORS['CIN3'], group: 'high' },
|
||||||
{ code: 'CIS', label: 'Carcinoma in situ', color: BIOPSY_COLORS['CIS'], group: 'high' },
|
{ code: 'CIS', label: 'Carcinoma in situ', color: BIOPSY_COLORS['CIS'], group: 'high' },
|
||||||
{
|
{
|
||||||
code: 'carcinoma',
|
code: 'carcinoma',
|
||||||
@@ -74,13 +76,13 @@ const TINT = { bar: DURATION, mark: QUARTILE };
|
|||||||
const ROUNDS = ['initial', 'subsequent', 'no_data'];
|
const ROUNDS = ['initial', 'subsequent', 'no_data'];
|
||||||
const ROUND_CAPTION =
|
const ROUND_CAPTION =
|
||||||
'Cada paciente está en un solo grupo, según su muestra (fecha de toma): detección inicial (primera vez en la vida), ' +
|
'Cada paciente está en un solo grupo, según su muestra (fecha de toma): detección inicial (primera vez en la vida), ' +
|
||||||
'subsecuente (detección previa registrada, o ya con colposcopía o tratamiento) o «Sin dato». ' +
|
'con detección anterior (registrada, o ya con colposcopía o tratamiento) o «Sin dato». ' +
|
||||||
'Un grupo sin pacientes se muestra en cero; sin porcentaje.';
|
'Un grupo sin pacientes se muestra en cero; sin porcentaje.';
|
||||||
|
|
||||||
/** The views the cytology and HPV-by-genotype cards share (one selector for both). */
|
/** The views the cytology and HPV-by-genotype cards share (one selector for both). */
|
||||||
const GENERAL = 'General';
|
const GENERAL = 'General';
|
||||||
const BY_AGE = 'Por grupo de edad';
|
const BY_AGE = 'Por grupo de edad';
|
||||||
const BY_ROUND = 'Por detección inicial y subsecuente';
|
const BY_ROUND = 'Por detección inicial y anterior';
|
||||||
const AGE_GROUPS = ['<25', '25-34', '35-44', '45-54', '55-64', '65+', 'no_data'];
|
const AGE_GROUPS = ['<25', '25-34', '35-44', '45-54', '55-64', '65+', 'no_data'];
|
||||||
/** HPV categories the cards do not draw (their reports stay in the total and the percentages). */
|
/** HPV categories the cards do not draw (their reports stay in the total and the percentages). */
|
||||||
const HPV_HIDDEN = {
|
const HPV_HIDDEN = {
|
||||||
@@ -156,7 +158,7 @@ const ppv = (
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
kind: 'shares',
|
kind: 'shares',
|
||||||
label: 'Por detección inicial y subsecuente',
|
label: 'Por detección inicial y anterior',
|
||||||
caption: ROUND_CAPTION,
|
caption: ROUND_CAPTION,
|
||||||
measure,
|
measure,
|
||||||
stratum: 'round',
|
stratum: 'round',
|
||||||
@@ -199,7 +201,7 @@ export const CACU: Page = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
measure: 'CACU_DIAS_DIAGNOSTICO_TRATAMIENTO',
|
measure: 'CACU_DIAS_DIAGNOSTICO_TRATAMIENTO',
|
||||||
title: 'Tiempo de diagnóstico a tratamiento',
|
title: 'Tiempo de diagnóstico tras biopsia a tratamiento',
|
||||||
...CACU_DAYS,
|
...CACU_DAYS,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -227,7 +229,9 @@ export const CACU: Page = {
|
|||||||
kind: 'days',
|
kind: 'days',
|
||||||
tint: TINT,
|
tint: TINT,
|
||||||
label: 'Por ventana de tiempo',
|
label: 'Por ventana de tiempo',
|
||||||
caption: 'Cada paso mide a sus propias pacientes: las medianas no se suman.',
|
staggered: true,
|
||||||
|
caption:
|
||||||
|
'Esquema: cada barra empieza donde termina la anterior. Cada paso mide a sus propias pacientes: las medianas no se suman.',
|
||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
label: 'Toma a resultado de citología',
|
label: 'Toma a resultado de citología',
|
||||||
|
|||||||
@@ -249,7 +249,14 @@ export const PAGES: Record<string, Page> = {
|
|||||||
},
|
},
|
||||||
cama: {
|
cama: {
|
||||||
anchor: 'CAMA_BIRADS456_PACIENTE',
|
anchor: 'CAMA_BIRADS456_PACIENTE',
|
||||||
|
// every single-number card, together at the start, in the order asked for
|
||||||
kpis: [
|
kpis: [
|
||||||
|
{
|
||||||
|
measure: 'CAMA_BIRADS456_PACIENTE',
|
||||||
|
title: 'Pacientes evaluadas con BI-RADS 4, 5 o 6',
|
||||||
|
value: '{n} pacientes',
|
||||||
|
note: 'Pacientes con mastografía BI-RADS 4, 5 o 6 en el periodo.',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
measure: 'CAMA_EU38A',
|
measure: 'CAMA_EU38A',
|
||||||
title: 'Tiempo de toma de mastografía a interpretación radiológica',
|
title: 'Tiempo de toma de mastografía a interpretación radiológica',
|
||||||
@@ -261,22 +268,25 @@ export const PAGES: Record<string, Page> = {
|
|||||||
...CAMA_DAYS,
|
...CAMA_DAYS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
measure: 'CAMA_BIRADS456_PACIENTE',
|
measure: 'CAMA_DIAS_RESULTADO_BIOPSIA',
|
||||||
title: 'Pacientes evaluadas con BI-RADS 4, 5 o 6',
|
title: 'Tiempo de interpretación radiológica a resultado de biopsia',
|
||||||
value: '{n} pacientes',
|
...CAMA_DAYS,
|
||||||
note: 'Pacientes con mastografía BI-RADS 4, 5 o 6 en el periodo.',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
measure: 'CAMA_TASA_DETECCION_HISTOPATOLOGICA',
|
measure: 'CAMA_DIAS_DIAGNOSTICO_TRATAMIENTO',
|
||||||
title: 'Tasa de detección histopatológica',
|
title: 'Tiempo de diagnóstico tras biopsia a tratamiento',
|
||||||
value: '{pct} %',
|
...CAMA_DAYS,
|
||||||
note: '{num} de {den} biopsias con grado conocido presentan carcinoma (in situ o invasor).',
|
},
|
||||||
|
{
|
||||||
|
measure: 'CAMA_DIAS_TOMA_DIAGNOSTICO',
|
||||||
|
title: 'Tiempo de tamizaje a diagnóstico',
|
||||||
|
...CAMA_DAYS,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
opportunity: [
|
opportunity: [
|
||||||
{
|
{
|
||||||
kind: 'route',
|
kind: 'route',
|
||||||
title: 'Tiempo de tamizaje a diagnóstico',
|
title: 'Tiempo de tamizaje a diagnóstico y tratamiento',
|
||||||
// from the mammography: only the two measures that start at it
|
// from the mammography: only the two measures that start at it
|
||||||
sample: [
|
sample: [
|
||||||
{ label: 'Interpretación radiológica', measure: 'CAMA_EU38A' },
|
{ label: 'Interpretación radiológica', measure: 'CAMA_EU38A' },
|
||||||
@@ -291,9 +301,15 @@ export const PAGES: Record<string, Page> = {
|
|||||||
label: 'Interpretación radiológica a diagnóstico',
|
label: 'Interpretación radiológica a diagnóstico',
|
||||||
measure: 'CAMA_DIAS_RESULTADO_DIAGNOSTICO',
|
measure: 'CAMA_DIAS_RESULTADO_DIAGNOSTICO',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Diagnóstico tras biopsia a tratamiento',
|
||||||
|
measure: 'CAMA_DIAS_DIAGNOSTICO_TRATAMIENTO',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Interpretación radiológica a resultado de biopsia',
|
label: 'Interpretación radiológica a resultado de biopsia',
|
||||||
measure: 'CAMA_DIAS_RESULTADO_BIOPSIA',
|
measure: 'CAMA_DIAS_RESULTADO_BIOPSIA',
|
||||||
|
// from the interpretation, as the diagnosis: not after it
|
||||||
|
after: 0,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -320,26 +336,28 @@ export const PAGES: Record<string, Page> = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
kind: 'readings',
|
kind: 'readings',
|
||||||
title: 'Resultado histopatológico por categoría BI-RADS',
|
title: 'Tipo histológico por categoría BI-RADS',
|
||||||
note: 'Pacientes: su mastografía BI-RADS 4, 5 o 6 más grave y su biopsia más grave reportada, por fecha del examen. El porcentaje maligno se calcula solo sobre las pacientes con biopsia con grado.',
|
note: 'Pacientes: su mastografía BI-RADS 4, 5 o 6 más grave y su biopsia más grave reportada, por fecha del examen. Los tipos siguen la clasificación CIE-O-3; «Sin dato» incluye tipos ausentes o con vínculo ambiguo. El porcentaje maligno conserva la clasificación de la biopsia y su denominador de pacientes con clasificación conocida.',
|
||||||
modes: [
|
modes: [
|
||||||
{
|
{
|
||||||
kind: 'outcomes',
|
kind: 'outcomes',
|
||||||
label: 'Por categoría BI-RADS',
|
label: 'Por categoría BI-RADS',
|
||||||
heading: 'Resultados por paciente',
|
heading: 'Resultados por paciente',
|
||||||
caption: NO_BIOPSY_MEANS,
|
caption: NO_BIOPSY_MEANS,
|
||||||
measure: 'CAMA_HISTOPATOLOGIA_BIRADS',
|
measure: 'CAMA_TIPO_HISTOLOGICO_BIRADS',
|
||||||
stratum: 'birads',
|
stratum: 'birads',
|
||||||
rows: BIRADS.categories,
|
rows: BIRADS.categories,
|
||||||
results: [...BIOPSY_GRADES, ...NO_RESULT],
|
results: NO_RESULT,
|
||||||
malignant: ['in_situ', 'invasive'],
|
malignant: ['in_situ', 'invasive'],
|
||||||
|
dynamicResults: true,
|
||||||
|
malignancyMeasure: 'CAMA_HISTOPATOLOGIA_BIRADS',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kind: 'counts',
|
kind: 'counts',
|
||||||
label: 'Todas las categorías',
|
label: 'Todas las categorías',
|
||||||
heading: 'Resultados por paciente',
|
heading: 'Resultados por paciente',
|
||||||
measure: 'CAMA_HISTOPATOLOGIA_BIRADS',
|
measure: 'CAMA_TIPO_HISTOLOGICO_BIRADS',
|
||||||
catalog: [...BIOPSY_GRADES, ...NO_RESULT],
|
catalog: [],
|
||||||
unit: 'Pacientes',
|
unit: 'Pacientes',
|
||||||
percent: true,
|
percent: true,
|
||||||
percentLabel: 'Porcentaje de pacientes',
|
percentLabel: 'Porcentaje de pacientes',
|
||||||
@@ -352,20 +370,19 @@ export const PAGES: Record<string, Page> = {
|
|||||||
card: true,
|
card: true,
|
||||||
choices: [
|
choices: [
|
||||||
{
|
{
|
||||||
label: 'Resultado de biopsias',
|
label: 'Tipos histológicos',
|
||||||
section: {
|
section: {
|
||||||
kind: 'readings',
|
kind: 'readings',
|
||||||
title: 'Resultado de biopsias',
|
title: 'Tipos histológicos',
|
||||||
headline: 'CAMA_TASA_DETECCION_HISTOPATOLOGICA',
|
|
||||||
unit: 'biopsias',
|
unit: 'biopsias',
|
||||||
note: 'Biopsias con resultado reportado, por fecha del reporte (no son pacientes ni mastografías). La tasa divide los carcinomas (in situ o invasor) entre biopsias con grado conocido. Los porcentajes de la distribución incluyen todas las biopsias reportadas, también «Sin dato» (sin grado), por lo que sus denominadores pueden ser distintos.',
|
note: 'Biopsias por fecha de reporte, agrupadas por tipo histológico (CIE-O-3). «Sin dato» incluye los tipos ausentes y los que no pueden vincularse de forma inequívoca. La tasa de detección conserva su cálculo de carcinomas entre biopsias con clasificación conocida; su denominador puede ser distinto.',
|
||||||
modes: [
|
modes: [
|
||||||
{
|
{
|
||||||
kind: 'counts',
|
kind: 'counts',
|
||||||
label: 'Biopsias reportadas',
|
label: 'Tipos histológicos',
|
||||||
heading: 'Biopsias reportadas',
|
heading: 'Tipo histológico',
|
||||||
measure: 'CAMA_BIOPSIAS',
|
measure: 'CAMA_TIPO_HISTOLOGICO',
|
||||||
catalog: [...BIOPSY_GRADES, NO_RESULT[1]],
|
catalog: [],
|
||||||
unit: 'Biopsias',
|
unit: 'Biopsias',
|
||||||
percent: true,
|
percent: true,
|
||||||
percentLabel: 'Porcentaje de reportes de biopsia',
|
percentLabel: 'Porcentaje de reportes de biopsia',
|
||||||
@@ -380,7 +397,7 @@ export const PAGES: Record<string, Page> = {
|
|||||||
title: 'Mastografías con biopsia',
|
title: 'Mastografías con biopsia',
|
||||||
headline: 'CAMA_CONFIRMACION_BIRADS45',
|
headline: 'CAMA_CONFIRMACION_BIRADS45',
|
||||||
unit: 'mastografías',
|
unit: 'mastografías',
|
||||||
note: 'Mastografías BI-RADS 4, 4A, 4B, 4C o 5 con reporte, por fecha del examen: cuántas tienen un reporte de biopsia. Mide el seguimiento, no el resultado de la biopsia; no es equivalente a la tasa de detección.',
|
note: 'Mastografías BI-RADS 4, 4A, 4B, 4C o 5 con reporte, por fecha del examen: cuántas tienen un reporte de biopsia. Mide el seguimiento, no el resultado de la biopsia.',
|
||||||
modes: [
|
modes: [
|
||||||
{
|
{
|
||||||
kind: 'split',
|
kind: 'split',
|
||||||
@@ -468,7 +485,9 @@ export const HISTORY: Record<string, History> = {
|
|||||||
[
|
[
|
||||||
['normal', 'Normal', '#9DBFE3'],
|
['normal', 'Normal', '#9DBFE3'],
|
||||||
['LSIL', 'LIEBG (CIN 1)', '#69C242'],
|
['LSIL', 'LIEBG (CIN 1)', '#69C242'],
|
||||||
|
['CIN2', 'CIN 2', '#E07A9C'],
|
||||||
['HSIL', 'LIEAG (CIN 2 y 3)', '#C24269'],
|
['HSIL', 'LIEAG (CIN 2 y 3)', '#C24269'],
|
||||||
|
['CIN3', 'CIN 3', '#A8325A'],
|
||||||
['CIS', 'Carcinoma in situ', '#9C42C2'],
|
['CIS', 'Carcinoma in situ', '#9C42C2'],
|
||||||
['carcinoma', 'Carcinoma invasor', '#5C42C2'],
|
['carcinoma', 'Carcinoma invasor', '#5C42C2'],
|
||||||
['no_biopsy', 'Sin biopsia aún', GREY],
|
['no_biopsy', 'Sin biopsia aún', GREY],
|
||||||
@@ -496,7 +515,7 @@ export const HISTORY: Record<string, History> = {
|
|||||||
kind: 'median',
|
kind: 'median',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Tiempo de diagnóstico a tratamiento',
|
title: 'Tiempo de diagnóstico tras biopsia a tratamiento',
|
||||||
measure: 'CACU_DIAS_DIAGNOSTICO_TRATAMIENTO',
|
measure: 'CACU_DIAS_DIAGNOSTICO_TRATAMIENTO',
|
||||||
kind: 'median',
|
kind: 'median',
|
||||||
},
|
},
|
||||||
@@ -511,6 +530,7 @@ export const HISTORY: Record<string, History> = {
|
|||||||
cama: {
|
cama: {
|
||||||
line: '#9C42C2',
|
line: '#9C42C2',
|
||||||
panels: [
|
panels: [
|
||||||
|
{ title: 'Tiempo de diagnóstico tras biopsia a tratamiento', measure: 'CAMA_DIAS_DIAGNOSTICO_TRATAMIENTO', kind: 'median' },
|
||||||
{
|
{
|
||||||
title: 'Días de la toma de la mastografía a su resultado',
|
title: 'Días de la toma de la mastografía a su resultado',
|
||||||
measure: 'CAMA_EU38A',
|
measure: 'CAMA_EU38A',
|
||||||
@@ -526,6 +546,7 @@ export const HISTORY: Record<string, History> = {
|
|||||||
measure: 'CAMA_DIAS_TOMA_DIAGNOSTICO',
|
measure: 'CAMA_DIAS_TOMA_DIAGNOSTICO',
|
||||||
kind: 'median',
|
kind: 'median',
|
||||||
},
|
},
|
||||||
|
{ title: 'Tasa de detección histopatológica', measure: 'CAMA_TASA_DETECCION_HISTOPATOLOGICA', kind: 'percent' },
|
||||||
stack(
|
stack(
|
||||||
'Porcentaje de mastografías con resultado BI-RADS 4, 5 ó 6',
|
'Porcentaje de mastografías con resultado BI-RADS 4, 5 ó 6',
|
||||||
'CAMA_BIRADS456_MASTOGRAFIA',
|
'CAMA_BIRADS456_MASTOGRAFIA',
|
||||||
@@ -546,7 +567,7 @@ export const HISTORY: Record<string, History> = {
|
|||||||
['no_data', 'Sin dato', GREY],
|
['no_data', 'Sin dato', GREY],
|
||||||
]),
|
]),
|
||||||
{
|
{
|
||||||
title: 'Tasa de confirmación histopatológica',
|
title: 'Confirmación histopatológica',
|
||||||
measure: 'CAMA_CONFIRMACION_BIRADS45',
|
measure: 'CAMA_CONFIRMACION_BIRADS45',
|
||||||
kind: 'percent',
|
kind: 'percent',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Component, computed, input, signal } from '@angular/core';
|
|||||||
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
||||||
import { Loading } from '../loading';
|
import { Loading } from '../loading';
|
||||||
import { Figure, Plot } from '../plot';
|
import { Figure, Plot } from '../plot';
|
||||||
import { bars, grouped, hiddenNote, Mode, subsequentHistory, unavailable } from './bars';
|
import { bars, grouped, hiddenNote, Mode, unavailable } from './bars';
|
||||||
import { Reading } from './measures';
|
import { Reading } from './measures';
|
||||||
|
|
||||||
/** A card read one mode at a time: its title, its headline, the toggle and the bars. */
|
/** A card read one mode at a time: its title, its headline, the toggle and the bars. */
|
||||||
@@ -60,7 +60,7 @@ import { Reading } from './measures';
|
|||||||
}
|
}
|
||||||
</h4>
|
</h4>
|
||||||
@for (row of group.rows; track row.label) {
|
@for (row of group.rows; track row.label) {
|
||||||
<div class="row" [attr.data-category]="row.label">
|
<div class="row" [class.sub]="row.sub" [attr.data-category]="row.label">
|
||||||
<span class="name">{{ row.label }}</span>
|
<span class="name">{{ row.label }}</span>
|
||||||
<span class="track" aria-hidden="true">
|
<span class="track" aria-hidden="true">
|
||||||
<span
|
<span
|
||||||
@@ -77,21 +77,6 @@ import { Reading } from './measures';
|
|||||||
@if (g.note) {
|
@if (g.note) {
|
||||||
<p class="state">{{ g.note }}</p>
|
<p class="state">{{ g.note }}</p>
|
||||||
}
|
}
|
||||||
@if (historyBreakdown(); as history) {
|
|
||||||
<section aria-label="Antecedente declarado en detección subsecuente">
|
|
||||||
<h4>Dentro de detección subsecuente: antecedente declarado</h4>
|
|
||||||
<p class="state">
|
|
||||||
Las categorías son respuestas del formulario; el denominador es el total de la ronda
|
|
||||||
subsecuente. La diferencia incluye valores no registrados o primera vez declarada con
|
|
||||||
procedimientos previos.
|
|
||||||
</p>
|
|
||||||
<ul>
|
|
||||||
@for (item of history; track item.label) {
|
|
||||||
<li>{{ item.label }}: {{ item.text }}</li>
|
|
||||||
}
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
}
|
|
||||||
} @else if (figure(); as f) {
|
} @else if (figure(); as f) {
|
||||||
<app-plot [figure]="f" [height]="height()" />
|
<app-plot [figure]="f" [height]="height()" />
|
||||||
@if (hidden(); as why) {
|
@if (hidden(); as why) {
|
||||||
@@ -109,7 +94,7 @@ import { Reading } from './measures';
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@for (row of t.rows; track row.label) {
|
@for (row of t.rows; track row.label) {
|
||||||
<tr>
|
<tr [class.sub]="row.sub">
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
{{ row.label }}
|
{{ row.label }}
|
||||||
@if (row.hint) {
|
@if (row.hint) {
|
||||||
@@ -131,6 +116,7 @@ import { Reading } from './measures';
|
|||||||
} @else {
|
} @else {
|
||||||
<span
|
<span
|
||||||
class="bar"
|
class="bar"
|
||||||
|
[style.margin-left.%]="row.offset"
|
||||||
[style.width.%]="row.width"
|
[style.width.%]="row.width"
|
||||||
[style.background]="row.color"
|
[style.background]="row.color"
|
||||||
></span>
|
></span>
|
||||||
@@ -166,6 +152,10 @@ import { Reading } from './measures';
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
styles: `
|
styles: `
|
||||||
|
tr.sub th,
|
||||||
|
.row.sub .name {
|
||||||
|
padding-left: 1.25rem;
|
||||||
|
}
|
||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
@@ -388,11 +378,6 @@ export class Readings {
|
|||||||
() => 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],
|
||||||
);
|
);
|
||||||
protected readonly groups = computed(() => grouped(this.mode(), this.read()));
|
protected readonly groups = computed(() => grouped(this.mode(), this.read()));
|
||||||
protected readonly historyBreakdown = computed(() => {
|
|
||||||
const mode = this.mode();
|
|
||||||
if (mode.kind !== 'grouped' || mode.stratum !== 'round') return undefined;
|
|
||||||
return subsequentHistory(this.read()(mode.measure));
|
|
||||||
});
|
|
||||||
protected readonly table = computed(() => bars(this.mode(), this.read()));
|
protected readonly table = computed(() => bars(this.mode(), this.read()));
|
||||||
/** The bars of a scenarios figure need more room than a donut. */
|
/** The bars of a scenarios figure need more room than a donut. */
|
||||||
protected readonly height = computed(() => {
|
protected readonly height = computed(() => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Component, input, signal } from '@angular/core';
|
|||||||
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
||||||
import { MatCardModule } from '@angular/material/card';
|
import { MatCardModule } from '@angular/material/card';
|
||||||
import { Loading } from '../loading';
|
import { Loading } from '../loading';
|
||||||
import { DurationRow, durationMax } from './durations';
|
import { chained, DurationRow, durationMax } from './durations';
|
||||||
|
|
||||||
/** A screening route as one compact card: a bar per step with its median, its observations
|
/** A screening route as one compact card: a bar per step with its median, its observations
|
||||||
* and its quartiles, read step by step or cumulatively from the sample. A step that is not
|
* and its quartiles, read step by step or cumulatively from the sample. A step that is not
|
||||||
@@ -29,15 +29,16 @@ import { DurationRow, durationMax } from './durations';
|
|||||||
@if (loading()) {
|
@if (loading()) {
|
||||||
<app-loading what="los tiempos" [figure]="true" />
|
<app-loading what="los tiempos" [figure]="true" />
|
||||||
} @else {
|
} @else {
|
||||||
@let rows = mode() === 'sample' ? sample() : step();
|
@let rows = mode() === 'sample' ? sample() : chain(step());
|
||||||
@let max = scale(rows);
|
@let max = scale(rows);
|
||||||
<p class="state">
|
<p class="state">
|
||||||
@if (mode() === 'sample') {
|
@if (mode() === 'sample') {
|
||||||
Mediana de días desde la toma de la mastografía hasta cada etapa; cada medida se
|
Mediana de días desde la toma de la mastografía hasta cada etapa; cada medida se
|
||||||
calcula por separado.
|
calcula por separado.
|
||||||
} @else {
|
} @else {
|
||||||
Cada barra es la mediana de su paso, desde cero y por separado; los pasos pueden
|
Esquema: cada barra es la mediana de su paso y empieza donde termina el paso del que
|
||||||
corresponder a poblaciones diferentes, por lo que las medianas no se suman.
|
parte. Los pasos pueden corresponder a poblaciones diferentes, por lo que las
|
||||||
|
medianas no se suman.
|
||||||
}
|
}
|
||||||
Las marcas indican el primer y tercer cuartil.
|
Las marcas indican el primer y tercer cuartil.
|
||||||
@if (max) {
|
@if (max) {
|
||||||
@@ -62,16 +63,17 @@ import { DurationRow, durationMax } from './durations';
|
|||||||
<span class="track" aria-hidden="true">
|
<span class="track" aria-hidden="true">
|
||||||
<span
|
<span
|
||||||
class="bar"
|
class="bar"
|
||||||
|
[style.margin-left.%]="max ? (100 * (row.start ?? 0)) / max : 0"
|
||||||
[style.width.%]="max ? (100 * row.median!) / max : 0"
|
[style.width.%]="max ? (100 * row.median!) / max : 0"
|
||||||
></span>
|
></span>
|
||||||
@if (row.low !== undefined && row.high !== undefined) {
|
@if (row.low !== undefined && row.high !== undefined) {
|
||||||
<span
|
<span
|
||||||
class="mark"
|
class="mark"
|
||||||
[style.left.%]="max ? (100 * row.low) / max : 0"
|
[style.left.%]="max ? (100 * ((row.start ?? 0) + row.low)) / max : 0"
|
||||||
></span>
|
></span>
|
||||||
<span
|
<span
|
||||||
class="mark"
|
class="mark"
|
||||||
[style.left.%]="max ? (100 * row.high) / max : 0"
|
[style.left.%]="max ? (100 * ((row.start ?? 0) + row.high)) / max : 0"
|
||||||
></span>
|
></span>
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
@@ -180,4 +182,5 @@ export class RouteCard {
|
|||||||
|
|
||||||
protected readonly mode = signal<'sample' | 'step'>('step');
|
protected readonly mode = signal<'sample' | 'step'>('step');
|
||||||
protected readonly scale = durationMax;
|
protected readonly scale = durationMax;
|
||||||
|
protected readonly chain = chained;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,21 @@ const PERIODS: Record<string, string> = { semester: 'Semestral', month: 'Mensual
|
|||||||
Pacientes evaluadas incluye a las pacientes con citología tomada en el periodo cuyo
|
Pacientes evaluadas incluye a las pacientes con citología tomada en el periodo cuyo
|
||||||
espécimen fue insatisfactorio.
|
espécimen fue insatisfactorio.
|
||||||
</p>
|
</p>
|
||||||
|
<h4>Riesgos de referencia NCI</h4>
|
||||||
|
<p>
|
||||||
|
Los riesgos de referencia corresponden a la cohorte Kaiser Permanente Northern
|
||||||
|
California (2003–2017, pacientes de 25 a 65 años). Las guías ASCCP deciden la
|
||||||
|
conducta con el riesgo de CIN3+. Los riesgos publicados de CIN2+ y cáncer son
|
||||||
|
resultados complementarios; no son directamente comparables con las estimaciones
|
||||||
|
institucionales porque no están validados para la población de esta plataforma.
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC7147417/" target="_blank" rel="noopener noreferrer">Egemen y colaboradores: estimaciones que sustentan las guías (2020).</a></li>
|
||||||
|
<li><a href="https://doi.org/10.1097/LGT.0000000000000528" target="_blank" rel="noopener noreferrer">Cheung y colaboradores: métodos de estimación (2020).</a></li>
|
||||||
|
<li><a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC7147428/" target="_blank" rel="noopener noreferrer">Perkins y colaboradores: guías de manejo ASCCP 2019.</a></li>
|
||||||
|
<li><a href="https://data.lhncbc.nlm.nih.gov/public/cervixca/AdditionalTables.zip" target="_blank" rel="noopener noreferrer">LHNCBC: libros de tablas adicionales.</a></li>
|
||||||
|
<li><a href="https://web.archive.org/web/20240710095705/https://lhncbc.nlm.nih.gov/LHC-research/LHC-projects/image-processing/cervixca.html" target="_blank" rel="noopener noreferrer">LHNCBC: página archivada de las tablas, 10 de julio de 2024.</a></li>
|
||||||
|
</ul>
|
||||||
}
|
}
|
||||||
@if (available().length) {
|
@if (available().length) {
|
||||||
<p>Periodicidad disponible: {{ available().join(', ') }}.</p>
|
<p>Periodicidad disponible: {{ available().join(', ') }}.</p>
|
||||||
@@ -48,6 +63,20 @@ const PERIODS: Record<string, string> = { semester: 'Semestral', month: 'Mensual
|
|||||||
@if (m.description) {
|
@if (m.description) {
|
||||||
<p>{{ m.description }}</p>
|
<p>{{ m.description }}</p>
|
||||||
}
|
}
|
||||||
|
@if (m.relatedArtifact?.length) {
|
||||||
|
<h4>Referencias</h4>
|
||||||
|
<ul>
|
||||||
|
@for (reference of m.relatedArtifact; track $index) {
|
||||||
|
<li>
|
||||||
|
@if (reference.url) {
|
||||||
|
<a [href]="reference.url" target="_blank" rel="noopener noreferrer">{{ reference.citation || reference.display || reference.url }}</a>
|
||||||
|
} @else {
|
||||||
|
{{ reference.citation || reference.display }}
|
||||||
|
}
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
}
|
||||||
<h4>Cálculo</h4>
|
<h4>Cálculo</h4>
|
||||||
<p>
|
<p>
|
||||||
{{ scoring[code(m.scoring) ?? ''] }}
|
{{ scoring[code(m.scoring) ?? ''] }}
|
||||||
|
|||||||
@@ -46,8 +46,8 @@
|
|||||||
<h2 id="opportunity-title">Indicadores de oportunidad</h2>
|
<h2 id="opportunity-title">Indicadores de oportunidad</h2>
|
||||||
<span class="period">Periodo {{ period }}</span>
|
<span class="period">Periodo {{ period }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="kpis" style="--kpi-cols-md: 2; --kpi-cols-lg: 2">
|
<div class="kpis" style="--kpi-cols-md: 3; --kpi-cols-lg: 3">
|
||||||
@for (k of pg.kpis.slice(0, 2); track k.title) {
|
@for (k of pg.kpis; track k.title) {
|
||||||
<ng-container *ngTemplateOutlet="kpiView; context: { $implicit: k }" />
|
<ng-container *ngTemplateOutlet="kpiView; context: { $implicit: k }" />
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -63,15 +63,7 @@
|
|||||||
<ng-container
|
<ng-container
|
||||||
*ngTemplateOutlet="sectionView; context: { $implicit: section, period: period }"
|
*ngTemplateOutlet="sectionView; context: { $implicit: section, period: period }"
|
||||||
/>
|
/>
|
||||||
@if ($index === 0) {
|
|
||||||
<div class="kpis">
|
|
||||||
<ng-container *ngTemplateOutlet="kpiView; context: { $implicit: pg.kpis[2] }" />
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
<div class="kpis">
|
|
||||||
<ng-container *ngTemplateOutlet="kpiView; context: { $implicit: pg.kpis[3] }" />
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
} @else {
|
} @else {
|
||||||
@if (domain() === 'cacu') {
|
@if (domain() === 'cacu') {
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import type { Measure } from 'fhir/r4';
|
||||||
|
import { Fhir } from '../fhir';
|
||||||
|
import { HISTORY } from './pages';
|
||||||
|
import { TabTrazabilidad } from './tab-trazabilidad';
|
||||||
|
|
||||||
|
describe('Trazabilidad: periodo seleccionado', () => {
|
||||||
|
for (const domain of ['cama', 'cacu']) {
|
||||||
|
it(`applies a monthly and semester period to the ${domain} queries`, async () => {
|
||||||
|
const requests: Record<string, string>[] = [];
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [TabTrazabilidad],
|
||||||
|
providers: [
|
||||||
|
{
|
||||||
|
provide: Fhir,
|
||||||
|
useValue: {
|
||||||
|
all: async (_domain: string, _resource: string, params: Record<string, string>) => {
|
||||||
|
requests.push(params);
|
||||||
|
return [{ resourceType: 'Bundle', type: 'searchset', entry: [] }];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}).compileComponents();
|
||||||
|
const fixture = TestBed.createComponent(TabTrazabilidad);
|
||||||
|
fixture.componentRef.setInput('domain', domain);
|
||||||
|
fixture.componentRef.setInput('measures', [
|
||||||
|
{ resourceType: 'Measure', id: 'test', name: HISTORY[domain].panels[0].measure },
|
||||||
|
] as Measure[]);
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
const component = fixture.componentInstance as any;
|
||||||
|
component.chosen.set('2025-03');
|
||||||
|
fixture.detectChanges();
|
||||||
|
(fixture.nativeElement.querySelector('button[mat-flat-button]') as HTMLButtonElement).click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
expect(requests.at(-1)?.['reporting-period'].split(',').at(-1)).toBe('2025-03');
|
||||||
|
expect(requests.at(-1)?.['as-of']).toBeUndefined();
|
||||||
|
component.setType('semester');
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
component.chosen.set('2024-S1');
|
||||||
|
fixture.detectChanges();
|
||||||
|
(fixture.nativeElement.querySelector('button[mat-flat-button]') as HTMLButtonElement).click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
expect(requests.at(-1)?.['reporting-period'].split(',').at(-1)).toBe('2024-S1');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
import { Component, computed, inject, input, resource, signal } from '@angular/core';
|
import { Component, computed, inject, input, resource, signal } from '@angular/core';
|
||||||
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
||||||
|
import { MatSelectModule } from '@angular/material/select';
|
||||||
import type { Measure, MeasureReport } from 'fhir/r4';
|
import type { Measure, MeasureReport } from 'fhir/r4';
|
||||||
import { Fhir, resources } from '../fhir';
|
import { Fhir, resources } from '../fhir';
|
||||||
import { Loading } from '../loading';
|
import { Loading } from '../loading';
|
||||||
import { Figure, Plot } from '../plot';
|
import { Figure, Plot } from '../plot';
|
||||||
import { historyFigure } from './figures';
|
import { historyFigure } from './figures';
|
||||||
import { periodLabel, periods, PeriodType, reading } from './measures';
|
import { historyPeriods, periodLabel, periods, PeriodType, reading } from './measures';
|
||||||
import { HISTORY, HistoryPanel } from './pages';
|
import { HISTORY, HistoryPanel } from './pages';
|
||||||
|
|
||||||
interface Drawn {
|
interface Drawn {
|
||||||
@@ -19,21 +21,30 @@ interface Drawn {
|
|||||||
* each measure period by period. */
|
* each measure period by period. */
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-tab-trazabilidad',
|
selector: 'app-tab-trazabilidad',
|
||||||
imports: [Loading, MatButtonToggleModule, Plot],
|
imports: [Loading, MatButtonModule, MatButtonToggleModule, MatSelectModule, Plot],
|
||||||
template: `
|
template: `
|
||||||
<section class="card filters" aria-labelledby="history-filters">
|
<section class="card filters" aria-labelledby="history-filters">
|
||||||
<h2 id="history-filters" class="filters-title">Filtros</h2>
|
<h2 id="history-filters" class="filters-title">Filtros</h2>
|
||||||
<mat-button-toggle-group
|
<mat-button-toggle-group
|
||||||
[value]="type()"
|
[value]="type()"
|
||||||
(change)="type.set($event.value)"
|
(change)="setType($event.value)"
|
||||||
aria-label="Intervalo de análisis"
|
aria-label="Intervalo de análisis"
|
||||||
>
|
>
|
||||||
<mat-button-toggle value="month">Mensual</mat-button-toggle>
|
<mat-button-toggle value="month">Mensual</mat-button-toggle>
|
||||||
<mat-button-toggle value="semester">Semestral</mat-button-toggle>
|
<mat-button-toggle value="semester">Semestral</mat-button-toggle>
|
||||||
</mat-button-toggle-group>
|
</mat-button-toggle-group>
|
||||||
@if (domain() === 'cama' || domain() === 'cacu') {
|
@if (domain() === 'cama' || domain() === 'cacu') {
|
||||||
<label>Fecha de corte <input type="date" [value]="chosenCutoff()" (input)="chosenCutoff.set($any($event.target).value)" /></label>
|
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
||||||
<button type="button" (click)="cutoff.set(chosenCutoff())">Aplicar</button>
|
<mat-label>Periodo seleccionado</mat-label>
|
||||||
|
<mat-select [value]="chosen()" (selectionChange)="chosen.set($event.value)">
|
||||||
|
@for (p of options(); track p) {
|
||||||
|
<mat-option [value]="p">{{ p }}</mat-option>
|
||||||
|
}
|
||||||
|
</mat-select>
|
||||||
|
</mat-form-field>
|
||||||
|
<button mat-flat-button (click)="applied.set(chosen())" [disabled]="chosen() === applied()">
|
||||||
|
Aplicar
|
||||||
|
</button>
|
||||||
}
|
}
|
||||||
</section>
|
</section>
|
||||||
@if (series.isLoading()) {
|
@if (series.isLoading()) {
|
||||||
@@ -75,6 +86,12 @@ interface Drawn {
|
|||||||
padding: 16px 20px;
|
padding: 16px 20px;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
|
.filters {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
.filters-title {
|
.filters-title {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
@@ -99,16 +116,28 @@ export class TabTrazabilidad {
|
|||||||
readonly domain = input.required<string>();
|
readonly domain = input.required<string>();
|
||||||
readonly measures = input.required<Measure[]>();
|
readonly measures = input.required<Measure[]>();
|
||||||
protected readonly type = signal<PeriodType>('month');
|
protected readonly type = signal<PeriodType>('month');
|
||||||
protected readonly chosenCutoff = signal('');
|
protected readonly options = computed(() => periods(this.type()));
|
||||||
protected readonly cutoff = signal('');
|
protected readonly chosen = signal(periods('month')[0]);
|
||||||
|
protected readonly applied = signal(periods('month')[0]);
|
||||||
|
|
||||||
|
protected setType(type: PeriodType): void {
|
||||||
|
this.type.set(type);
|
||||||
|
const latest = this.options()[0];
|
||||||
|
this.chosen.set(latest);
|
||||||
|
this.applied.set(latest);
|
||||||
|
}
|
||||||
|
|
||||||
protected readonly series = resource({
|
protected readonly series = resource({
|
||||||
params: () => ({ domain: this.domain(), type: this.type(), measures: this.measures(), cutoff: this.cutoff() }),
|
params: () => ({
|
||||||
|
domain: this.domain(),
|
||||||
|
type: this.type(),
|
||||||
|
measures: this.measures(),
|
||||||
|
period: this.applied(),
|
||||||
|
}),
|
||||||
loader: async ({ params }) => {
|
loader: async ({ params }) => {
|
||||||
const history = HISTORY[params.domain];
|
const history = HISTORY[params.domain];
|
||||||
if (!history) return [];
|
if (!history) return [];
|
||||||
const day = params.cutoff ? new Date(`${params.cutoff}T12:00:00`) : new Date();
|
const asked = historyPeriods(params.type, params.period);
|
||||||
const asked = periods(params.type, 6, day).reverse();
|
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
history.panels.map(async (panel) => {
|
history.panels.map(async (panel) => {
|
||||||
const measure = params.measures.find((m) => m.name === panel.measure);
|
const measure = params.measures.find((m) => m.name === panel.measure);
|
||||||
@@ -116,11 +145,6 @@ export class TabTrazabilidad {
|
|||||||
const pages = await this.fhir.all(params.domain, 'MeasureReport', {
|
const pages = await this.fhir.all(params.domain, 'MeasureReport', {
|
||||||
measure: measure.id!,
|
measure: measure.id!,
|
||||||
'reporting-period': asked.join(','),
|
'reporting-period': asked.join(','),
|
||||||
...(params.cutoff ? {
|
|
||||||
'as-of': `${params.cutoff}T23:59:59.999999Z`,
|
|
||||||
'event-cutoff': params.cutoff,
|
|
||||||
'period-cutoff': params.cutoff,
|
|
||||||
} : {}),
|
|
||||||
});
|
});
|
||||||
// One report per period asked, in the order asked.
|
// One report per period asked, in the order asked.
|
||||||
const found = resources<MeasureReport>(pages, 'MeasureReport');
|
const found = resources<MeasureReport>(pages, 'MeasureReport');
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export const CRITERION_TEXT: Record<string, string> = {
|
|||||||
outcome_before_index: 'Resultado CIN2+ entre tratamiento e índice',
|
outcome_before_index: 'Resultado CIN2+ entre tratamiento e índice',
|
||||||
no_birth_date: 'Fecha de nacimiento desconocida',
|
no_birth_date: 'Fecha de nacimiento desconocida',
|
||||||
died_by_index: 'Defunción en o antes de la visita índice',
|
died_by_index: 'Defunción en o antes de la visita índice',
|
||||||
|
not_evaluated: 'Escenario que la plataforma no evalúa por ahora',
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface Reason {
|
export interface Reason {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { EligibilityState, Visit } from './eligibility';
|
import type { EligibilityState, Visit } from './eligibility';
|
||||||
import { ineligibility } from './ineligibility';
|
import { currency, ineligibility } from './ineligibility';
|
||||||
|
|
||||||
const visit = (indexDate: string, ...reasons: string[]): Visit => ({
|
const visit = (indexDate: string, ...reasons: string[]): Visit => ({
|
||||||
indexDate,
|
indexDate,
|
||||||
@@ -28,4 +28,28 @@ describe('ineligibility', () => {
|
|||||||
expect(ineligibility(state, 'case', '2025-06-01')).toBeUndefined();
|
expect(ineligibility(state, 'case', '2025-06-01')).toBeUndefined();
|
||||||
expect(ineligibility({ kind: 'error' }, 'pre_colposcopy', '2025-06-01')).toBeUndefined();
|
expect(ineligibility({ kind: 'error' }, 'pre_colposcopy', '2025-06-01')).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('says of a treated patient only that she was already treated', () => {
|
||||||
|
const text = 'No disponible por: paciente ya tratada.';
|
||||||
|
expect(ineligibility(state, 'post_treatment', '2025-06-01')).toBe(text);
|
||||||
|
expect(ineligibility({ kind: 'error' }, 'post_treatment', '2025-06-01')).toBe(text);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('currency', () => {
|
||||||
|
const pre = [{ model: 'cacu.cin2_pim', index: '2025-01-01' }];
|
||||||
|
const post = [{ model: 'cacu.cin2_pim_post_colposcopy', index: '2025-01-01' }];
|
||||||
|
|
||||||
|
it('dates the estimate and says when there is a later cytology', () => {
|
||||||
|
expect(currency(pre, ['2025-01-01', '2024-01-01']).note).toBe(
|
||||||
|
'Estimación de la citología del 2025-01-01.',
|
||||||
|
);
|
||||||
|
expect(currency(pre, ['2025-06-01', '2025-01-01']).note).toContain('posterior, del 2025-06-01');
|
||||||
|
expect(currency([], ['2025-06-01'])).toEqual({});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows no post-colposcopy estimate once there is a later visit', () => {
|
||||||
|
expect(currency(post, ['2025-01-01']).excluded).toBeUndefined();
|
||||||
|
expect(currency(post, ['2025-06-01', '2025-01-01']).excluded).toContain('(2025-06-01)');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import type { EligibilityState } from './eligibility';
|
|||||||
const SCENARIOS: Record<string, string[]> = {
|
const SCENARIOS: Record<string, string[]> = {
|
||||||
pre_colposcopy: ['pre_colposcopy', 'surveillance'],
|
pre_colposcopy: ['pre_colposcopy', 'surveillance'],
|
||||||
post_colposcopy: ['post_colposcopy'],
|
post_colposcopy: ['post_colposcopy'],
|
||||||
post_treatment: ['post_treatment'],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** What the risk section says when she is not eligible in her clinical scenario, from its latest
|
/** What the risk section says when she is not eligible in her clinical scenario, from its latest
|
||||||
@@ -15,6 +14,8 @@ export function ineligibility(
|
|||||||
status: string,
|
status: string,
|
||||||
day: string,
|
day: string,
|
||||||
): string | undefined {
|
): string | undefined {
|
||||||
|
// a treated patient has no risk estimate, whatever visit was indexed
|
||||||
|
if (status === 'post_treatment') return 'No disponible por: paciente ya tratada.';
|
||||||
if (state.kind !== 'evaluated') return undefined;
|
if (state.kind !== 'evaluated') return undefined;
|
||||||
for (const scenario of SCENARIOS[status] ?? []) {
|
for (const scenario of SCENARIOS[status] ?? []) {
|
||||||
// visits come latest first
|
// visits come latest first
|
||||||
@@ -29,3 +30,27 @@ export function ineligibility(
|
|||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Which cytology her estimates speak of, against her latest by the cut-off. After the first
|
||||||
|
* post-colposcopy visit nothing is evaluated; otherwise a later cytology is only said. */
|
||||||
|
export function currency(
|
||||||
|
estimates: { model: string; index: string }[],
|
||||||
|
cytologies: string[],
|
||||||
|
): { sample?: string; excluded?: string; note?: string } {
|
||||||
|
const sample = estimates.map((e) => e.index.slice(0, 10)).sort().at(-1);
|
||||||
|
if (!sample) return {};
|
||||||
|
const latest = cytologies.map((d) => d.slice(0, 10)).sort().at(-1);
|
||||||
|
if (!latest || latest <= sample) {
|
||||||
|
return { sample, note: `Estimación de la citología del ${sample}.` };
|
||||||
|
}
|
||||||
|
if (estimates.some((e) => e.model.includes('post_colposcopy'))) {
|
||||||
|
return {
|
||||||
|
sample,
|
||||||
|
excluded: `No disponible por: hay una citología posterior a la primera visita poscolposcopía (${latest}) y solo se evalúa esa primera visita.`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
sample,
|
||||||
|
note: `Estimación de la citología del ${sample}. Hay una citología posterior, del ${latest}, que no se evalúa.`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -131,6 +131,9 @@
|
|||||||
@if (saveError()) {
|
@if (saveError()) {
|
||||||
<p class="muted" role="alert">{{ saveError() }}</p>
|
<p class="muted" role="alert">{{ saveError() }}</p>
|
||||||
}
|
}
|
||||||
|
<p class="muted route-note">
|
||||||
|
Los pasos muestran el tamizaje actual, en curso: el de la citología que se consulta.
|
||||||
|
</p>
|
||||||
<div data-section="etapas">
|
<div data-section="etapas">
|
||||||
<app-stages [stages]="s" [detail]="true" />
|
<app-stages [stages]="s" [detail]="true" />
|
||||||
</div>
|
</div>
|
||||||
@@ -258,69 +261,72 @@
|
|||||||
</mat-card>
|
</mat-card>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (
|
@if (excluded() || groups().length || domain() !== 'cacu' || riskModels().length) {
|
||||||
riskExclusion() || withheld() || groups().length || domain() !== 'cacu' || riskModels().length
|
|
||||||
) {
|
|
||||||
<mat-card appearance="outlined" class="wide" data-section="riesgos">
|
<mat-card appearance="outlined" class="wide" data-section="riesgos">
|
||||||
|
@if (excluded(); as reason) {
|
||||||
|
<mat-card-header>
|
||||||
|
<mat-card-title>Sin estimación de riesgo: criterio de exclusión</mat-card-title>
|
||||||
|
</mat-card-header>
|
||||||
|
}
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
@if (withheld(); as why) {
|
@if (excluded(); as reason) {
|
||||||
<p role="status" data-state="withheld">{{ why }}</p>
|
<p role="status" data-state="excluded">{{ reason }}</p>
|
||||||
}
|
|
||||||
@if (riskExclusion(); as reason) {
|
|
||||||
<p role="status">{{ reason }}</p>
|
|
||||||
} @else {
|
} @else {
|
||||||
|
@if (currency().note; as note) {
|
||||||
|
<p class="muted route-note" data-state="toma">{{ note }}</p>
|
||||||
|
}
|
||||||
<app-risk-scales [groups]="groups()" />
|
<app-risk-scales [groups]="groups()" />
|
||||||
}
|
@if (riskModels().length) {
|
||||||
@if (riskModels().length) {
|
<details data-section="modelos">
|
||||||
<details data-section="modelos">
|
<summary>Modelos y valores</summary>
|
||||||
<summary>Modelos y valores</summary>
|
<table class="plain">
|
||||||
<table class="plain">
|
<thead>
|
||||||
<thead>
|
<tr>
|
||||||
<tr>
|
<th>Modelo</th>
|
||||||
<th>Modelo</th>
|
<th>Fecha índice</th>
|
||||||
<th>Fecha índice</th>
|
<th>Horizonte</th>
|
||||||
<th>Horizonte</th>
|
<th>Probabilidad</th>
|
||||||
<th>Probabilidad</th>
|
<th>IC 95 %</th>
|
||||||
<th>IC 95 %</th>
|
</tr>
|
||||||
</tr>
|
</thead>
|
||||||
</thead>
|
<tbody>
|
||||||
<tbody>
|
@for (m of riskModels(); track m.model) {
|
||||||
@for (m of riskModels(); track m.model) {
|
@for (p of m.predictions; track p.years) {
|
||||||
@for (p of m.predictions; track p.years) {
|
<tr>
|
||||||
<tr>
|
<td>{{ $first ? m.text : '' }}</td>
|
||||||
<td>{{ $first ? m.text : '' }}</td>
|
<td>{{ $first ? m.index : '' }}</td>
|
||||||
<td>{{ $first ? m.index : '' }}</td>
|
<td>{{ p.years }} {{ p.years === 1 ? 'año' : 'años' }}</td>
|
||||||
<td>{{ p.years }} {{ p.years === 1 ? 'año' : 'años' }}</td>
|
<td>{{ p.p * 100 | number: '1.1-2' }} %</td>
|
||||||
<td>{{ p.p * 100 | number: '1.1-2' }} %</td>
|
<td>
|
||||||
<td>
|
@if (p.low !== undefined) {
|
||||||
@if (p.low !== undefined) {
|
{{ p.low * 100 | number: '1.1-2' }}–{{
|
||||||
{{ p.low * 100 | number: '1.1-2' }}–{{
|
p.high! * 100 | number: '1.1-2'
|
||||||
p.high! * 100 | number: '1.1-2'
|
}}
|
||||||
}}
|
%
|
||||||
%
|
} @else {
|
||||||
} @else {
|
—
|
||||||
—
|
}
|
||||||
}
|
</td>
|
||||||
</td>
|
</tr>
|
||||||
</tr>
|
}
|
||||||
}
|
}
|
||||||
}
|
</tbody>
|
||||||
</tbody>
|
</table>
|
||||||
</table>
|
</details>
|
||||||
</details>
|
}
|
||||||
}
|
@if (riskModels().length || hasCurves()) {
|
||||||
@if (!riskExclusion() && (riskModels().length || riskSeries.value()?.length)) {
|
<details class="curves" open data-section="curvas">
|
||||||
<details class="curves" open data-section="curvas">
|
<summary>Curvas de probabilidad con su intervalo</summary>
|
||||||
<summary>Curvas de probabilidad con su intervalo</summary>
|
@if (hasCurves()) {
|
||||||
@if (riskSeries.value()?.length) {
|
<app-risk-series [series]="riskSeries.value()!" />
|
||||||
<app-risk-series [series]="riskSeries.value()!" />
|
} @else {
|
||||||
} @else {
|
<app-plot [figure]="curve()" [height]="300" [toolbar]="false" />
|
||||||
<app-plot [figure]="curve()" [height]="300" [toolbar]="false" />
|
}
|
||||||
}
|
</details>
|
||||||
</details>
|
}
|
||||||
}
|
@if (!riskModels().length) {
|
||||||
@if (!riskModels().length && !riskExclusion()) {
|
<p class="muted">Sin evaluación de un modelo en producción.</p>
|
||||||
<p class="muted">Sin evaluación de un modelo en producción.</p>
|
}
|
||||||
}
|
}
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import { firstValueFrom } from 'rxjs';
|
|||||||
import { ApiConfiguration } from '../api/api-configuration';
|
import { ApiConfiguration } from '../api/api-configuration';
|
||||||
import { ANTECEDENTS, Fact, group, hpvApart, split } from './record-groups';
|
import { ANTECEDENTS, Fact, group, hpvApart, split } from './record-groups';
|
||||||
import { eligibilityFailure, eligibilityView, type EligibilityState } from './eligibility';
|
import { eligibilityFailure, eligibilityView, type EligibilityState } from './eligibility';
|
||||||
import { ineligibility } from './ineligibility';
|
import { currency, ineligibility } from './ineligibility';
|
||||||
import { parseSeries, RiskSeries, Series } from './risk-series';
|
import { parseSeries, RiskSeries, Series } from './risk-series';
|
||||||
import { curveFigure } from './risk-curve';
|
import { curveFigure } from './risk-curve';
|
||||||
import { riskGroups, riskScales, RiskScales, survivalGroups } from './risk-scales';
|
import { riskGroups, riskScales, RiskScales, survivalGroups } from './risk-scales';
|
||||||
@@ -202,6 +202,26 @@ export class Paciente {
|
|||||||
const patient = this.patient();
|
const patient = this.patient();
|
||||||
return patient ? ext(patient, 'risk-withheld')?.valueString : undefined;
|
return patient ? ext(patient, 'risk-withheld')?.valueString : undefined;
|
||||||
});
|
});
|
||||||
|
/** The one criterion she does not meet: nothing else of her risk is then shown. */
|
||||||
|
protected readonly excluded = computed(
|
||||||
|
() => this.withheld() ?? this.riskExclusion() ?? this.currency().excluded,
|
||||||
|
);
|
||||||
|
/** CaCu: the cytology her estimates speak of, against her latest by the cut-off. */
|
||||||
|
protected readonly currency = computed(() =>
|
||||||
|
this.domain() === 'cacu'
|
||||||
|
? currency(
|
||||||
|
this.riskModels(),
|
||||||
|
(this.data.value()?.reports ?? [])
|
||||||
|
.filter((r) => code(r.code) === 'cervical_cytology')
|
||||||
|
.map((r) => r.effectiveDateTime ?? '')
|
||||||
|
.filter((d) => d && d.slice(0, 10) <= this.cutoff()),
|
||||||
|
)
|
||||||
|
: {},
|
||||||
|
);
|
||||||
|
/** Whether any published series has a point to draw. */
|
||||||
|
protected readonly hasCurves = computed(
|
||||||
|
() => this.riskSeries.value()?.some((s) => s.points.length > 0) ?? false,
|
||||||
|
);
|
||||||
/** CaCu: the route of the cytology she was opened at, else of her latest, by the cut-off. */
|
/** CaCu: the route of the cytology she was opened at, else of her latest, by the cut-off. */
|
||||||
protected readonly stages = computed(() => {
|
protected readonly stages = computed(() => {
|
||||||
const cytologies = (this.data.value()?.reports ?? []).filter(
|
const cytologies = (this.data.value()?.reports ?? []).filter(
|
||||||
@@ -251,7 +271,12 @@ export class Paciente {
|
|||||||
protected readonly riskSeries = resource({
|
protected readonly riskSeries = resource({
|
||||||
params: () =>
|
params: () =>
|
||||||
this.domain() === 'cacu'
|
this.domain() === 'cacu'
|
||||||
? { id: this.id(), cutoff: this.corte(), sample: this.citologia() }
|
? // the NCI's series speak of the same cytology as the institutional estimate
|
||||||
|
{
|
||||||
|
id: this.id(),
|
||||||
|
cutoff: this.corte(),
|
||||||
|
sample: this.currency().sample ?? this.citologia(),
|
||||||
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
loader: async ({ params }): Promise<Series[] | undefined> => {
|
loader: async ({ params }): Promise<Series[] | undefined> => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ export class RiskScales {
|
|||||||
hpv: 'VPH',
|
hpv: 'VPH',
|
||||||
hpv_positive: 'VPH',
|
hpv_positive: 'VPH',
|
||||||
hpv_16_18: 'VPH 16/18',
|
hpv_16_18: 'VPH 16/18',
|
||||||
referral_grade: 'Referencia',
|
referral_grade: 'Citología de referencia',
|
||||||
bethesda: 'Citología',
|
bethesda: 'Citología',
|
||||||
hpv_16: 'VPH 16',
|
hpv_16: 'VPH 16',
|
||||||
hpv_18: 'VPH 18',
|
hpv_18: 'VPH 18',
|
||||||
@@ -339,6 +339,8 @@ export class RiskScales {
|
|||||||
)[name] ?? name;
|
)[name] ?? name;
|
||||||
protected readonly inputValue = (name: string, value: unknown) => {
|
protected readonly inputValue = (name: string, value: unknown) => {
|
||||||
if (value === null || value === undefined) return 'No documentado';
|
if (value === null || value === undefined) return 'No documentado';
|
||||||
|
if (name === 'referral_grade' && (value === 'high' || value === 'low'))
|
||||||
|
return value === 'high' ? 'Alto grado' : 'Bajo grado';
|
||||||
if (name.startsWith('hpv') && (value === 0 || value === 1 || typeof value === 'boolean'))
|
if (name.startsWith('hpv') && (value === 0 || value === 1 || typeof value === 'boolean'))
|
||||||
return value ? 'Positivo' : 'Negativo';
|
return value ? 'Positivo' : 'Negativo';
|
||||||
if (name.startsWith('hpv') && value === 'positive') return 'Positivo';
|
if (name.startsWith('hpv') && value === 'positive') return 'Positivo';
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ describe('risk series', () => {
|
|||||||
});
|
});
|
||||||
expect(series.points).toEqual([{ years: 0, p: 0, low: undefined, high: undefined }]);
|
expect(series.points).toEqual([{ years: 0, p: 0, low: undefined, high: undefined }]);
|
||||||
expect(seriesName(series)).toBe('ISSSTELEON, LIEAG+');
|
expect(seriesName(series)).toBe('ISSSTELEON, LIEAG+');
|
||||||
expect(seriesName({ ...series, source: 'NCI (tabla de ingreso)' })).toBe(
|
expect(seriesName({ ...series, source: 'NCI', outcome: 'CIN3+' })).toBe('NCI, CIN3+');
|
||||||
'NCI, ingreso a LIEAG+',
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -29,13 +29,9 @@ const OUTCOME_TEXT: Record<string, string> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const seriesName = (s: Series) => {
|
export const seriesName = (s: Series) => {
|
||||||
const outcome = OUTCOME_TEXT[s.outcome] ?? s.outcome;
|
const outcome = (OUTCOME_TEXT[s.outcome] ?? s.outcome).replace(' (CIN2+)', '');
|
||||||
if (s.source === 'NCI (tabla de ingreso)')
|
// the platform's own models are the hospital's
|
||||||
return `NCI, ingreso a ${outcome.replace(' (CIN2+)', '').replace(/^Cáncer$/, 'cáncer')}`;
|
return `${s.source === 'Institucional' ? 'ISSSTELEON' : s.source}, ${outcome}`;
|
||||||
// the platform's own models are the hospital's: its name, and the outcome without its synonym
|
|
||||||
return s.source === 'Institucional'
|
|
||||||
? `ISSSTELEON, ${outcome.replace(' (CIN2+)', '')}`
|
|
||||||
: `${s.source} · ${outcome}`;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The series of the answer. A value absent from it stays absent. */
|
/** The series of the answer. A value absent from it stays absent. */
|
||||||
@@ -65,7 +61,6 @@ export function parseSeries(answer: Parameters): Series[] {
|
|||||||
selector: 'app-risk-series',
|
selector: 'app-risk-series',
|
||||||
imports: [CurveChooser],
|
imports: [CurveChooser],
|
||||||
template: `
|
template: `
|
||||||
<p class="muted">Cada serie tiene su propio desenlace y población: no se restan entre sí.</p>
|
|
||||||
@if (available().length) {
|
@if (available().length) {
|
||||||
<app-curve-chooser [choices]="choices()" [draw]="draw()" [notes]="assumptions()" />
|
<app-curve-chooser [choices]="choices()" [draw]="draw()" [notes]="assumptions()" />
|
||||||
} @else {
|
} @else {
|
||||||
@@ -81,12 +76,13 @@ export function parseSeries(answer: Parameters): Series[] {
|
|||||||
export class RiskSeries {
|
export class RiskSeries {
|
||||||
readonly series = input.required<Series[]>();
|
readonly series = input.required<Series[]>();
|
||||||
protected readonly available = computed(() => this.series().filter((s) => s.points.length));
|
protected readonly available = computed(() => this.series().filter((s) => s.points.length));
|
||||||
/** the platform's own series are drawn until the user says otherwise */
|
/** the platform's own series and the NCI master table's CIN2+ and CIN3+ are drawn until the
|
||||||
|
* user says otherwise */
|
||||||
protected readonly choices = computed(() =>
|
protected readonly choices = computed(() =>
|
||||||
this.available().map((s) => ({
|
this.available().map((s) => ({
|
||||||
id: s.id,
|
id: s.id,
|
||||||
name: seriesName(s),
|
name: seriesName(s),
|
||||||
on: s.source === 'Institucional',
|
on: s.source === 'Institucional' || ['nci-master-CIN2+', 'nci-master-CIN3+'].includes(s.id),
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
private readonly among = computed(() => {
|
private readonly among = computed(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user