Add TEA status measure view
This commit is contained in:
@@ -6,6 +6,12 @@ const loadIndicadores = () => import('./features/indicadores/indicadores-page').
|
|||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
{ path: '', component: Home, title: 'Análisis de información | ISSSTELEON' },
|
{ path: '', component: Home, title: 'Análisis de información | 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: 'Casos por estatus' },
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'conectar',
|
path: 'conectar',
|
||||||
title: 'Conectar datos | ISSSTELEON',
|
title: 'Conectar datos | ISSSTELEON',
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import { provideHttpClient } from '@angular/common/http';
|
||||||
|
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { TeaStatusPage } from './tea-status-page';
|
||||||
|
|
||||||
|
describe('TeaStatusPage', () => {
|
||||||
|
it('shows the stages in a FHIR report and reports a failed query', () => {
|
||||||
|
TestBed.configureTestingModule({ providers: [provideHttpClient(), provideHttpClientTesting()] });
|
||||||
|
const component = TestBed.createComponent(TeaStatusPage).componentInstance;
|
||||||
|
const http = TestBed.inject(HttpTestingController);
|
||||||
|
component.consultar();
|
||||||
|
const request = http.expectOne('/tea/fhir/Measure/M28_casos_por_estado/$evaluate-measure?periodo=2025-S1');
|
||||||
|
request.flush({ group: [{ population: [{ count: 6 }], stratifier: [{ stratum: [
|
||||||
|
{ value: { coding: [{ code: 'SOLO_MCHAT' }] }, population: [{ count: 2 }] },
|
||||||
|
] }] }] });
|
||||||
|
expect(component.total()).toBe(6);
|
||||||
|
expect(component.filas()).toEqual([{ codigo: 'SOLO_MCHAT', nombre: 'M-CHAT', cantidad: 2 }]);
|
||||||
|
component.consultar();
|
||||||
|
http.expectOne('/tea/fhir/Measure/M28_casos_por_estado/$evaluate-measure?periodo=2025-S1')
|
||||||
|
.flush({}, { status: 404, statusText: 'Not Found' });
|
||||||
|
expect(component.estado()).toBe('error');
|
||||||
|
http.verify();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||||
|
import { Component, inject, signal } from '@angular/core';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
|
interface Population { count?: number }
|
||||||
|
interface Stratum { value?: { coding?: { code?: string; display?: string }[] }; population?: Population[] }
|
||||||
|
interface Report { group?: { population?: Population[]; stratifier?: { stratum?: Stratum[] }[] }[] }
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-tea-status-page',
|
||||||
|
imports: [FormsModule],
|
||||||
|
template: `
|
||||||
|
<h1>Casos por estatus</h1>
|
||||||
|
<p>Consulte la etapa alcanzada por las niñas y los niños en el periodo seleccionado.</p>
|
||||||
|
<form (ngSubmit)="consultar()">
|
||||||
|
<label>Periodo <input name="periodo" [(ngModel)]="periodo" required placeholder="2025-S1" /></label>
|
||||||
|
<button type="submit" [disabled]="estado() === 'cargando'">Consultar</button>
|
||||||
|
</form>
|
||||||
|
@if (estado() === 'cargando') { <p role="status">Consultando información…</p> }
|
||||||
|
@if (estado() === 'error') { <p role="alert">No fue posible consultar el periodo. Verifique el periodo e intente de nuevo.</p> }
|
||||||
|
@if (estado() === 'listo') {
|
||||||
|
<p>Total: {{ total() }}</p>
|
||||||
|
@if (filas().length === 0) { <p>No hay casos para este periodo.</p> }
|
||||||
|
@else { <ul>@for (fila of filas(); track fila.codigo) { <li>{{ fila.nombre }}: {{ fila.cantidad }}</li> }</ul> }
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
})
|
||||||
|
export class TeaStatusPage {
|
||||||
|
private readonly http = inject(HttpClient);
|
||||||
|
periodo = '2025-S1';
|
||||||
|
readonly estado = signal<'inicial' | 'cargando' | 'listo' | 'error'>('inicial');
|
||||||
|
readonly total = signal(0);
|
||||||
|
readonly filas = signal<{ codigo: string; nombre: string; cantidad: number }[]>([]);
|
||||||
|
|
||||||
|
consultar() {
|
||||||
|
this.estado.set('cargando');
|
||||||
|
this.http.get<Report>('/tea/fhir/Measure/M28_casos_por_estado/$evaluate-measure', {
|
||||||
|
params: new HttpParams().set('periodo', this.periodo),
|
||||||
|
}).subscribe({
|
||||||
|
next: report => {
|
||||||
|
const group = report.group?.[0];
|
||||||
|
this.total.set(group?.population?.[0]?.count ?? 0);
|
||||||
|
const nombres: Record<string, string> = { SOLO_MCHAT: 'M-CHAT', PSICOLOGIA: 'Psicología', NEUROPEDIATRIA: 'Neuropediatría', EEG: 'EEG' };
|
||||||
|
this.filas.set((group?.stratifier?.[0]?.stratum ?? []).map(s => {
|
||||||
|
const codigo = s.value?.coding?.[0]?.code ?? '';
|
||||||
|
return { codigo, nombre: nombres[codigo] ?? s.value?.coding?.[0]?.display ?? codigo, cantidad: s.population?.[0]?.count ?? 0 };
|
||||||
|
}));
|
||||||
|
this.estado.set('listo');
|
||||||
|
},
|
||||||
|
error: () => this.estado.set('error'),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user