CaCu indicators: HPV genotype, biopsy results, diagnosis timing by ICD-10 and referral PPV cards

The HPV genotype and biopsy distributions, the biopsy request confirmation and the
timing by ICD-10 code are placed beside cytology. The referral PPV cards are titled as
registered procedures and say that a colposcopy may be inferred from notes and that the
preceding cytology is a date association, not a confirmed referral. The new strata and
their values have Spanish labels.
This commit is contained in:
Angel Capetillo Zavala
2026-11-27 18:42:41 -06:00
parent 07212a2083
commit 31400c77b1
8 changed files with 441 additions and 13 deletions
+55
View File
@@ -0,0 +1,55 @@
import { Reading } from './measures';
const CATEGORIES = [
['NILM', 'Normal', '#408651'],
['ASC-US', 'ASC-US', '#2778B8'],
['LSIL', 'LIEBG', '#B19525'],
['ASC-H', 'ASC-H', '#7955B1'],
['HSIL', 'LIEAG', '#CE4778'],
['CIS', 'Carcinoma in situ', '#AA394D'],
] as const;
/** EU7 selects one sample per patient. Unknown categories stay outside the denominator. */
export function cytologyDistribution(reading: Reading | undefined) {
return distribution(reading, CATEGORIES);
}
const HPV = [
['negative', 'Negativo', '#42a77e'],
['positive_16', 'Positivo 16 exclusivamente', '#df8640'],
['positive_18', 'Positivo 18 exclusivamente', '#c29c42'],
['positive_16_18', 'Positivo 16 y 18', '#c24269'],
['positive_other', 'Positivo sin detección de 16/18', '#a8c243'],
['positive_incomplete', 'Positivo con genotipificación incompleta', '#9c42c2'],
['inconsistent', 'No clasificable o inconsistente', '#687786'],
] as const;
const BIOPSY = [
['normal', 'Normal', '#408651'],
['LSIL', 'LIEBG (CIN 1)', '#B19525'],
['HSIL', 'LIEAG (CIN 2 y 3)', '#CE4778'],
['CIS', 'Carcinoma in situ', '#AA394D'],
['carcinoma', 'Carcinoma invasor', '#8D4C79'],
] as const;
export function hpvDistribution(reading: Reading | undefined) {
const result = distribution(reading, HPV);
return result && { ...result, total: result.total + result.outside };
}
export const biopsyDistribution = (reading: Reading | undefined) => distribution(reading, BIOPSY);
function distribution(reading: Reading | undefined, categories: readonly (readonly [string, string, string])[]) {
const cells = reading?.strata['category'];
const population = reading?.populations['initial-population'];
if (!cells || population === undefined) return undefined;
const counts = Object.values(cells).map((cell) => cell['initial-population']);
if (counts.some((n) => n === undefined || !Number.isInteger(n) || n < 0) ||
counts.reduce((a, b) => a + b, 0) !== population) return undefined;
const rows = categories.map(([code, label, color]) => ({
label, color, count: cells[code]?.['initial-population'] ?? 0,
}));
const total = rows.reduce((sum, row) => sum + row.count, 0);
const max = Math.max(0, ...rows.map((row) => row.count));
return { rows, total, outside: population - total, max,
noData: cells['no_data']?.['initial-population'] ?? 0 };
}