Gobernanza preview saved as PDF; Playwright TEA page tests
- The EEG preview dialog gets "Guardar como PDF": previewPdfContent is a
pure function (verdict, checks, metrics with scores per electrode and
zone, ADOS-2 classification/CSS and items by their Core titles,
warnings), downloadPreviewPdf a thin wrapper over export/pdf; the file
is tea-gobernanza-<day>.pdf. Unit-tested without mocks.
- e2e/pages.spec.ts now holds only the TEA page tests (the CaCu/CaMa
cases needed fixtures P7 removed): every indicator tab, the follow-up
xlsx export, the patient record and risk page with their PDFs, and
every Gobernanza section in sync mode including the preview PDF. Each
download is checked for a file and a name without a record number.
- Fixes the page tests found: the TEA xlsx name ('seguimiento-tea') failed
validateName, so the export always threw; it is now tea-<page>-<day>.
ng serve crashed on every Plotly page (has-hover reads 'global'): the
build defines global as globalThis. Record numbers repeated once per
source identifier; they are deduplicated. A refused bundle export showed
'{}': the blob error body is now read for the API's detail.
This commit is contained in:
@@ -305,9 +305,13 @@ export function teaRows(page: Bundle) {
|
||||
return {
|
||||
patient,
|
||||
name: patient.name?.[0]?.text,
|
||||
recordNumbers: (patient.identifier ?? [])
|
||||
.filter((i) => i.system?.startsWith('urn:isssteleon:') && !!i.value)
|
||||
.map((i) => i.value!),
|
||||
recordNumbers: [
|
||||
...new Set(
|
||||
(patient.identifier ?? [])
|
||||
.filter((i) => i.system?.startsWith('urn:isssteleon:') && !!i.value)
|
||||
.map((i) => i.value!),
|
||||
),
|
||||
],
|
||||
status,
|
||||
steps: TEA_STEPS.map((step, i) => ({
|
||||
...step,
|
||||
|
||||
@@ -14,6 +14,7 @@ import { associationRows, teaParams, teaWorkbook } from './tea-list';
|
||||
const measure: Measure = { resourceType: 'Measure', status: 'active' };
|
||||
const r: Reading = { strata: {}, populations: {}, score: 12, low: 7, high: 18 };
|
||||
const cssPair = 'spindles|central|CSS';
|
||||
const DAY = new Date('2026-11-30T12:00:00Z');
|
||||
|
||||
function fixture(): Bundle {
|
||||
const subject = { reference: 'Patient/child' };
|
||||
@@ -233,8 +234,8 @@ describe('TEA indicators', () => {
|
||||
});
|
||||
|
||||
it('builds the follow-up workbook', () => {
|
||||
expect(teaWorkbook(teaRows(fixture()), false)).toEqual({
|
||||
name: 'seguimiento-tea',
|
||||
expect(teaWorkbook(teaRows(fixture()), false, DAY)).toEqual({
|
||||
name: 'tea-seguimiento-2026-11-30',
|
||||
sheets: [
|
||||
expect.objectContaining({
|
||||
name: 'Seguimiento',
|
||||
@@ -247,8 +248,8 @@ describe('TEA indicators', () => {
|
||||
});
|
||||
|
||||
it('builds the risk workbook with children and pair details', () => {
|
||||
expect(teaWorkbook(associationRows(teaRows(fixture())), true)).toEqual({
|
||||
name: 'analisis-de-riesgo-tea',
|
||||
expect(teaWorkbook(associationRows(teaRows(fixture())), true, DAY)).toEqual({
|
||||
name: 'tea-riesgos-2026-11-30',
|
||||
sheets: [
|
||||
expect.objectContaining({ name: 'Niños' }),
|
||||
expect.objectContaining({
|
||||
|
||||
@@ -6,6 +6,7 @@ import { RouterLink } from '@angular/router';
|
||||
import type { Bundle, Patient } from 'fhir/r4';
|
||||
import { debounceTime, distinctUntilChanged, map } from 'rxjs';
|
||||
import { allRows } from '../export/fetch-all';
|
||||
import { safeName } from '../export/safe-name';
|
||||
import { downloadXlsx, type Sheet } from '../export/xlsx';
|
||||
import { Fhir, type Params } from '../fhir';
|
||||
import { TEA_STEPS, teaRows, type TeaRow } from './follow-up';
|
||||
@@ -140,7 +141,11 @@ function parameters(page?: Bundle): Record<string, string> {
|
||||
const columns = (entries: [string, string][]): Sheet['columns'] =>
|
||||
entries.map(([key, header]) => ({ key, header }));
|
||||
|
||||
export function teaWorkbook(rows: TeaRow[], risk: boolean): { name: string; sheets: Sheet[] } {
|
||||
export function teaWorkbook(
|
||||
rows: TeaRow[],
|
||||
risk: boolean,
|
||||
day = new Date(),
|
||||
): { name: string; sheets: Sheet[] } {
|
||||
const identity: [string, string][] = [
|
||||
['id', 'Paciente'],
|
||||
['record', 'Expediente'],
|
||||
@@ -194,7 +199,8 @@ export function teaWorkbook(rows: TeaRow[], risk: boolean): { name: string; shee
|
||||
rows: rows.flatMap((row) => row.pairs.map((pair) => ({ id: row.patient.id, ...pair }))),
|
||||
});
|
||||
}
|
||||
return { name: risk ? 'analisis-de-riesgo-tea' : 'seguimiento-tea', sheets };
|
||||
const page = risk ? 'riesgos' : 'seguimiento';
|
||||
return { name: safeName(['tea', page, day.toISOString().slice(0, 10)]), sheets };
|
||||
}
|
||||
|
||||
export function exportTea(
|
||||
|
||||
Reference in New Issue
Block a user