import { Component, computed, input } from '@angular/core'; import type { Measure } from 'fhir/r4'; import { DOMAINS } from '../app'; import type { Domain } from '../api/models/domain'; import { code, label } from '../fhir'; import { periodTypes, STRATA } from './measures'; const SCORING: Record = { proportion: 'Proporción', 'continuous-variable': 'Variable continua (mediana)', cohort: 'Composición (conteo)', }; const IMPROVEMENT: Record = { increase: 'Mejor si sube', decrease: 'Mejor si baja', }; 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: `

Datos y definiciones de {{ domainName() }}

Información del dominio

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

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

} @if (available().length) {

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

} @else {

Periodicidad: pendiente de información.

}

Catálogo de indicadores

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

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

{{ m.description }}

}

Cálculo

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

Tipos de periodo admitidos

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

Pendiente de información.

}

Estratos

{{ strata(m) }}

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

} @empty {

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

}
`, styles: ` :host { display: block; padding-top: 16px; } .card { background: var(--mat-sys-surface); border: 1px solid var(--mat-sys-outline-variant); border-radius: 12px; padding: 16px 20px; } h2, h3 { font-size: 20px; font-weight: 500; } h4 { font-size: 14px; font-weight: 500; margin: 12px 0 4px; } details { border-bottom: 1px solid var(--mat-sys-outline-variant); padding: 8px 0; } summary { cursor: pointer; font-weight: 500; } .indicator-detail { padding: 4px 0 8px 16px; } `, }) export class TabDefiniciones { readonly domain = input.required(); readonly measures = input.required(); protected readonly scoring = SCORING; protected readonly improvement = IMPROVEMENT; protected readonly code = code; protected readonly domainName = computed( () => DOMAINS[this.domain() as Domain]?.toLocaleLowerCase('es-MX') ?? this.domain(), ); /** The periodicities any of its indicators admits. */ protected readonly available = computed(() => [...new Set(this.measures().flatMap((m) => periodTypes(m)))].map((p) => PERIODS[p] ?? p), ); protected types(m: Measure): string[] { return periodTypes(m).map((p) => PERIODS[p] ?? p); } protected strata(m: Measure): string { const names = (m.group?.[0]?.stratifier ?? []).map((s) => code(s.code) ?? label(s.code)); return names.map((n) => STRATA[n] ?? n).join(', ') || '—'; } }