From 7c98566579afdd0e47413a521e358d5b42457590 Mon Sep 17 00:00:00 2001 From: alberto Date: Tue, 1 Dec 2026 06:48:57 -0600 Subject: [PATCH] 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. --- package.json | 2 - src/app/ados2.ts | 8 +- src/app/app.config.ts | 1 - src/app/app.scss | 4 +- src/app/app.ts | 5 - src/app/auth/auth.ts | 10 +- src/app/auth/login.scss | 3 - src/app/auth/login.ts | 2 - src/app/card-actions.spec.ts | 53 ----- src/app/card-actions.ts | 72 ------- src/app/conectar/concept-map-editor.ts | 53 +++-- src/app/conectar/conectar.scss | 2 - src/app/conectar/conectar.ts | 51 ++--- src/app/conectar/schema-form.ts | 24 +-- src/app/conectar/source-dialog.ts | 21 +- src/app/eeg-labels.ts | 3 - src/app/export/blob.ts | 8 + src/app/export/export.spec.ts | 23 +- src/app/export/fetch-all.ts | 20 -- src/app/export/index.ts | 2 +- src/app/fhir.ts | 21 +- src/app/gobernanza/bundles.ts | 10 +- src/app/gobernanza/figures.ts | 9 +- src/app/gobernanza/models.ts | 2 +- src/app/gobernanza/tea/preview-pdf.ts | 3 +- src/app/indicadores/figures.ts | 24 +-- src/app/indicadores/follow-up.spec.ts | 2 +- src/app/indicadores/follow-up.ts | 23 +- src/app/indicadores/indicadores.ts | 1 - src/app/indicadores/layout.ts | 85 -------- src/app/indicadores/measures.ts | 213 ------------------- src/app/indicadores/pager.ts | 53 +++++ src/app/indicadores/pages.ts | 24 +-- src/app/indicadores/patient-search.ts | 6 - src/app/indicadores/tab-definiciones.ts | 4 - src/app/indicadores/tab-indicadores.html | 56 +---- src/app/indicadores/tab-indicadores.scss | 50 ----- src/app/indicadores/tab-indicadores.ts | 103 +-------- src/app/indicadores/tab-riesgos-tea.html | 51 ++--- src/app/indicadores/tab-riesgos-tea.ts | 8 +- src/app/indicadores/tab-riesgos.html | 34 +-- src/app/indicadores/tab-riesgos.scss | 24 --- src/app/indicadores/tab-riesgos.ts | 9 +- src/app/indicadores/tab-seguimiento-tea.html | 30 +-- src/app/indicadores/tab-seguimiento-tea.scss | 31 +-- src/app/indicadores/tab-seguimiento-tea.ts | 6 +- src/app/indicadores/tab-seguimiento.html | 26 ++- src/app/indicadores/tab-seguimiento.ts | 5 +- src/app/indicadores/tab-trazabilidad.ts | 6 +- src/app/indicadores/tea-indicators.spec.ts | 48 +++-- src/app/indicadores/tea-rows.ts | 7 +- src/app/loading.ts | 5 - src/app/paciente/factores.ts | 6 - src/app/paciente/paciente.html | 8 +- src/app/paciente/paciente.ts | 40 ++-- src/app/paciente/tea-data.ts | 19 +- src/app/paciente/tea-sections.ts | 18 +- src/app/plot.ts | 12 +- src/app/revision/revision.ts | 13 -- src/print.scss | 9 +- src/styles.scss | 33 ++- 61 files changed, 338 insertions(+), 1166 deletions(-) delete mode 100644 src/app/card-actions.spec.ts delete mode 100644 src/app/card-actions.ts create mode 100644 src/app/export/blob.ts delete mode 100644 src/app/export/fetch-all.ts delete mode 100644 src/app/indicadores/layout.ts create mode 100644 src/app/indicadores/pager.ts diff --git a/package.json b/package.json index 8d49884..02451a9 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,8 @@ "name": "webapp", "version": "0.0.0", "scripts": { - "ng": "ng", "start": "ng serve --proxy-config proxy.conf.json", "build": "ng build", - "watch": "ng build --watch --configuration development", "test": "ng test", "api": "ng-openapi-gen -c ng-openapi-gen.json" }, diff --git a/src/app/ados2.ts b/src/app/ados2.ts index 657fabb..939ea23 100644 --- a/src/app/ados2.ts +++ b/src/app/ados2.ts @@ -1,7 +1,7 @@ import type { Observation, ObservationComponent } from 'fhir/r4'; import { code, ext } from './fhir'; -export const ADOS2_ITEMS = [ +const ADOS2_ITEMS = [ 'vocalization_directed', 'pointing', 'gestures', @@ -26,18 +26,18 @@ export const ADOS2_ITEMS = [ 'repetitive_interests', ]; -export interface Ados2Item { +interface Ados2Item { code: string; title: string; score?: number; } -export interface Ados2Subdomain { +interface Ados2Subdomain { subdomain: string; items: Ados2Item[]; } -export interface Ados2Domain { +interface Ados2Domain { domain: string; subdomains: Ados2Subdomain[]; } diff --git a/src/app/app.config.ts b/src/app/app.config.ts index 92dfc01..dbd3431 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -16,7 +16,6 @@ export const appConfig: ApplicationConfig = { provideRouter(routes, withComponentInputBinding()), provideHttpClient(), provideApiConfiguration('/api'), - // Icons are the Material Symbols font served with the app. provideAppInitializer(() => { inject(MatIconRegistry).setDefaultFontSetClass('material-symbols-outlined'); }), diff --git a/src/app/app.scss b/src/app/app.scss index 269e44e..48e9c03 100644 --- a/src/app/app.scss +++ b/src/app/app.scss @@ -21,7 +21,7 @@ .title { flex: 1; - min-width: 0; // gives way to the switcher and the sections, on one line + min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; @@ -29,7 +29,6 @@ font-weight: 500; } -// Nothing in the header wraps or shrinks: the title gives way first, then hides. .domain, .sections a, .user { @@ -90,7 +89,6 @@ .sections { gap: var(--space-3); } - // the account by its icon alone; the switcher's name cut short if it must be .user .who-name { display: none; } diff --git a/src/app/app.ts b/src/app/app.ts index d19637f..8b06d6f 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -16,7 +16,6 @@ export const DOMAINS: Record = { tea: 'Trastorno del espectro autista', }; -/** The shell: header (logo, the domain's title and switcher, or the section), page, footer. */ @Component({ selector: 'app-root', imports: [ @@ -43,17 +42,13 @@ export class App { ), { initialValue: '' }, ); - /** The section and domain of a page that has one (indicators, governance): the switcher - * moves between that section's domains. */ private readonly place = computed(() => /^\/(indicadores|gobernanza)\/(\w+)/.exec(this.url())); protected readonly section = computed(() => this.place()?.[1] ?? 'indicadores'); protected readonly domain = computed(() => this.place()?.[2] as Domain | undefined); protected readonly others = computed(() => (this.domains.value() ?? []).filter((d) => d !== this.domain() && this.auth.canSee(d)), ); - /** The sign-in page shows only the brand. */ protected readonly onLogin = computed(() => this.url().startsWith('/login')); - /** Where "Indicadores" goes: the first domain this user may see. */ protected readonly home = computed( () => `/indicadores/${this.auth.user()?.domains[0] ?? 'cacu'}`, ); diff --git a/src/app/auth/auth.ts b/src/app/auth/auth.ts index d1254d8..22b946e 100644 --- a/src/app/auth/auth.ts +++ b/src/app/auth/auth.ts @@ -5,7 +5,6 @@ import { firstValueFrom } from 'rxjs'; import { ApiConfiguration } from '../api/api-configuration'; import type { Domain } from '../api/models/domain'; -/** Who is signed in, and the domains the app shows them. */ export interface User { id: string; email: string; @@ -14,18 +13,14 @@ export interface User { domains: Domain[]; } -/** The web app's sign-in (the API's fastapi-users, a session cookie). It decides only what - * the app shows: the API answers without a session. */ @Injectable({ providedIn: 'root' }) export class Auth { private readonly http = inject(HttpClient); private readonly root = inject(ApiConfiguration).rootUrl; - /** undefined: not asked yet; null: nobody signed in. */ private readonly current = signal(undefined); readonly user = this.current.asReadonly(); readonly signedIn = computed(() => !!this.current()); - /** Whether the signed-in user may see the domain (an administrator sees every one). */ canSee(domain: string): boolean { const u = this.current(); return !!u && (u.is_superuser || u.domains.includes(domain as Domain)); @@ -40,7 +35,6 @@ export class Auth { return this.current() ?? null; } - /** Signs in; a wrong user or password comes back as words for the form. */ async login(email: string, password: string): Promise { const body = new HttpParams().set('username', email.trim()).set('password', password); try { @@ -64,15 +58,13 @@ export class Auth { } } -/** Pages show only to someone signed in; the others go to the sign-in page and come back. */ export const signedIn: CanActivateFn = async (_route, state) => { const auth = inject(Auth); - const router = inject(Router); // before any await: inject works only in the guard's first turn + const router = inject(Router); const user = auth.user() === undefined ? await auth.load() : auth.user(); return user ? true : router.createUrlTree(['/login'], { queryParams: { next: state.url } }); }; -/** A domain's pages show only to whom may see it. */ export const domainAllowed: CanActivateFn = (route) => { const auth = inject(Auth); const domain = route.paramMap.get('domain') ?? route.data['domain']; diff --git a/src/app/auth/login.scss b/src/app/auth/login.scss index b99692c..d19712a 100644 --- a/src/app/auth/login.scss +++ b/src/app/auth/login.scss @@ -22,7 +22,6 @@ width: 100%; } -/* The brand opens the screen and is the biggest thing on it. */ .logo { align-self: center; animation: logo-in 600ms ease-out both; @@ -43,7 +42,6 @@ } } -/* The title between two rules. */ .title { align-items: center; color: var(--color-text); @@ -86,7 +84,6 @@ margin: -4px 0 0; } -/* One column with the fields; its border turns to the action color once the form is complete. */ .enter { align-items: center; background: var(--login-background); diff --git a/src/app/auth/login.ts b/src/app/auth/login.ts index 76f6ed8..13d8997 100644 --- a/src/app/auth/login.ts +++ b/src/app/auth/login.ts @@ -7,7 +7,6 @@ import { MatInputModule } from '@angular/material/input'; import { Router } from '@angular/router'; import { Auth } from './auth'; -/** "Inicio de sesión": the brand, two fields and one button. */ @Component({ selector: 'app-login', imports: [FormsModule, MatButtonModule, MatFormFieldModule, MatIconModule, MatInputModule], @@ -17,7 +16,6 @@ import { Auth } from './auth'; export class Login { private readonly auth = inject(Auth); private readonly router = inject(Router); - /** Where to go once signed in (the page that asked for it). */ readonly next = input(''); protected email = ''; protected password = ''; diff --git a/src/app/card-actions.spec.ts b/src/app/card-actions.spec.ts deleted file mode 100644 index 473ff34..0000000 --- a/src/app/card-actions.spec.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { TestBed } from '@angular/core/testing'; -import { MatDialog } from '@angular/material/dialog'; -import { describe, expect, it, vi } from 'vitest'; -import { CardActions } from './card-actions'; - -describe('CardActions', () => { - it('opens the published definition and emits back only through the filtered action', async () => { - const fixture = TestBed.createComponent(CardActions); - fixture.componentRef.setInput('measures', [ - { - resourceType: 'Measure', - status: 'active', - title: 'Oportunidad', - description: 'Definición publicada', - group: [ - { - population: [ - { - code: { text: 'Numerador' }, - criteria: { language: 'text/plain', description: 'Casos oportunos' }, - }, - { criteria: { language: 'text/plain' } }, - ], - }, - ], - }, - ]); - const back = vi.fn(); - fixture.componentInstance.back.subscribe(back); - fixture.detectChanges(); - - const host: HTMLElement = fixture.nativeElement; - expect(host.textContent).not.toContain('Volver'); - host.querySelector('[aria-label="Ver definición"]')!.click(); - fixture.detectChanges(); - await fixture.whenStable(); - - const dialog = document.querySelector('[role="dialog"]')!; - expect(dialog.textContent).toContain('Oportunidad'); - expect(dialog.textContent).toContain('Definición publicada'); - expect(dialog.textContent).toContain('Numerador'); - expect(dialog.textContent).toContain('Casos oportunos'); - expect(dialog.textContent).toContain('Sin definición publicada'); - TestBed.inject(MatDialog).closeAll(); - - fixture.componentRef.setInput('filtered', true); - fixture.detectChanges(); - [...host.querySelectorAll('button')] - .find((button) => button.textContent?.trim() === 'Volver')! - .click(); - expect(back).toHaveBeenCalledOnce(); - }); -}); diff --git a/src/app/card-actions.ts b/src/app/card-actions.ts deleted file mode 100644 index 6eee1f6..0000000 --- a/src/app/card-actions.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { Component, inject, input, output, TemplateRef } from '@angular/core'; -import { NgTemplateOutlet } from '@angular/common'; -import { MatButtonModule } from '@angular/material/button'; -import { MatDialog, MatDialogModule } from '@angular/material/dialog'; -import { MatMenuModule } from '@angular/material/menu'; -import type { Measure } from 'fhir/r4'; - -@Component({ - selector: 'app-card-actions', - imports: [NgTemplateOutlet, MatButtonModule, MatDialogModule, MatMenuModule], - template: ` - - @if (settings(); as content) { - - - - - - - } - @if (filtered()) { - - } - - -

Definición

- - @for (measure of measures(); track $index) { -

{{ measure.title }}

- @if (measure.description) { -

{{ measure.description }}

- } - @for (group of measure.group ?? []; track $index) { - @for (population of group.population ?? []; track $index) { -

- @if (population.code?.text; as text) { - {{ text }} - } - @if (population.criteria.description; as description) { - {{ description }} - } @else if (!population.code?.text) { - Sin definición publicada - } -

- } @empty { -

Sin definición publicada

- } - } @empty { -

Sin definición publicada

- } - } -
- - - -
- `, - styles: ':host { display: inline-flex; align-items: center; gap: var(--space-1); }', -}) -export class CardActions { - private readonly dialog = inject(MatDialog); - readonly measures = input.required(); - readonly settings = input>(); - readonly filtered = input(false); - readonly back = output(); - - protected open(template: TemplateRef): void { - this.dialog.open(template); - } -} diff --git a/src/app/conectar/concept-map-editor.ts b/src/app/conectar/concept-map-editor.ts index cf6f19c..392013f 100644 --- a/src/app/conectar/concept-map-editor.ts +++ b/src/app/conectar/concept-map-editor.ts @@ -2,23 +2,30 @@ import { HttpErrorResponse } from '@angular/common/http'; import { Component, inject, input, output, signal } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; +import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; +import { MatInputModule } from '@angular/material/input'; +import { MatSelectModule } from '@angular/material/select'; import { Api } from '../api/api'; import { getConceptMap } from '../api/fn/ingest/get-concept-map'; import { saveConceptMap } from '../api/fn/ingest/save-concept-map'; -/** One translation: a site's code onto a platform code of one target system. */ interface Row { target: string; code: string; platform: string; } -/** A site's codes in platform terms (a FHIR ConceptMap), edited as a table: a new - * laboratory spelling is one more row. The API refuses a code no platform field allows. */ @Component({ selector: 'app-concept-map-editor', - imports: [FormsModule, MatButtonModule, MatIconModule], + imports: [ + FormsModule, + MatButtonModule, + MatFormFieldModule, + MatIconModule, + MatInputModule, + MatSelectModule, + ], template: `

Códigos del sitio · {{ id() }} @@ -36,20 +43,31 @@ interface Row { @for (row of rows(); track $index) { - + + + @for (t of targets(); track t) { + {{ short(t) }} + } + + - + + + - + + + + + + `, + 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(); + readonly nextDisabled = input.required(); + readonly previous = output(); + readonly next = output(); +} diff --git a/src/app/indicadores/pages.ts b/src/app/indicadores/pages.ts index 100ccb0..a9447a8 100644 --- a/src/app/indicadores/pages.ts +++ b/src/app/indicadores/pages.ts @@ -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; } diff --git a/src/app/indicadores/patient-search.ts b/src/app/indicadores/patient-search.ts index ba73080..cd35ce0 100644 --- a/src/app/indicadores/patient-search.ts +++ b/src/app/indicadores/patient-search.ts @@ -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(); protected readonly draft = signal(''); diff --git a/src/app/indicadores/tab-definiciones.ts b/src/app/indicadores/tab-definiciones.ts index 07523bc..65adafb 100644 --- a/src/app/indicadores/tab-definiciones.ts +++ b/src/app/indicadores/tab-definiciones.ts @@ -16,9 +16,6 @@ const IMPROVEMENT: Record = { }; const PERIODS: Record = { 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), ); diff --git a/src/app/indicadores/tab-indicadores.html b/src/app/indicadores/tab-indicadores.html index 7a88c15..c9edae8 100644 --- a/src/app/indicadores/tab-indicadores.html +++ b/src/app/indicadores/tab-indicadores.html @@ -1,4 +1,4 @@ -
+

Filtros

Intervalo de análisis @@ -219,58 +219,4 @@ } } -} @else { - @if (kpis().length) { -

Indicadores de oportunidad

-
- @for (m of kpis(); track m.id) { - - -
{{ m.title }}
-
{{ score(m) }}
-
{{ detail(m) }}
-
-
- } -
- } - - @if (layout().route.length) { - - - Ruta del tamizaje - - Acumulado desde la toma - Por pasos - - - - - - - } - -

Indicadores clínicos

-
- @for (m of clinical(); track m.id) { - - - {{ m.title }} - {{ score(m) }} · {{ detail(m) }} - - - @for (f of figureSets().get(m.name!) ?? []; track f.title) { -

{{ f.title }}

- - } @empty { -

Sin datos en el periodo.

- } -
-
- } -
} diff --git a/src/app/indicadores/tab-indicadores.scss b/src/app/indicadores/tab-indicadores.scss index f641449..d9ebd9f 100644 --- a/src/app/indicadores/tab-indicadores.scss +++ b/src/app/indicadores/tab-indicadores.scss @@ -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; diff --git a/src/app/indicadores/tab-indicadores.ts b/src/app/indicadores/tab-indicadores.ts index f815d16..973fa57 100644 --- a/src/app/indicadores/tab-indicadores.ts +++ b/src/app/indicadores/tab-indicadores.ts @@ -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('semester'); protected readonly options = computed(() => periods(this.type())); protected readonly chosen = signal(undefined); - /** The period the figures show (set by Aplicar). */ protected readonly applied = signal(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 | 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
(() => { - 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) })); diff --git a/src/app/indicadores/tab-riesgos-tea.html b/src/app/indicadores/tab-riesgos-tea.html index c3cd8c0..02664fc 100644 --- a/src/app/indicadores/tab-riesgos-tea.html +++ b/src/app/indicadores/tab-riesgos-tea.html @@ -1,4 +1,4 @@ -
+
Fecha de corte @@ -91,14 +91,22 @@

EEG de los pacientes del periodo

- {{ eeg.normal }} Normales - {{ eeg.abnormal }} Anormales - {{ eeg.notValid }} Sin EEG válido + {{ eeg.normal }} Normales + {{ eeg.abnormal }} Anormales + {{ eeg.notValid }} Sin EEG válido
@if (eeg.alterations.length) {
    @for (alteration of eeg.alterations; track alteration.code) { -
  • {{ name(alteration.code) }}: {{ alteration.patients }}
  • +
  • + {{ name(alteration.code) }}: {{ alteration.patients }} +
  • }
} @@ -195,9 +203,7 @@ {{ (pair.probability | number: '1.0-4') ?? '—' }} {{ (pair.reference | number: '1.0-4') ?? '—' }} - {{ - pair.sameDirection == null ? '—' : pair.sameDirection ? 'Sí' : 'No' - }} + {{ pair.sameDirection == null ? '—' : pair.sameDirection ? 'Sí' : 'No' }} } @@ -215,25 +221,12 @@
- + + Página {{ index() + 1 }} de {{ pageCount() }} · {{ filtered().length }} registros + } diff --git a/src/app/indicadores/tab-riesgos-tea.ts b/src/app/indicadores/tab-riesgos-tea.ts index 6ae84dc..cde8a40 100644 --- a/src/app/indicadores/tab-riesgos-tea.ts +++ b/src/app/indicadores/tab-riesgos-tea.ts @@ -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()), diff --git a/src/app/indicadores/tab-riesgos.html b/src/app/indicadores/tab-riesgos.html index 9500b4d..686c984 100644 --- a/src/app/indicadores/tab-riesgos.html +++ b/src/app/indicadores/tab-riesgos.html @@ -1,7 +1,7 @@ @if (domain() === 'tea') { } @else { -
+ Fecha de corte @@ -80,8 +80,12 @@ Última citología Último resultado de VPH Última biopsia - Probabilidad a LIEAG+ a {{ horizon() }} {{ horizon() === 1 ? 'año' : 'años' }} (%) - Probabilidad a cáncer a {{ horizon() }} {{ horizon() === 1 ? 'año' : 'años' }} (%) + + Probabilidad 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 reciente Días de toma a diagnóstico @@ -168,17 +172,15 @@
-
- - @if (page()?.total; as total) { - Página {{ pageNumber() }} de {{ pageCount() }}, {{ total }} registros - } - - - -
+ + @if (page()?.total; as total) { + Página {{ pageNumber() }} de {{ pageCount() }}, {{ total }} registros + } + } diff --git a/src/app/indicadores/tab-riesgos.scss b/src/app/indicadores/tab-riesgos.scss index ad492df..a9b2b38 100644 --- a/src/app/indicadores/tab-riesgos.scss +++ b/src/app/indicadores/tab-riesgos.scss @@ -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; diff --git a/src/app/indicadores/tab-riesgos.ts b/src/app/indicadores/tab-riesgos.ts index 9fbaaf0..739954b 100644 --- a/src/app/indicadores/tab-riesgos.ts +++ b/src/app/indicadores/tab-riesgos.ts @@ -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(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) diff --git a/src/app/indicadores/tab-seguimiento-tea.html b/src/app/indicadores/tab-seguimiento-tea.html index 3e2ab01..24baec1 100644 --- a/src/app/indicadores/tab-seguimiento-tea.html +++ b/src/app/indicadores/tab-seguimiento-tea.html @@ -1,9 +1,7 @@ @if (focused(); as id) { - + } @else { -
+
Fecha de corte @@ -149,21 +147,13 @@
@if (!focused()) { - + + Página {{ pageNumber() }} de {{ pageCount() }} · {{ page()?.total ?? 0 }} registros + } } diff --git a/src/app/indicadores/tab-seguimiento-tea.scss b/src/app/indicadores/tab-seguimiento-tea.scss index 7234c53..7037084 100644 --- a/src/app/indicadores/tab-seguimiento-tea.scss +++ b/src/app/indicadores/tab-seguimiento-tea.scss @@ -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); } diff --git a/src/app/indicadores/tab-seguimiento-tea.ts b/src/app/indicadores/tab-seguimiento-tea.ts index b85d629..2b640a2 100644 --- a/src/app/indicadores/tab-seguimiento-tea.ts +++ b/src/app/indicadores/tab-seguimiento-tea.ts @@ -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(); diff --git a/src/app/indicadores/tab-seguimiento.html b/src/app/indicadores/tab-seguimiento.html index 7959369..f97538d 100644 --- a/src/app/indicadores/tab-seguimiento.html +++ b/src/app/indicadores/tab-seguimiento.html @@ -1,7 +1,7 @@ @if (domain() === 'tea') { } @else { - + Fecha de corte @@ -106,17 +106,15 @@
-
- - @if (page()?.total; as total) { - Página {{ pageNumber() }} de {{ pageCount() }}, {{ total }} registros - } - - - -
+ + @if (page()?.total; as total) { + Página {{ pageNumber() }} de {{ pageCount() }}, {{ total }} registros + } + } diff --git a/src/app/indicadores/tab-seguimiento.ts b/src/app/indicadores/tab-seguimiento.ts index 12dc2b2..ed274e9 100644 --- a/src/app/indicadores/tab-seguimiento.ts +++ b/src/app/indicadores/tab-seguimiento.ts @@ -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(''); protected readonly size = signal(20); - /** "Buscar paciente": her name, CURP or record number, as applied. */ protected readonly search = signal(''); private readonly moved = signal(undefined); diff --git a/src/app/indicadores/tab-trazabilidad.ts b/src/app/indicadores/tab-trazabilidad.ts index e108d96..21e03ea 100644 --- a/src/app/indicadores/tab-trazabilidad.ts +++ b/src/app/indicadores/tab-trazabilidad.ts @@ -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: ` -
+

Filtros

(pages, 'MeasureReport'); return { panel, points: asked.map((period, i) => ({ period, r: reading(found[i]) })) }; }), diff --git a/src/app/indicadores/tea-indicators.spec.ts b/src/app/indicadores/tea-indicators.spec.ts index 1691c6c..0f6994d 100644 --- a/src/app/indicadores/tea-indicators.spec.ts +++ b/src/app/indicadores/tea-indicators.spec.ts @@ -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', () => { diff --git a/src/app/indicadores/tea-rows.ts b/src/app/indicadores/tea-rows.ts index 2c91ccb..2444fbb 100644 --- a/src/app/indicadores/tea-rows.ts +++ b/src/app/indicadores/tea-rows.ts @@ -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 ?? []) diff --git a/src/app/loading.ts b/src/app/loading.ts index 820974f..247ee7d 100644 --- a/src/app/loading.ts +++ b/src/app/loading.ts @@ -1,8 +1,6 @@ import { Component, input } from '@angular/core'; import { MatProgressBarModule } from '@angular/material/progress-bar'; -/** What a page or a figure shows while its data comes, as the old app did: a progress bar - * named for what loads, "Cargando …" in words, and for a figure the place it will take. */ @Component({ selector: 'app-loading', imports: [MatProgressBarModule], @@ -37,10 +35,7 @@ import { MatProgressBarModule } from '@angular/material/progress-bar'; host: { '[class.figure]': 'figure()' }, }) export class Loading { - /** What is loading, in words: "los indicadores", "la figura". */ readonly what = input.required(); - /** The whole line instead ("Calculando los indicadores…"). */ readonly text = input(''); - /** A figure's skeleton under the bar. */ readonly figure = input(false); } diff --git a/src/app/paciente/factores.ts b/src/app/paciente/factores.ts index c225c91..0add2c0 100644 --- a/src/app/paciente/factores.ts +++ b/src/app/paciente/factores.ts @@ -2,7 +2,6 @@ import { Component, computed, input, signal } from '@angular/core'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatSelectModule } from '@angular/material/select'; -/** One scenario's row of a model's scenario summary (models.factors.scenario_row). */ export interface ScenarioFactors { escenario: string; n_escenario: number; @@ -17,7 +16,6 @@ interface Entry { robust: boolean; } -/** A listing cell, `variable=category (robusto|sugerente, share)` separated by `;`. */ export function entries(cell: string | null | undefined): Entry[] { return (cell ?? '') .split(';') @@ -26,9 +24,6 @@ export function entries(cell: string | null | undefined): Entry[] { .map((text) => ({ text, robust: /\(\s*robusto\b/i.test(text) })); } -/** "Factores de riesgo de este escenario", as the old record: per scenario of hers, the risk - * factors present in at least 95 % of it and those in 50 to 95 %, a robust one solid and a - * suggestive one outlined; with a horizon to choose when the model has several. */ @Component({ selector: 'app-factores', imports: [MatFormFieldModule, MatSelectModule], @@ -102,7 +97,6 @@ export function entries(cell: string | null | undefined): Entry[] { `, }) export class Factores { - /** Her scenarios' rows (every horizon when the model has several). */ readonly rows = input.required(); protected readonly chosen = signal(undefined); protected readonly horizons = computed(() => diff --git a/src/app/paciente/paciente.html b/src/app/paciente/paciente.html index be84a25..7077f43 100644 --- a/src/app/paciente/paciente.html +++ b/src/app/paciente/paciente.html @@ -11,12 +11,12 @@ } @else if (tea.value(); as t) { @if (risk()) {

Análisis de riesgo TEA

- @if (t.patient.name?.[0]?.text; as name) { + @if (patientName(t.patient); as name) {

{{ name }}

} } @else {

- {{ t.patient.name?.[0]?.text ?? 'Paciente' }} + {{ patientName(t.patient) ?? 'Paciente' }} {{ t.patient.id!.slice(0, 10) }}

@@ -54,9 +54,7 @@ @for (section of teaSections(); track section.title) { @if (risk() && section.title === forestTitle) { - Solo zonas alteradas } diff --git a/src/app/paciente/paciente.ts b/src/app/paciente/paciente.ts index cfdc31b..8488f85 100644 --- a/src/app/paciente/paciente.ts +++ b/src/app/paciente/paciente.ts @@ -19,9 +19,19 @@ import { Api } from '../api/api'; import { curve } from '../api/fn/models/curve'; import { readReport$Json } from '../api/fn/models/read-report-json'; import type { Domain } from '../api/models/domain'; -import { code, EXT, ext, Fhir, label, resources } from '../fhir'; +import { + code, + CURP, + ext, + extensions, + Fhir, + label, + patientCurp, + patientName, + resources, +} from '../fhir'; import { scenarioFigure } from '../gobernanza/figures'; -import { ageGroup, CAMA_AGE_GROUPS, camaRows, CURP } from '../indicadores/follow-up'; +import { ageGroup, CAMA_AGE_GROUPS, camaRows } from '../indicadores/follow-up'; import { LABELS, name, PRIORITY } from '../indicadores/measures'; import { Figure, PALETTE, Plot } from '../plot'; import { Loading } from '../loading'; @@ -38,11 +48,9 @@ import { Section, } from './tea-sections'; -/** An Observation's value as the screens say it, whatever its type. */ function shown(o: Observation): string { if (o.valueBoolean !== undefined) return o.valueBoolean ? 'positivo' : 'negativo'; if (o.valueCodeableConcept) { - // The screens' own name for the code (BI-RADS 4C), else the server's display. const c = code(o.valueCodeableConcept) ?? ''; return (c in LABELS ? name(c) : '') || label(o.valueCodeableConcept); } @@ -50,8 +58,6 @@ function shown(o: Observation): string { return o.valueString ?? o.valueDateTime ?? ''; } -/** One patient: her history (conditions, procedures), her tests and results, and the - * champion models' risks with their curves. Everything read from the FHIR API. */ @Component({ selector: 'app-paciente', imports: [ @@ -77,7 +83,6 @@ export class Paciente { private readonly host = inject>(ElementRef); readonly domain = input.required(); readonly id = input.required(); - /** The follow-up list she was opened from: its window (months) and cut-off. */ readonly ventana = input(); readonly corte = input(); readonly risk = input(false); @@ -117,7 +122,6 @@ export class Paciente { date: c.recordedDate ?? '', kind: 'Diagnóstico', text: label(c.code), - // the ICD-10 code a note diagnosed by (the platform's own codes stay unsaid) code: c.code?.coding?.find((x) => x.system?.includes('icd-10'))?.code, })), ...d.procedures.map((p) => ({ @@ -140,7 +144,6 @@ export class Paciente { reported: ext(r, 'report-date')?.valueDate, kind: label(r.code), status: r.status, - // "BI-RADS 4C", not "BI-RADS: BI-RADS 4C" results: results.map((o) => { const [name, value] = [label(o.code), shown(o)]; return value.startsWith(name) ? value : `${name}: ${value}`; @@ -148,7 +151,6 @@ export class Paciente { }; }); }); - /** One model's latest risk assessment per model. */ protected readonly models = computed(() => { const latest = new Map(); for (const r of this.data.value()?.risks ?? []) { @@ -164,10 +166,7 @@ export class Paciente { text: r.method?.text ?? '', version: Number(/v(\d+)$/.exec(r.method?.text ?? '')?.[1] ?? 0), index: r.occurrenceDateTime ?? '', - // the clinical scenarios of the model's report she falls in - scenarios: (r.extension ?? []) - .filter((e) => e.url === EXT + 'escenario-clinico') - .map((e) => e.valueString ?? ''), + scenarios: extensions(r, 'escenario-clinico').map((e) => e.valueString ?? ''), predictions: (r.prediction ?? []).map((p) => ({ years: p.whenRange?.high?.value ?? 0, p: p.probabilityDecimal ?? 0, @@ -176,8 +175,6 @@ export class Paciente { })), })); }); - /** "Análisis de supervivencia" and "Análisis de recurrencia": the curves of her clinical - * scenarios, from the report of the model version that scored her. */ protected readonly survival = this.analysis('survival'); protected readonly recurrence = this.analysis('recurrence'); protected readonly recurrenceModel = computed(() => @@ -202,7 +199,6 @@ export class Paciente { const mine = (all: any[]) => all.filter((e) => m.scenarios.includes(e.escenario)); if (name === 'recurrence') { const r = (report?.['recurrencia'] ?? {}) as any; - // The risk factors of her scenarios, by horizon (the development tables). const technical = (await this.api.invoke(readReport$Json, { domain: domain as Domain, name, @@ -274,7 +270,6 @@ export class Paciente { }), layout: { xaxis: { title: { text: 'Años desde la fecha índice' }, dtick: 1 }, - // At least 0–5 %: a near-zero risk reads as near zero, not as a full axis. yaxis: { title: { text: 'Probabilidad (%)' }, range: [0, Math.max(5, this.top() * 110)], @@ -287,12 +282,12 @@ export class Paciente { return Math.max(0, ...this.models().flatMap((m) => m.predictions.map((p) => p.high ?? p.p))); } protected readonly name = name; + protected readonly patientName = patientName; protected readonly identity = computed(() => { const p = this.patient(); return { - name: p?.name?.[0]?.text, - curp: p?.identifier?.find((i) => i.system === CURP)?.value, - // each record number once (several sources may carry the same one) + name: patientName(p), + curp: patientCurp(p), numbers: [ ...new Set( (p?.identifier ?? []).filter((i) => i.system !== CURP).map((i) => i.value ?? ''), @@ -300,8 +295,6 @@ export class Paciente { ].filter(Boolean), }; }); - /** CaMa: her row on the follow-up list (window and cut-off as opened, else the widest - * window up to the last day with data), as the list shows it: the old record's card. */ private readonly listed = resource({ params: () => this.domain() === 'cama' @@ -329,7 +322,6 @@ export class Paciente { const found = this.listed.value(); const d = this.data.value(); if (!found || !d) return undefined; - // Her own latest mammogram and biopsy, on the list or not. const latest = (study: string) => d.reports .filter((r) => code(r.code) === study) diff --git a/src/app/paciente/tea-data.ts b/src/app/paciente/tea-data.ts index cf9e6a5..a153950 100644 --- a/src/app/paciente/tea-data.ts +++ b/src/app/paciente/tea-data.ts @@ -7,8 +7,8 @@ import type { RiskAssessment, } from 'fhir/r4'; import { ados2Component, ados2Groups } from '../ados2'; -import { code, ext, Fhir, label, resources } from '../fhir'; -import { CURP } from '../indicadores/follow-up'; +import { ZONE_NAMES } from '../eeg-labels'; +import { code, CURP, ext, Fhir, label, resources } from '../fhir'; const NSS = 'https://isssteleon.org/fhir/sid/nss'; @@ -27,19 +27,6 @@ const metrics: Record = { anteroposterior_gradient: 'Gradiente anteroposterior', }; -const regions: Record = { - frontal_left: 'Frontal izquierda', - frontal_right: 'Frontal derecha', - frontal_midline: 'Frontal medial', - central: 'Central', - parietal: 'Parietal', - temporal_left: 'Temporal izquierda', - temporal_right: 'Temporal derecha', - occipital: 'Occipital', - posterior: 'Posterior', - global: 'Global', -}; - const biomarkers: Record = { spikes: 'paroxysmal_spikes', spindles: 'spindles_n2', @@ -262,7 +249,7 @@ export type Pair = { export type Study = ReturnType; export function zoneLabel(zone: string): string { - return regions[zone] ?? zone; + return zone === 'frontal_midline' ? 'Frontal medial' : (ZONE_NAMES[zone] ?? zone); } export function alteration(outside: number | undefined): string { diff --git a/src/app/paciente/tea-sections.ts b/src/app/paciente/tea-sections.ts index cbf25b7..4d52a6f 100644 --- a/src/app/paciente/tea-sections.ts +++ b/src/app/paciente/tea-sections.ts @@ -1,6 +1,4 @@ -import type { PdfContent } from '../export/pdf'; -import { downloadPdf } from '../export/pdf'; -import { safeName } from '../export/safe-name'; +import { downloadPdf, safeName, type PdfContent } from '../export'; import type { Figure } from '../plot'; import plotly from '../plotly-bundle'; import { adosItems, adosSummary, alteration, Pair, percent, shown, TeaPatient } from './tea-data'; @@ -8,7 +6,7 @@ import { forest, headMap, probabilityCurve, zBars } from './tea-figures'; type Table = { headers: string[]; rows: string[][] }; type Chart = { title: string; figure: Figure; height?: number }; -export type Block = { +type Block = { title?: string; fields?: string[][]; table?: Table; @@ -20,9 +18,9 @@ export type Section = { title: string; blocks: Block[] }; export const forestTitle = 'Razones de momios por par'; export const probabilityTitle = 'Probabilidad según z'; -export const calculation = +const calculation = 'El modelo estima, para cada par de métrica o zona del EEG y resultado del ADOS-2, la probabilidad de un puntaje elevado de severidad calibrada (CSS) o de un ítem alterado. La razón de momios corresponde al cambio asociado con una unidad de z. La probabilidad de referencia corresponde a z = 0, la edad media y el módulo más frecuente de la cohorte.'; -export const limitations = +const limitations = 'Las estimaciones dependen de la cohorte de referencia, de la calidad del EEG y de la disponibilidad de mediciones y pares. Las asociaciones no establecen causalidad. Las probabilidades no sustituyen la evaluación clínica ni establecen un diagnóstico.'; function associationRows(pairs: Pair[]): string[][] { @@ -150,7 +148,7 @@ export function riskSections(patient: TeaPatient, alteredOnly: boolean, pair?: P ]; } -export function probabilityRows(pairs: Pair[]): Table { +function probabilityRows(pairs: Pair[]): Table { return { headers: ['Par', 'Probabilidad', 'Referencia'], rows: pairs.map((p) => [ @@ -165,7 +163,11 @@ export function teaPdfName(page: 'seguimiento' | 'riesgos', day = new Date()): s return safeName(['tea', page, day.toISOString().slice(0, 10)]); } -export function teaPdfContent(title: string, sections: Section[], images: (string | undefined)[]): PdfContent[] { +export function teaPdfContent( + title: string, + sections: Section[], + images: (string | undefined)[], +): PdfContent[] { const charts = images[Symbol.iterator](); const content: PdfContent[] = [{ text: title, fontSize: 18, bold: true }]; for (const section of sections) { diff --git a/src/app/plot.ts b/src/app/plot.ts index bded306..bd4a226 100644 --- a/src/app/plot.ts +++ b/src/app/plot.ts @@ -4,7 +4,6 @@ import plotly from './plotly-bundle'; export type Figure = { data: Partial[]; layout?: Partial }; -/** The series colours today's charts use, in order. */ export const PALETTE = [ '#A8C243', '#42C29C', @@ -21,21 +20,16 @@ const LAYOUT: Partial = { margin: { t: 24, r: 16, b: 48, l: 56 }, paper_bgcolor: 'rgba(0,0,0,0)', plot_bgcolor: 'rgba(0,0,0,0)', - // Above the plot, left-aligned: Plotly reserves its room, so it never meets an axis title. legend: { orientation: 'h', x: 0, xanchor: 'left', y: 1.02, yanchor: 'bottom' }, hoverlabel: { font: { family: 'Roboto, Arial, sans-serif', size: 13 } }, }; -// Axes make room for their labels and titles; a title keeps clear of the tick labels. -// (`ticklabelstandoff` is Plotly's, newer than its published types.) const AXIS = { automargin: true, title: { standoff: 12 }, - ticklabelstandoff: 4, // the lowest y label and the first x label never touch + ticklabelstandoff: 4, } as Partial; -/** The platform's layout under a figure's own: legend, margins and axes merged key by key, - * so a figure that sets one of their keys keeps the others. */ -export function layoutOf(layout: Partial = {}): Partial { +function layoutOf(layout: Partial = {}): Partial { const axes = Object.fromEntries( Object.entries(layout) .filter(([k]) => /^[xy]axis\d*$/.test(k)) @@ -56,7 +50,6 @@ export function layoutOf(layout: Partial = {}): Partial[]): Plotly.Data[] { return data.map((d) => (d.type === 'pie' ? { automargin: true, ...d } : d)) as Plotly.Data[]; } @@ -66,7 +59,6 @@ const CONFIG: Partial = { modeBarButtonsToRemove: ['lasso2d', 'select2d'], }; -/** One Plotly chart: the figure, drawn with the platform's layout and config. */ @Component({ selector: 'app-plot', template: '
', diff --git a/src/app/revision/revision.ts b/src/app/revision/revision.ts index 59972e6..a3be866 100644 --- a/src/app/revision/revision.ts +++ b/src/app/revision/revision.ts @@ -49,7 +49,6 @@ const IDENTITY_FIELDS: Correction['field'][] = [ 'birth_date', 'sex', ]; -/** Identity fields as linkage names them (core.schema.Identity). */ const IDENTITY_TITLES: Record = { record_number: 'Expediente', curp: 'CURP', @@ -57,7 +56,6 @@ const IDENTITY_TITLES: Record = { full_name: 'Nombre', }; -/** The platform's hold reasons (English in its logs) as the reviewer reads them. */ const REASONS: [RegExp, (m: RegExpExecArray) => string][] = [ [/^Field required$/, () => 'falta el dato'], [ @@ -82,7 +80,6 @@ const REASONS: [RegExp, (m: RegExpExecArray) => string][] = [ ], ]; -/** Bookkeeping columns, not values a reviewer judges. */ const HIDDEN = [ '_pipeline', '_target', @@ -95,8 +92,6 @@ const HIDDEN = [ 'known_at', ]; -/** /revision: what ingestion held for a person to decide. Every decision is logged and - * applied on the pipeline's next run. */ @Component({ selector: 'app-revision', imports: [ @@ -128,9 +123,7 @@ export class Revision { loader: ({ params }) => this.api.invoke(conflicts, { entity: params }), }); - /** The pipeline and link node whose persons are reviewed. */ protected readonly pipelines = resource({ loader: () => this.api.invoke(pipelines) }); - /** The chosen pipeline; the first one until the reviewer picks another. */ protected readonly pipeline = linkedSignal( () => this.pipelines.value()?.[0]?.['pipeline_id'], ); @@ -152,13 +145,11 @@ export class Revision { : Promise.resolve({ to_settle: [], torn: [] } as Record), }); - /** Documents the chosen pipeline's routes don't recognise (its `otherwise` routes). */ protected readonly unrecognised = resource({ params: () => this.pipeline(), loader: ({ params }) => params ? this.api.invoke(unrecognised, { pipeline: params }) : Promise.resolve([] as Row[]), }); - /** A row's fields but its route and preview, as `name: value`. */ protected details(row: Row): string { return Object.entries(row) .filter(([k, v]) => !['route', 'preview'].includes(k) && v !== null && v !== '') @@ -181,7 +172,6 @@ export class Revision { const found = row['_held']; return Array.isArray(found) ? found.join('; ') : String(found ?? ''); } - /** The platform's field titles (the catalog's), by entity: what the page calls a field. */ protected readonly titles = resource({ loader: async () => { const found = (await this.api.invoke(schema)) as Record; @@ -201,13 +191,11 @@ export class Revision { protected title(field: string): string { return this.titles.value()?.[this.entity()]?.[field] ?? field; } - /** A hold's reasons as the reviewer reads them (the platform logs them in English). */ protected said(row: Row): string { const found = row['_held']; const all = Array.isArray(found) ? (found as string[]) : [String(found ?? '')]; return all.map((r) => this.spanish(r)).join('; '); } - /** Why linkage proposes two records as one person, in the reviewer's words. */ protected candidateReason(reason: unknown): string { const text = String(reason ?? ''); const typo = /^(\w+) one typo apart$/.exec(text); @@ -272,7 +260,6 @@ export class Revision { ); } - /** Runs the pipeline so the decisions apply, then reloads what is left. */ protected async apply(): Promise { const id = this.pipeline(); if (!id) return; diff --git a/src/print.scss b/src/print.scss index 8a540fb..8d31f62 100644 --- a/src/print.scss +++ b/src/print.scss @@ -4,25 +4,18 @@ body .shell > .footer, mat-toolbar, .mat-mdc-tab-header, button, -app-card-actions, app-report-button, .modebar, .filters .field, .filters input, -.filters select, .filters mat-form-field, mat-button-toggle-group { display: none !important; } -.print-only { - display: inline !important; -} - body .shell, body .main, -body .kpis, -body .clinical { +body .kpis { display: block; } diff --git a/src/styles.scss b/src/styles.scss index 8f75d06..c4a9339 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -1,5 +1,3 @@ -// The platform's look: Material 3 from the brand seeds (olive primary, teal tertiary), -// Roboto for text and Rajdhani for headings, served from the app (internal network). @use '@angular/material' as mat; @use './theme-colors' as brand; @use 'sass:meta'; @@ -38,7 +36,6 @@ html { density: 0, ) ); - // Indicator pages use small corners, as today. --mat-sys-corner-extra-small: 2px; --mat-sys-corner-small: 2px; --mat-sys-corner-medium: 4px; @@ -112,7 +109,6 @@ table.plain th { font-weight: 500; } -// Cards are white on the light background, as today (no M3 surface tint). html { --mat-card-outlined-container-color: var(--color-surface); --mat-card-elevated-container-color: var(--color-surface); @@ -123,10 +119,31 @@ html { white-space: nowrap; } -.print-only { - display: none; -} - @media print { @include meta.load-css('print'); } + +.filters { + display: flex; + flex-wrap: wrap; + gap: var(--space-3); + margin-bottom: var(--space-4); +} + +.worklist-filters mat-form-field { + min-width: 14.5rem; +} + +.indicator-filters { + align-items: center; + background: var(--color-surface); + border: 1px solid var(--color-border); + border-radius: 8px; + gap: var(--space-4); + padding: 16px; +} + +app-tab-riesgos-tea .worklist-filters, +app-tab-seguimiento-tea .worklist-filters { + align-items: center; +}