Usar barras comunes en confirmación y renombrar la serie de ingreso del NCI
This commit is contained in:
@@ -54,6 +54,8 @@ export type Mode = {
|
|||||||
hidden?: Hidden;
|
hidden?: Hidden;
|
||||||
}
|
}
|
||||||
| { kind: 'days'; steps: { label: string; measure: string }[]; tint?: Tint }
|
| { 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 }
|
| { 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 */
|
/** 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] }
|
| { kind: 'split'; measure: string; yes: string; no: string; colors?: [string, string] }
|
||||||
@@ -70,7 +72,7 @@ export type Mode = {
|
|||||||
| {
|
| {
|
||||||
kind: 'figure';
|
kind: 'figure';
|
||||||
measure: string;
|
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 */
|
/** a donut's colour by part (a category, or numerator and rest); none: the page's palette */
|
||||||
colors?: Colors;
|
colors?: Colors;
|
||||||
catalog?: Category[];
|
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. */
|
/** 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 {
|
export function bars(mode: Mode, of: (measure: string) => Reading | undefined): Bars | undefined {
|
||||||
switch (mode.kind) {
|
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': {
|
case 'counts': {
|
||||||
const cells = of(mode.measure)?.strata['category'] ?? {};
|
const cells = of(mode.measure)?.strata['category'] ?? {};
|
||||||
const total = Object.values(cells).reduce((n, c) => n + size(c), 0);
|
const total = Object.values(cells).reduce((n, c) => n + size(c), 0);
|
||||||
|
|||||||
@@ -202,41 +202,6 @@ export function detail(measure: Measure, r: Reading | undefined, unit = 'pacient
|
|||||||
|
|
||||||
const pct = (v?: number) => (v === undefined ? '—' : `${(v * 100).toFixed(1)} %`);
|
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)}<br>IC 95 %: ${pct(r.low)}–${pct(r.high)}<extra></extra>`,
|
|
||||||
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. */
|
/** A donut of one stratifier's counts (initial population), or of numerator vs the rest. */
|
||||||
export function donut(
|
export function donut(
|
||||||
measure: Measure,
|
measure: Measure,
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ const ppv = (measure: string, title: string, note: string, ...more: Mode[]): Rea
|
|||||||
footnote: true,
|
footnote: true,
|
||||||
note: `${note} Confirma la histología LIEBG o mayor.`,
|
note: `${note} Confirma la histología LIEBG o mayor.`,
|
||||||
modes: [
|
modes: [
|
||||||
{ kind: 'figure', label: 'Total', measure, figure: 'interval', colors: PPV_DONUT },
|
{ kind: 'ratio', label: 'Total', measure, colors: PPV_DONUT },
|
||||||
{
|
{
|
||||||
kind: 'shares',
|
kind: 'shares',
|
||||||
label: 'Citología previa',
|
label: 'Citología previa',
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { MatCardModule } from '@angular/material/card';
|
|||||||
import type { Measure } from 'fhir/r4';
|
import type { Measure } from 'fhir/r4';
|
||||||
import { Mode } from './bars';
|
import { Mode } from './bars';
|
||||||
import { scenarioBars } from './figures';
|
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 type { ReadingsCard, Section } from './pages';
|
||||||
import { Readings } from './readings';
|
import { Readings } from './readings';
|
||||||
|
|
||||||
@@ -175,7 +175,6 @@ export class ReadingsSection {
|
|||||||
const r = this.of().reading(mode.measure);
|
const r = this.of().reading(mode.measure);
|
||||||
const measure = this.of().measure(mode.measure);
|
const measure = this.of().measure(mode.measure);
|
||||||
if (!measure || !r?.populations['initial-population']) return undefined;
|
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);
|
if (mode.figure === 'donut') return donut(measure, r, 'category', mode.colors);
|
||||||
const categories = (mode.catalog ?? []).map((c) => ({ ...c, group: '' }));
|
const categories = (mode.catalog ?? []).map((c) => ({ ...c, group: '' }));
|
||||||
return scenarioBars(
|
return scenarioBars(
|
||||||
|
|||||||
@@ -25,5 +25,8 @@ 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(
|
||||||
|
'NCI, ingreso a LIEAG+',
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ 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;
|
||||||
|
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
|
// the platform's own models are the hospital's: its name, and the outcome without its synonym
|
||||||
return s.source === 'Institucional'
|
return s.source === 'Institucional'
|
||||||
? `ISSSTELEON, ${outcome.replace(' (CIN2+)', '')}`
|
? `ISSSTELEON, ${outcome.replace(' (CIN2+)', '')}`
|
||||||
|
|||||||
Reference in New Issue
Block a user