Indicators: CaCu and CaMa pages read by rounds, genotypes and steps; history to a chosen period; NCI and indicator references; CaMa follow-up export; API client for eligibility and risk series

This commit is contained in:
Roberto Treviño
2026-12-05 23:46:51 -06:00
parent e0084ef9ff
commit d3f6f5c214
45 changed files with 2694 additions and 1157 deletions
+44 -8
View File
@@ -1,12 +1,14 @@
import { Component, computed, inject, input, resource, signal } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatButtonToggleModule } from '@angular/material/button-toggle';
import { MatSelectModule } from '@angular/material/select';
import type { Measure, MeasureReport } from 'fhir/r4';
import { Fhir, resources } from '../fhir';
import { Loading } from '../loading';
import { Figure, Plot } from '../plot';
import { historyFigure } from './figures';
import { periodLabel, periods, PeriodType, reading } from './measures';
import { HISTORY, HistoryPanel } from './pages';
import { periodLabel, periods, periodStart, PeriodType, reading } from './measures';
import { HISTORY, HistoryPanel } from './history';
interface Drawn {
panel: HistoryPanel;
@@ -19,24 +21,37 @@ interface Drawn {
* each measure period by period. */
@Component({
selector: 'app-tab-trazabilidad',
imports: [Loading, MatButtonToggleModule, Plot],
imports: [Loading, MatButtonModule, MatButtonToggleModule, MatSelectModule, Plot],
template: `
<section class="card filters" aria-labelledby="history-filters">
<h2 id="history-filters" class="filters-title">Filtros</h2>
<mat-button-toggle-group
[value]="type()"
(change)="type.set($event.value)"
(change)="setType($event.value)"
aria-label="Intervalo de análisis"
>
<mat-button-toggle value="month">Mensual</mat-button-toggle>
<mat-button-toggle value="semester">Semestral</mat-button-toggle>
</mat-button-toggle-group>
@if (domain() !== 'tea') {
<mat-form-field appearance="outline" subscriptSizing="dynamic">
<mat-label>Periodo seleccionado</mat-label>
<mat-select [value]="chosen()" (selectionChange)="chosen.set($event.value)">
@for (p of options(); track p) {
<mat-option [value]="p">{{ p }}</mat-option>
}
</mat-select>
</mat-form-field>
<button mat-flat-button (click)="upTo.set(chosen())" [disabled]="chosen() === upTo()">
Aplicar
</button>
}
</section>
@if (series.isLoading()) {
<app-loading what="la trazabilidad" text="Cargando trazabilidad…" />
<app-loading what="el histórico" text="Cargando histórico…" />
} @else if (series.error()) {
<p class="muted" role="alert">
No se pudo cargar la trazabilidad.
No se pudo cargar el histórico.
<button type="button" class="retry" (click)="series.reload()">Reintentar</button>
</p>
} @else {
@@ -71,6 +86,12 @@ interface Drawn {
padding: 16px 20px;
margin-bottom: 16px;
}
.filters {
align-items: center;
display: flex;
flex-wrap: wrap;
gap: 16px;
}
.filters-title {
font-size: 16px;
font-weight: 500;
@@ -95,13 +116,28 @@ export class TabTrazabilidad {
readonly domain = input.required<string>();
readonly measures = input.required<Measure[]>();
protected readonly type = signal<PeriodType>('month');
protected readonly options = computed(() => periods(this.type()));
/** The period the history ends in (CaCu, CaMa): the chosen one, once applied. */
protected readonly chosen = signal(periods('month')[0]);
protected readonly upTo = signal(periods('month')[0]);
protected setType(type: PeriodType): void {
this.type.set(type);
this.chosen.set(this.options()[0]);
this.upTo.set(this.options()[0]);
}
protected readonly series = resource({
params: () => ({ domain: this.domain(), type: this.type(), measures: this.measures() }),
params: () => ({
domain: this.domain(),
type: this.type(),
measures: this.measures(),
upTo: this.upTo(),
}),
loader: async ({ params }) => {
const history = HISTORY[params.domain];
if (!history) return [];
const asked = periods(params.type).reverse();
const asked = periods(params.type, 6, periodStart(params.upTo)).reverse();
return Promise.all(
history.panels.map(async (panel) => {
const measure = params.measures.find((m) => m.name === panel.measure);