Add TEA status measure view
This commit is contained in:
@@ -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