Indicators: CaCu and CaMa pages read by rounds, genotypes and steps; history to a chosen period; NCI and indicator references; CaMa follow-up export; API client for eligibility and risk series
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { name } from './labels';
|
||||
import type { Measure, MeasureReport, MeasureReportGroup } from 'fhir/r4';
|
||||
import { code, ext } from '../fhir';
|
||||
import { Figure, PALETTE } from '../plot';
|
||||
@@ -23,6 +24,13 @@ export function periods(type: PeriodType, years = 6, today = new Date()): string
|
||||
return found;
|
||||
}
|
||||
|
||||
/** A period's first day ("2026-S2": July 1st; "2026-03": March 1st). */
|
||||
export function periodStart(period: string): Date {
|
||||
const [year, part] = period.split('-');
|
||||
const month = part.startsWith('S') ? (part === 'S1' ? 0 : 6) : Number(part) - 1;
|
||||
return new Date(Number(year), month, 1);
|
||||
}
|
||||
|
||||
export function periodLabel(period: string): string {
|
||||
const [year, part] = period.split('-');
|
||||
if (part.startsWith('S')) return `${part === 'S1' ? 'Ene–Jun' : 'Jul–Dic'} ${year}`;
|
||||
@@ -98,78 +106,6 @@ export function reading(report: MeasureReport | undefined): Reading | undefined
|
||||
};
|
||||
}
|
||||
|
||||
/** Codes as the screens name them. */
|
||||
export const LABELS: Record<string, string> = {
|
||||
NILM: 'Normal (NILM)',
|
||||
LSIL: 'LIEBG',
|
||||
HSIL: 'LIEAG',
|
||||
normal: 'Normal',
|
||||
carcinoma: 'Carcinoma',
|
||||
no_data: 'Sin dato',
|
||||
no_biopsy: 'Sin biopsia',
|
||||
pre_colposcopy: 'Pre colposcopia',
|
||||
post_colposcopy: 'Post colposcopia',
|
||||
post_treatment: 'Post tratamiento',
|
||||
case: 'Caso (cáncer)',
|
||||
low: 'Bajo',
|
||||
intermediate: 'Intermedio',
|
||||
high: 'Alto',
|
||||
satisfactory: 'satisfactoria',
|
||||
unsatisfactory: 'insatisfactoria',
|
||||
benign: 'Benigno',
|
||||
in_situ: 'Carcinoma in situ',
|
||||
invasive: 'Carcinoma invasor',
|
||||
cancer: 'Diagnóstico confirmado',
|
||||
pending_biopsy: 'Pendiente de biopsia',
|
||||
biopsy_no_result: 'Biopsia sin resultado',
|
||||
benign_biopsy: 'Biopsia benigna',
|
||||
confirmed: 'Diagnóstico confirmado',
|
||||
in_process: 'En proceso',
|
||||
not_confirmed: 'Sin TEA',
|
||||
mchat_only: 'Solo M-CHAT',
|
||||
psychology: 'Psicología (ADOS-2)',
|
||||
neuropediatrics: 'Neuropediatría',
|
||||
eeg: 'EEG',
|
||||
good: 'Bueno',
|
||||
bad: 'Malo',
|
||||
not_analyzed: 'Sin analizar',
|
||||
initial: 'Inicial',
|
||||
subsequent: 'Subsecuente',
|
||||
positive: 'Positivo',
|
||||
negative: 'Negativo',
|
||||
hpv_16: 'VPH 16',
|
||||
hpv_18: 'VPH 18',
|
||||
ascus_plus: 'ASC-US o mayor',
|
||||
lsil_plus: 'LIEBG o mayor',
|
||||
hsil_plus: 'LIEAG o mayor',
|
||||
cin1_plus: 'Histología LIEBG o mayor',
|
||||
cin2_plus: 'Histología LIEAG o mayor',
|
||||
several: 'Varios códigos',
|
||||
no_result: 'Sin resultado de VPH',
|
||||
inconsistent: 'Inconsistente',
|
||||
no_grade: 'Sin grado',
|
||||
...Object.fromEntries(
|
||||
['0', '1', '2', '3', '4', '4A', '4B', '4C', '5', '6'].map((c) => [c, `BI-RADS ${c}`]),
|
||||
),
|
||||
};
|
||||
/** A follow-up priority's label. */
|
||||
export const PRIORITY: Record<string, string> = { high: 'Alta', medium: 'Media', low: 'Baja' };
|
||||
export const STRATA: Record<string, string> = {
|
||||
category: 'Categoría',
|
||||
age_group: 'Grupo de edad',
|
||||
follow_up_status: 'Estatus de seguimiento',
|
||||
result: 'Citología de alto grado',
|
||||
birads: 'BI-RADS de la mastografía',
|
||||
diagnosis_code: 'Diagnóstico CIE-10',
|
||||
cytology: 'Citología previa',
|
||||
hpv: 'VPH de la citología previa',
|
||||
level: 'Histología confirmada',
|
||||
round: 'Tamizaje inicial o subsecuente',
|
||||
hpv_16: 'VPH 16',
|
||||
hpv_18: 'VPH 18',
|
||||
};
|
||||
export const name = (value: string) => LABELS[value] ?? value;
|
||||
|
||||
export function formatScore(measure: Measure, r: Reading | undefined): string {
|
||||
if (!r || r.score === undefined) return 'Sin dato';
|
||||
switch (scoring(measure)) {
|
||||
@@ -182,14 +118,14 @@ export function formatScore(measure: Measure, r: Reading | undefined): string {
|
||||
}
|
||||
}
|
||||
|
||||
export function detail(measure: Measure, r: Reading | undefined): string {
|
||||
export function detail(measure: Measure, r: Reading | undefined, unit = 'pacientes'): string {
|
||||
if (!r) return '';
|
||||
const p = r.populations;
|
||||
switch (scoring(measure)) {
|
||||
case 'proportion':
|
||||
return r.score === undefined
|
||||
? 'Sin pacientes en el periodo.'
|
||||
: `${p['numerator']} de ${p['denominator']} pacientes. IC 95 %: ${pct(r.low)}–${pct(r.high)}.`;
|
||||
? `Sin ${unit} en el periodo.`
|
||||
: `${p['numerator']} de ${p['denominator']} ${unit}. IC 95 %: ${pct(r.low)}–${pct(r.high)}.`;
|
||||
case 'continuous-variable':
|
||||
return r.score === undefined
|
||||
? `${p['initial-population'] ?? 0} sin medición en el periodo.`
|
||||
|
||||
Reference in New Issue
Block a user