TEA Indicadores as the old page: the period summary in words, the three timeliness boxes, counts and age-group figures; tab named Resumen
This commit is contained in:
+4
-3
@@ -87,7 +87,7 @@ test("indicators: the KPIs are the API's MeasureReports, every tab and the patie
|
||||
const camaRows = page.locator('table.worklist tbody tr');
|
||||
await expect(camaRows.first()).toContainText('BI-RADS');
|
||||
await page.goto('/indicadores/tea');
|
||||
await expect(page.getByRole('tab', { name: 'Indicadores' })).toBeVisible();
|
||||
await expect(page.getByRole('tab', { name: 'Resumen' })).toBeVisible();
|
||||
expect(problems).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -184,7 +184,8 @@ test('conectar: someone who knows nothing of databases connects the SQL Server w
|
||||
* opportunity section on, in order, and the kind of each plot (its traces' types). */
|
||||
function captured(domain: string) {
|
||||
const path = `../tests/fixtures/reference/${domain}/ui/pages.json`;
|
||||
const items = JSON.parse(readFileSync(path, 'utf8')).tabs['Indicadores'] as any[];
|
||||
const tabs = JSON.parse(readFileSync(path, 'utf8')).tabs;
|
||||
const items = (tabs['Indicadores'] ?? tabs['Resumen']) as any[]; // TEA's first tab is its summary
|
||||
const from = items.findIndex((i) => i.text === 'Indicadores de oportunidad');
|
||||
return items
|
||||
.slice(from)
|
||||
@@ -194,7 +195,7 @@ function captured(domain: string) {
|
||||
const period = (text: string) => text.replace(/, \d{4}-(S[12]|\d{2})$/, ', <periodo>');
|
||||
const kindOf = (types: string[]) => [...new Set(types)].sort().join('+');
|
||||
|
||||
for (const domain of ['cacu', 'cama']) {
|
||||
for (const domain of ['cacu', 'cama', 'tea']) {
|
||||
test(`indicadores ${domain}: the old page's headings, in order, and the same kinds of plots`, async ({
|
||||
page,
|
||||
}) => {
|
||||
|
||||
@@ -326,3 +326,92 @@ export function shareDonut(r: Reading, catalog: Catalog, center: string): Figure
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/** A category's count per bar, one bar each, in the period. */
|
||||
export function countBars(r: Reading, catalog: Catalog, axis: string, period: string): Figure {
|
||||
const y = catalog.categories.map((c) => c.label);
|
||||
return {
|
||||
data: [
|
||||
{
|
||||
type: 'bar',
|
||||
orientation: 'h',
|
||||
name: period,
|
||||
y,
|
||||
x: catalog.categories.map((c) => counted(r, c.code)),
|
||||
marker: { color: catalog.categories.map((c) => c.color) },
|
||||
texttemplate: '%{x}',
|
||||
textposition: 'outside',
|
||||
hovertemplate: '%{y}: %{x}<extra></extra>',
|
||||
} as Partial<Plotly.Data>,
|
||||
],
|
||||
layout: {
|
||||
showlegend: false,
|
||||
xaxis: { title: { text: axis }, rangemode: 'tozero' },
|
||||
yaxis: { type: 'category', autorange: 'reversed', automargin: true },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const AGE_COLORS = ['#A8C243', '#42C29C', '#9C42C2', '#4269C2'];
|
||||
/** "16-23" as the screens say it: "16 a 23 meses". */
|
||||
export const ageLabel = (band: string) => band.replace(/^(\d+)-(\d+)$/, '$1 a $2 meses');
|
||||
|
||||
function ages(r: Reading): [string, Record<string, number>][] {
|
||||
return Object.entries(r.strata['age_group'] ?? {}).sort(
|
||||
([a], [b]) => parseInt(a, 10) - parseInt(b, 10),
|
||||
);
|
||||
}
|
||||
|
||||
/** By age group: the numerator and the rest of the denominator, stacked. */
|
||||
export function ageStack(r: Reading, names: [string, string]): Figure {
|
||||
const rows = ages(r);
|
||||
const x = rows.map(([a]) => ageLabel(a));
|
||||
return {
|
||||
data: [
|
||||
{
|
||||
type: 'bar',
|
||||
name: names[0],
|
||||
x,
|
||||
y: rows.map(([, c]) => c['numerator'] ?? 0),
|
||||
marker: { color: AGE_COLORS[0] },
|
||||
},
|
||||
{
|
||||
type: 'bar',
|
||||
name: names[1],
|
||||
x,
|
||||
y: rows.map(([, c]) => (c['denominator'] ?? 0) - (c['numerator'] ?? 0)),
|
||||
marker: { color: AGE_COLORS[1] },
|
||||
},
|
||||
] as Partial<Plotly.Data>[],
|
||||
layout: {
|
||||
barmode: 'stack',
|
||||
xaxis: { title: { text: 'Grupo de edad' }, type: 'category' },
|
||||
yaxis: { title: { text: 'Pacientes' }, rangemode: 'tozero' },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/** By age group: the numerator's share of the denominator, one bar each. */
|
||||
export function ageShare(r: Reading, axis: string): Figure {
|
||||
const rows = ages(r);
|
||||
return {
|
||||
data: [
|
||||
{
|
||||
type: 'bar',
|
||||
x: rows.map(([a]) => ageLabel(a)),
|
||||
y: rows.map(([, c]) =>
|
||||
c['denominator'] ? (100 * (c['numerator'] ?? 0)) / c['denominator'] : 0,
|
||||
),
|
||||
marker: { color: rows.map((_, i) => AGE_COLORS[i % AGE_COLORS.length]) },
|
||||
texttemplate: '%{y:.1f} %',
|
||||
textposition: 'outside',
|
||||
hovertemplate: '%{x}: %{y:.1f} %<extra></extra>',
|
||||
} as Partial<Plotly.Data>,
|
||||
],
|
||||
layout: {
|
||||
showlegend: false,
|
||||
xaxis: { title: { text: 'Grupo de edad' }, type: 'category' },
|
||||
yaxis: { title: { text: axis }, range: [0, 100], ticksuffix: ' %' },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import { Loading } from '../loading';
|
||||
<p class="muted empty">Este dominio todavía no tiene indicadores publicados.</p>
|
||||
} @else {
|
||||
<mat-tab-group mat-stretch-tabs="false" mat-align-tabs="center" animationDuration="0ms">
|
||||
<mat-tab label="Indicadores">
|
||||
<mat-tab [label]="domain() === 'tea' ? 'Resumen' : 'Indicadores'">
|
||||
<app-tab-indicadores [domain]="domain()" [measures]="measures.value()!" />
|
||||
</mat-tab>
|
||||
<mat-tab label="Trazabilidad">
|
||||
|
||||
@@ -20,7 +20,18 @@ export interface Kpi {
|
||||
export type Section =
|
||||
| { kind: 'route'; title: string; steps: { label: string; measure: string }[] }
|
||||
| { kind: 'figures'; title?: string; figures: FigureSpec[] }
|
||||
| { kind: 'boxes'; title: string; cards: { measure?: string; title: string }[] }
|
||||
| {
|
||||
kind: 'boxes';
|
||||
/** none: the boxes stand alone (TEA) */
|
||||
title?: string;
|
||||
cards: { measure?: string; title: string }[];
|
||||
/** the measure's own title under each card's (CaMa) */
|
||||
subtitles?: boolean;
|
||||
}
|
||||
/** Each figure in its own card, titled, two to a row (TEA). */
|
||||
| { kind: 'grid'; figures: FigureSpec[] }
|
||||
/** TEA's period summary in words, its numbers from the measures. */
|
||||
| { kind: 'tea-summary' }
|
||||
| ({ kind: 'card' } & Kpi);
|
||||
/** Figure titles may carry `{p}`, the applied period. */
|
||||
export type FigureSpec =
|
||||
@@ -32,6 +43,14 @@ export type FigureSpec =
|
||||
center: string;
|
||||
}
|
||||
| { kind: 'scenario-bars'; title: string; measure: string; catalog: Catalog; stratum: string }
|
||||
| { kind: 'counts'; title: string; measure: string; catalog: Catalog; axis: string }
|
||||
| {
|
||||
kind: 'age-stack' | 'age-share';
|
||||
title: string;
|
||||
measure: string;
|
||||
/** the numerator's and the rest's names (stack), or the axis (share) */
|
||||
names: [string, string];
|
||||
}
|
||||
| {
|
||||
kind: 'rates';
|
||||
title: string;
|
||||
@@ -128,6 +147,98 @@ const BREAST_BIOPSY: Catalog = {
|
||||
};
|
||||
|
||||
export const PAGES: Record<string, Page> = {
|
||||
tea: {
|
||||
anchor: 'M23_PACIENTES_EVALUADOS',
|
||||
kpis: [],
|
||||
opportunity: [
|
||||
{ kind: 'tea-summary' },
|
||||
{
|
||||
kind: 'boxes',
|
||||
cards: [
|
||||
{ measure: 'M26_DIAS_MCHAT_ADOS2', title: 'Días de M-CHAT a ADOS-2' },
|
||||
{ measure: 'M27_DIAS_ADOS2_DIAGNOSTICO', title: 'Días de ADOS-2 a diagnóstico' },
|
||||
{ measure: 'M25_DIAS_MCHAT_DIAGNOSTICO', title: 'Días de M-CHAT a diagnóstico positivo' },
|
||||
],
|
||||
},
|
||||
],
|
||||
clinical: [
|
||||
{
|
||||
kind: 'grid',
|
||||
figures: [
|
||||
{
|
||||
kind: 'counts',
|
||||
title: 'Pacientes evaluados por resultado diagnóstico',
|
||||
measure: 'M23_PACIENTES_EVALUADOS',
|
||||
axis: 'Conteo (paciente)',
|
||||
catalog: {
|
||||
groups: [],
|
||||
categories: [
|
||||
{ code: 'confirmed', label: 'Diagnóstico confirmado', color: OLIVE, group: '' },
|
||||
{ code: 'in_process', label: 'En proceso', color: '#B8433A', group: '' },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'age-stack',
|
||||
title: 'Porcentaje de confirmación diagnóstica',
|
||||
measure: 'M24_CONFIRMACION_DIAGNOSTICO',
|
||||
names: ['Diagnóstico confirmado', 'En proceso'],
|
||||
},
|
||||
{
|
||||
kind: 'age-share',
|
||||
title: 'Porcentaje de pacientes con diagnóstico de TEA con EEG',
|
||||
measure: 'M21_DIAGNOSTICADOS_CON_EEG',
|
||||
names: ['% de pacientes con EEG', ''],
|
||||
},
|
||||
{
|
||||
kind: 'age-share',
|
||||
title: 'Porcentaje de pacientes con diagnóstico de TEA sin EEG',
|
||||
measure: 'M22_DIAGNOSTICADOS_SIN_EEG',
|
||||
names: ['% de pacientes sin EEG', ''],
|
||||
},
|
||||
{
|
||||
kind: 'counts',
|
||||
title: 'Casos por estatus',
|
||||
measure: 'M28_CASOS_POR_ESTADO',
|
||||
axis: 'Conteo (paciente)',
|
||||
catalog: {
|
||||
groups: [],
|
||||
categories: [
|
||||
{ code: 'mchat_only', label: 'Solo M-CHAT', color: '#B8433A', group: '' },
|
||||
{
|
||||
code: 'psychology',
|
||||
label: 'Hasta evaluación psicológica',
|
||||
color: '#42C29C',
|
||||
group: '',
|
||||
},
|
||||
{
|
||||
code: 'neuropediatrics',
|
||||
label: 'Hasta evaluación neuropediátrica',
|
||||
color: '#7184A2',
|
||||
group: '',
|
||||
},
|
||||
{ code: 'eeg', label: 'Con EEG', color: OLIVE, group: '' },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'counts',
|
||||
title: 'Calidad del EEG',
|
||||
measure: 'M29_CALIDAD_EEG',
|
||||
axis: 'Conteo (examen)',
|
||||
catalog: {
|
||||
groups: [],
|
||||
categories: [
|
||||
{ code: 'good', label: 'Bueno', color: OLIVE, group: '' },
|
||||
{ code: 'bad', label: 'No aceptable', color: '#B8433A', group: '' },
|
||||
{ code: 'not_analyzed', label: 'Sin analizar', color: '#C9CDD2', group: '' },
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
cama: {
|
||||
anchor: 'CAMA_BIRADS456_PACIENTE',
|
||||
kpis: [
|
||||
@@ -163,6 +274,7 @@ export const PAGES: Record<string, Page> = {
|
||||
{
|
||||
kind: 'boxes',
|
||||
title: 'Tiempo de tamizaje a diagnóstico',
|
||||
subtitles: true,
|
||||
cards: [
|
||||
{
|
||||
measure: 'CAMA_EU38A',
|
||||
|
||||
@@ -83,9 +83,60 @@
|
||||
<p class="state">Sin tiempos publicados en el periodo.</p>
|
||||
}
|
||||
}
|
||||
@case ('tea-summary') {
|
||||
@if (teaSummary(); as t) {
|
||||
<mat-card appearance="outlined" class="summary">
|
||||
<mat-card-content>
|
||||
<h2 class="box-title">Resumen</h2>
|
||||
<p>
|
||||
Al cierre del periodo <mark>{{ period }}</mark>, se evaluaron
|
||||
<mark>{{ t.evaluated }}</mark> niños entre 16 y 36 meses;
|
||||
<mark>{{ t.mchatOnly }}</mark> únicamente tienen M-CHAT,
|
||||
<mark>{{ t.psychology }}</mark> hasta la evaluación psicológica y
|
||||
<mark>{{ t.neuropediatrics }}</mark> presentan evaluación neuropediátrica. En este
|
||||
periodo el <mark>{{ t.confirmed }}</mark> de los pacientes tiene diagnóstico
|
||||
confirmado de TEA (CIE-10 F84.0). Las ventanas de tiempo<sup>*</sup> de tamizaje
|
||||
son: <mark>{{ t.toAdos }}</mark> de M-CHAT (psicología) a ADOS-2,
|
||||
<mark>{{ t.toDiagnosis }}</mark> de ADOS-2 a diagnóstico. El tiempo<sup>*</sup> de
|
||||
tamizaje completo de M-CHAT a diagnóstico fue de <mark>{{ t.whole }}</mark>.
|
||||
</p>
|
||||
<p>
|
||||
De los <mark>{{ t.diagnosed }}</mark> niños con diagnóstico confirmado en este
|
||||
periodo, <mark>{{ t.eeg }}</mark> presentan estudio de EEG y faltan
|
||||
<mark>{{ t.missing }}</mark> por realizarlo. <mark>{{ t.unusable }}</mark> estudios
|
||||
de EEG no son aceptables para un análisis.
|
||||
</p>
|
||||
<p class="state">*tomando la mediana de los tiempos</p>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
} @else if (reports.isLoading()) {
|
||||
<app-loading what="el resumen del periodo" />
|
||||
}
|
||||
}
|
||||
@case ('grid') {
|
||||
<div class="grid-figures">
|
||||
@for (f of section.figures; track f.title) {
|
||||
<mat-card appearance="outlined" class="figure-card" [attr.data-figure]="f.kind">
|
||||
<mat-card-content>
|
||||
<h2 class="box-title">{{ f.title }}</h2>
|
||||
<p class="state">Filtro general aplicado: {{ period }}</p>
|
||||
@if (reports.isLoading()) {
|
||||
<app-loading what="la figura" [figure]="true" />
|
||||
} @else if (figureOf(f); as fig) {
|
||||
<app-plot [figure]="fig" [height]="320" />
|
||||
} @else {
|
||||
<div class="empty-figure">Sin datos publicados</div>
|
||||
}
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@case ('boxes') {
|
||||
<h3 class="boxes-title">{{ section.title }}</h3>
|
||||
<div class="box-grid">
|
||||
@if (section.title) {
|
||||
<h3 class="boxes-title">{{ section.title }}</h3>
|
||||
}
|
||||
<div class="box-grid" [class.standalone]="!section.title">
|
||||
@for (b of section.cards; track b.title) {
|
||||
<mat-card
|
||||
appearance="outlined"
|
||||
@@ -99,8 +150,10 @@
|
||||
<div class="empty-figure">Sin datos publicados</div>
|
||||
} @else {
|
||||
<p class="state">Filtro general aplicado: {{ period }}</p>
|
||||
<h2 class="box-subtitle">{{ measureTitle(b.measure) }}</h2>
|
||||
<p class="state">Figura: Caja de cuartiles</p>
|
||||
@if (section.subtitles) {
|
||||
<h2 class="box-subtitle">{{ measureTitle(b.measure) }}</h2>
|
||||
<p class="state">Figura: Caja de cuartiles</p>
|
||||
}
|
||||
@if (reports.isLoading()) {
|
||||
<app-loading what="la figura" [figure]="true" />
|
||||
} @else if (boxOf(b.measure); as fig) {
|
||||
|
||||
@@ -241,3 +241,45 @@ h2.box-subtitle {
|
||||
.kpi.closing {
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.summary {
|
||||
margin-bottom: 24px;
|
||||
|
||||
p {
|
||||
font-size: 20px;
|
||||
line-height: 2.1;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
p.state {
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
mark {
|
||||
background: #f1f5df;
|
||||
border: 1px solid #d8e3a8;
|
||||
border-radius: 4px;
|
||||
font-weight: 700;
|
||||
padding: 1px 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.grid-figures {
|
||||
display: grid;
|
||||
gap: 24px;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
@media (min-width: 1100px) {
|
||||
.grid-figures {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1000px) {
|
||||
.box-grid.standalone {
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,10 @@ import { Fhir, resources } from '../fhir';
|
||||
import { Figure, Plot } from '../plot';
|
||||
import { LAYOUTS } from './layout';
|
||||
import {
|
||||
ageShare,
|
||||
ageStack,
|
||||
boxFigure,
|
||||
countBars,
|
||||
fill,
|
||||
nestedDonut,
|
||||
rateDots,
|
||||
@@ -215,6 +218,40 @@ export class TabIndicadores {
|
||||
const r = measure ? this.rd(measure) : undefined;
|
||||
return r && r.score !== undefined ? boxFigure(r, this.applied() ?? '') : undefined;
|
||||
}
|
||||
/** TEA's summary of the period: its numbers from the measures (none: no summary). */
|
||||
protected readonly teaSummary = computed(() => {
|
||||
const rd = (c: string) => this.reports.value()?.get(c);
|
||||
const status = rd('M28_CASOS_POR_ESTADO');
|
||||
if (!status) return undefined;
|
||||
const n = (r: Reading | undefined, pop: string) => r?.populations[pop] ?? 0;
|
||||
const cat = (r: Reading | undefined, c: string) =>
|
||||
r?.strata['category']?.[c]?.['initial-population'] ?? 0;
|
||||
const days = (c: string) => {
|
||||
const v = rd(c)?.score;
|
||||
return v === undefined
|
||||
? '—'
|
||||
: `${v.toLocaleString('es-MX', { maximumFractionDigits: 1 })} días`;
|
||||
};
|
||||
const confirmed = rd('M24_CONFIRMACION_DIAGNOSTICO')?.score;
|
||||
const withEeg = rd('M21_DIAGNOSTICADOS_CON_EEG');
|
||||
return {
|
||||
evaluated: n(status, 'initial-population'),
|
||||
mchatOnly: cat(status, 'mchat_only'),
|
||||
psychology: cat(status, 'psychology'),
|
||||
neuropediatrics: cat(status, 'neuropediatrics') + cat(status, 'eeg'),
|
||||
confirmed:
|
||||
confirmed === undefined
|
||||
? '—'
|
||||
: `${(confirmed * 100).toLocaleString('es-MX', { maximumFractionDigits: 1 })}%`,
|
||||
toAdos: days('M26_DIAS_MCHAT_ADOS2'),
|
||||
toDiagnosis: days('M27_DIAS_ADOS2_DIAGNOSTICO'),
|
||||
whole: days('M25_DIAS_MCHAT_DIAGNOSTICO'),
|
||||
diagnosed: n(withEeg, 'denominator'),
|
||||
eeg: n(withEeg, 'numerator'),
|
||||
missing: n(rd('M22_DIAGNOSTICADOS_SIN_EEG'), 'numerator'),
|
||||
unusable: cat(rd('M29_CALIDAD_EEG'), 'bad'),
|
||||
};
|
||||
});
|
||||
protected measureTitle(code: string | undefined): string {
|
||||
return (code && this.byName().get(code)?.title) || '';
|
||||
}
|
||||
@@ -232,6 +269,12 @@ export class TabIndicadores {
|
||||
return nestedDonut(r, spec.catalog, spec.center);
|
||||
case 'share-donut':
|
||||
return shareDonut(r, spec.catalog, spec.center);
|
||||
case 'counts':
|
||||
return countBars(r, spec.catalog, spec.axis, this.applied() ?? '');
|
||||
case 'age-stack':
|
||||
return ageStack(r, spec.names);
|
||||
case 'age-share':
|
||||
return ageShare(r, spec.names[0]);
|
||||
case 'scenario-bars':
|
||||
return scenarioBars(r, spec.catalog, spec.stratum, name);
|
||||
case 'rates':
|
||||
|
||||
Reference in New Issue
Block a user