Merge the CaMa diagnostic pathway and biopsy results into the CaCu rounds, record and risk work

This commit is contained in:
Angel Capetillo Zavala
2026-12-01 19:02:02 -06:00
12 changed files with 760 additions and 65 deletions
+108 -39
View File
@@ -1,5 +1,6 @@
import type { Mode } from './bars';
import { CACU } from './pages-cacu';
import type { RouteStep } from './durations';
/** A domain's Indicadores page as the old app showed it (tests/fixtures/reference/<domain>/ui):
* the timeliness cards with their own words, then the clinical sections and their figures.
@@ -25,6 +26,8 @@ export interface ReadingsCard {
kind: 'readings';
title: string;
headline?: string;
/** what the headline proportion counts, in the plural (default: pacientes) */
unit?: string;
note?: string;
modes: Mode[];
/** in a `columns` section with `views`: takes the mode whose label the section's selector chose */
@@ -32,6 +35,10 @@ export interface ReadingsCard {
}
export type Section =
| ReadingsCard
/** A screening route as one compact card: a bar per step with its median, observations and
* quartiles. `sample` reads each step from the sample (its own measure, never a sum of
* medians); `step` reads each from the previous step. A reading with no steps is not offered. */
| { kind: 'route'; title: string; sample: RouteStep[]; step: RouteStep[] }
/** Cards side by side; the last one alone when odd. */
| {
kind: 'columns';
@@ -42,7 +49,14 @@ export type Section =
viewsLabel?: string;
}
/** One section at a time. */
| { kind: 'choice'; title: string; choices: { label: string; section: ReadingsCard }[] }
/** `card`: the title, the tabs and the chosen reading in one card (the reading's own title is
* left out: its tab names it) */
| {
kind: 'choice';
title: string;
choices: { label: string; section: ReadingsCard }[];
card?: boolean;
}
| { kind: 'figures'; title?: string; figures: FigureSpec[] }
| {
kind: 'boxes';
@@ -122,17 +136,22 @@ const BIRADS: Catalog = {
{ code: '6', label: 'BI-RADS 6', color: '#7A3496', group: '' },
],
};
const BREAST_BIOPSY: Catalog = {
groups: [
{ id: 'benign', label: 'No maligno', color: '#42C29C' },
{ id: 'malignant', label: 'Maligno', color: ROSE },
],
categories: [
{ code: 'benign', label: 'Benigno', color: OLIVE, group: 'benign' },
{ code: 'in_situ', label: 'Carcinoma in situ', color: '#9C42C2', group: 'malignant' },
{ code: 'invasive', label: 'Carcinoma invasor', color: '#5C42C2', group: 'malignant' },
],
};
/** A breast biopsy's grades, and what stands in their place when there is none. */
const BIOPSY_GRADES = [
{ code: 'benign', label: 'Benigno', color: '#A8C243' },
{ code: 'in_situ', label: 'Carcinoma in situ', color: '#9C42C2' },
{ code: 'invasive', label: 'Carcinoma invasor', color: '#5C42C2' },
];
/** What «Sin biopsia» says, whatever the contract's category is called. */
const NO_BIOPSY_MEANS =
'«Sin biopsia»: no existe una biopsia vinculada según los datos disponibles.';
const INSTITUTIONAL = '#A8C243';
const NEUTRAL = '#C9CDD2';
const NO_RESULT = [
{ code: 'no_biopsy', label: 'Sin biopsia', color: '#C9CDD2' },
{ code: 'no_data', label: 'Sin dato', color: '#8C949C' },
];
export const PAGES: Record<string, Page> = {
tea: {
@@ -238,9 +257,9 @@ export const PAGES: Record<string, Page> = {
},
{
measure: 'CAMA_TASA_DETECCION_HISTOPATOLOGICA',
title: 'Tasa de confirmación histopatológica',
title: 'Tasa de detección histopatológica',
value: '{pct} %',
note: '{num} de {den} biopsias con riesgo a carcinoma.',
note: '{num} de {den} biopsias con grado conocido presentan carcinoma (in situ o invasor).',
},
{
measure: 'CAMA_EU38A',
@@ -260,21 +279,27 @@ export const PAGES: Record<string, Page> = {
],
opportunity: [
{
kind: 'boxes',
kind: 'route',
title: 'Tiempo de tamizaje a diagnóstico',
subtitles: true,
cards: [
// from the mammography: only the two measures that start at it
sample: [
{ label: 'Interpretación radiológica', measure: 'CAMA_EU38A' },
{
measure: 'CAMA_EU38A',
title: 'Tiempo de toma de mastografía a interpretación radiológica',
label: 'Diagnóstico (tiempo total de tamizaje a diagnóstico)',
measure: 'CAMA_DIAS_TOMA_DIAGNOSTICO',
},
],
step: [
{ label: 'Toma de mastografía a interpretación radiológica', measure: 'CAMA_EU38A' },
{
label: 'Interpretación radiológica a diagnóstico',
measure: 'CAMA_DIAS_RESULTADO_DIAGNOSTICO',
title: 'Tiempo de interpretación radiológica a diagnóstico',
},
{ title: 'Tiempo de interpretación radiológica a resultado de biopsia' },
{ title: 'Tiempo de diagnóstico a tratamiento' },
{ measure: 'CAMA_DIAS_TOMA_DIAGNOSTICO', title: 'Tiempo de tamizaje a diagnóstico' },
{
label: 'Interpretación radiológica a resultado de biopsia',
measure: 'CAMA_DIAS_RESULTADO_BIOPSIA',
},
{ label: 'Diagnóstico a tratamiento' },
],
},
],
@@ -299,34 +324,78 @@ export const PAGES: Record<string, Page> = {
],
},
{
kind: 'figures',
kind: 'readings',
title: 'Resultado histopatológico por categoría BI-RADS',
figures: [
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.',
modes: [
{
kind: 'rates',
title: 'Por categoría BI-RADS, {p}',
kind: 'outcomes',
label: 'Por categoría BI-RADS',
heading: 'Resultados por paciente',
caption: NO_BIOPSY_MEANS,
measure: 'CAMA_HISTOPATOLOGIA_BIRADS',
stratum: 'birads',
rows: BIRADS.categories,
colored: true,
positive: ['in_situ', 'invasive'],
axis: 'Porcentaje con resultado maligno',
results: [...BIOPSY_GRADES, ...NO_RESULT],
malignant: ['in_situ', 'invasive'],
},
{
kind: 'donut',
title: 'Resultado de la biopsia, {p}',
kind: 'counts',
label: 'Todas las categorías',
heading: 'Resultados por paciente',
caption: `Todas las categorías BI-RADS juntas. ${NO_BIOPSY_MEANS}`,
measure: 'CAMA_HISTOPATOLOGIA_BIRADS',
catalog: BREAST_BIOPSY,
center: 'con resultado',
catalog: [...BIOPSY_GRADES, ...NO_RESULT],
percent: true,
},
],
},
{
kind: 'card',
measure: 'CAMA_CONFIRMACION_BIRADS45',
title: 'Tasa de confirmación histopatológica',
value: '{pct} %',
note: '{num} de {den} mastografías BI-RADS 4 y 5 con reporte de biopsia.',
kind: 'choice',
title: 'Confirmación histopatológica',
card: true,
choices: [
{
label: 'Resultado de biopsias',
section: {
kind: 'readings',
title: 'Resultado de biopsias',
headline: 'CAMA_TASA_DETECCION_HISTOPATOLOGICA',
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.',
modes: [
{
kind: 'counts',
label: 'Biopsias reportadas',
heading: 'Biopsias reportadas',
measure: 'CAMA_BIOPSIAS',
catalog: [...BIOPSY_GRADES, NO_RESULT[1]],
percent: true,
},
],
},
},
{
label: 'Mastografías con biopsia',
section: {
kind: 'readings',
title: 'Mastografías con biopsia',
headline: 'CAMA_CONFIRMACION_BIRADS45',
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.',
modes: [
{
kind: 'split',
label: 'Con y sin biopsia',
measure: 'CAMA_CONFIRMACION_BIRADS45',
yes: 'Con reporte de biopsia',
no: 'Sin reporte de biopsia',
colors: [INSTITUTIONAL, NEUTRAL],
},
],
},
},
],
},
],
},