T17: sweep of the WebApp after the feature-parity work

Removed the legacy indicator layout, unused chart helpers, styles and
exports, the card-actions component, fetch-all and explanatory comments;
one pager shared by the four worklists, shared filter-row styles, one
FHIR name and CURP reader, downloads through export/, the concept-map
editor on Material controls.
This commit is contained in:
2026-12-01 06:48:57 -06:00
parent 8237e9f483
commit 7c98566579
61 changed files with 338 additions and 1166 deletions
+2 -22
View File
@@ -12,7 +12,6 @@ function rgba(hex: string, alpha: number): string {
return `rgba(${v >> 16},${(v >> 8) & 255},${v & 255},${alpha})`;
}
/** The screening route: each step's median days from the sample, with Q1–Q3. */
export function routeFigure(steps: { label: string; r: Reading | undefined }[]): Figure {
const shown = steps.filter((s) => s.r?.score !== undefined);
return {
@@ -44,12 +43,10 @@ export function routeFigure(steps: { label: string; r: Reading | undefined }[]):
};
}
/** A category's count in the report (the composition's `category` stratum). */
function counted(r: Reading, code: string): number {
return r.strata['category']?.[code]?.['initial-population'] ?? 0;
}
/** Groups inside, their categories outside, the total in the centre. */
export function nestedDonut(r: Reading, catalog: Catalog, center: string): Figure {
const values = catalog.categories.map((c) => counted(r, c.code));
const total = values.reduce((a, b) => a + b, 0);
@@ -108,7 +105,6 @@ export function nestedDonut(r: Reading, catalog: Catalog, center: string): Figur
labels: catalog.categories.map((c) => c.label),
hole: 0.74,
domain: { x: [0, 1], y: [0, 1] },
// along the thin ring, so a label fits its slice
insidetextorientation: 'tangential',
text: values.map((n, i) => (total && n / total >= 0.05 ? catalog.categories[i].label : '')),
marker: {
@@ -122,7 +118,6 @@ export function nestedDonut(r: Reading, catalog: Catalog, center: string): Figur
};
}
/** Each clinical scenario's results as shares of its patients, one stacked bar each. */
export function scenarioBars(
r: Reading,
catalog: Catalog,
@@ -166,8 +161,7 @@ export function scenarioBars(
};
}
/** Wilson score interval at 95 %, in percent. */
export function wilson(k: number, n: number): [number, number] {
function wilson(k: number, n: number): [number, number] {
const z = 1.959963984540054;
const p = k / n;
const d = 1 + (z * z) / n;
@@ -176,8 +170,6 @@ export function wilson(k: number, n: number): [number, number] {
return [100 * (c - h), 100 * (c + h)];
}
/** Per cytology result: of the women with a biopsy, the share whose biopsy is a positive,
* with its 95 % interval; a result nobody had a biopsy for is named, not drawn. */
export function rateDots(
r: Reading,
spec: { stratum: string; rows: Category[]; positive: string[]; axis: string; colored?: boolean },
@@ -248,8 +240,6 @@ export function rateDots(
const decimal = (n: number) => n.toLocaleString('es-MX', { maximumFractionDigits: 2 });
/** A card's template filled from its measure's reading in the period: {n} counted, {obs}
* measured, {median} {q1} {q3} days, {num} {den} {pct}. */
export function fill(template: string, r: Reading): string {
const p = r.populations;
const values: Record<string, string> = {
@@ -265,7 +255,6 @@ export function fill(template: string, r: Reading): string {
return template.replace(/\{(\w+)\}/g, (_, k) => values[k] ?? '');
}
/** A duration's quartile box in the period. */
export function boxFigure(r: Reading, period: string): Figure {
const q1 = r.low ?? r.score!;
const q3 = r.high ?? r.score!;
@@ -289,7 +278,6 @@ export function boxFigure(r: Reading, period: string): Figure {
};
}
/** One ring: the categories' shares, the total in the centre. */
export function shareDonut(r: Reading, catalog: Catalog, center: string): Figure {
const values = catalog.categories.map((c) => counted(r, c.code));
const total = values.reduce((a, b) => a + b, 0);
@@ -306,7 +294,6 @@ export function shareDonut(r: Reading, catalog: Catalog, center: string): Figure
colors: catalog.categories.map((c) => c.color),
line: { color: '#FFFFFF', width: 2 },
},
// an empty slice says nothing (its label would sit on its neighbours')
texttemplate: values.map((v) => (v ? '%{label}<br>%{percent}' : '')),
textposition: 'outside',
hovertemplate: '%{label}<br>%{value} (%{percent})<extra></extra>',
@@ -329,7 +316,6 @@ 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 {
@@ -355,8 +341,7 @@ export function countBars(r: Reading, catalog: Catalog, axis: string, period: st
}
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');
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(
@@ -364,7 +349,6 @@ function ages(r: Reading): [string, Record<string, number>][] {
);
}
/** 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));
@@ -393,7 +377,6 @@ export function ageStack(r: Reading, names: [string, string]): Figure {
};
}
/** 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 {
@@ -418,9 +401,6 @@ 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 }[],
+1 -1
View File
@@ -5,7 +5,7 @@ import { periods } from './measures';
describe('follow-up list', () => {
it('starts the window the day after the same day months before (core.follow_up)', () => {
expect(windowStart('2026-11-22', 3)).toBe('2026-08-23');
expect(windowStart('2026-05-31', 3)).toBe('2026-03-01'); // 2026-02-28, plus one
expect(windowStart('2026-05-31', 3)).toBe('2026-03-01');
expect(windowStart('2026-01-15', 1)).toBe('2025-12-16');
});
+6 -17
View File
@@ -1,7 +1,6 @@
import type { Bundle, DiagnosticReport, Observation, Patient, RiskAssessment } from 'fhir/r4';
import { code, ext, resources } from '../fhir';
import { code, ext, patientCurp, patientName, resources } from '../fhir';
/** One row of the follow-up list: what the list shows of a patient at the cut-off. */
export interface Row {
patient: Patient;
name?: string;
@@ -15,8 +14,6 @@ export interface Row {
risk: Record<'cin2' | 'cancer', number | undefined>;
}
export const CURP = 'https://isssteleon.org/fhir/sid/curp';
const AGE_GROUPS: [number, number][] = [
[25, 34],
[35, 44],
@@ -38,8 +35,6 @@ export function ageGroup(
return age < groups[0][0] ? `<${groups[0][0]}` : `${groups.at(-1)![1] + 1}+`;
}
/** Her current risk of an outcome at a horizon: from the latest index date any of the
* outcome's models scored her at, the highest when several did (as the list is sorted). */
export function currentRisk(
risks: RiskAssessment[],
outcome: 'cin2' | 'cancer',
@@ -64,8 +59,6 @@ export function currentRisk(
);
}
/** The list's rows from one page: per patient, her latest cytology and HPV sampled in the
* window, her days to diagnosis, and her latest reported biopsy. */
export function rows(page: Bundle, start: string, cutoff: string, horizon: number): Row[] {
const reports = resources<DiagnosticReport>(page, 'DiagnosticReport');
const observations = new Map(resources<Observation>(page, 'Observation').map((o) => [o.id, o]));
@@ -99,8 +92,8 @@ export function rows(page: Bundle, start: string, cutoff: string, horizon: numbe
const theirs = risks.filter((r) => r.subject?.reference === `Patient/${patient.id}`);
return {
patient,
name: patient.name?.[0]?.text,
curp: patient.identifier?.find((i) => i.system === CURP)?.value,
name: patientName(patient),
curp: patientCurp(patient),
status: ext(patient, 'follow-up-status')?.valueCoding?.code ?? '',
ageGroup: ageGroup(patient.birthDate, cutoff),
cytology: last && {
@@ -126,7 +119,6 @@ export function rows(page: Bundle, start: string, cutoff: string, horizon: numbe
});
}
/** The window's first day: `months` before the cut-off (the month's last day when shorter), plus one. */
export function windowStart(cutoff: string, months: number): string {
const [y, m, d] = cutoff.split('-').map(Number);
const total = y * 12 + (m - 1) - months;
@@ -137,16 +129,13 @@ export function windowStart(cutoff: string, months: number): string {
return day.toISOString().slice(0, 10);
}
/** One row of CaMa's follow-up list: her latest mammogram reported by the cut-off, where the
* biopsy it led to stands, and how soon she should be seen. */
export interface CamaRow {
interface CamaRow {
patient: Patient;
name?: string;
curp?: string;
status: string;
priority: string;
ageGroup: string;
/** `days`: from the mammogram to its diagnosis, when known by the cut-off. */
mammogram: { date: string; birads?: string; days?: number };
biopsy?: { date: string; histology?: string };
}
@@ -187,8 +176,8 @@ export function camaRows(page: Bundle, cutoff: string): CamaRow[] {
.at(-1);
return {
patient,
name: patient.name?.[0]?.text,
curp: patient.identifier?.find((i) => i.system === CURP)?.value,
name: patientName(patient),
curp: patientCurp(patient),
status: ext(patient, 'follow-up-status')?.valueCoding?.code ?? '',
priority: ext(patient, 'follow-up-priority')?.valueCoding?.code ?? '',
ageGroup: ageGroup(patient.birthDate, cutoff, CAMA_AGE_GROUPS),
-1
View File
@@ -13,7 +13,6 @@ import { TabSeguimiento } from './tab-seguimiento';
import { TabTrazabilidad } from './tab-trazabilidad';
import { Loading } from '../loading';
/** A domain's indicator page: four tabs over its FHIR measures and patients. */
@Component({
selector: 'app-indicadores',
imports: [
-85
View File
@@ -1,85 +0,0 @@
/** Where each measure goes on a domain's indicator page (today's layout); measures not
* named here are clinical cards. Measures are named by their code (`Measure.name`). */
export interface Layout {
kpis: string[];
route: { label: string; fromSample: string; fromStep: string; step: string }[];
/** The measure whose data decides the default period. */
anchor: string;
}
export const LAYOUTS: Record<string, Layout> = {
cacu: {
kpis: [
'CACU_EU7',
'CACU_EU_TIEMPO_REPORTE',
'CACU_DIAS_TOMA_DIAGNOSTICO',
'CACU_DIAS_TOMA_TRATAMIENTO',
'CACU_DIAS_DIAGNOSTICO_TRATAMIENTO',
],
route: [
{
label: 'Resultado de citología',
step: 'Toma a resultado de citología',
fromSample: 'CACU_EU_TIEMPO_REPORTE',
fromStep: 'CACU_EU_TIEMPO_REPORTE',
},
{
label: 'Colposcopía',
step: 'Del resultado de citología a la colposcopía',
fromSample: 'CACU_DIAS_TOMA_COLPOSCOPIA',
fromStep: 'CACU_DIAS_RESULTADO_COLPOSCOPIA',
},
{
label: 'Resultado de biopsia',
step: 'De la colposcopía al resultado de biopsia',
fromSample: 'CACU_DIAS_TOMA_BIOPSIA',
fromStep: 'CACU_DIAS_COLPOSCOPIA_BIOPSIA',
},
{
label: 'Diagnóstico',
step: 'Del resultado de biopsia al diagnóstico',
fromSample: 'CACU_DIAS_TOMA_DIAGNOSTICO',
fromStep: 'CACU_DIAS_BIOPSIA_DIAGNOSTICO',
},
],
anchor: 'IND1',
},
cama: {
kpis: [
'CAMA_BIRADS',
'CAMA_EU38A',
'CAMA_DIAS_TOMA_DIAGNOSTICO',
'CAMA_CONFIRMACION_BIRADS45',
'CAMA_TASA_DETECCION_HISTOPATOLOGICA',
],
route: [
{
label: 'Resultado de mastografía',
step: 'Toma a resultado de mastografía',
fromSample: 'CAMA_EU38A',
fromStep: 'CAMA_EU38A',
},
{
label: 'Diagnóstico',
step: 'Del resultado de mastografía al diagnóstico',
fromSample: 'CAMA_DIAS_TOMA_DIAGNOSTICO',
fromStep: 'CAMA_DIAS_RESULTADO_DIAGNOSTICO',
},
],
anchor: 'CAMA_BIRADS',
},
tea: {
kpis: [
'M26_DIAS_MCHAT_ADOS2',
'M27_DIAS_ADOS2_DIAGNOSTICO',
'M25_DIAS_MCHAT_DIAGNOSTICO',
'M23_PACIENTES_EVALUADOS',
'M24_CONFIRMACION_DIAGNOSTICO',
'M21_DIAGNOSTICADOS_CON_EEG',
'M22_DIAGNOSTICADOS_SIN_EEG',
'M29_CALIDAD_EEG',
],
route: [],
anchor: 'M23_PACIENTES_EVALUADOS',
},
};
-213
View File
@@ -1,11 +1,8 @@
import type { Measure, MeasureReport, MeasureReportGroup } from 'fhir/r4';
import { code, ext } from '../fhir';
import { Figure, PALETTE } from '../plot';
export type PeriodType = 'semester' | 'month';
export type Scoring = 'proportion' | 'continuous-variable' | 'cohort';
/** The periods back from today, most recent first: semesters (`2025-S1`) or months. */
export function periods(type: PeriodType, years = 6, today = new Date()): string[] {
const found: string[] = [];
const year = today.getFullYear();
@@ -32,17 +29,12 @@ export function periodLabel(period: string): string {
return `${month} ${year}`;
}
export function scoring(measure: Measure): Scoring {
return code(measure.scoring) as Scoring;
}
export function periodTypes(measure: Measure): PeriodType[] {
return (measure.extension ?? [])
.filter((e) => e.url.endsWith('/period-type'))
.map((e) => e.valueCode as PeriodType);
}
/** What one report says: its counts, its score and interval, and its strata. */
export interface Reading {
populations: Record<string, number>;
score?: number;
@@ -66,7 +58,6 @@ export function reading(report: MeasureReport | undefined): Reading | undefined
const score = group.measureScore;
const strata: Reading['strata'] = {};
for (const s of group.stratifier ?? []) {
// A crossed stratifier (several codes) is keyed `a-b`, its strata `valueA|valueB`.
const name = (s.code ?? []).map((c) => code(c) ?? c.text ?? '').join('-');
strata[name] = Object.fromEntries(
(s.stratum ?? []).map((x) => [
@@ -87,7 +78,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',
@@ -136,7 +126,6 @@ export const LABELS: Record<string, string> = {
['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',
@@ -146,205 +135,3 @@ export const STRATA: Record<string, string> = {
birads: 'BI-RADS de la mastografía',
};
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)) {
case 'proportion':
return `${(r.score * 100).toFixed(1)} %`;
case 'continuous-variable':
return `${Math.round(r.score * 10) / 10} días`;
default:
return `${r.score}`;
}
}
export function detail(measure: Measure, r: Reading | undefined): 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)}.`;
case 'continuous-variable':
return r.score === undefined
? `${p['initial-population'] ?? 0} sin medición en el periodo.`
: `Mediana de ${p['measure-observation']} mediciones; cuartiles ${r.low}–${r.high} días.`;
default:
return `${p['initial-population'] ?? 0} pacientes.`;
}
}
const pct = (v?: number) => (v === undefined ? '—' : `${(v * 100).toFixed(1)} %`);
/** A donut of one stratifier's counts (initial population), or of numerator vs the rest. */
export type Ring = { labels: string[]; values: number[] };
export function donut(
measure: Measure,
r: Reading,
stratifier = 'category',
inner?: Ring,
outer?: Ring,
): Figure {
let labels: string[], values: number[];
if (scoring(measure) === 'proportion') {
const { numerator = 0, denominator = 0 } = r.populations;
labels = ['Numerador', 'Resto'];
values = [numerator, denominator - numerator];
} else {
const cells = Object.entries(r.strata[stratifier] ?? {});
labels = cells.map(([v]) => name(v));
values = cells.map(([, c]) => c['initial-population'] ?? 0);
}
return {
data: [
{
type: 'pie',
hole: inner ? 0.68 : 0.62,
...(outer ?? { labels, values }),
sort: false,
textinfo: 'value+percent',
marker: { colors: PALETTE },
},
...(inner
? [
{
type: 'pie' as const,
hole: 0.45,
...inner,
sort: false,
textinfo: 'percent' as const,
domain: { x: [0.17, 0.83] as [number, number], y: [0.17, 0.83] as [number, number] },
marker: { colors: PALETTE },
},
]
: []),
],
layout: { showlegend: true, margin: { t: 32, r: 8, b: 32, l: 8 } },
};
}
/** Bars per stratum: the rate (proportion) or the count (others). */
export function strataBars(
measure: Measure,
r: Reading,
stratifier: string,
showCounts = false,
): Figure {
const cells = Object.entries(r.strata[stratifier] ?? {});
const proportion = scoring(measure) === 'proportion';
const values = cells.map(([, c]) =>
proportion
? c['denominator']
? (100 * (c['numerator'] ?? 0)) / c['denominator']
: 0
: (c['initial-population'] ?? 0),
);
return {
data: [
{
type: 'bar',
orientation: 'h',
y: cells.map(([v]) => name(v)),
x: values,
...(showCounts
? {
text: cells.map(([, c], i) => `${c['numerator'] ?? 0} (${values[i].toFixed(1)} %)`),
hovertemplate: '%{y}: %{text}<extra></extra>',
}
: {}),
marker: { color: PALETTE[0] },
},
],
layout: {
xaxis: { title: { text: proportion ? '%' : 'Pacientes' } },
yaxis: { automargin: true },
margin: { t: 8, r: 16, b: 48, l: 8 },
},
};
}
/** Horizontal median bars with their interquartile range, one per measure. */
export function medians(rows: { label: string; r: Reading | undefined }[]): Figure {
const shown = rows.filter((x) => x.r?.score !== undefined);
return {
data: [
{
type: 'bar',
orientation: 'h',
y: shown.map((x) => x.label),
x: shown.map((x) => x.r!.score!),
error_x: {
type: 'data',
symmetric: false,
array: shown.map((x) => (x.r!.high ?? x.r!.score!) - x.r!.score!),
arrayminus: shown.map((x) => x.r!.score! - (x.r!.low ?? x.r!.score!)),
color: '#17324d',
},
marker: { color: PALETTE[0] },
hovertemplate: '%{y}: %{x} días<extra></extra>',
},
],
layout: {
xaxis: { title: { text: 'Días (mediana, Q1–Q3)' } },
yaxis: { automargin: true, autorange: 'reversed' },
},
};
}
/** A measure over time: % with its interval, median with its quartiles, or counts by category. */
export function history(
measure: Measure,
series: { period: string; r: Reading | undefined }[],
): Figure {
const x = series.map((s) => periodLabel(s.period));
const kind = scoring(measure);
if (kind === 'cohort') {
const categories = [
...new Set(series.flatMap((s) => Object.keys(s.r?.strata['category'] ?? {}))),
];
return {
data: categories.map((c, i) => ({
type: 'bar',
name: name(c),
x,
y: series.map((s) => s.r?.strata['category']?.[c]?.['initial-population'] ?? 0),
marker: { color: PALETTE[i % PALETTE.length] },
})),
layout: { barmode: 'stack', yaxis: { title: { text: 'Pacientes' } } },
};
}
const k = kind === 'proportion' ? 100 : 1;
const value = (v?: number) => (v === undefined ? null : v * k);
return {
data: [
{
x,
y: series.map((s) => value(s.r?.high)),
mode: 'lines',
line: { width: 0 },
showlegend: false,
hoverinfo: 'skip',
},
{
x,
y: series.map((s) => value(s.r?.low)),
mode: 'lines',
line: { width: 0 },
fill: 'tonexty',
fillcolor: 'rgba(168,194,67,0.25)',
name: kind === 'proportion' ? 'IC 95 %' : 'Q1–Q3',
},
{
x,
y: series.map((s) => value(s.r?.score)),
mode: 'lines+markers',
name: kind === 'proportion' ? '%' : 'Mediana',
line: { color: PALETTE[0] },
},
],
layout: { yaxis: { title: { text: kind === 'proportion' ? '%' : 'Días' } } },
};
}
+53
View File
@@ -0,0 +1,53 @@
import { Component, input, output } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
@Component({
selector: 'app-pager',
imports: [MatButtonModule],
template: `
<nav class="pager" aria-label="Páginas de pacientes">
<span class="muted"><ng-content /></span>
<button
mat-stroked-button
type="button"
(click)="previous.emit()"
[disabled]="previousDisabled()"
>
Anterior
</button>
<button mat-stroked-button type="button" (click)="next.emit()" [disabled]="nextDisabled()">
Siguiente
</button>
</nav>
`,
styles: `
.pager {
align-items: center;
display: flex;
flex-wrap: wrap;
gap: var(--space-3);
justify-content: flex-end;
margin-top: var(--space-3);
}
:host(.print-pagination) .pager {
flex-wrap: nowrap;
}
@media print {
:host(.print-pagination) .pager {
display: flex !important;
}
}
.muted {
margin-right: auto;
}
`,
})
export class Pager {
readonly previousDisabled = input.required<boolean>();
readonly nextDisabled = input.required<boolean>();
readonly previous = output<void>();
readonly next = output<void>();
}
+2 -22
View File
@@ -1,13 +1,9 @@
export interface Page {
interface Page {
kpis: Kpi[];
/** Under the cards, before the clinical indicators (CaMa's timeliness boxes). */
opportunity?: Section[];
clinical: Section[];
/** The measure whose data decides the default period. */
anchor: string;
}
/** A card: its measure (none: not published yet), its title, and its value and note as
* templates (figures.fill). */
export interface Kpi {
measure?: string;
title: string;
@@ -19,18 +15,13 @@ export type Section =
| { kind: 'figures'; title?: string; figures: FigureSpec[] }
| {
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 =
| {
kind: 'donut' | 'share-donut';
@@ -45,7 +36,6 @@ export type FigureSpec =
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];
}
| {
@@ -54,9 +44,7 @@ export type FigureSpec =
measure: string;
stratum: string;
rows: Category[];
/** each row in its category's colour (else all rose) */
colored?: boolean;
/** the categories (of the measure) that count as a positive */
positive: string[];
axis: string;
};
@@ -70,14 +58,12 @@ export interface Category {
export interface Catalog {
groups: { id: string; label: string; color: string }[];
categories: Category[];
/** categories drawn faded (not the ones the figure is about) */
faded?: string[];
}
const OLIVE = '#A8C243';
const ROSE = '#C24269';
/** Bethesda results as the old app grouped and coloured them. */
const CYTOLOGY: Catalog = {
groups: [
{ id: 'normal', label: 'Sin anomalía', color: OLIVE },
@@ -93,7 +79,6 @@ const CYTOLOGY: Catalog = {
],
};
/** Biopsy grades: below high grade, and high grade or worse (what confirmation counts). */
const BIOPSY: Catalog = {
groups: [
{ id: 'low', label: 'Menor que LIEAG', color: OLIVE },
@@ -119,7 +104,6 @@ const CAMA_DAYS = {
};
const PENDING = 'Indicador no publicado en el catálogo institucional.';
/** BI-RADS 4 to 6 as the old app named and coloured them. */
const BIRADS: Catalog = {
groups: [],
categories: [
@@ -430,17 +414,13 @@ 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 {
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;
}
-6
View File
@@ -5,8 +5,6 @@ import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
/** A search box's text as FHIR Patient search parameters: one word with a digit is an
* identifier (a CURP or a record number); anything else is her name. */
export function patientSearch(text: string): { name?: string; identifier?: string } {
const t = text.trim();
if (!t) return {};
@@ -15,8 +13,6 @@ export function patientSearch(text: string): { name?: string; identifier?: strin
const fold = (s: string) => s.normalize('NFKD').replace(/\p{M}/gu, '').toLowerCase();
/** Whether a row matches the search in the browser (lists loaded whole): each word starts a
* word of one of its texts (a name, an identifier, the pseudonymous id). */
export function matchesSearch(text: string, texts: (string | undefined)[]): boolean {
const words = fold(text).split(/\s+/).filter(Boolean);
if (!words.length) return true;
@@ -24,7 +20,6 @@ export function matchesSearch(text: string, texts: (string | undefined)[]): bool
return known.some((parts) => words.every((w) => parts.some((p) => p.startsWith(w))));
}
/** "Buscar paciente": applied on Enter or the search button, cleared with the cross. */
@Component({
selector: 'app-patient-search',
imports: [FormsModule, MatButtonModule, MatFormFieldModule, MatIconModule, MatInputModule],
@@ -65,7 +60,6 @@ export function matchesSearch(text: string, texts: (string | undefined)[]): bool
`,
})
export class PatientSearch {
/** The search as applied. */
readonly value = model('');
readonly searched = output<string>();
protected readonly draft = signal('');
-4
View File
@@ -16,9 +16,6 @@ const IMPROVEMENT: Record<string, string> = {
};
const PERIODS: Record<string, string> = { semester: 'Semestral', month: 'Mensual' };
/** "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: `
@@ -124,7 +121,6 @@ export class TabDefiniciones {
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),
);
+1 -55
View File
@@ -1,4 +1,4 @@
<div class="filters card">
<div class="filters indicator-filters card">
<h2 class="filters-title">Filtros</h2>
<div class="field">
<span class="label">Intervalo de análisis</span>
@@ -219,58 +219,4 @@
}
}
</ng-template>
} @else {
@if (kpis().length) {
<h2>Indicadores de oportunidad</h2>
<div class="kpis">
@for (m of kpis(); track m.id) {
<mat-card appearance="outlined" class="kpi" [attr.data-measure]="m.name">
<mat-card-content>
<div class="kpi-title">{{ m.title }}</div>
<div class="kpi-value">{{ score(m) }}</div>
<div class="kpi-detail muted">{{ detail(m) }}</div>
</mat-card-content>
</mat-card>
}
</div>
}
@if (layout().route.length) {
<mat-card appearance="outlined" class="route">
<mat-card-header>
<mat-card-title>Ruta del tamizaje</mat-card-title>
<mat-button-toggle-group
[value]="routeView()"
(change)="routeView.set($event.value)"
class="route-toggle"
>
<mat-button-toggle value="sample">Acumulado desde la toma</mat-button-toggle>
<mat-button-toggle value="step">Por pasos</mat-button-toggle>
</mat-button-toggle-group>
</mat-card-header>
<mat-card-content>
<app-plot [figure]="route()" [height]="260" />
</mat-card-content>
</mat-card>
}
<h2>Indicadores clínicos</h2>
<div class="clinical">
@for (m of clinical(); track m.id) {
<mat-card appearance="outlined" class="clinical-card" [attr.data-measure]="m.name">
<mat-card-header>
<mat-card-title>{{ m.title }}</mat-card-title>
<mat-card-subtitle>{{ score(m) }} · {{ detail(m) }}</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
@for (f of figureSets().get(m.name!) ?? []; track f.title) {
<h3 class="figure-title">{{ f.title }}</h3>
<app-plot [figure]="f.figure" [height]="260" />
} @empty {
<p class="muted">Sin datos en el periodo.</p>
}
</mat-card-content>
</mat-card>
}
</div>
}
-50
View File
@@ -3,14 +3,6 @@
padding-top: var(--space-4);
}
.filters {
align-items: center;
display: flex;
flex-wrap: wrap;
gap: var(--space-4);
margin-bottom: var(--space-4);
}
.field {
display: flex;
flex-direction: column;
@@ -73,40 +65,9 @@ h2 {
.kpi-detail {
font-size: 13px;
}
.route {
margin-top: var(--space-4);
}
.route mat-card-header {
align-items: center;
display: flex;
flex-wrap: wrap;
gap: var(--space-3);
justify-content: space-between;
}
.clinical {
display: grid;
gap: var(--space-4);
grid-template-columns: 1fr;
}
@media (min-width: 1304px) {
.clinical {
grid-template-columns: repeat(2, 1fr);
}
}
.figure-title {
color: var(--color-text-secondary);
font-size: 14px;
font-weight: 500;
margin: var(--space-3) 0 0;
}
/* The old app's page: white sections with a title, cards inside. */
.card.opportunity,
.card.clinical-page {
background: var(--color-surface);
@@ -140,10 +101,6 @@ h3.kpi-title {
min-height: 2.6em;
}
.kpi-detail {
color: var(--color-text-secondary);
}
h3.route-title {
font-size: 16px;
font-weight: 700;
@@ -183,13 +140,6 @@ h2.figure-card-title {
font-size: 14px;
}
.filters {
background: var(--color-surface);
border: 1px solid var(--color-border);
border-radius: 8px;
padding: 16px;
}
h2.filters-title {
flex-basis: 100%;
font-size: 16px;
+3 -100
View File
@@ -1,6 +1,5 @@
import { Component, computed, effect, inject, input, resource, signal } from '@angular/core';
import { NgTemplateOutlet } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatButtonToggleModule } from '@angular/material/button-toggle';
import { MatCardModule } from '@angular/material/card';
@@ -8,7 +7,6 @@ import { MatSelectModule } from '@angular/material/select';
import type { Measure, MeasureReport } from 'fhir/r4';
import { Fhir, resources } from '../fhir';
import { Figure, Plot } from '../plot';
import { LAYOUTS } from './layout';
import {
ageShare,
ageStack,
@@ -22,30 +20,13 @@ import {
shareDonut,
} from './figures';
import { FigureSpec, Kpi, PAGES, Section } from './pages';
import {
detail,
donut,
formatScore,
medians,
name,
periodLabel,
periods,
PeriodType,
reading,
Reading,
scoring,
STRATA,
strataBars,
} from './measures';
import { name, periods, PeriodType, reading, Reading } from './measures';
import { Loading } from '../loading';
/** The period's indicators: the timeliness KPIs, the screening route, and a card per
* clinical measure with its figures. */
@Component({
selector: 'app-tab-indicadores',
imports: [
Loading,
FormsModule,
NgTemplateOutlet,
MatButtonModule,
MatButtonToggleModule,
@@ -64,35 +45,15 @@ export class TabIndicadores {
protected readonly type = signal<PeriodType>('semester');
protected readonly options = computed(() => periods(this.type()));
protected readonly chosen = signal<string | undefined>(undefined);
/** The period the figures show (set by Aplicar). */
protected readonly applied = signal<string | undefined>(undefined);
protected readonly routeView = signal<'sample' | 'step'>('sample');
protected readonly layout = computed(
() => LAYOUTS[this.domain()] ?? { kpis: [], route: [], anchor: '' },
);
protected readonly pending = 'Indicador no publicado en el catálogo institucional.';
/** The old app's page for this domain, when it is rebuilt as it was (else today's). */
protected readonly page = computed(() => PAGES[this.domain()]);
private readonly byName = computed(() => new Map(this.measures().map((m) => [m.name!, m])));
protected readonly kpis = computed(() =>
this.layout()
.kpis.map((n) => this.byName().get(n))
.filter((m) => !!m),
);
protected readonly clinical = computed(() => {
const placed = new Set([
...this.layout().kpis,
...this.layout().route.flatMap((s) => [s.fromSample, s.fromStep]),
]);
return this.measures().filter((m) => !placed.has(m.name!));
});
/** The latest period with data, the default. */
private readonly latest = resource({
params: () => ({
domain: this.domain(),
anchor: this.byName().get(this.page()?.anchor ?? this.layout().anchor) ?? this.measures()[0],
anchor: this.byName().get(this.page()?.anchor ?? '') ?? this.measures()[0],
all: this.options(),
}),
loader: async ({ params }) => {
@@ -125,8 +86,6 @@ export class TabIndicadores {
},
});
/** The period's readings; none while they load or when reading them failed (an errored
* resource throws on `value()`). */
protected loaded(): Map<string, Reading | undefined> | undefined {
return this.reports.hasValue() ? this.reports.value() : undefined;
}
@@ -141,67 +100,15 @@ export class TabIndicadores {
});
}
protected readonly label = periodLabel;
protected readonly strataNames = STRATA;
protected r(m: Measure): Reading | undefined {
return this.loaded()?.get(m.name!);
}
protected score(m: Measure): string {
return formatScore(m, this.r(m));
}
protected detail(m: Measure): string {
return detail(m, this.r(m));
}
protected readonly pending = 'Indicador no publicado en el catálogo institucional.';
protected setType(type: PeriodType): void {
this.type.set(type);
this.chosen.set(this.options()[0]);
}
protected readonly route = computed<Figure>(() => {
const view = this.routeView();
return medians(
this.layout().route.map((s) => {
const m = this.byName().get(view === 'sample' ? s.fromSample : s.fromStep);
return { label: view === 'sample' ? s.label : s.step, r: m && this.r(m) };
}),
);
});
/** Each clinical card's figures, built once per loaded period. */
protected readonly figureSets = computed(
() =>
new Map(this.clinical().map((m) => [m.name!, this.build(m, this.loaded()?.get(m.name!))])),
);
/** A clinical card's figures: the overall split, then one per stratum. */
private build(m: Measure, r: Reading | undefined): { title: string; figure: Figure }[] {
if (!r || !(r.populations['initial-population'] ?? 0)) return [];
const strata = Object.keys(r.strata).filter(
(s) => s !== 'category' && !s.includes('-') && Object.keys(r.strata[s]).length,
);
const kind = scoring(m);
if (kind === 'continuous-variable')
return [{ title: 'Mediana y cuartiles', figure: medians([{ label: m.title!, r }]) }];
return [
{ title: kind === 'proportion' ? 'Numerador y resto' : 'Por categoría', figure: donut(m, r) },
...strata.map((s) => ({
title: `Por ${STRATA[s]?.toLowerCase() ?? s}`,
figure: strataBars(m, r, s),
})),
];
}
protected readonly name = name;
/** A measure's reading in the applied period, by code. */
protected rd(code: string): Reading | undefined {
return this.loaded()?.get(code);
}
protected kpi(code: string): Measure | undefined {
return this.byName().get(code);
}
/** A card's value and note, from its templates (a card with no measure: its words). */
/** "27 días (mediana)" as the value and its qualifier, shown smaller beneath it. */
protected kpiParts(text: string): [string, string] {
const found = /^(.*?)\s*(\([^)]*\))$/.exec(text);
return found ? [found[1], found[2]] : [text, ''];
@@ -218,16 +125,13 @@ export class TabIndicadores {
if (!r || r.score === undefined) return 'Sin valor disponible';
return k.note ? fill(k.note, r) : '';
}
/** A figure's title, with the applied period in it. */
protected titled(title: string): string {
return title.replace('{p}', this.applied() ?? '');
}
/** A duration's box, or nothing to draw. */
protected boxOf(measure: string | undefined): Figure | undefined {
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.loaded()?.get(c);
const status = rd('M28_CASOS_POR_ESTADO');
@@ -264,7 +168,6 @@ export class TabIndicadores {
protected measureTitle(code: string | undefined): string {
return (code && this.byName().get(code)?.title) || '';
}
/** A clinical section's route or figures, drawn from the applied period's reports. */
protected routeOf(section: Section): Figure | undefined {
if (section.kind !== 'route') return undefined;
const steps = section.steps.map((s) => ({ label: s.label, r: this.rd(s.measure) }));
+22 -29
View File
@@ -1,4 +1,4 @@
<div class="filters card">
<div class="filters worklist-filters card">
<app-patient-search [(value)]="search" (searched)="index.set(0)" />
<mat-form-field appearance="outline" subscriptSizing="dynamic">
<mat-label>Fecha de corte</mat-label>
@@ -91,14 +91,22 @@
<section class="card eeg-summary" aria-labelledby="tea-eeg-summary">
<h3 id="tea-eeg-summary">EEG de los pacientes del periodo</h3>
<div class="counts">
<span><strong>{{ eeg.normal }}</strong> Normales</span>
<span><strong>{{ eeg.abnormal }}</strong> Anormales</span>
<span><strong>{{ eeg.notValid }}</strong> Sin EEG válido</span>
<span
><strong>{{ eeg.normal }}</strong> Normales</span
>
<span
><strong>{{ eeg.abnormal }}</strong> Anormales</span
>
<span
><strong>{{ eeg.notValid }}</strong> Sin EEG válido</span
>
</div>
@if (eeg.alterations.length) {
<ul class="by-alteration">
@for (alteration of eeg.alterations; track alteration.code) {
<li>{{ name(alteration.code) }}: <strong>{{ alteration.patients }}</strong></li>
<li>
{{ name(alteration.code) }}: <strong>{{ alteration.patients }}</strong>
</li>
}
</ul>
}
@@ -195,9 +203,7 @@
<td>{{ (pair.probability | number: '1.0-4') ?? '—' }}</td>
<td>{{ (pair.reference | number: '1.0-4') ?? '—' }}</td>
<td>
{{
pair.sameDirection == null ? '—' : pair.sameDirection ? 'Sí' : 'No'
}}
{{ pair.sameDirection == null ? '—' : pair.sameDirection ? 'Sí' : 'No' }}
</td>
</tr>
}
@@ -215,25 +221,12 @@
</table>
</div>
<nav class="pager" aria-label="Páginas de pacientes">
<span class="muted">
Página {{ index() + 1 }} de {{ pageCount() }} · {{ filtered().length }} registros
</span>
<button
mat-stroked-button
type="button"
(click)="index.set(index() - 1)"
[disabled]="index() === 0"
>
Anterior
</button>
<button
mat-stroked-button
type="button"
(click)="index.set(index() + 1)"
[disabled]="index() + 1 >= pageCount()"
>
Siguiente
</button>
</nav>
<app-pager
[previousDisabled]="index() === 0"
[nextDisabled]="index() + 1 >= pageCount()"
(previous)="index.set(index() - 1)"
(next)="index.set(index() + 1)"
>
Página {{ index() + 1 }} de {{ pageCount() }} · {{ filtered().length }} registros
</app-pager>
}
+6 -2
View File
@@ -14,6 +14,7 @@ import { Fhir } from '../fhir';
import { Loading } from '../loading';
import { windowStart } from './follow-up';
import { name } from './measures';
import { Pager } from './pager';
import { PatientSearch } from './patient-search';
import {
ASSOCIATION_LABELS,
@@ -41,6 +42,7 @@ import {
MatInputModule,
MatSelectModule,
PatientSearch,
Pager,
RouterLink,
],
templateUrl: './tab-riesgos-tea.html',
@@ -109,8 +111,10 @@ export class TabRiesgosTea {
(this.cutoff() ? windowStart(this.cutoff(), this.filters().window ?? 3) : ''),
);
protected readonly filtered = computed(() =>
associationRows(this.results.hasValue() ? this.results.value().rows : [], this.association())
.filter((row) => matchesTeaSearch(row, this.search())),
associationRows(
this.results.hasValue() ? this.results.value().rows : [],
this.association(),
).filter((row) => matchesTeaSearch(row, this.search())),
);
protected readonly rows = computed(() =>
this.filtered().slice(this.index() * this.size(), (this.index() + 1) * this.size()),
+18 -16
View File
@@ -1,7 +1,7 @@
@if (domain() === 'tea') {
<app-tab-riesgos-tea />
} @else {
<form class="filters card" (submit)="$event.preventDefault()">
<form class="filters worklist-filters card" (submit)="$event.preventDefault()">
<app-patient-search [(value)]="search" />
<mat-form-field appearance="outline" subscriptSizing="dynamic">
<mat-label>Fecha de corte</mat-label>
@@ -80,8 +80,12 @@
<th>Última citología</th>
<th>Último resultado de VPH</th>
<th>Última biopsia</th>
<th>Probabilidad a LIEAG+ a {{ horizon() }} {{ horizon() === 1 ? 'año' : 'años' }} (%)</th>
<th>Probabilidad a cáncer a {{ horizon() }} {{ horizon() === 1 ? 'año' : 'años' }} (%)</th>
<th>
Probabilidad a LIEAG+ a {{ horizon() }} {{ horizon() === 1 ? 'año' : 'años' }} (%)
</th>
<th>
Probabilidad a cáncer a {{ horizon() }} {{ horizon() === 1 ? 'año' : 'años' }} (%)
</th>
<th>Estudio más reciente</th>
<th>Días de toma a diagnóstico</th>
</tr>
@@ -168,17 +172,15 @@
</table>
</div>
<div class="pager">
<span class="muted">
@if (page()?.total; as total) {
Página {{ pageNumber() }} de {{ pageCount() }}, {{ total }} registros
}
</span>
<button mat-stroked-button (click)="go('previous')" [disabled]="!has('previous') || loading()">
Anterior
</button>
<button mat-stroked-button (click)="go('next')" [disabled]="!has('next') || loading()">
Siguiente
</button>
</div>
<app-pager
class="print-pagination"
[previousDisabled]="!has('previous') || loading()"
[nextDisabled]="!has('next') || loading()"
(previous)="go('previous')"
(next)="go('next')"
>
@if (page()?.total; as total) {
Página {{ pageNumber() }} de {{ pageCount() }}, {{ total }} registros
}
</app-pager>
}
-24
View File
@@ -3,18 +3,6 @@
padding-top: var(--space-4);
}
.filters {
display: flex;
flex-wrap: wrap;
gap: var(--space-3);
margin-bottom: var(--space-4);
}
// a field as wide as its label ("Horizonte de la probabilidad")
.filters mat-form-field {
min-width: 14.5rem;
}
.table-wrap {
overflow-x: auto;
padding: 0;
@@ -34,18 +22,6 @@ a {
font-size: 12px;
}
.pager {
align-items: center;
display: flex;
gap: var(--space-3);
justify-content: flex-end;
margin-top: var(--space-3);
}
.pager .muted {
margin-right: auto;
}
.worklist td small {
display: block;
white-space: nowrap;
+2 -7
View File
@@ -9,6 +9,7 @@ import { RouterLink } from '@angular/router';
import type { Bundle } from 'fhir/r4';
import { Fhir } from '../fhir';
import { Row, rows, windowStart } from './follow-up';
import { Pager } from './pager';
import { PatientSearch, patientSearch } from './patient-search';
import { TabRiesgosTea } from './tab-riesgos-tea';
import { Loading } from '../loading';
@@ -16,12 +17,11 @@ import { name } from './measures';
const STATUSES = ['case', 'pre_colposcopy', 'post_colposcopy', 'post_treatment'];
/** CaCu's follow-up list at a cut-off: who had a cytology in the window, her status,
* results and current risks, in the order asked for. */
@Component({
selector: 'app-tab-riesgos',
imports: [
PatientSearch,
Pager,
DecimalPipe,
FormsModule,
Loading,
@@ -45,9 +45,7 @@ export class TabRiesgos {
protected readonly horizon = signal(5);
protected readonly sort = signal('-recent');
protected readonly size = signal(20);
/** "Buscar paciente": her name, CURP or record number, as applied. */
protected readonly search = signal('');
/** A page the user moved to (`next`/`previous`), else the first. */
private readonly moved = signal<Bundle | undefined>(undefined);
protected readonly statuses = STATUSES;
@@ -80,7 +78,6 @@ export class TabRiesgos {
protected readonly page = computed(
() => this.moved() ?? (this.first.hasValue() ? this.first.value() : undefined),
);
/** The cut-off as applied (the server's default when none is given). */
protected readonly applied = computed(() => {
const self = this.page()?.link?.find((l) => l.relation === 'self')?.url;
return self ? (new URL(self).searchParams.get('follow-up-cutoff') ?? '') : '';
@@ -98,7 +95,6 @@ export class TabRiesgos {
});
protected readonly error = computed(() => this.first.error());
/** "Ventana consultada": the window's first day for the applied cut-off. */
protected readonly start = computed(() =>
this.applied() ? windowStart(this.applied(), this.window()) : '',
);
@@ -106,7 +102,6 @@ export class TabRiesgos {
protected readonly pageCount = computed(() =>
Math.max(1, Math.ceil((this.page()?.total ?? 0) / this.size())),
);
/** "Estudio más reciente": her latest cytology or HPV sample. */
protected latest(row: Row): string | undefined {
return [row.cytology?.date, row.hpv?.date]
.filter((d) => !!d)
+10 -20
View File
@@ -1,9 +1,7 @@
@if (focused(); as id) {
<button mat-stroked-button type="button" (click)="clearFocus(id)">
Ver todos los pacientes
</button>
<button mat-stroked-button type="button" (click)="clearFocus(id)">Ver todos los pacientes</button>
} @else {
<div class="filters card">
<div class="filters worklist-filters card">
<app-patient-search [(value)]="search" />
<mat-form-field appearance="outline" subscriptSizing="dynamic">
<mat-label>Fecha de corte</mat-label>
@@ -149,21 +147,13 @@
</div>
@if (!focused()) {
<nav class="pager" aria-label="Páginas de pacientes">
<span class="muted">
Página {{ pageNumber() }} de {{ pageCount() }} · {{ page()?.total ?? 0 }} registros
</span>
<button
mat-stroked-button
type="button"
(click)="go('previous')"
[disabled]="!has('previous')"
>
Anterior
</button>
<button mat-stroked-button type="button" (click)="go('next')" [disabled]="!has('next')">
Siguiente
</button>
</nav>
<app-pager
[previousDisabled]="!has('previous')"
[nextDisabled]="!has('next')"
(previous)="go('previous')"
(next)="go('next')"
>
Página {{ pageNumber() }} de {{ pageCount() }} · {{ page()?.total ?? 0 }} registros
</app-pager>
}
}
+6 -25
View File
@@ -3,24 +3,6 @@
padding-top: var(--space-4);
}
.filters,
.actions,
.pager {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--space-3);
}
.filters,
.actions {
margin-bottom: var(--space-4);
}
.filters mat-form-field {
min-width: 14.5rem;
}
.table-wrap {
overflow-x: auto;
padding: 0;
@@ -36,11 +18,10 @@ a {
color: var(--color-action);
}
.pager {
justify-content: flex-end;
margin-top: var(--space-3);
}
.pager .muted {
margin-right: auto;
.actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--space-3);
margin-bottom: var(--space-4);
}
+3 -3
View File
@@ -10,6 +10,7 @@ import { Fhir } from '../fhir';
import { Loading } from '../loading';
import { windowStart } from './follow-up';
import { name } from './measures';
import { Pager } from './pager';
import { PatientSearch, patientSearch } from './patient-search';
import {
ageMonths,
@@ -34,6 +35,7 @@ import {
MatInputModule,
MatSelectModule,
PatientSearch,
Pager,
RouterLink,
],
templateUrl: './tab-seguimiento-tea.html',
@@ -68,9 +70,7 @@ export class TabSeguimientoTea {
params: () => ({ ...this.request(), _count: this.size() }),
loader: ({ params }) => teaPatientPage(this.fhir, params),
});
private readonly moved = signal<
{ first: Bundle; page: Bundle } | undefined
>(undefined);
private readonly moved = signal<{ first: Bundle; page: Bundle } | undefined>(undefined);
protected readonly page = computed(() => {
const first = this.first.hasValue() ? this.first.value() : undefined;
const moved = this.moved();
+12 -14
View File
@@ -1,7 +1,7 @@
@if (domain() === 'tea') {
<app-tab-seguimiento-tea [patientId]="patientId()" />
} @else {
<form class="filters card" (submit)="$event.preventDefault()">
<form class="filters worklist-filters card" (submit)="$event.preventDefault()">
<app-patient-search [(value)]="search" />
<mat-form-field appearance="outline" subscriptSizing="dynamic">
<mat-label>Fecha de corte</mat-label>
@@ -106,17 +106,15 @@
</table>
</div>
<div class="pager">
<span class="muted">
@if (page()?.total; as total) {
Página {{ pageNumber() }} de {{ pageCount() }}, {{ total }} registros
}
</span>
<button mat-stroked-button (click)="go('previous')" [disabled]="!has('previous') || loading()">
Anterior
</button>
<button mat-stroked-button (click)="go('next')" [disabled]="!has('next') || loading()">
Siguiente
</button>
</div>
<app-pager
class="print-pagination"
[previousDisabled]="!has('previous') || loading()"
[nextDisabled]="!has('next') || loading()"
(previous)="go('previous')"
(next)="go('next')"
>
@if (page()?.total; as total) {
Página {{ pageNumber() }} de {{ pageCount() }}, {{ total }} registros
}
</app-pager>
}
+2 -3
View File
@@ -8,6 +8,7 @@ import { RouterLink } from '@angular/router';
import type { Bundle } from 'fhir/r4';
import { Fhir } from '../fhir';
import { camaRows, windowStart } from './follow-up';
import { Pager } from './pager';
import { PatientSearch, patientSearch } from './patient-search';
import { TabSeguimientoTea } from './tab-seguimiento-tea';
import { Loading } from '../loading';
@@ -15,12 +16,11 @@ import { name, PRIORITY } from './measures';
const STATUSES = ['cancer', 'pending_biopsy', 'biopsy_no_result', 'benign_biopsy'];
/** CaMa's follow-up list at a cut-off: patients whose latest mammogram in the window is
* BI-RADS 4 to 6, where their biopsy stands and how soon they should be seen. */
@Component({
selector: 'app-tab-seguimiento',
imports: [
PatientSearch,
Pager,
FormsModule,
Loading,
MatButtonModule,
@@ -42,7 +42,6 @@ export class TabSeguimiento {
protected readonly window = signal(3);
protected readonly status = signal<string>('');
protected readonly size = signal(20);
/** "Buscar paciente": her name, CURP or record number, as applied. */
protected readonly search = signal('');
private readonly moved = signal<Bundle | undefined>(undefined);
+1 -5
View File
@@ -10,18 +10,15 @@ import { HISTORY, HistoryPanel } from './pages';
interface Drawn {
panel: HistoryPanel;
/** the group's heading, on the first panel of its run */
heading?: string;
figure?: Figure;
}
/** Trazabilidad as the old tab: the domain's declared panels (pages.HISTORY), in their order,
* each measure period by period. */
@Component({
selector: 'app-tab-trazabilidad',
imports: [Loading, MatButtonToggleModule, Plot],
template: `
<section class="card filters" aria-labelledby="history-filters">
<section class="card" aria-labelledby="history-filters">
<h2 id="history-filters" class="filters-title">Filtros</h2>
<mat-button-toggle-group
[value]="type()"
@@ -110,7 +107,6 @@ export class TabTrazabilidad {
measure: measure.id!,
'reporting-period': asked.join(','),
});
// One report per period asked, in the order asked.
const found = resources<MeasureReport>(pages, 'MeasureReport');
return { panel, points: asked.map((period, i) => ({ period, r: reading(found[i]) })) };
}),
+30 -18
View File
@@ -1,13 +1,7 @@
import type {
Bundle,
DiagnosticReport,
Measure,
Observation,
Patient,
RiskAssessment,
} from 'fhir/r4';
import type { Bundle, DiagnosticReport, Observation, Patient, RiskAssessment } from 'fhir/r4';
import { EXT } from '../fhir';
import { donut, type Reading } from './measures';
import { nestedDonut, shareDonut } from './figures';
import type { Catalog } from './pages';
import {
ageMonths,
associationRows,
@@ -17,8 +11,6 @@ import {
teaWorkbook,
} from './tea-rows';
const measure: Measure = { resourceType: 'Measure', status: 'active' };
const r: Reading = { strata: {}, populations: {}, score: 12, low: 7, high: 18 };
const cssPair = 'spindles|central|CSS';
const DAY = new Date('2026-11-30T12:00:00Z');
@@ -110,14 +102,34 @@ function fixture(): Bundle {
}
describe('TEA indicators', () => {
it('builds two concentric rings from the supplied counts', () => {
const inner = { labels: ['Femenino'], values: [3] };
const outer = { labels: ['Femenino · 16-23', 'Femenino · 24-29'], values: [2, 1] };
expect(donut(measure, r, 'category', inner, outer).data).toEqual([
expect.objectContaining(outer),
expect.objectContaining(inner),
it('builds the category and group rings from the supplied counts', () => {
const catalog: Catalog = {
groups: [{ id: 'female', label: 'Femenino', color: '#123456' }],
categories: [
{ code: 'female-16-23', label: 'Femenino · 16-23', group: 'female', color: '#123456' },
{ code: 'female-24-29', label: 'Femenino · 24-29', group: 'female', color: '#123456' },
],
};
const reading = {
populations: {},
strata: {
category: {
'female-16-23': { 'initial-population': 2 },
'female-24-29': { 'initial-population': 1 },
},
},
};
expect(nestedDonut(reading, catalog, 'Pacientes').data).toEqual([
expect.objectContaining({ name: 'centro' }),
expect.objectContaining({ labels: ['Femenino'], values: [3] }),
expect.objectContaining({
labels: ['Femenino · 16-23', 'Femenino · 24-29'],
values: [2, 1],
}),
]);
expect(donut(measure, r).data).toHaveLength(1);
expect(
shareDonut(reading, catalog, 'Pacientes').data.filter((trace) => 'hole' in trace),
).toHaveLength(1);
});
it('maps every search filter and encodes closed ranges as repeated ge/le values', () => {
+3 -4
View File
@@ -1,8 +1,7 @@
import type { Bundle, DiagnosticReport, Observation, Patient, RiskAssessment } from 'fhir/r4';
import { ados2Component } from '../ados2';
import { safeName } from '../export/safe-name';
import { downloadXlsx, type Sheet } from '../export/xlsx';
import { code, ext, resources, type Fhir, type Params } from '../fhir';
import { downloadXlsx, safeName, type Sheet } from '../export';
import { code, ext, patientName, resources, type Fhir, type Params } from '../fhir';
import { name } from './measures';
import { matchesSearch } from './patient-search';
@@ -97,7 +96,7 @@ export function teaRows(page: Bundle) {
const step = ext(patient, 'tea-step')?.valueCode;
return {
patient,
name: patient.name?.[0]?.text,
name: patientName(patient),
recordNumbers: [
...new Set(
(patient.identifier ?? [])