diff --git a/src/app/app.config.ts b/src/app/app.config.ts index d9c42bd..a8b7623 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -2,11 +2,21 @@ import { ApplicationConfig, provideBrowserGlobalErrorListeners } from '@angular/ import { provideHttpClient } from '@angular/common/http'; import { provideRouter } from '@angular/router'; import { routes } from './app.routes'; +import { IndicadoresService } from './features/indicadores/indicadores.service'; +import { IndicadoresPeriodos } from './features/indicadores/indicadores-periodos'; +import { TeaSeguimientoService } from './features/indicadores/tea-seguimiento.service'; +import { FhirIndicadoresPeriodos, FhirIndicadoresService } from './features/indicadores/indicadores-fhir'; +import { FhirTeaSeguimientoService } from './features/indicadores/tea-seguimiento-fhir'; export const appConfig: ApplicationConfig = { providers: [ provideBrowserGlobalErrorListeners(), provideRouter(routes), provideHttpClient(), + // The indicator page reads the WebApi's FHIR endpoint; without these lines it reads the indicator JSON contract + // (`//indicadores//datos`, `/tea/seguimiento`). + { provide: IndicadoresService, useClass: FhirIndicadoresService }, + { provide: IndicadoresPeriodos, useClass: FhirIndicadoresPeriodos }, + { provide: TeaSeguimientoService, useClass: FhirTeaSeguimientoService }, ] }; diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 9857d72..feed61d 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -7,12 +7,11 @@ const loadIndicadores = () => import('./features/indicadores/indicadores-page'). export const routes: Routes = [ { path: '', component: Home, title: 'Análisis de información | ISSSTELEON' }, { - path: 'indicadores/tea', - title: 'Indicadores TEA | ISSSTELEON', + path: 'indicadores/tea-estatus', + title: 'Casos por estatus | ISSSTELEON', loadComponent: () => import('./features/indicadores/tea-status-page').then(m => m.TeaStatusPage), - data: { workspace: true, breadcrumb: 'Indicadores TEA' }, + data: { workspace: true, breadcrumb: 'Casos por estatus' }, }, - { path: 'indicadores/tea-estatus', pathMatch: 'full', redirectTo: 'indicadores/tea' }, { path: 'conectar', title: 'Conectar datos | ISSSTELEON', @@ -40,7 +39,7 @@ export const routes: Routes = [ data: { workspace: true, breadcrumb: 'Indicadores' }, }, { path: 'indicadores', pathMatch: 'full', redirectTo: 'indicadores/tea' }, - ...DOMINIOS.filter(dominio => dominio !== 'tea').map(dominio => ({ + ...DOMINIOS.map(dominio => ({ path: `indicadores/${dominio}`, title: 'Indicadores | ISSSTELEON', data: { workspace: true, breadcrumb: 'Indicadores', dominio }, diff --git a/src/app/features/indicadores/cacu-seguimiento.models.ts b/src/app/features/indicadores/cacu-seguimiento.models.ts index d6f1b6c..7197e8c 100644 --- a/src/app/features/indicadores/cacu-seguimiento.models.ts +++ b/src/app/features/indicadores/cacu-seguimiento.models.ts @@ -1,4 +1,4 @@ -export interface SeguimientoQuery { corte?: string; meses: 1 | 3 | 6 | 12; estatus?: string; page: number; page_size: number; } +export interface SeguimientoQuery { corte?: string; meses: 1 | 3 | 6 | 12; estatus?: string; grupo_edad?: string; mchat?: string; css?: string; estado_caso?: string; alteracion?: string; page: number; page_size: number; } export interface SeguimientoStatus { codigo: string; etiqueta: string; } export interface SeguimientoPaciente { id_seudonimo: string; diff --git a/src/app/features/indicadores/cacu-seguimiento.spec.ts b/src/app/features/indicadores/cacu-seguimiento.spec.ts index f3c85c8..9b74a50 100644 --- a/src/app/features/indicadores/cacu-seguimiento.spec.ts +++ b/src/app/features/indicadores/cacu-seguimiento.spec.ts @@ -16,11 +16,10 @@ describe('Seguimiento CaCu con contrato de demostración', () => { afterEach(()=>{ fixture.destroy(); http.verify(); }); function open() { fixture.componentRef.setInput('active',true); fixture.detectChanges(); return http.expectOne(r=>r.url==='/cacu/seguimiento'); } function respond() { open().flush(fixtureData); http.expectOne('/cacu/indicadores/cacu_eu7/metadatos').flush({categorias:{NORMAL:{etiqueta:'Normal'}}}); fixture.detectChanges(); } - it('prioridad deshabilitada con una sola opción y sin parámetros nuevos al consultar o paginar', () => { + it('sin selector de prioridad ni filtros de TEA, y sin parámetros nuevos al consultar o paginar', () => { respond(); - const select = fixture.nativeElement.querySelector('select[name="prioridad"]') as HTMLSelectElement; - expect(select.disabled).toBe(true); expect(select.labels?.[0].textContent).toContain('Ordenar por prioridad'); - expect(Array.from(select.options).map(o => o.text)).toEqual(['No disponible']); + expect(fixture.nativeElement.querySelector('select[name="prioridad"]')).toBeNull(); + expect(fixture.nativeElement.querySelector('select[name="mchat"]')).toBeNull(); const order = fixture.componentInstance.data!.items.map(i => i.id_seudonimo); expect(Array.from(fixture.nativeElement.querySelectorAll('tbody tr td:first-child')).map(e => (e as HTMLElement).textContent)).toEqual(order); fixture.componentInstance.apply(); @@ -92,7 +91,7 @@ describe('Seguimiento CaCu con contrato de demostración', () => { expect(()=>seguimientoResponse({...fixtureData,items:[{...fixtureData.items[2],ultima_citologia:{...fixtureData.items[2].ultima_citologia,calidad:42}}]})).toThrow(); open().flush({...fixtureData,simulado:false}); fixture.detectChanges(); expect(fixture.nativeElement.querySelector('tbody')).toBeNull(); }); - it.each(['tea','cama'])('%s conserva su estado pendiente sin consultas de pacientes', dominio => { + it.each(['cama'])('%s conserva su estado pendiente sin consultas de pacientes', dominio => { fixture.componentRef.setInput('dominio',dominio); fixture.componentRef.setInput('active',true); fixture.detectChanges(); http.expectNone(()=>true); expect(fixture.nativeElement.textContent).toContain('El seguimiento aún no está disponible'); expect(fixture.nativeElement.textContent).not.toContain('Columnas propuestas para revisión.'); diff --git a/src/app/features/indicadores/fhir.ts b/src/app/features/indicadores/fhir.ts new file mode 100644 index 0000000..016d0fc --- /dev/null +++ b/src/app/features/indicadores/fhir.ts @@ -0,0 +1,54 @@ +// The parts of FHIR R4 the WebApi's `//fhir/` endpoints serve, read loosely: every field is optional and the +// readers below decide what a missing one means. + +export interface Coding { system?: string; code?: string; display?: string } +export interface Concept { coding?: Coding[]; text?: string } +export interface Quantity { value?: number; unit?: string } +export interface Extension { + url: string; + valueCode?: string; valueString?: string; valueInteger?: number; valueDecimal?: number; + valueDate?: string; valueDateTime?: string; valueCoding?: Coding; valueReference?: { reference?: string }; + extension?: Extension[]; +} +export interface Resource { + resourceType: string; + id?: string; + meta?: { tag?: Coding[] }; + extension?: Extension[]; + [field: string]: unknown; +} +export interface Bundle extends Resource { + total?: number; + entry?: { fullUrl?: string; resource: Resource; search?: { mode?: string } }[]; +} + +export const CODE_SYSTEM = 'https://isssteleon.org/fhir/CodeSystem/'; + +export function code(concept: Concept | undefined): string | undefined { + return concept?.coding?.[0]?.code; +} +export function display(concept: Concept | undefined): string | undefined { + return concept?.coding?.[0]?.display ?? concept?.text; +} +// The code of a concept from `system` (a name under the project's CodeSystem base, or a full URL). +export function codeIn(concept: Concept | undefined, system: string): string | undefined { + const url = system.includes('://') ? system : CODE_SYSTEM + system; + return concept?.coding?.find(c => c.system === url)?.code; +} +// The extensions named `name` (the last segment of their URL). +export function extensions(owner: { extension?: Extension[] } | undefined, name: string): Extension[] { + return (owner?.extension ?? []).filter(e => e.url === name || e.url.endsWith('/' + name)); +} +export function extension(owner: { extension?: Extension[] } | undefined, name: string): Extension | undefined { + return extensions(owner, name)[0]; +} +export function resources(bundle: Bundle | undefined, type?: string): Resource[] { + return (bundle?.entry ?? []).map(e => e.resource).filter(r => !type || r.resourceType === type); +} +export function isSimulated(resource: Resource): boolean { + return !!resource.meta?.tag?.some(t => t.code === 'simulado'); +} +// `Patient/P-1` -> `P-1`. +export function referenceId(reference: { reference?: string } | undefined): string | undefined { + return reference?.reference?.split('/').pop(); +} diff --git a/src/app/features/indicadores/indicador-catalog-card.spec.ts b/src/app/features/indicadores/indicador-catalog-card.spec.ts index eb30893..062b9b9 100644 --- a/src/app/features/indicadores/indicador-catalog-card.spec.ts +++ b/src/app/features/indicadores/indicador-catalog-card.spec.ts @@ -3,7 +3,6 @@ import { TestBed } from '@angular/core/testing'; import { provideHttpClient } from '@angular/common/http'; import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing'; import { By } from '@angular/platform-browser'; -import { MatSelect } from '@angular/material/select'; import { IndicadorCatalogCard } from './indicador-catalog-card'; import { IndicadorFigureCard } from './indicador-figure-card'; import { IndicadorFigurePanel } from './indicador-figure-panel'; @@ -28,7 +27,6 @@ describe('UX-06E.D.2.1 selector de representación', () => { fixture.componentRef.setInput('indicador', { id: 'i', titulo: 'I', contrato: 'C2', figuras, tipos_periodo: ['semestre'] }); fixture.componentRef.setInput('tema', 'claro'); fixture.componentRef.setInput('applied', applied); fixture.detectChanges(); } - function select() { return fixture.debugElement.query(By.directive(MatSelect)).componentInstance as MatSelect; } function panels() { return fixture.debugElement.queryAll(By.directive(IndicadorFigurePanel)).filter(e => e.componentInstance.result().status !== 'deferred'); } function request(id: string) { return http.expectOne(r => r.url.endsWith('/figuras/' + id)); } function open() { fixture.componentInstance.setVisible(true); fixture.detectChanges(); } @@ -47,13 +45,9 @@ describe('UX-06E.D.2.1 selector de representación', () => { expect(fixture.componentInstance.indicador.contrato).toBe(contrato); http.expectNone(() => true); }); - it('UX-07A/07D.1 presenta nombres amigables y conserva IDs para selector, consulta y memoria', () => { + it('UX-07A/07D.1 presenta nombres amigables y conserva IDs para consulta y memoria', () => { fixture.destroy(); create(['fig_c1_grupos', 'fig_c2_apiladas', 'fig_c2_barras', 'fig_c2_donas', 'fig_c9_futura']); fixture.componentRef.setInput('indicador', { ...fixture.componentInstance.indicador, contrato: 'C1' }); fixture.detectChanges(); - expect(select().options.map(option => [option.value, option.viewValue])).toEqual([ - ['fig_c1_grupos', 'Grupos'], ['fig_c2_apiladas', 'Barras apiladas'], - ['fig_c2_barras', 'Barras'], ['fig_c2_donas', 'Donas'], ['fig_c9_futura', 'Representación 5'], - ]); http.expectNone(() => true); open(); request('fig_c1_grupos').flush({ data: [], layout: {} }); for (const [id, label] of [ @@ -62,7 +56,7 @@ describe('UX-06E.D.2.1 selector de representación', () => { ['fig_c2_donas', 'Donas'], ['fig_c9_futura', 'Representación 5'], ]) { - select().selectionChange.emit({ source: select(), value: id }); fixture.detectChanges(); + fixture.componentInstance.selectFigure(id); fixture.detectChanges(); const pending = request(id); expect(pending.request.url).toBe('/cacu/indicadores/i/figuras/' + id); expect(pending.request.params.get('tema')).toBe('claro'); @@ -74,9 +68,9 @@ describe('UX-06E.D.2.1 selector de representación', () => { } http.expectNone(() => true); }); - it('una opción publicada está deshabilitada y sólo consulta esa figura', () => { - fixture.destroy(); create(['f']); open(); expect(select().disabled).toBe(true); - expect(select().options.map(o => o.value)).toEqual(['f']); request('f').flush({ data: [], layout: {} }); http.expectNone(() => true); + it('no ofrece selector de representación y sólo consulta la figura mostrada', () => { + fixture.destroy(); create(['f', 'g']); open(); expect(fixture.nativeElement.querySelector('mat-select')).toBeNull(); + request('f').flush({ data: [], layout: {} }); http.expectNone(() => true); }); it('comparte una sola solicitud de metadatos entre las dos figuras y asocia por ID exacto', () => { fixture.componentRef.setInput('indicador', { id: 'cacu_eu13', titulo: 'EU13', contrato: 'C2', @@ -98,9 +92,8 @@ describe('UX-06E.D.2.1 selector de representación', () => { expect(cards.every(card => card.interpretation.every(line => line !== 'No debe asignarse.'))).toBe(true); }); it('múltiples opciones habilitan el selector, mantienen una representación y cancelan cambios rápidos', () => { - open(); const first = request('f'); expect(select().disabled).toBe(false); - expect(select().options.map(o => o.value)).toEqual(['f', 'g']); expect(panels()).toHaveLength(1); - select().selectionChange.emit({ source: select(), value: 'g' }); fixture.detectChanges(); + open(); const first = request('f'); expect(panels()).toHaveLength(1); + fixture.componentInstance.selectFigure('g'); fixture.detectChanges(); const next = request('g'); expect(first.cancelled).toBe(true); expect(panels()).toHaveLength(1); expect(next.request.params.get('periodos')).toBe('2025-S1'); fixture.componentInstance.selectFigure('f'); fixture.detectChanges(); expect(next.cancelled).toBe(true); diff --git a/src/app/features/indicadores/indicador-catalog-card.ts b/src/app/features/indicadores/indicador-catalog-card.ts index 25e56cd..29fa3db 100644 --- a/src/app/features/indicadores/indicador-catalog-card.ts +++ b/src/app/features/indicadores/indicador-catalog-card.ts @@ -2,8 +2,6 @@ import { ChangeDetectorRef, Component, effect, ElementRef, inject, Input, OnChan import { catchError, of, Subscription } from 'rxjs'; import { MatButtonModule } from '@angular/material/button'; import { MatCardModule } from '@angular/material/card'; -import { MatFormFieldModule } from '@angular/material/form-field'; -import { MatSelectModule } from '@angular/material/select'; import { MatIconModule } from '@angular/material/icon'; import { Dominio, Indicador, IndicadorMetadatos, Tema } from './indicadores.models'; import { GlobalApplied, IndicadoresMemory } from './indicadores-memory'; @@ -25,7 +23,7 @@ import { parTiempos } from './indicadores-tiempos-pareados'; @Component({ selector: 'app-indicador-catalog-card', host: { '[class.dual-card]': 'isDual || isEu7 || isConfirmacion || !!tiempos' }, - imports: [MatButtonModule, MatCardModule, MatIconModule, MatFormFieldModule, MatSelectModule, IndicadorFigurePanel, IndicadorEu7Escenario, IndicadorTiemposPareados, IndicadorConfirmacionCitologia], + imports: [MatButtonModule, MatCardModule, MatIconModule, IndicadorFigurePanel, IndicadorEu7Escenario, IndicadorTiemposPareados, IndicadorConfirmacionCitologia], template: `
@@ -53,16 +51,6 @@ import { parTiempos } from './indicadores-tiempos-pareados'; } @else if (selectedFigure) { - @if (!pair.length || otherFigures.length) { - - Representación gráfica - - @if (pair.length) { Dona y barras } - @for (figure of (pair.length ? otherFigures : indicador.figuras); track figure) { {{ figureDisplayName(figure, indicador.figuras) }} } - - - }
@for (figure of displayFigures; track panelIdentity(figure)) {
@@ -136,7 +124,6 @@ export class IndicadorCatalogCard implements OnChanges, OnDestroy { get isConfirmacion() { return this.dominio === 'cacu' && this.indicador.id === ID_CONFIRMACION; } // Connected time pairs replace the diagnosis card with one coordinated box plot. get tiempos() { return parTiempos(this.dominio, this.indicador.id); } - get otherFigures() { return this.indicador.figuras.filter(id => !this.pair.includes(id)); } get isDual() { return this.pair.includes(this.selectedFigure ?? ''); } get displayFigures() { return this.isDual ? this.pair : this.selectedFigure ? [this.selectedFigure] : []; } private updateNumeric() { diff --git a/src/app/features/indicadores/indicador-figure-card.html b/src/app/features/indicadores/indicador-figure-card.html index 817476f..406c5c4 100644 --- a/src/app/features/indicadores/indicador-figure-card.html +++ b/src/app/features/indicadores/indicador-figure-card.html @@ -83,7 +83,23 @@
} - @if (state.status === 'ready' && state.donutLegend?.length) { + @if (state.status === 'ready' && state.highlight; as h) { +
+

Selección: {{ highlightStatus }}

+ + @for (row of highlightRows(h); track row.group?.id ?? '') { +
+ @if (row.group; as g) { + + } + @for (c of row.items; track c.id) { + + } +
+ } +
+ } @else if (state.status === 'ready' && state.donutLegend?.length) {
@for (entry of state.donutLegend; track entry.label) { @@ -94,7 +110,7 @@ }
- +
}