From 6ea54d6e6d9909502a76f6fe83d868fc2dcf68ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Trevi=C3=B1o?= Date: Sat, 28 Nov 2026 17:24:29 -0600 Subject: [PATCH] Trazabilidad, Datos y definiciones and the risk lists as the old app: declared panels, old labels and order; page tests against the capture --- e2e/pages.spec.ts | 56 +++++++ src/app/indicadores/figures.ts | 67 +++++++- src/app/indicadores/indicadores.ts | 2 +- src/app/indicadores/pages.ts | 200 +++++++++++++++++++++++ src/app/indicadores/tab-definiciones.ts | 138 ++++++++++++---- src/app/indicadores/tab-riesgos.html | 80 ++++++--- src/app/indicadores/tab-riesgos.scss | 14 ++ src/app/indicadores/tab-riesgos.ts | 28 +++- src/app/indicadores/tab-seguimiento.html | 41 +++-- src/app/indicadores/tab-seguimiento.ts | 19 ++- src/app/indicadores/tab-trazabilidad.ts | 129 ++++++++++----- 11 files changed, 654 insertions(+), 120 deletions(-) diff --git a/e2e/pages.spec.ts b/e2e/pages.spec.ts index 5c15f58..0528658 100644 --- a/e2e/pages.spec.ts +++ b/e2e/pages.spec.ts @@ -227,3 +227,59 @@ for (const domain of ['cacu', 'cama', 'tea']) { for (const types of drawn) expect(kinds).toContain(kindOf(types)); }); } + +for (const domain of ['cacu', 'cama', 'tea']) { + test(`trazabilidad ${domain}: the old tab's panels, in order, and the same kinds of plots`, async ({ + page, + }) => { + const tabs = JSON.parse( + readFileSync(`../tests/fixtures/reference/${domain}/ui/pages.json`, 'utf8'), + ).tabs; + const old = (tabs['Trazabilidad'] as any[]).filter((i) => + ['h2', 'h3', 'plot'].includes(i.kind), + ); + await page.goto(`/indicadores/${domain}`); + await page.getByRole('tab', { name: 'Trazabilidad' }).click(); + const tab = page.locator('app-tab-trazabilidad'); + await expect(tab.getByRole('heading', { name: 'Filtros' })).toBeVisible(); + await expect(tab.locator('app-loading')).toHaveCount(0, { timeout: 5 * 60_000 }); + const headings = await tab + .locator('h2, h3') + .evaluateAll((els) => els.map((e) => (e as HTMLElement).innerText.trim())); + expect(headings).toEqual(old.filter((i) => i.kind !== 'plot').map((i) => i.text)); + const drawn = await tab + .locator('.js-plotly-plot') + .evaluateAll((els) => + els.map((e: any) => (e.data ?? []).map((t: any) => t.type ?? 'scatter')), + ); + const kinds = new Set( + old.filter((i) => i.kind === 'plot').map((i) => kindOf(i.traces.map((t: any) => t.type))), + ); + for (const types of drawn) expect(kinds).toContain(kindOf(types)); + }); +} + +for (const domain of ['cacu', 'cama', 'tea']) { + test(`datos y definiciones ${domain}: the old tab's headings and an indicator that opens`, async ({ + page, + }) => { + const tabs = JSON.parse( + readFileSync(`../tests/fixtures/reference/${domain}/ui/pages.json`, 'utf8'), + ).tabs; + const old = (tabs['Datos y definiciones'] as any[]) + .filter((i) => ['h2', 'h3'].includes(i.kind)) + .map((i) => i.text); + await page.goto(`/indicadores/${domain}`); + await page.getByRole('tab', { name: 'Datos y definiciones' }).click(); + const tab = page.locator('app-tab-definiciones'); + await expect(tab.getByRole('heading', { name: 'Catálogo de indicadores' })).toBeVisible(); + const headings = await tab + .locator('h2, h3') + .evaluateAll((els) => els.map((e) => (e as HTMLElement).innerText.trim())); + expect(headings).toEqual(old); + await tab.locator('summary').first().click(); + await expect( + tab.getByRole('heading', { name: 'Tipos de periodo admitidos' }).first(), + ).toBeVisible(); + }); +} diff --git a/src/app/indicadores/figures.ts b/src/app/indicadores/figures.ts index 068bd04..f6adafb 100644 --- a/src/app/indicadores/figures.ts +++ b/src/app/indicadores/figures.ts @@ -1,6 +1,6 @@ -import type { Figure } from '../plot'; -import type { Reading } from './measures'; -import type { Catalog, Category } from './pages'; +import { type Figure, PALETTE } from '../plot'; +import { name, type Reading } from './measures'; +import type { Catalog, Category, HistoryPanel } from './pages'; const OLIVE = '#A8C243'; const ROSE = '#C24269'; @@ -415,3 +415,64 @@ export function ageShare(r: Reading, axis: string): Figure { }, }; } + +/** A Trazabilidad panel's figure (pages.HISTORY), as the old tab drew it: stacked bars by + * category, or a line with its band (95 % interval, or first to third quartile) drawn as one + * closed shape. */ +export function historyFigure( + panel: HistoryPanel, + series: { label: string; r: Reading | undefined }[], + line: string, + xTitle: string, +): Figure { + const x = series.map((s) => s.label); + const layout = (y: string) => ({ + xaxis: { title: { text: xTitle }, type: 'category' as const }, + yaxis: { title: { text: y } }, + }); + if (panel.kind === 'stack') { + const found = [...new Set(series.flatMap((s) => Object.keys(s.r?.strata['category'] ?? {})))]; + const declared = panel.series ?? []; + const named = [ + ...declared, + ...found + .filter((c) => !declared.some((d) => d.code === c)) + .map((c, i) => ({ code: c, label: name(c), color: PALETTE[i % PALETTE.length] })), + ]; + return { + data: named.map((c) => ({ + type: 'bar', + name: c.label, + x, + y: series.map((s) => s.r?.strata['category']?.[c.code]?.['initial-population'] ?? 0), + marker: { color: c.color }, + })), + layout: { ...layout(panel.axis ?? 'Pacientes'), barmode: 'stack' }, + }; + } + const k = panel.kind === 'percent' ? 100 : 1; + const at = (v?: number) => (v === undefined ? null : v * k); + return { + data: [ + { + x: [...x, ...[...x].reverse()], + y: [...series.map((s) => at(s.r?.high)), ...[...series].reverse().map((s) => at(s.r?.low))], + mode: 'lines', + fill: 'toself', + fillcolor: line + '33', + line: { width: 0 }, + name: panel.kind === 'percent' ? 'Intervalo de confianza' : 'Primer a tercer cuartil', + hoverinfo: 'skip', + }, + { + x, + y: series.map((s) => at(s.r?.score)), + mode: 'lines+markers', + name: panel.kind === 'percent' ? 'Porcentaje' : 'Mediana', + line: { color: line }, + marker: { color: line }, + }, + ], + layout: layout(panel.kind === 'percent' ? 'Porcentaje' : 'Días'), + }; +} diff --git a/src/app/indicadores/indicadores.ts b/src/app/indicadores/indicadores.ts index 032b54f..eb103a3 100644 --- a/src/app/indicadores/indicadores.ts +++ b/src/app/indicadores/indicadores.ts @@ -65,7 +65,7 @@ import { Loading } from '../loading'; } - + diff --git a/src/app/indicadores/pages.ts b/src/app/indicadores/pages.ts index cf7636f..3875143 100644 --- a/src/app/indicadores/pages.ts +++ b/src/app/indicadores/pages.ts @@ -428,3 +428,203 @@ export const PAGES: Record = { ], }, }; + +/** One panel of Trazabilidad (tests/fixtures/reference//ui, tab "Trazabilidad"): a + * measure month by month, as stacked counts by category, a percentage with its 95 % interval, + * or a median with its quartiles. `group` heads a run of panels (TEA's "Tiempos del tamizaje"). */ +export interface HistoryPanel { + title: string; + measure: string; + kind: 'stack' | 'percent' | 'median'; + /** stack: the categories, in the old order, with their names and colours */ + series?: { code: string; label: string; color: string }[]; + /** stack: the y axis */ + axis?: string; + group?: string; +} +export interface History { + panels: HistoryPanel[]; + /** the line's colour (percent and median) */ + line: string; + /** how many of the latest months the tab opens with (none: from the first with data) */ + months?: number; +} + +const GREY = '#C9CDD2'; +const stack = ( + title: string, + measure: string, + axis: string, + series: [string, string, string][], +): HistoryPanel => ({ + title, + measure, + kind: 'stack', + axis, + series: series.map(([code, label, color]) => ({ code, label, color })), +}); +const BIRADS_SERIES: [string, string, string][] = [ + ['4A', 'BI-RADS 4A', '#C24269'], + ['4B', 'BI-RADS 4B', '#9C42C2'], + ['4C', 'BI-RADS 4C', '#5C42C2'], + ['5', 'BI-RADS 5', '#C2429C'], + ['6', 'BI-RADS 6', '#8E2F62'], + ['4', 'BI-RADS 4 (sin subcategoría)', '#7A3496'], +]; + +export const HISTORY: Record = { + cacu: { + line: '#6A8000', + months: 5, + panels: [ + stack('Distribución de resultados citológicos', 'CACU_EU7', 'Pacientes', [ + ['NILM', 'Normal', '#9DBFE3'], + ['ASC-US', 'ASC-US', '#2F6DB3'], + ['LSIL', 'LIEBG', '#9C42C2'], + ['ASC-H', 'ASC-H', '#5C42C2'], + ['HSIL', 'LIEAG', '#C2429C'], + ['CIS', 'Carcinoma in situ', '#8E2F62'], + ['no_data', 'Sin dato', GREY], + ]), + { title: 'Pacientes con citología anómala', measure: 'IND1', kind: 'percent' }, + { title: 'Tasa de detección histopatológica', measure: 'CACU_EU13', kind: 'percent' }, + stack( + 'Resultado de biopsia tras citología de alto grado', + 'CACU_CONFIRMACION_CITOLOGIA', + 'Pacientes', + [ + ['normal', 'Normal', '#9DBFE3'], + ['LSIL', 'LIEBG (CIN 1)', '#69C242'], + ['HSIL', 'LIEAG (CIN 2 y 3)', '#C24269'], + ['CIS', 'Carcinoma in situ', '#9C42C2'], + ['carcinoma', 'Carcinoma invasor', '#5C42C2'], + ['no_biopsy', 'Sin biopsia aún', GREY], + ['no_data', 'Biopsia sin grado', GREY], + ], + ), + { + title: 'Días de la toma de la citología a su resultado', + measure: 'CACU_EU_TIEMPO_REPORTE', + kind: 'median', + }, + { + title: 'Tiempo de tamizaje a diagnóstico', + measure: 'CACU_DIAS_TOMA_DIAGNOSTICO', + kind: 'median', + }, + { + title: 'Tiempo de tamizaje a tratamiento', + measure: 'CACU_DIAS_TOMA_TRATAMIENTO', + kind: 'median', + }, + { + title: 'Tiempo de diagnóstico a tratamiento', + measure: 'CACU_DIAS_DIAGNOSTICO_TRATAMIENTO', + kind: 'median', + }, + { + title: 'Riesgo CIN2+ por banda', + measure: 'CACU_RIESGO_BANDA', + kind: 'stack', + axis: 'Pacientes', + }, + ], + }, + cama: { + line: '#9C42C2', + panels: [ + { + title: 'Días de la toma de la mastografía a su resultado', + measure: 'CAMA_EU38A', + kind: 'median', + }, + { + title: 'Días del resultado de la mastografía al diagnóstico', + measure: 'CAMA_DIAS_RESULTADO_DIAGNOSTICO', + kind: 'median', + }, + { + title: 'Días de tamizaje a diagnóstico', + measure: 'CAMA_DIAS_TOMA_DIAGNOSTICO', + kind: 'median', + }, + stack( + 'Porcentaje de mastografías con resultado BI-RADS 4, 5 ó 6', + 'CAMA_BIRADS456_MASTOGRAFIA', + 'Mastografías', + BIRADS_SERIES, + ), + stack( + 'Pacientes con resultado BI-RADS 4, 5 ó 6', + 'CAMA_BIRADS456_PACIENTE', + 'Pacientes', + BIRADS_SERIES, + ), + stack('Resultado histopatológico', 'CAMA_HISTOPATOLOGIA_BIRADS', 'Pacientes', [ + ['benign', 'Benigno', '#9DBFE3'], + ['in_situ', 'Carcinoma in situ', '#C24269'], + ['invasive', 'Carcinoma invasor', '#9C42C2'], + ['no_biopsy', 'Sin biopsia reportada', GREY], + ['no_data', 'Sin dato', GREY], + ]), + { + title: 'Tasa de confirmación histopatológica', + measure: 'CAMA_CONFIRMACION_BIRADS45', + kind: 'percent', + }, + ], + }, + tea: { + line: '#9C42C2', + panels: [ + { + group: 'Tiempos del tamizaje', + title: 'Días de M-CHAT a ADOS-2', + measure: 'M26_DIAS_MCHAT_ADOS2', + kind: 'median', + }, + { + group: 'Tiempos del tamizaje', + title: 'Días de ADOS-2 a diagnóstico', + measure: 'M27_DIAS_ADOS2_DIAGNOSTICO', + kind: 'median', + }, + { + group: 'Tiempos del tamizaje', + title: 'Días de M-CHAT a diagnóstico positivo', + measure: 'M25_DIAS_MCHAT_DIAGNOSTICO', + kind: 'median', + }, + stack('Progresión del proceso diagnóstico', 'M23_PACIENTES_EVALUADOS', 'Pacientes', [ + ['confirmed', 'Diagnóstico confirmado', '#A8C243'], + ['in_process', 'En proceso', '#B8433A'], + ]), + { + title: 'Porcentaje de confirmación diagnóstica', + measure: 'M24_CONFIRMACION_DIAGNOSTICO', + kind: 'percent', + }, + { + title: 'Porcentaje de pacientes con diagnóstico de TEA con EEG', + measure: 'M21_DIAGNOSTICADOS_CON_EEG', + kind: 'percent', + }, + { + title: 'Porcentaje de pacientes con diagnóstico de TEA sin EEG', + measure: 'M22_DIAGNOSTICADOS_SIN_EEG', + kind: 'percent', + }, + stack('Flujo del proceso diagnóstico y estudios de EEG', 'M28_CASOS_POR_ESTADO', 'Casos', [ + ['mchat_only', 'Solo M-CHAT', '#B8433A'], + ['psychology', 'Hasta evaluación psicológica', '#42C29C'], + ['neuropediatrics', 'Hasta evaluación neuropediátrica', '#7184A2'], + ['eeg', 'Con EEG', '#A8C243'], + ]), + stack('Calidad del EEG', 'M29_CALIDAD_EEG', 'Estudios de EEG', [ + ['good', 'Bueno', '#A8C243'], + ['bad', 'No aceptable', '#B8433A'], + ['not_analyzed', 'Sin analizar', GREY], + ]), + ], + }, +}; diff --git a/src/app/indicadores/tab-definiciones.ts b/src/app/indicadores/tab-definiciones.ts index a806cfd..07523bc 100644 --- a/src/app/indicadores/tab-definiciones.ts +++ b/src/app/indicadores/tab-definiciones.ts @@ -1,5 +1,7 @@ -import { Component, input } from '@angular/core'; +import { Component, computed, input } from '@angular/core'; import type { Measure } from 'fhir/r4'; +import { DOMAINS } from '../app'; +import type { Domain } from '../api/models/domain'; import { code, label } from '../fhir'; import { periodTypes, STRATA } from './measures'; @@ -14,48 +16,120 @@ const IMPROVEMENT: Record = { }; const PERIODS: Record = { semester: 'Semestral', month: 'Mensual' }; -/** What each measure is: how it scores, which way is better, its periods and strata. */ +/** "Datos y definiciones" as the old tab: the domain's information, then its catalog, each + * indicator opening to what it is (how it scores, which way is better, its periods and + * strata). */ @Component({ selector: 'app-tab-definiciones', template: ` - - - - - - - - - - - - - @for (m of measures(); track m.id) { - - - - - - - - +
+

Datos y definiciones de {{ domainName() }}

+
+

Información del dominio

+ @if (domain() === 'cacu') { +

+ Pacientes evaluadas incluye a las pacientes con citología tomada en el periodo cuyo + espécimen fue insatisfactorio. +

} -
-
IndicadorClaveCálculoMejoraPeriodosEstratos
{{ m.title }} - {{ m.name }} v{{ m.version }} - {{ scoring[code(m.scoring) ?? ''] }}{{ improvement[code(m.improvementNotation) ?? ''] ?? '—' }}{{ types(m) }}{{ strata(m) }}
+ @if (available().length) { +

Periodicidad disponible: {{ available().join(', ') }}.

+ } @else { +

Periodicidad: pendiente de información.

+ } + +
+

Catálogo de indicadores

+

Consulta las gráficas disponibles y la periodicidad de cada indicador.

+ @for (m of measures(); track m.id) { +
+ {{ m.title || 'Nombre pendiente de publicación' }} +
+ @if (m.description) { +

{{ m.description }}

+ } +

Cálculo

+

+ {{ scoring[code(m.scoring) ?? ''] }} + @if (improvement[code(m.improvementNotation) ?? '']; as better) { + · {{ better }} + } +

+

Tipos de periodo admitidos

+ @if (types(m).length) { +
    + @for (t of types(m); track t) { +
  • {{ t }}
  • + } +
+ } @else { +

Pendiente de información.

+ } +

Estratos

+

{{ strata(m) }}

+

+ Clave {{ m.name }} · versión {{ m.version }} +

+
+
+ } @empty { +

+ No hay indicadores disponibles en el catálogo. Las definiciones están pendientes de + información. +

+ } +
+ + `, + styles: ` + :host { + display: block; + padding-top: 16px; + } + .card { + background: var(--mat-sys-surface); + border: 1px solid var(--mat-sys-outline-variant); + border-radius: 12px; + padding: 16px 20px; + } + h2, + h3 { + font-size: 20px; + font-weight: 500; + } + h4 { + font-size: 14px; + font-weight: 500; + margin: 12px 0 4px; + } + details { + border-bottom: 1px solid var(--mat-sys-outline-variant); + padding: 8px 0; + } + summary { + cursor: pointer; + font-weight: 500; + } + .indicator-detail { + padding: 4px 0 8px 16px; + } `, - styles: ':host { display: block; padding-top: 16px; overflow-x: auto; }', }) export class TabDefiniciones { + readonly domain = input.required(); readonly measures = input.required(); protected readonly scoring = SCORING; protected readonly improvement = IMPROVEMENT; protected readonly code = code; - protected types(m: Measure): string { - return periodTypes(m) - .map((p) => PERIODS[p] ?? p) - .join(', '); + protected readonly domainName = computed( + () => DOMAINS[this.domain() as Domain]?.toLocaleLowerCase('es-MX') ?? this.domain(), + ); + /** The periodicities any of its indicators admits. */ + protected readonly available = computed(() => + [...new Set(this.measures().flatMap((m) => periodTypes(m)))].map((p) => PERIODS[p] ?? p), + ); + protected types(m: Measure): string[] { + return periodTypes(m).map((p) => PERIODS[p] ?? p); } protected strata(m: Measure): string { const names = (m.group?.[0]?.stratifier ?? []).map((s) => code(s.code) ?? label(s.code)); diff --git a/src/app/indicadores/tab-riesgos.html b/src/app/indicadores/tab-riesgos.html index 6caf560..12223b6 100644 --- a/src/app/indicadores/tab-riesgos.html +++ b/src/app/indicadores/tab-riesgos.html @@ -10,7 +10,7 @@ /> - Ventana + Ventana de meses @for (m of [1, 3, 6, 12]; track m) { {{ m }} {{ m === 1 ? 'mes' : 'meses' }} @@ -18,7 +18,7 @@ - Estatus + Estatus de seguimiento Todos @for (s of statuses; track s) { @@ -27,7 +27,7 @@ - Horizonte + Horizonte de la probabilidad @for (h of [1, 2, 3, 4, 5]; track h) { {{ h }} {{ h === 1 ? 'año' : 'años' }} @@ -35,7 +35,7 @@ - Orden + Ordenar por Estudio más reciente Mayor riesgo de LIEAG+ @@ -43,7 +43,7 @@ - Por página + Registros por página @for (n of [20, 50, 100]; track n) { {{ n }} @@ -53,22 +53,33 @@ @if (error()) { - + +} @else if (!page() || loading()) { + +} @else if (applied()) { +

Ventana consultada: {{ start() }} al {{ applied() }}.

}
+ - + - - - - - + + + + + + @@ -86,7 +97,6 @@ - + + } @empty { - + } @@ -136,8 +165,7 @@
@if (page()?.total; as total) { - {{ offset() + 1 }}–{{ offset() + rows().length }} de {{ total }} pacientes · corte - {{ applied() }} + Página {{ pageNumber() }} de {{ pageCount() }}, {{ total }} registros } +

+} @else if (!page() || loading()) { + +} @else if (applied()) { +

Ventana consultada: {{ start() }} al {{ applied() }}.

}
+ Resultados disponibles por paciente +
Paciente Grupo de edadEstatusEstatus de seguimiento Última citologíaVPHBiopsiaRiesgo LIEAG+ ({{ horizon() }} a)Riesgo cáncer ({{ horizon() }} a)Días toma → diagnósticoÚltimo resultado de VPHÚltima biopsiaProbabilidad a LIEAG+ a {{ horizon() }} {{ horizon() === 1 ? 'año' : 'años' }} (%)Probabilidad a cáncer a {{ horizon() }} {{ horizon() === 1 ? 'año' : 'años' }} (%)Estudio más recienteDías de toma a diagnóstico
{{ name(row.status) }} @if (row.cytology; as c) { - {{ c.date }} · {{ c.result ? name(c.result) @@ -94,39 +104,58 @@ ? 'Insatisfactoria' : 'Pendiente' }} + Fecha: {{ c.date }} + Calidad: {{ c.adequacy ? name(c.adequacy) : '—' }} } @else { - — + No disponible } @if (row.hpv; as h) { - {{ h.positive ? 'Positivo' : 'Negativo' }}{{ h.types1618 ? ' (16/18)' : '' }} + {{ h.positive ? 'Positivo' : 'Negativo' }} + Fecha: {{ h.date }} + Genotipo 16/18: + {{ + h.types1618 === undefined + ? 'No disponible' + : h.types1618 + ? 'Presente' + : 'No detectado' + }} } @else { - — + No disponible } @if (row.biopsy; as b) { - {{ b.date }} · {{ name(b.histology ?? '') || 'Sin dato' }} + {{ name(b.histology ?? '') || 'Sin grado' }} + Fecha: {{ b.date }} } @else { - — + No disponible } - {{ row.risk.cin2 === undefined ? '—' : (row.risk.cin2 * 100 | number: '1.1-1') + ' %' }} + {{ + row.risk.cin2 === undefined + ? 'No disponible' + : (row.risk.cin2 * 100 | number: '1.1-1') + ' %' + }} {{ - row.risk.cancer === undefined ? '—' : (row.risk.cancer * 100 | number: '1.1-1') + ' %' + row.risk.cancer === undefined + ? 'No disponible' + : (row.risk.cancer * 100 | number: '1.1-1') + ' %' }} {{ row.daysToDiagnosis ?? '—' }}{{ latest(row) ?? 'No disponible' }}{{ row.daysToDiagnosis ?? 'No disponible' }}
- {{ page() ? 'Nadie en la lista con estos filtros.' : 'Cargando…' }} - No hay registros para los filtros aplicados.
+ - - - + + + @@ -64,12 +74,16 @@ } - + @@ -77,9 +91,7 @@ } @empty { - + } @@ -89,8 +101,7 @@
@if (page()?.total; as total) { - {{ offset() + 1 }}–{{ offset() + rows().length }} de {{ total }} pacientes · corte - {{ applied() }} + Página {{ pageNumber() }} de {{ pageCount() }}, {{ total }} registros } +

+ } @else { + @for (d of drawn(); track d.panel.measure) { + @if (d.heading) { +

{{ d.heading }}

+ } +
+ @if (d.panel.group) { +

{{ d.panel.title }}

+ } @else { +

{{ d.panel.title }}

+ } + @if (d.figure) { + + } @else { +

Sin datos para el periodo.

+ } +
} -
+ } `, styles: ` :host { display: block; padding-top: 16px; } - .bar { + .card { + background: var(--mat-sys-surface); + border: 1px solid var(--mat-sys-outline-variant); + border-radius: 12px; + padding: 16px 20px; margin-bottom: 16px; } - .grid { - display: grid; - gap: 16px; - grid-template-columns: 1fr; + .filters-title { + font-size: 16px; + font-weight: 500; + margin: 0 0 12px; } - @media (min-width: 1304px) { - .grid { - grid-template-columns: repeat(2, 1fr); - } + .panel-title, + .group-title { + font-size: 20px; + font-weight: 700; + margin: 0 0 8px; + } + h3.panel-title { + font-size: 16px; + } + .group-title { + margin: 24px 0 12px; } `, }) @@ -60,31 +94,48 @@ export class TabTrazabilidad { private readonly fhir = inject(Fhir); readonly domain = input.required(); readonly measures = input.required(); - protected readonly type = signal('semester'); + protected readonly type = signal('month'); protected readonly series = resource({ params: () => ({ domain: this.domain(), type: this.type(), measures: this.measures() }), loader: async ({ params }) => { + const history = HISTORY[params.domain]; + if (!history) return []; const asked = periods(params.type).reverse(); - const shown = params.measures.filter((m) => periodTypes(m).includes(params.type)); return Promise.all( - shown.map(async (measure) => { + history.panels.map(async (panel) => { + const measure = params.measures.find((m) => m.name === panel.measure); + if (!measure) return { panel, points: [] }; const pages = await this.fhir.all(params.domain, 'MeasureReport', { measure: measure.id!, 'reporting-period': asked.join(','), }); + // One report per period asked, in the order asked. const found = resources(pages, 'MeasureReport'); - return { measure, points: asked.map((period, i) => ({ period, r: reading(found[i]) })) }; + return { panel, points: asked.map((period, i) => ({ period, r: reading(found[i]) })) }; }), ); }, }); - protected readonly figures = computed<{ measure: Measure; figure: Figure }[]>(() => - (this.series.value() ?? []).map(({ measure, points }) => { - // From the first period with data on. - const first = points.findIndex((p) => (p.r?.populations['initial-population'] ?? 0) > 0); - return { measure, figure: history(measure, first < 0 ? [] : points.slice(first)) }; - }), - ); + protected readonly drawn = computed(() => { + const history = HISTORY[this.domain()]; + const xTitle = this.type() === 'month' ? 'Mes y año' : 'Semestre'; + let group: string | undefined; + if (!this.series.hasValue()) return []; + return this.series.value().map(({ panel, points }) => { + const heading = panel.group && panel.group !== group ? panel.group : undefined; + group = panel.group; + const has = (p: (typeof points)[number]) => (p.r?.populations['initial-population'] ?? 0) > 0; + const first = points.findIndex(has); + if (first < 0 || !history) return { panel, heading }; + const last = points.length - 1 - [...points].reverse().findIndex(has); + const shown = + history.months && this.type() === 'month' + ? points.slice(Math.max(first, last + 1 - history.months), last + 1) + : points.slice(first, last + 1); + const series = shown.map((p) => ({ label: periodLabel(p.period), r: p.r })); + return { panel, heading, figure: historyFigure(panel, series, history.line, xTitle) }; + }); + }); }
+ Resultados disponibles por paciente +
Paciente Grupo de edadMastografíaBiopsiaEstatusÚltima mastografíaÚltima biopsiaEstatus de seguimiento Prioridad
{{ row.ageGroup }}{{ row.mammogram.date }} · {{ name(row.mammogram.birads ?? '') || 'Sin dato' }} + {{ name(row.mammogram.birads ?? '') || 'Sin dato' }} + Fecha: {{ row.mammogram.date }} + @if (row.biopsy; as b) { - {{ b.date }} · {{ name(b.histology ?? '') || 'Sin resultado' }} + {{ name(b.histology ?? '') || 'Sin resultado' }} + Fecha: {{ b.date }} } @else { - — + No disponible } {{ name(row.status) }}
- {{ page() ? 'Nadie en la lista con estos filtros.' : 'Cargando…' }} - No hay registros para los filtros aplicados.