One shell with the current look: indicators, follow-up list and patient view from FHIR; /conectar canvas; /revision; Playwright page tests
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
import { Component, computed, inject, input, resource, signal } from '@angular/core';
|
||||
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import type { Measure, MeasureReport } from 'fhir/r4';
|
||||
import { Fhir, resources } from '../fhir';
|
||||
import { Figure, Plot } from '../plot';
|
||||
import { history, periods, PeriodType, periodTypes, reading } from './measures';
|
||||
|
||||
/** Each measure over time: every period of the chosen kind, oldest first. */
|
||||
@Component({
|
||||
selector: 'app-tab-trazabilidad',
|
||||
imports: [MatButtonToggleModule, MatCardModule, Plot],
|
||||
template: `
|
||||
<div class="bar">
|
||||
<mat-button-toggle-group
|
||||
[value]="type()"
|
||||
(change)="type.set($event.value)"
|
||||
aria-label="Intervalo"
|
||||
>
|
||||
<mat-button-toggle value="month">Mensual</mat-button-toggle>
|
||||
<mat-button-toggle value="semester">Semestral</mat-button-toggle>
|
||||
</mat-button-toggle-group>
|
||||
</div>
|
||||
@if (series.isLoading()) {
|
||||
<p class="muted">Calculando…</p>
|
||||
}
|
||||
<div class="grid">
|
||||
@for (item of figures(); track item.measure.id) {
|
||||
<mat-card appearance="outlined" [attr.data-measure]="item.measure.name">
|
||||
<mat-card-header
|
||||
><mat-card-title>{{ item.measure.title }}</mat-card-title></mat-card-header
|
||||
>
|
||||
<mat-card-content><app-plot [figure]="item.figure" [height]="280" /></mat-card-content>
|
||||
</mat-card>
|
||||
}
|
||||
</div>
|
||||
`,
|
||||
styles: `
|
||||
:host {
|
||||
display: block;
|
||||
padding-top: 16px;
|
||||
}
|
||||
.bar {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.grid {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
@media (min-width: 1304px) {
|
||||
.grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
`,
|
||||
})
|
||||
export class TabTrazabilidad {
|
||||
private readonly fhir = inject(Fhir);
|
||||
readonly domain = input.required<string>();
|
||||
readonly measures = input.required<Measure[]>();
|
||||
protected readonly type = signal<PeriodType>('semester');
|
||||
|
||||
protected readonly series = resource({
|
||||
params: () => ({ domain: this.domain(), type: this.type(), measures: this.measures() }),
|
||||
loader: async ({ params }) => {
|
||||
const asked = periods(params.type).reverse();
|
||||
const shown = params.measures.filter((m) => periodTypes(m).includes(params.type));
|
||||
return Promise.all(
|
||||
shown.map(async (measure) => {
|
||||
const pages = await this.fhir.all(params.domain, 'MeasureReport', {
|
||||
measure: measure.id!,
|
||||
'reporting-period': asked.join(','),
|
||||
});
|
||||
const found = resources<MeasureReport>(pages, 'MeasureReport');
|
||||
return { measure, points: asked.map((period, i) => ({ period, r: reading(found[i]) })) };
|
||||
}),
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
protected readonly figures = computed<{ measure: Measure; figure: Figure }[]>(() =>
|
||||
(this.series.value() ?? []).map(({ measure, points }) => {
|
||||
// From the first period with data on.
|
||||
const first = points.findIndex((p) => (p.r?.populations['initial-population'] ?? 0) > 0);
|
||||
return { measure, figure: history(measure, first < 0 ? [] : points.slice(first)) };
|
||||
}),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user