From 9c17a383d168e548937e062647f273ecd5312638 Mon Sep 17 00:00:00 2001 From: edgar Date: Thu, 3 Dec 2026 00:06:32 -0600 Subject: [PATCH] =?UTF-8?q?Usar=20barras=20comunes=20en=20confirmaci=C3=B3?= =?UTF-8?q?n=20y=20renombrar=20la=20serie=20de=20ingreso=20del=20NCI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/indicadores/bars.ts | 23 +++++++++++++++++- src/app/indicadores/measures.ts | 35 ---------------------------- src/app/indicadores/pages-cacu.ts | 2 +- src/app/indicadores/section.ts | 3 +-- src/app/paciente/risk-series.spec.ts | 3 +++ src/app/paciente/risk-series.ts | 2 ++ 6 files changed, 29 insertions(+), 39 deletions(-) diff --git a/src/app/indicadores/bars.ts b/src/app/indicadores/bars.ts index 4d4cb6a..5bb4f5f 100644 --- a/src/app/indicadores/bars.ts +++ b/src/app/indicadores/bars.ts @@ -54,6 +54,8 @@ export type Mode = { hidden?: Hidden; } | { kind: 'days'; steps: { label: string; measure: string }[]; tint?: Tint } + /** A proportion as one bar of 0 to 100 %, its 95 % interval as the two marks on it */ + | { kind: 'ratio'; measure: string; colors?: Colors } | { kind: 'days-by'; measure: string; stratum: string; tint?: Tint } /** A proportion as its two parts (what counted and what did not), in units, with the shares */ | { kind: 'split'; measure: string; yes: string; no: string; colors?: [string, string] } @@ -70,7 +72,7 @@ export type Mode = { | { kind: 'figure'; measure: string; - figure: 'donut' | 'scenarios' | 'interval'; + figure: 'donut' | 'scenarios'; /** a donut's colour by part (a category, or numerator and rest); none: the page's palette */ colors?: Colors; catalog?: Category[]; @@ -204,6 +206,25 @@ const days = (n: number) => (Math.round(n * 10) / 10).toLocaleString('es-MX'); /** The bars of a mode; none when the period has nothing to draw. */ export function bars(mode: Mode, of: (measure: string) => Reading | undefined): Bars | undefined { switch (mode.kind) { + case 'ratio': { + const r = of(mode.measure); + const n = r?.populations['numerator'] ?? 0; + const total = r?.populations['denominator'] ?? 0; + if (r?.score === undefined || !total) return undefined; + const ends = r.low !== undefined && r.high !== undefined ? [r.low, r.high] : []; + return { + head: ['n/N', '%', 'IC 95 %'], + rows: [ + { + label: 'Total', + color: mode.colors?.['numerator'], + width: 100 * r.score, + marks: ends.map((v) => 100 * v), + cells: [`${n}/${total}`, pct(n, total), ends.map((v) => pct(v, 1)).join('–') || '—'], + }, + ], + }; + } case 'counts': { const cells = of(mode.measure)?.strata['category'] ?? {}; const total = Object.values(cells).reduce((n, c) => n + size(c), 0); diff --git a/src/app/indicadores/measures.ts b/src/app/indicadores/measures.ts index ff20074..54793ee 100644 --- a/src/app/indicadores/measures.ts +++ b/src/app/indicadores/measures.ts @@ -202,41 +202,6 @@ export function detail(measure: Measure, r: Reading | undefined, unit = 'pacient const pct = (v?: number) => (v === undefined ? '—' : `${(v * 100).toFixed(1)} %`); -/** A proportion as one bar of 0 to 100 % with its published 95 % interval as the error bar. */ -export function intervalBar(r: Reading, color?: string): Figure { - const score = r.score ?? 0; - const known = r.low !== undefined && r.high !== undefined; - return { - data: [ - { - type: 'bar', - orientation: 'h', - x: [score], - y: [''], - width: [0.4], - marker: { color: color ?? PALETTE[0] }, - hovertemplate: `${pct(r.score)}
IC 95 %: ${pct(r.low)}–${pct(r.high)}`, - error_x: known - ? { - type: 'data', - symmetric: false, - array: [r.high! - score], - arrayminus: [score - r.low!], - color: '#17324d', - thickness: 2, - width: 10, - } - : undefined, - }, - ], - layout: { - showlegend: false, - margin: { t: 16, r: 16, b: 32, l: 16 }, - xaxis: { range: [0, 1], tickformat: '.0%' }, - }, - } as Figure; -} - /** A donut of one stratifier's counts (initial population), or of numerator vs the rest. */ export function donut( measure: Measure, diff --git a/src/app/indicadores/pages-cacu.ts b/src/app/indicadores/pages-cacu.ts index ba39dff..d965a76 100644 --- a/src/app/indicadores/pages-cacu.ts +++ b/src/app/indicadores/pages-cacu.ts @@ -119,7 +119,7 @@ const ppv = (measure: string, title: string, note: string, ...more: Mode[]): Rea footnote: true, note: `${note} Confirma la histología LIEBG o mayor.`, modes: [ - { kind: 'figure', label: 'Total', measure, figure: 'interval', colors: PPV_DONUT }, + { kind: 'ratio', label: 'Total', measure, colors: PPV_DONUT }, { kind: 'shares', label: 'Citología previa', diff --git a/src/app/indicadores/section.ts b/src/app/indicadores/section.ts index cabf2d7..bcefd5d 100644 --- a/src/app/indicadores/section.ts +++ b/src/app/indicadores/section.ts @@ -4,7 +4,7 @@ import { MatCardModule } from '@angular/material/card'; import type { Measure } from 'fhir/r4'; import { Mode } from './bars'; import { scenarioBars } from './figures'; -import { detail, donut, formatScore, intervalBar, name, Reading, scoring } from './measures'; +import { detail, donut, formatScore, name, Reading, scoring } from './measures'; import type { ReadingsCard, Section } from './pages'; import { Readings } from './readings'; @@ -175,7 +175,6 @@ export class ReadingsSection { const r = this.of().reading(mode.measure); const measure = this.of().measure(mode.measure); if (!measure || !r?.populations['initial-population']) return undefined; - if (mode.figure === 'interval') return intervalBar(r, mode.colors?.['numerator']); if (mode.figure === 'donut') return donut(measure, r, 'category', mode.colors); const categories = (mode.catalog ?? []).map((c) => ({ ...c, group: '' })); return scenarioBars( diff --git a/src/app/paciente/risk-series.spec.ts b/src/app/paciente/risk-series.spec.ts index 18d9d58..d14d92b 100644 --- a/src/app/paciente/risk-series.spec.ts +++ b/src/app/paciente/risk-series.spec.ts @@ -25,5 +25,8 @@ describe('risk series', () => { }); expect(series.points).toEqual([{ years: 0, p: 0, low: undefined, high: undefined }]); expect(seriesName(series)).toBe('ISSSTELEON, LIEAG+'); + expect(seriesName({ ...series, source: 'NCI (tabla de ingreso)' })).toBe( + 'NCI, ingreso a LIEAG+', + ); }); }); diff --git a/src/app/paciente/risk-series.ts b/src/app/paciente/risk-series.ts index fbf3677..6895d7b 100644 --- a/src/app/paciente/risk-series.ts +++ b/src/app/paciente/risk-series.ts @@ -31,6 +31,8 @@ const OUTCOME_TEXT: Record = { export const seriesName = (s: Series) => { const outcome = OUTCOME_TEXT[s.outcome] ?? s.outcome; + if (s.source === 'NCI (tabla de ingreso)') + return `NCI, ingreso a ${outcome.replace(' (CIN2+)', '').replace(/^Cáncer$/, 'cáncer')}`; // 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+)', '')}`