Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c0e4920159 | |||
| 31400c77b1 |
+11
-116
@@ -1,4 +1,3 @@
|
|||||||
import { readFileSync } from 'node:fs';
|
|
||||||
import { expect, Page, test } from '@playwright/test';
|
import { expect, Page, test } from '@playwright/test';
|
||||||
|
|
||||||
/** Every page loads from the API with no failed request and no console error. */
|
/** Every page loads from the API with no failed request and no console error. */
|
||||||
@@ -10,32 +9,6 @@ function watch(page: Page): string[] {
|
|||||||
return problems;
|
return problems;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The pages show only to someone signed in (the API itself answers everyone).
|
|
||||||
test.beforeEach(async ({ page }) => {
|
|
||||||
const signed = await page.request.post('/api/auth/login', {
|
|
||||||
form: { username: 'admin@isssteleon.mx', password: 'solo-para-pruebas' },
|
|
||||||
});
|
|
||||||
expect(signed.status()).toBe(204);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('login: the pages wait for a sign-in, and a wrong password says so', async ({ browser }) => {
|
|
||||||
const page = await browser.newPage({ baseURL: 'http://127.0.0.1:4310' });
|
|
||||||
await page.goto('/conectar');
|
|
||||||
await expect(page).toHaveURL(/\/login\?next=%2Fconectar/);
|
|
||||||
await expect(page.getByRole('heading', { name: 'Inicio de sesión' })).toBeVisible();
|
|
||||||
await page.getByRole('textbox', { name: 'Usuario' }).fill('admin@isssteleon.mx');
|
|
||||||
await page.getByRole('textbox', { name: 'Contraseña' }).fill('otra');
|
|
||||||
await page.getByRole('button', { name: 'Ingresar' }).click();
|
|
||||||
await expect(page.getByText('Usuario o contraseña incorrectos.')).toBeVisible();
|
|
||||||
await page.getByRole('textbox', { name: 'Contraseña' }).fill('solo-para-pruebas');
|
|
||||||
await page.getByRole('button', { name: 'Ingresar' }).click();
|
|
||||||
await expect(page).toHaveURL(/\/conectar$/);
|
|
||||||
await page.getByRole('button', { name: 'Cuenta' }).click();
|
|
||||||
await page.getByRole('menuitem', { name: 'Salir' }).click();
|
|
||||||
await expect(page).toHaveURL(/\/login/);
|
|
||||||
await page.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("indicators: the KPIs are the API's MeasureReports, every tab and the patient view load", async ({
|
test("indicators: the KPIs are the API's MeasureReports, every tab and the patient view load", async ({
|
||||||
page,
|
page,
|
||||||
}) => {
|
}) => {
|
||||||
@@ -46,19 +19,21 @@ test("indicators: the KPIs are the API's MeasureReports, every tab and the patie
|
|||||||
r.url().includes('measure=cacu-eu7') &&
|
r.url().includes('measure=cacu-eu7') &&
|
||||||
!r.url().includes('%2C'),
|
!r.url().includes('%2C'),
|
||||||
);
|
);
|
||||||
|
const catalog = page.waitForResponse((r) => r.url().endsWith('/cacu/fhir/Measure'));
|
||||||
await page.goto('/indicadores/cacu');
|
await page.goto('/indicadores/cacu');
|
||||||
|
const measures = await (await catalog).json();
|
||||||
const eu7 = await (await report).json();
|
const eu7 = await (await report).json();
|
||||||
const count = eu7.entry[0].resource.group[0].population.find(
|
const count = eu7.entry[0].resource.group[0].population.find(
|
||||||
(p: any) => p.code.coding[0].code === 'initial-population',
|
(p: any) => p.code.coding[0].code === 'initial-population',
|
||||||
).count;
|
).count;
|
||||||
await expect(page.locator('[data-measure="CACU_EU7"] .kpi-value')).toHaveText(String(count));
|
await expect(page.locator('[data-measure="CACU_EU7"] mat-card-subtitle')).toContainText(String(count));
|
||||||
await expect(page.locator('app-tab-indicadores app-plot').first()).toBeVisible();
|
await expect(page.locator('app-tab-indicadores app-plot').first()).toBeVisible();
|
||||||
|
|
||||||
await page.getByRole('tab', { name: 'Trazabilidad' }).click();
|
await page.getByRole('tab', { name: 'Trazabilidad' }).click();
|
||||||
await expect(page.locator('app-tab-trazabilidad mat-card')).toHaveCount(14);
|
await expect(page.locator('app-tab-trazabilidad mat-card')).toHaveCount(measures.total);
|
||||||
|
|
||||||
await page.getByRole('tab', { name: 'Datos y definiciones' }).click();
|
await page.getByRole('tab', { name: 'Datos y definiciones' }).click();
|
||||||
await expect(page.locator('app-tab-definiciones tbody tr')).toHaveCount(14);
|
await expect(page.locator('app-tab-definiciones tbody tr')).toHaveCount(measures.total);
|
||||||
|
|
||||||
const list = page.waitForResponse((r) => r.url().includes('/fhir/Patient?'));
|
const list = page.waitForResponse((r) => r.url().includes('/fhir/Patient?'));
|
||||||
await page.getByRole('tab', { name: 'Análisis de riesgos' }).click();
|
await page.getByRole('tab', { name: 'Análisis de riesgos' }).click();
|
||||||
@@ -81,13 +56,13 @@ test("indicators: the KPIs are the API's MeasureReports, every tab and the patie
|
|||||||
|
|
||||||
await page.goto('/indicadores/cama');
|
await page.goto('/indicadores/cama');
|
||||||
await expect(page.getByRole('tab', { name: 'Indicadores' })).toBeVisible();
|
await expect(page.getByRole('tab', { name: 'Indicadores' })).toBeVisible();
|
||||||
await page.getByRole('tab', { name: 'Análisis de riesgos' }).click();
|
await page.getByRole('tab', { name: 'Seguimiento' }).click();
|
||||||
await page.locator('mat-form-field', { hasText: 'Ventana' }).click();
|
await page.locator('mat-form-field', { hasText: 'Ventana' }).click();
|
||||||
await page.getByRole('option', { name: '12 meses' }).click();
|
await page.getByRole('option', { name: '12 meses' }).click();
|
||||||
const camaRows = page.locator('table.worklist tbody tr');
|
const camaRows = page.locator('table.worklist tbody tr');
|
||||||
await expect(camaRows.first()).toContainText('BI-RADS');
|
await expect(camaRows.first()).toContainText('BI-RADS');
|
||||||
await page.goto('/indicadores/tea');
|
await page.goto('/indicadores/tea');
|
||||||
await expect(page.getByRole('tab', { name: 'Resumen' })).toBeVisible();
|
await expect(page.getByRole('tab', { name: 'Indicadores' })).toBeVisible();
|
||||||
expect(problems).toEqual([]);
|
expect(problems).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -98,12 +73,12 @@ test('conectar: open the hospital pipeline, preview a source, run it to success'
|
|||||||
await page.goto('/conectar');
|
await page.goto('/conectar');
|
||||||
await page.getByText('cacu', { exact: true }).click();
|
await page.getByText('cacu', { exact: true }).click();
|
||||||
await expect(page.locator('vflow')).toBeVisible();
|
await expect(page.locator('vflow')).toBeVisible();
|
||||||
await page.getByText('Fuente de datos · Patients').click();
|
await page.getByText('Fuente · Patients').click();
|
||||||
await expect(page.locator('formly-form')).toBeVisible(); // drawn by hand: its raw form
|
await expect(page.locator('formly-form')).toBeVisible();
|
||||||
await page.getByRole('button', { name: 'Vista previa' }).click();
|
await page.getByRole('button', { name: 'Vista previa' }).click();
|
||||||
await expect(page.locator('.preview tr[mat-row]').first()).toBeVisible();
|
await expect(page.locator('.preview tr[mat-row]').first()).toBeVisible();
|
||||||
// A map node shows the site's codes in platform terms (its ConceptMap), editable as rows.
|
// A map node shows the site's codes in platform terms (its ConceptMap), editable as rows.
|
||||||
await page.getByText('Traducir códigos · cytology', { exact: true }).click();
|
await page.getByText('Mapear · cytology', { exact: true }).click();
|
||||||
await expect(page.getByText('Códigos del sitio')).toBeVisible();
|
await expect(page.getByText('Códigos del sitio')).toBeVisible();
|
||||||
await expect
|
await expect
|
||||||
.poll(() =>
|
.poll(() =>
|
||||||
@@ -117,9 +92,7 @@ test('conectar: open the hospital pipeline, preview a source, run it to success'
|
|||||||
expect(problems).toEqual([]);
|
expect(problems).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('revision: what the hospital source holds, and a decision through the page', async ({
|
test('revision: what the hospital source holds, and a decision through the page', async ({ page }) => {
|
||||||
page,
|
|
||||||
}) => {
|
|
||||||
const problems = watch(page);
|
const problems = watch(page);
|
||||||
await page.goto('/revision');
|
await page.goto('/revision');
|
||||||
await page.getByRole('tab', { name: 'Personas' }).click();
|
await page.getByRole('tab', { name: 'Personas' }).click();
|
||||||
@@ -145,81 +118,3 @@ test('gobernanza: a version with its reports, its curves, and promotion refused
|
|||||||
await expect(page.getByText('No se promovió')).toContainText('clinical_validation');
|
await expect(page.getByText('No se promovió')).toContainText('clinical_validation');
|
||||||
expect(problems.filter((p) => !p.includes('409'))).toEqual([]);
|
expect(problems.filter((p) => !p.includes('409'))).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('conectar: someone who knows nothing of databases connects the SQL Server with the dialog', async ({
|
|
||||||
page,
|
|
||||||
}) => {
|
|
||||||
const site = new URL((process.env['SITE_URL'] ?? '').replace(/^mssql\+pymssql/, 'http'));
|
|
||||||
const problems = watch(page);
|
|
||||||
await page.goto('/conectar');
|
|
||||||
await page.getByLabel('Nueva canalización').fill('asistente');
|
|
||||||
await page.getByLabel('Nueva canalización').press('Enter');
|
|
||||||
await page.getByRole('button', { name: 'Fuente de datos' }).click();
|
|
||||||
await expect(page.getByText('¿Dónde están los datos?')).toBeVisible();
|
|
||||||
await page.locator('[data-type="sqlserver"]').click();
|
|
||||||
await page.locator('[data-field="host"]').fill(site.hostname);
|
|
||||||
await page.locator('[data-field="database"]').fill(site.pathname.slice(1));
|
|
||||||
await page.locator('[data-field="user"]').fill(decodeURIComponent(site.username));
|
|
||||||
await page.locator('[data-field="password"]').fill(decodeURIComponent(site.password));
|
|
||||||
await page.getByRole('button', { name: 'Probar conexión' }).click();
|
|
||||||
await expect(page.getByText('Conexión correcta: 1 tabla.')).toBeVisible();
|
|
||||||
await page.locator('mat-select[data-field="table"]').click();
|
|
||||||
await page.getByRole('option', { name: 'ResultadoSubrogado' }).click();
|
|
||||||
await expect(page.getByText(/Primeras \d+ filas/)).toBeVisible();
|
|
||||||
await page.getByLabel('Nombre de esta fuente').fill('Resultados');
|
|
||||||
await page.getByRole('button', { name: 'Guardar', exact: true }).last().click();
|
|
||||||
await expect(page.getByText('Fuente de datos · Resultados')).toBeVisible();
|
|
||||||
// A wrong password says so in words, not a stack trace.
|
|
||||||
await page.getByRole('button', { name: 'Editar conexión' }).click();
|
|
||||||
await page.locator('[data-field="password"]').fill('not-it');
|
|
||||||
await page.getByRole('button', { name: 'Probar conexión' }).click();
|
|
||||||
await expect(page.getByText(/usuario o la contraseña no son correctos/)).toBeVisible();
|
|
||||||
await page.getByRole('button', { name: 'Cancelar' }).click();
|
|
||||||
await page.getByRole('button', { name: 'Guardar', exact: true }).click();
|
|
||||||
await expect(page.getByText('Versión 1 guardada.')).toBeVisible();
|
|
||||||
expect(problems).toEqual([]);
|
|
||||||
});
|
|
||||||
|
|
||||||
/** The old app's Indicadores tab as captured (tools/capture_pages.py): its headings from the
|
|
||||||
* opportunity section on, in order, and the kind of each plot (its traces' types). */
|
|
||||||
function captured(domain: string) {
|
|
||||||
const path = `../tests/fixtures/reference/${domain}/ui/pages.json`;
|
|
||||||
const tabs = JSON.parse(readFileSync(path, 'utf8')).tabs;
|
|
||||||
const items = (tabs['Indicadores'] ?? tabs['Resumen']) as any[]; // TEA's first tab is its summary
|
|
||||||
const from = items.findIndex((i) => i.text === 'Indicadores de oportunidad');
|
|
||||||
return items
|
|
||||||
.slice(from)
|
|
||||||
.filter((i) => ['h2', 'h3', 'plot'].includes(i.kind))
|
|
||||||
.filter((i) => !/^(cacu|cama|tea), /.test(i.text ?? '')); // a figure's machine caption
|
|
||||||
}
|
|
||||||
const period = (text: string) => text.replace(/, \d{4}-(S[12]|\d{2})$/, ', <periodo>');
|
|
||||||
const kindOf = (types: string[]) => [...new Set(types)].sort().join('+');
|
|
||||||
|
|
||||||
for (const domain of ['cacu', 'cama', 'tea']) {
|
|
||||||
test(`indicadores ${domain}: the old page's headings, in order, and the same kinds of plots`, async ({
|
|
||||||
page,
|
|
||||||
}) => {
|
|
||||||
const old = captured(domain);
|
|
||||||
await page.goto(`/indicadores/${domain}`);
|
|
||||||
const tab = page.locator('app-tab-indicadores');
|
|
||||||
await expect(tab.getByRole('heading', { name: 'Indicadores clínicos' })).toBeVisible();
|
|
||||||
await expect(tab.locator('app-loading')).toHaveCount(0, { timeout: 5 * 60_000 });
|
|
||||||
const headings = await tab
|
|
||||||
.locator('h2, h3')
|
|
||||||
.evaluateAll((els) => els.map((e) => (e as HTMLElement).innerText.trim()));
|
|
||||||
const from = headings.indexOf('Indicadores de oportunidad');
|
|
||||||
expect(headings.slice(from).map(period)).toEqual(
|
|
||||||
old.filter((i) => i.kind !== 'plot').map((i) => period(i.text)),
|
|
||||||
);
|
|
||||||
// Each figure drawn is one of the old kinds (a figure with no data in the period is named).
|
|
||||||
const drawn = await tab
|
|
||||||
.locator('.js-plotly-plot')
|
|
||||||
.evaluateAll((els) =>
|
|
||||||
els.map((e: any) => (e.data ?? []).map((t: any) => t.type ?? 'scatter')),
|
|
||||||
);
|
|
||||||
const kinds = new Set(
|
|
||||||
old.filter((i) => i.kind === 'plot').map((i) => kindOf(i.traces.map((t: any) => t.type))),
|
|
||||||
);
|
|
||||||
for (const types of drawn) expect(kinds).toContain(kindOf(types));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|||||||
+57
-1712
File diff suppressed because it is too large
Load Diff
@@ -1,32 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { filter, map } from 'rxjs/operators';
|
|
||||||
import { StrictHttpResponse } from '../../strict-http-response';
|
|
||||||
import { RequestBuilder } from '../../request-builder';
|
|
||||||
|
|
||||||
import { Login } from '../../models/login';
|
|
||||||
|
|
||||||
export interface AuthCookieLogin$Params {
|
|
||||||
body: Login
|
|
||||||
}
|
|
||||||
|
|
||||||
export function authCookieLogin(http: HttpClient, rootUrl: string, params: AuthCookieLogin$Params, context?: HttpContext): Observable<StrictHttpResponse<any>> {
|
|
||||||
const rb = new RequestBuilder(rootUrl, authCookieLogin.PATH, 'post');
|
|
||||||
if (params) {
|
|
||||||
rb.body(params.body, 'application/x-www-form-urlencoded');
|
|
||||||
}
|
|
||||||
|
|
||||||
return http.request(
|
|
||||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
|
||||||
).pipe(
|
|
||||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
|
||||||
map((r: HttpResponse<any>) => {
|
|
||||||
return r as StrictHttpResponse<any>;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
authCookieLogin.PATH = '/auth/login';
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { filter, map } from 'rxjs/operators';
|
|
||||||
import { StrictHttpResponse } from '../../strict-http-response';
|
|
||||||
import { RequestBuilder } from '../../request-builder';
|
|
||||||
|
|
||||||
|
|
||||||
export interface AuthCookieLogout$Params {
|
|
||||||
}
|
|
||||||
|
|
||||||
export function authCookieLogout(http: HttpClient, rootUrl: string, params?: AuthCookieLogout$Params, context?: HttpContext): Observable<StrictHttpResponse<any>> {
|
|
||||||
const rb = new RequestBuilder(rootUrl, authCookieLogout.PATH, 'post');
|
|
||||||
if (params) {
|
|
||||||
}
|
|
||||||
|
|
||||||
return http.request(
|
|
||||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
|
||||||
).pipe(
|
|
||||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
|
||||||
map((r: HttpResponse<any>) => {
|
|
||||||
return r as StrictHttpResponse<any>;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
authCookieLogout.PATH = '/auth/logout';
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { filter, map } from 'rxjs/operators';
|
|
||||||
import { StrictHttpResponse } from '../../strict-http-response';
|
|
||||||
import { RequestBuilder } from '../../request-builder';
|
|
||||||
|
|
||||||
import { Browsed } from '../../models/browsed';
|
|
||||||
|
|
||||||
export interface Browse$Params {
|
|
||||||
path?: (string | null);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function browse(http: HttpClient, rootUrl: string, params?: Browse$Params, context?: HttpContext): Observable<StrictHttpResponse<Browsed>> {
|
|
||||||
const rb = new RequestBuilder(rootUrl, browse.PATH, 'get');
|
|
||||||
if (params) {
|
|
||||||
rb.query('path', params.path, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
return http.request(
|
|
||||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
|
||||||
).pipe(
|
|
||||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
|
||||||
map((r: HttpResponse<any>) => {
|
|
||||||
return r as StrictHttpResponse<Browsed>;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
browse.PATH = '/ingest/sources/browse';
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { filter, map } from 'rxjs/operators';
|
|
||||||
import { StrictHttpResponse } from '../../strict-http-response';
|
|
||||||
import { RequestBuilder } from '../../request-builder';
|
|
||||||
|
|
||||||
import { SignIn } from '../../models/sign-in';
|
|
||||||
|
|
||||||
export interface OauthStart$Params {
|
|
||||||
provider: string;
|
|
||||||
origin: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function oauthStart(http: HttpClient, rootUrl: string, params: OauthStart$Params, context?: HttpContext): Observable<StrictHttpResponse<SignIn>> {
|
|
||||||
const rb = new RequestBuilder(rootUrl, oauthStart.PATH, 'get');
|
|
||||||
if (params) {
|
|
||||||
rb.path('provider', params.provider, {});
|
|
||||||
rb.query('origin', params.origin, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
return http.request(
|
|
||||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
|
||||||
).pipe(
|
|
||||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
|
||||||
map((r: HttpResponse<any>) => {
|
|
||||||
return r as StrictHttpResponse<SignIn>;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
oauthStart.PATH = '/ingest/sources/oauth/{provider}/start';
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { filter, map } from 'rxjs/operators';
|
|
||||||
import { StrictHttpResponse } from '../../strict-http-response';
|
|
||||||
import { RequestBuilder } from '../../request-builder';
|
|
||||||
|
|
||||||
import { Catalog } from '../../models/catalog';
|
|
||||||
|
|
||||||
export interface SourceTypes$Params {
|
|
||||||
}
|
|
||||||
|
|
||||||
export function sourceTypes(http: HttpClient, rootUrl: string, params?: SourceTypes$Params, context?: HttpContext): Observable<StrictHttpResponse<Catalog>> {
|
|
||||||
const rb = new RequestBuilder(rootUrl, sourceTypes.PATH, 'get');
|
|
||||||
if (params) {
|
|
||||||
}
|
|
||||||
|
|
||||||
return http.request(
|
|
||||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
|
||||||
).pipe(
|
|
||||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
|
||||||
map((r: HttpResponse<any>) => {
|
|
||||||
return r as StrictHttpResponse<Catalog>;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceTypes.PATH = '/ingest/sources/types';
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { filter, map } from 'rxjs/operators';
|
|
||||||
import { StrictHttpResponse } from '../../strict-http-response';
|
|
||||||
import { RequestBuilder } from '../../request-builder';
|
|
||||||
|
|
||||||
import { Answers } from '../../models/answers';
|
|
||||||
import { Tested } from '../../models/tested';
|
|
||||||
|
|
||||||
export interface TestSource$Params {
|
|
||||||
limit?: number;
|
|
||||||
body: Answers
|
|
||||||
}
|
|
||||||
|
|
||||||
export function testSource(http: HttpClient, rootUrl: string, params: TestSource$Params, context?: HttpContext): Observable<StrictHttpResponse<Tested>> {
|
|
||||||
const rb = new RequestBuilder(rootUrl, testSource.PATH, 'post');
|
|
||||||
if (params) {
|
|
||||||
rb.query('limit', params.limit, {});
|
|
||||||
rb.body(params.body, 'application/json');
|
|
||||||
}
|
|
||||||
|
|
||||||
return http.request(
|
|
||||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
|
||||||
).pipe(
|
|
||||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
|
||||||
map((r: HttpResponse<any>) => {
|
|
||||||
return r as StrictHttpResponse<Tested>;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
testSource.PATH = '/ingest/sources/test';
|
|
||||||
@@ -8,13 +8,14 @@ import { StrictHttpResponse } from '../../strict-http-response';
|
|||||||
import { RequestBuilder } from '../../request-builder';
|
import { RequestBuilder } from '../../request-builder';
|
||||||
|
|
||||||
import { BodyUpload } from '../../models/body-upload';
|
import { BodyUpload } from '../../models/body-upload';
|
||||||
import { Uploaded } from '../../models/uploaded';
|
|
||||||
|
|
||||||
export interface Upload$Params {
|
export interface Upload$Params {
|
||||||
body: BodyUpload
|
body: BodyUpload
|
||||||
}
|
}
|
||||||
|
|
||||||
export function upload(http: HttpClient, rootUrl: string, params: Upload$Params, context?: HttpContext): Observable<StrictHttpResponse<Uploaded>> {
|
export function upload(http: HttpClient, rootUrl: string, params: Upload$Params, context?: HttpContext): Observable<StrictHttpResponse<{
|
||||||
|
[key: string]: string;
|
||||||
|
}>> {
|
||||||
const rb = new RequestBuilder(rootUrl, upload.PATH, 'post');
|
const rb = new RequestBuilder(rootUrl, upload.PATH, 'post');
|
||||||
if (params) {
|
if (params) {
|
||||||
rb.body(params.body, 'multipart/form-data');
|
rb.body(params.body, 'multipart/form-data');
|
||||||
@@ -25,7 +26,9 @@ export function upload(http: HttpClient, rootUrl: string, params: Upload$Params,
|
|||||||
).pipe(
|
).pipe(
|
||||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
||||||
map((r: HttpResponse<any>) => {
|
map((r: HttpResponse<any>) => {
|
||||||
return r as StrictHttpResponse<Uploaded>;
|
return r as StrictHttpResponse<{
|
||||||
|
[key: string]: string;
|
||||||
|
}>;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { filter, map } from 'rxjs/operators';
|
|
||||||
import { StrictHttpResponse } from '../../strict-http-response';
|
|
||||||
import { RequestBuilder } from '../../request-builder';
|
|
||||||
|
|
||||||
|
|
||||||
export interface Unrecognised$Params {
|
|
||||||
pipeline: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function unrecognised(http: HttpClient, rootUrl: string, params: Unrecognised$Params, context?: HttpContext): Observable<StrictHttpResponse<Array<{
|
|
||||||
[key: string]: any;
|
|
||||||
}>>> {
|
|
||||||
const rb = new RequestBuilder(rootUrl, unrecognised.PATH, 'get');
|
|
||||||
if (params) {
|
|
||||||
rb.query('pipeline', params.pipeline, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
return http.request(
|
|
||||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
|
||||||
).pipe(
|
|
||||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
|
||||||
map((r: HttpResponse<any>) => {
|
|
||||||
return r as StrictHttpResponse<Array<{
|
|
||||||
[key: string]: any;
|
|
||||||
}>>;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
unrecognised.PATH = '/review/unrecognised';
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { filter, map } from 'rxjs/operators';
|
|
||||||
import { StrictHttpResponse } from '../../strict-http-response';
|
|
||||||
import { RequestBuilder } from '../../request-builder';
|
|
||||||
|
|
||||||
import { UserCreate } from '../../models/user-create';
|
|
||||||
import { UserRead } from '../../models/user-read';
|
|
||||||
|
|
||||||
export interface RegisterRegister$Params {
|
|
||||||
body: UserCreate
|
|
||||||
}
|
|
||||||
|
|
||||||
export function registerRegister(http: HttpClient, rootUrl: string, params: RegisterRegister$Params, context?: HttpContext): Observable<StrictHttpResponse<UserRead>> {
|
|
||||||
const rb = new RequestBuilder(rootUrl, registerRegister.PATH, 'post');
|
|
||||||
if (params) {
|
|
||||||
rb.body(params.body, 'application/json');
|
|
||||||
}
|
|
||||||
|
|
||||||
return http.request(
|
|
||||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
|
||||||
).pipe(
|
|
||||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
|
||||||
map((r: HttpResponse<any>) => {
|
|
||||||
return r as StrictHttpResponse<UserRead>;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
registerRegister.PATH = '/users/register';
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { filter, map } from 'rxjs/operators';
|
|
||||||
import { StrictHttpResponse } from '../../strict-http-response';
|
|
||||||
import { RequestBuilder } from '../../request-builder';
|
|
||||||
|
|
||||||
import { UserRead } from '../../models/user-read';
|
|
||||||
|
|
||||||
export interface UsersCurrentUser$Params {
|
|
||||||
}
|
|
||||||
|
|
||||||
export function usersCurrentUser(http: HttpClient, rootUrl: string, params?: UsersCurrentUser$Params, context?: HttpContext): Observable<StrictHttpResponse<UserRead>> {
|
|
||||||
const rb = new RequestBuilder(rootUrl, usersCurrentUser.PATH, 'get');
|
|
||||||
if (params) {
|
|
||||||
}
|
|
||||||
|
|
||||||
return http.request(
|
|
||||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
|
||||||
).pipe(
|
|
||||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
|
||||||
map((r: HttpResponse<any>) => {
|
|
||||||
return r as StrictHttpResponse<UserRead>;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
usersCurrentUser.PATH = '/users/me';
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { filter, map } from 'rxjs/operators';
|
|
||||||
import { StrictHttpResponse } from '../../strict-http-response';
|
|
||||||
import { RequestBuilder } from '../../request-builder';
|
|
||||||
|
|
||||||
|
|
||||||
export interface UsersDeleteUser$Params {
|
|
||||||
id: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function usersDeleteUser(http: HttpClient, rootUrl: string, params: UsersDeleteUser$Params, context?: HttpContext): Observable<StrictHttpResponse<void>> {
|
|
||||||
const rb = new RequestBuilder(rootUrl, usersDeleteUser.PATH, 'delete');
|
|
||||||
if (params) {
|
|
||||||
rb.path('id', params.id, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
return http.request(
|
|
||||||
rb.build({ responseType: 'text', accept: '*/*', context })
|
|
||||||
).pipe(
|
|
||||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
|
||||||
map((r: HttpResponse<any>) => {
|
|
||||||
return (r as HttpResponse<any>).clone({ body: undefined }) as StrictHttpResponse<void>;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
usersDeleteUser.PATH = '/users/{id}';
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { filter, map } from 'rxjs/operators';
|
|
||||||
import { StrictHttpResponse } from '../../strict-http-response';
|
|
||||||
import { RequestBuilder } from '../../request-builder';
|
|
||||||
|
|
||||||
import { UserRead } from '../../models/user-read';
|
|
||||||
import { UserUpdate } from '../../models/user-update';
|
|
||||||
|
|
||||||
export interface UsersPatchCurrentUser$Params {
|
|
||||||
body: UserUpdate
|
|
||||||
}
|
|
||||||
|
|
||||||
export function usersPatchCurrentUser(http: HttpClient, rootUrl: string, params: UsersPatchCurrentUser$Params, context?: HttpContext): Observable<StrictHttpResponse<UserRead>> {
|
|
||||||
const rb = new RequestBuilder(rootUrl, usersPatchCurrentUser.PATH, 'patch');
|
|
||||||
if (params) {
|
|
||||||
rb.body(params.body, 'application/json');
|
|
||||||
}
|
|
||||||
|
|
||||||
return http.request(
|
|
||||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
|
||||||
).pipe(
|
|
||||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
|
||||||
map((r: HttpResponse<any>) => {
|
|
||||||
return r as StrictHttpResponse<UserRead>;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
usersPatchCurrentUser.PATH = '/users/me';
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { filter, map } from 'rxjs/operators';
|
|
||||||
import { StrictHttpResponse } from '../../strict-http-response';
|
|
||||||
import { RequestBuilder } from '../../request-builder';
|
|
||||||
|
|
||||||
import { UserRead } from '../../models/user-read';
|
|
||||||
import { UserUpdate } from '../../models/user-update';
|
|
||||||
|
|
||||||
export interface UsersPatchUser$Params {
|
|
||||||
id: string;
|
|
||||||
body: UserUpdate
|
|
||||||
}
|
|
||||||
|
|
||||||
export function usersPatchUser(http: HttpClient, rootUrl: string, params: UsersPatchUser$Params, context?: HttpContext): Observable<StrictHttpResponse<UserRead>> {
|
|
||||||
const rb = new RequestBuilder(rootUrl, usersPatchUser.PATH, 'patch');
|
|
||||||
if (params) {
|
|
||||||
rb.path('id', params.id, {});
|
|
||||||
rb.body(params.body, 'application/json');
|
|
||||||
}
|
|
||||||
|
|
||||||
return http.request(
|
|
||||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
|
||||||
).pipe(
|
|
||||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
|
||||||
map((r: HttpResponse<any>) => {
|
|
||||||
return r as StrictHttpResponse<UserRead>;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
usersPatchUser.PATH = '/users/{id}';
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { HttpClient, HttpContext, HttpResponse } from '@angular/common/http';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { filter, map } from 'rxjs/operators';
|
|
||||||
import { StrictHttpResponse } from '../../strict-http-response';
|
|
||||||
import { RequestBuilder } from '../../request-builder';
|
|
||||||
|
|
||||||
import { UserRead } from '../../models/user-read';
|
|
||||||
|
|
||||||
export interface UsersUser$Params {
|
|
||||||
id: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function usersUser(http: HttpClient, rootUrl: string, params: UsersUser$Params, context?: HttpContext): Observable<StrictHttpResponse<UserRead>> {
|
|
||||||
const rb = new RequestBuilder(rootUrl, usersUser.PATH, 'get');
|
|
||||||
if (params) {
|
|
||||||
rb.path('id', params.id, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
return http.request(
|
|
||||||
rb.build({ responseType: 'json', accept: 'application/json', context })
|
|
||||||
).pipe(
|
|
||||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
|
||||||
map((r: HttpResponse<any>) => {
|
|
||||||
return r as StrictHttpResponse<UserRead>;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
usersUser.PATH = '/users/{id}';
|
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
||||||
|
|
||||||
export type { AuthCookieLogin$Params as AuthCookieLogin$Params } from './fn/auth/auth-cookie-login';
|
|
||||||
export { authCookieLogin as authCookieLogin } from './fn/auth/auth-cookie-login';
|
|
||||||
export type { AuthCookieLogout$Params as AuthCookieLogout$Params } from './fn/auth/auth-cookie-logout';
|
|
||||||
export { authCookieLogout as authCookieLogout } from './fn/auth/auth-cookie-logout';
|
|
||||||
export type { Domains$Params as Domains$Params } from './fn/operations/domains';
|
export type { Domains$Params as Domains$Params } from './fn/operations/domains';
|
||||||
export { domains as domains } from './fn/operations/domains';
|
export { domains as domains } from './fn/operations/domains';
|
||||||
export type { Health$Params as Health$Params } from './fn/operations/health';
|
export type { Health$Params as Health$Params } from './fn/operations/health';
|
||||||
@@ -27,18 +23,10 @@ export type { StartRun$Params as StartRun$Params } from './fn/ingest/start-run';
|
|||||||
export { startRun as startRun } from './fn/ingest/start-run';
|
export { startRun as startRun } from './fn/ingest/start-run';
|
||||||
export type { Schema$Params as Schema$Params } from './fn/ingest/schema';
|
export type { Schema$Params as Schema$Params } from './fn/ingest/schema';
|
||||||
export { schema as schema } from './fn/ingest/schema';
|
export { schema as schema } from './fn/ingest/schema';
|
||||||
export type { Browse$Params as Browse$Params } from './fn/ingest/browse';
|
|
||||||
export { browse as browse } from './fn/ingest/browse';
|
|
||||||
export type { OauthStart$Params as OauthStart$Params } from './fn/ingest/oauth-start';
|
|
||||||
export { oauthStart as oauthStart } from './fn/ingest/oauth-start';
|
|
||||||
export type { SourcePreview$Params as SourcePreview$Params } from './fn/ingest/source-preview';
|
export type { SourcePreview$Params as SourcePreview$Params } from './fn/ingest/source-preview';
|
||||||
export { sourcePreview as sourcePreview } from './fn/ingest/source-preview';
|
export { sourcePreview as sourcePreview } from './fn/ingest/source-preview';
|
||||||
export type { SourceResources$Params as SourceResources$Params } from './fn/ingest/source-resources';
|
export type { SourceResources$Params as SourceResources$Params } from './fn/ingest/source-resources';
|
||||||
export { sourceResources as sourceResources } from './fn/ingest/source-resources';
|
export { sourceResources as sourceResources } from './fn/ingest/source-resources';
|
||||||
export type { TestSource$Params as TestSource$Params } from './fn/ingest/test-source';
|
|
||||||
export { testSource as testSource } from './fn/ingest/test-source';
|
|
||||||
export type { SourceTypes$Params as SourceTypes$Params } from './fn/ingest/source-types';
|
|
||||||
export { sourceTypes as sourceTypes } from './fn/ingest/source-types';
|
|
||||||
export type { Upload$Params as Upload$Params } from './fn/ingest/upload';
|
export type { Upload$Params as Upload$Params } from './fn/ingest/upload';
|
||||||
export { upload as upload } from './fn/ingest/upload';
|
export { upload as upload } from './fn/ingest/upload';
|
||||||
export type { Models$Params as Models$Params } from './fn/models/models';
|
export type { Models$Params as Models$Params } from './fn/models/models';
|
||||||
@@ -71,26 +59,12 @@ export type { DecidePersons$Params as DecidePersons$Params } from './fn/review/d
|
|||||||
export { decidePersons as decidePersons } from './fn/review/decide-persons';
|
export { decidePersons as decidePersons } from './fn/review/decide-persons';
|
||||||
export type { Reject$Params as Reject$Params } from './fn/review/reject';
|
export type { Reject$Params as Reject$Params } from './fn/review/reject';
|
||||||
export { reject as reject } from './fn/review/reject';
|
export { reject as reject } from './fn/review/reject';
|
||||||
export type { Unrecognised$Params as Unrecognised$Params } from './fn/review/unrecognised';
|
|
||||||
export { unrecognised as unrecognised } from './fn/review/unrecognised';
|
|
||||||
export type { RunStatus$Params as RunStatus$Params } from './fn/runs/run-status';
|
export type { RunStatus$Params as RunStatus$Params } from './fn/runs/run-status';
|
||||||
export { runStatus as runStatus } from './fn/runs/run-status';
|
export { runStatus as runStatus } from './fn/runs/run-status';
|
||||||
export type { Studies$Params as Studies$Params } from './fn/eeg/studies';
|
export type { Studies$Params as Studies$Params } from './fn/eeg/studies';
|
||||||
export { studies as studies } from './fn/eeg/studies';
|
export { studies as studies } from './fn/eeg/studies';
|
||||||
export type { Study$Params as Study$Params } from './fn/eeg/study';
|
export type { Study$Params as Study$Params } from './fn/eeg/study';
|
||||||
export { study as study } from './fn/eeg/study';
|
export { study as study } from './fn/eeg/study';
|
||||||
export type { UsersCurrentUser$Params as UsersCurrentUser$Params } from './fn/users/users-current-user';
|
|
||||||
export { usersCurrentUser as usersCurrentUser } from './fn/users/users-current-user';
|
|
||||||
export type { UsersPatchCurrentUser$Params as UsersPatchCurrentUser$Params } from './fn/users/users-patch-current-user';
|
|
||||||
export { usersPatchCurrentUser as usersPatchCurrentUser } from './fn/users/users-patch-current-user';
|
|
||||||
export type { RegisterRegister$Params as RegisterRegister$Params } from './fn/users/register-register';
|
|
||||||
export { registerRegister as registerRegister } from './fn/users/register-register';
|
|
||||||
export type { UsersUser$Params as UsersUser$Params } from './fn/users/users-user';
|
|
||||||
export { usersUser as usersUser } from './fn/users/users-user';
|
|
||||||
export type { UsersDeleteUser$Params as UsersDeleteUser$Params } from './fn/users/users-delete-user';
|
|
||||||
export { usersDeleteUser as usersDeleteUser } from './fn/users/users-delete-user';
|
|
||||||
export type { UsersPatchUser$Params as UsersPatchUser$Params } from './fn/users/users-patch-user';
|
|
||||||
export { usersPatchUser as usersPatchUser } from './fn/users/users-patch-user';
|
|
||||||
export type { PostBundle$Params as PostBundle$Params } from './fn/fhir/post-bundle';
|
export type { PostBundle$Params as PostBundle$Params } from './fn/fhir/post-bundle';
|
||||||
export { postBundle as postBundle } from './fn/fhir/post-bundle';
|
export { postBundle as postBundle } from './fn/fhir/post-bundle';
|
||||||
export type { SearchCondition$Params as SearchCondition$Params } from './fn/fhir/search-condition';
|
export type { SearchCondition$Params as SearchCondition$Params } from './fn/fhir/search-condition';
|
||||||
|
|||||||
@@ -2,49 +2,30 @@
|
|||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
||||||
|
|
||||||
export type { Analysis } from './models/analysis';
|
export type { Analysis } from './models/analysis';
|
||||||
export type { Answers } from './models/answers';
|
|
||||||
export type { BodyAddClinicalValidation } from './models/body-add-clinical-validation';
|
export type { BodyAddClinicalValidation } from './models/body-add-clinical-validation';
|
||||||
export type { BodyUpload } from './models/body-upload';
|
export type { BodyUpload } from './models/body-upload';
|
||||||
export type { Browsed } from './models/browsed';
|
|
||||||
export type { Catalog } from './models/catalog';
|
|
||||||
export type { Condition } from './models/condition';
|
export type { Condition } from './models/condition';
|
||||||
export type { Correction } from './models/correction';
|
export type { Correction } from './models/correction';
|
||||||
export type { Domain } from './models/domain';
|
export type { Domain } from './models/domain';
|
||||||
export type { Entry } from './models/entry';
|
|
||||||
export type { ErrorModel } from './models/error-model';
|
|
||||||
export type { Extract } from './models/extract';
|
export type { Extract } from './models/extract';
|
||||||
export type { Fhir } from './models/fhir';
|
export type { Fhir } from './models/fhir';
|
||||||
export type { FieldSpec } from './models/field-spec';
|
|
||||||
export type { Group } from './models/group';
|
|
||||||
export type { Guided } from './models/guided';
|
|
||||||
export type { HttpValidationError } from './models/http-validation-error';
|
export type { HttpValidationError } from './models/http-validation-error';
|
||||||
export type { Join } from './models/join';
|
export type { Join } from './models/join';
|
||||||
export type { Link } from './models/link';
|
export type { Link } from './models/link';
|
||||||
export type { Listing } from './models/listing';
|
|
||||||
export type { Login } from './models/login';
|
|
||||||
export type { Map } from './models/map';
|
export type { Map } from './models/map';
|
||||||
export type { Metric } from './models/metric';
|
export type { Metric } from './models/metric';
|
||||||
export type { Option } from './models/option';
|
|
||||||
export type { PersonDecision } from './models/person-decision';
|
export type { PersonDecision } from './models/person-decision';
|
||||||
export type { Pipeline } from './models/pipeline';
|
export type { Pipeline } from './models/pipeline';
|
||||||
export type { Position } from './models/position';
|
export type { Position } from './models/position';
|
||||||
export type { Provider } from './models/provider';
|
|
||||||
export type { Read } from './models/read';
|
export type { Read } from './models/read';
|
||||||
export type { Rejection } from './models/rejection';
|
export type { Rejection } from './models/rejection';
|
||||||
export type { Route } from './models/route';
|
export type { Route } from './models/route';
|
||||||
export type { RunRequest } from './models/run-request';
|
export type { RunRequest } from './models/run-request';
|
||||||
export type { SavedPipeline } from './models/saved-pipeline';
|
export type { SavedPipeline } from './models/saved-pipeline';
|
||||||
export type { SignIn } from './models/sign-in';
|
|
||||||
export type { Source } from './models/source';
|
export type { Source } from './models/source';
|
||||||
export type { SourceRef } from './models/source-ref';
|
export type { SourceRef } from './models/source-ref';
|
||||||
export type { SourceType } from './models/source-type';
|
|
||||||
export type { Study } from './models/study';
|
export type { Study } from './models/study';
|
||||||
export type { Target } from './models/target';
|
export type { Target } from './models/target';
|
||||||
export type { Tested } from './models/tested';
|
|
||||||
export type { Training } from './models/training';
|
export type { Training } from './models/training';
|
||||||
export type { Uploaded } from './models/uploaded';
|
|
||||||
export type { UserCreate } from './models/user-create';
|
|
||||||
export type { UserRead } from './models/user-read';
|
|
||||||
export type { UserUpdate } from './models/user-update';
|
|
||||||
export type { ValidationError } from './models/validation-error';
|
export type { ValidationError } from './models/validation-error';
|
||||||
export type { Version } from './models/version';
|
export type { Version } from './models/version';
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
export interface Answers {
|
|
||||||
answers?: {
|
|
||||||
[key: string]: any;
|
|
||||||
};
|
|
||||||
node?: (string | null);
|
|
||||||
pipeline?: (string | null);
|
|
||||||
type: string;
|
|
||||||
}
|
|
||||||
@@ -2,6 +2,5 @@
|
|||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
||||||
|
|
||||||
export interface BodyUpload {
|
export interface BodyUpload {
|
||||||
files: Array<string>;
|
file: string;
|
||||||
folder?: (string | null);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { Entry } from '../models/entry';
|
|
||||||
export interface Browsed {
|
|
||||||
entries: Array<Entry>;
|
|
||||||
parent: (string | null);
|
|
||||||
path: (string | null);
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { Group } from '../models/group';
|
|
||||||
import { Option } from '../models/option';
|
|
||||||
import { Provider } from '../models/provider';
|
|
||||||
import { SourceType } from '../models/source-type';
|
|
||||||
export interface Catalog {
|
|
||||||
formats: Array<Option>;
|
|
||||||
groups: {
|
|
||||||
[key: string]: Group;
|
|
||||||
};
|
|
||||||
providers: {
|
|
||||||
[key: string]: Provider;
|
|
||||||
};
|
|
||||||
types: {
|
|
||||||
[key: string]: SourceType;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -2,15 +2,7 @@
|
|||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
||||||
|
|
||||||
export interface Condition {
|
export interface Condition {
|
||||||
|
|
||||||
/**
|
|
||||||
* Por ejemplo «text», el texto leído del documento.
|
|
||||||
*/
|
|
||||||
column: string;
|
column: string;
|
||||||
op: 'equals' | 'contains' | 'matches' | 'present';
|
op: 'equals' | 'contains' | 'matches' | 'present';
|
||||||
|
|
||||||
/**
|
|
||||||
* Lo que se busca; por ejemplo «citología».
|
|
||||||
*/
|
|
||||||
value?: string;
|
value?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
export interface Entry {
|
|
||||||
kind: 'folder' | 'file';
|
|
||||||
name: string;
|
|
||||||
path: string;
|
|
||||||
size?: (number | null);
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
export interface ErrorModel {
|
|
||||||
detail: (string | {
|
|
||||||
[key: string]: string;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -13,40 +13,17 @@ import { Position } from '../models/position';
|
|||||||
*/
|
*/
|
||||||
export interface Extract {
|
export interface Extract {
|
||||||
column: (string | Array<string>);
|
column: (string | Array<string>);
|
||||||
|
|
||||||
/**
|
|
||||||
* Dato → columna, sin leer el texto.
|
|
||||||
*/
|
|
||||||
columns?: {
|
|
||||||
[key: string]: string;
|
|
||||||
};
|
|
||||||
concept_map?: (string | null);
|
concept_map?: (string | null);
|
||||||
|
|
||||||
/**
|
|
||||||
* Qué estudio se saca del documento.
|
|
||||||
*/
|
|
||||||
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'breast_treatment' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
|
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'breast_treatment' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
|
||||||
formats?: {
|
formats?: {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Para el modelo de lenguaje.
|
|
||||||
*/
|
|
||||||
hints?: string;
|
hints?: string;
|
||||||
id: string;
|
id: string;
|
||||||
inputs?: Array<string>;
|
inputs?: Array<string>;
|
||||||
kind?: 'extract';
|
kind?: 'extract';
|
||||||
|
|
||||||
/**
|
|
||||||
* Cómo se ve en el diagrama.
|
|
||||||
*/
|
|
||||||
label?: string;
|
label?: string;
|
||||||
method?: 'auto' | 'llm' | 'patterns';
|
method?: 'auto' | 'llm' | 'patterns';
|
||||||
|
|
||||||
/**
|
|
||||||
* Dato → expresión con un grupo ( ).
|
|
||||||
*/
|
|
||||||
patterns?: {
|
patterns?: {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,10 +15,6 @@ export interface Fhir {
|
|||||||
id: string;
|
id: string;
|
||||||
inputs?: Array<string>;
|
inputs?: Array<string>;
|
||||||
kind?: 'fhir';
|
kind?: 'fhir';
|
||||||
|
|
||||||
/**
|
|
||||||
* Cómo se ve en el diagrama.
|
|
||||||
*/
|
|
||||||
label?: string;
|
label?: string;
|
||||||
position?: (Position | null);
|
position?: (Position | null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { Option } from '../models/option';
|
|
||||||
export interface FieldSpec {
|
|
||||||
advanced?: boolean;
|
|
||||||
default?: any;
|
|
||||||
help?: string;
|
|
||||||
label: string;
|
|
||||||
options?: Array<Option>;
|
|
||||||
placeholder?: string;
|
|
||||||
provider?: (string | null);
|
|
||||||
required?: boolean;
|
|
||||||
type?: 'text' | 'number' | 'password' | 'select' | 'folder' | 'server_file' | 'upload' | 'url' | 'oauth' | 'table' | 'format';
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
export interface Group {
|
|
||||||
description: string;
|
|
||||||
title: string;
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* How the Conectar dialog drew a source: its type (core.sources) and the answers given.
|
|
||||||
* The node's dlt fields are made from them; drawn by hand ("Avanzado"), a node has none.
|
|
||||||
*/
|
|
||||||
export interface Guided {
|
|
||||||
answers?: {
|
|
||||||
[key: string]: any;
|
|
||||||
};
|
|
||||||
type: string;
|
|
||||||
}
|
|
||||||
@@ -11,15 +11,7 @@ export interface Join {
|
|||||||
id: string;
|
id: string;
|
||||||
inputs?: Array<string>;
|
inputs?: Array<string>;
|
||||||
kind?: 'join';
|
kind?: 'join';
|
||||||
|
|
||||||
/**
|
|
||||||
* Cómo se ve en el diagrama.
|
|
||||||
*/
|
|
||||||
label?: string;
|
label?: string;
|
||||||
|
|
||||||
/**
|
|
||||||
* Pares [columna izquierda, derecha].
|
|
||||||
*/
|
|
||||||
on: Array<[string, string]>;
|
on: Array<[string, string]>;
|
||||||
position?: (Position | null);
|
position?: (Position | null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,20 +16,8 @@ export interface Link {
|
|||||||
id: string;
|
id: string;
|
||||||
inputs?: Array<string>;
|
inputs?: Array<string>;
|
||||||
kind?: 'link';
|
kind?: 'link';
|
||||||
|
|
||||||
/**
|
|
||||||
* Cómo se ve en el diagrama.
|
|
||||||
*/
|
|
||||||
label?: string;
|
label?: string;
|
||||||
position?: (Position | null);
|
position?: (Position | null);
|
||||||
|
|
||||||
/**
|
|
||||||
* Parecidos por encima de esto los ve un revisor.
|
|
||||||
*/
|
|
||||||
review?: number;
|
review?: number;
|
||||||
|
|
||||||
/**
|
|
||||||
* Vacío: las de siempre (mismo identificador, o misma fecha de nacimiento y nombre).
|
|
||||||
*/
|
|
||||||
rules?: Array<string>;
|
rules?: Array<string>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* What "Probar conexión" shows: a database's tables (the resources of `source`, built
|
|
||||||
* from `args`), or the first rows the type's own node reads (files, records).
|
|
||||||
*/
|
|
||||||
export interface Listing {
|
|
||||||
args?: {
|
|
||||||
[key: string]: any;
|
|
||||||
};
|
|
||||||
kind: 'tables' | 'rows';
|
|
||||||
source?: (string | null);
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
export interface Login {
|
|
||||||
client_id?: (string | null);
|
|
||||||
client_secret?: (string | null);
|
|
||||||
grant_type?: (string | null);
|
|
||||||
password: string;
|
|
||||||
scope?: string;
|
|
||||||
username: string;
|
|
||||||
}
|
|
||||||
@@ -8,38 +8,18 @@ import { Position } from '../models/position';
|
|||||||
* (core.concept_map), and its date formats.
|
* (core.concept_map), and its date formats.
|
||||||
*/
|
*/
|
||||||
export interface Map {
|
export interface Map {
|
||||||
|
|
||||||
/**
|
|
||||||
* La tabla de códigos del sitio.
|
|
||||||
*/
|
|
||||||
concept_map?: (string | null);
|
concept_map?: (string | null);
|
||||||
|
|
||||||
/**
|
|
||||||
* Dato de la plataforma → columna del sitio.
|
|
||||||
*/
|
|
||||||
fields: {
|
fields: {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Por ejemplo %d/%m/%Y.
|
|
||||||
*/
|
|
||||||
formats?: {
|
formats?: {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
};
|
};
|
||||||
id: string;
|
id: string;
|
||||||
inputs?: Array<string>;
|
inputs?: Array<string>;
|
||||||
kind?: 'map';
|
kind?: 'map';
|
||||||
|
|
||||||
/**
|
|
||||||
* Cómo se ve en el diagrama.
|
|
||||||
*/
|
|
||||||
label?: string;
|
label?: string;
|
||||||
position?: (Position | null);
|
position?: (Position | null);
|
||||||
|
|
||||||
/**
|
|
||||||
* Un dato igual para todas las filas.
|
|
||||||
*/
|
|
||||||
values?: {
|
values?: {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
export interface Option {
|
|
||||||
label: string;
|
|
||||||
value: any;
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A sign-in button's OAuth 2.0 provider (authorization code flow).
|
|
||||||
*/
|
|
||||||
export interface Provider {
|
|
||||||
authorize_params?: {
|
|
||||||
[key: string]: string;
|
|
||||||
};
|
|
||||||
authorize_url: string;
|
|
||||||
env: string;
|
|
||||||
scope: string;
|
|
||||||
title: string;
|
|
||||||
token_url: string;
|
|
||||||
}
|
|
||||||
@@ -7,18 +7,10 @@ import { Position } from '../models/position';
|
|||||||
* Files in a column (PDF, Word, Excel, scans...) to text (MarkItDown, OCRmyPDF).
|
* Files in a column (PDF, Word, Excel, scans...) to text (MarkItDown, OCRmyPDF).
|
||||||
*/
|
*/
|
||||||
export interface Read {
|
export interface Read {
|
||||||
|
|
||||||
/**
|
|
||||||
* Donde la entrada trae cada documento.
|
|
||||||
*/
|
|
||||||
column: string;
|
column: string;
|
||||||
id: string;
|
id: string;
|
||||||
inputs?: Array<string>;
|
inputs?: Array<string>;
|
||||||
kind?: 'read';
|
kind?: 'read';
|
||||||
|
|
||||||
/**
|
|
||||||
* Cómo se ve en el diagrama.
|
|
||||||
*/
|
|
||||||
label?: string;
|
label?: string;
|
||||||
position?: (Position | null);
|
position?: (Position | null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,24 +5,13 @@ import { Condition } from '../models/condition';
|
|||||||
import { Position } from '../models/position';
|
import { Position } from '../models/position';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only the rows where every condition holds (e.g. reports titled "Citología"). An
|
* Only the rows where every condition holds (e.g. reports titled "Citología").
|
||||||
* `otherwise` route takes the rows of its input that none of the other routes on that
|
|
||||||
* input take (documents nobody recognises, for a reviewer), then its own conditions.
|
|
||||||
*/
|
*/
|
||||||
export interface Route {
|
export interface Route {
|
||||||
id: string;
|
id: string;
|
||||||
inputs?: Array<string>;
|
inputs?: Array<string>;
|
||||||
kind?: 'route';
|
kind?: 'route';
|
||||||
|
|
||||||
/**
|
|
||||||
* Cómo se ve en el diagrama.
|
|
||||||
*/
|
|
||||||
label?: string;
|
label?: string;
|
||||||
|
|
||||||
/**
|
|
||||||
* Recoge lo que nadie reconoce, para revisarlo.
|
|
||||||
*/
|
|
||||||
otherwise?: boolean;
|
|
||||||
position?: (Position | null);
|
position?: (Position | null);
|
||||||
when?: Array<Condition>;
|
when: Array<Condition>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
export interface SignIn {
|
|
||||||
state: string;
|
|
||||||
url: string;
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { FieldSpec } from '../models/field-spec';
|
|
||||||
import { Listing } from '../models/listing';
|
|
||||||
export interface SourceType {
|
|
||||||
args?: {
|
|
||||||
[key: string]: any;
|
|
||||||
};
|
|
||||||
description: string;
|
|
||||||
fields: {
|
|
||||||
[key: string]: FieldSpec;
|
|
||||||
};
|
|
||||||
group: string;
|
|
||||||
icon: string;
|
|
||||||
listing?: (Listing | null);
|
|
||||||
primary_key?: Array<string>;
|
|
||||||
resource?: (string | null);
|
|
||||||
source: string;
|
|
||||||
then?: (string | null);
|
|
||||||
title: string;
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
||||||
|
|
||||||
import { Guided } from '../models/guided';
|
|
||||||
import { Position } from '../models/position';
|
import { Position } from '../models/position';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -9,41 +8,16 @@ import { Position } from '../models/position';
|
|||||||
* own primary key or `primary_key`; replaced whole when it has none.
|
* own primary key or `primary_key`; replaced whole when it has none.
|
||||||
*/
|
*/
|
||||||
export interface Source {
|
export interface Source {
|
||||||
|
|
||||||
/**
|
|
||||||
* Los de la fuente dlt.
|
|
||||||
*/
|
|
||||||
args?: {
|
args?: {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
guided?: (Guided | null);
|
|
||||||
id: string;
|
id: string;
|
||||||
inputs?: Array<string>;
|
inputs?: Array<string>;
|
||||||
kind?: 'source';
|
kind?: 'source';
|
||||||
|
|
||||||
/**
|
|
||||||
* Cómo se ve en el diagrama.
|
|
||||||
*/
|
|
||||||
label?: string;
|
label?: string;
|
||||||
position?: (Position | null);
|
position?: (Position | null);
|
||||||
|
|
||||||
/**
|
|
||||||
* Columnas que identifican una fila.
|
|
||||||
*/
|
|
||||||
primary_key?: Array<string>;
|
primary_key?: Array<string>;
|
||||||
|
|
||||||
/**
|
|
||||||
* Cuál, si la fuente ofrece varios (una tabla).
|
|
||||||
*/
|
|
||||||
resource?: (string | null);
|
resource?: (string | null);
|
||||||
|
|
||||||
/**
|
|
||||||
* Módulo:función de la fuente dlt.
|
|
||||||
*/
|
|
||||||
source: string;
|
source: string;
|
||||||
|
|
||||||
/**
|
|
||||||
* Transformador dlt para los archivos.
|
|
||||||
*/
|
|
||||||
then?: (string | null);
|
then?: (string | null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,18 +8,10 @@ import { Position } from '../models/position';
|
|||||||
* one `link` node among the inputs. Rule breaks are held for review.
|
* one `link` node among the inputs. Rule breaks are held for review.
|
||||||
*/
|
*/
|
||||||
export interface Target {
|
export interface Target {
|
||||||
|
|
||||||
/**
|
|
||||||
* En qué estudio de la plataforma se guarda.
|
|
||||||
*/
|
|
||||||
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'breast_treatment' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
|
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'breast_treatment' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
|
||||||
id: string;
|
id: string;
|
||||||
inputs?: Array<string>;
|
inputs?: Array<string>;
|
||||||
kind?: 'target';
|
kind?: 'target';
|
||||||
|
|
||||||
/**
|
|
||||||
* Cómo se ve en el diagrama.
|
|
||||||
*/
|
|
||||||
label?: string;
|
label?: string;
|
||||||
position?: (Position | null);
|
position?: (Position | null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
export interface Tested {
|
|
||||||
detail?: (string | null);
|
|
||||||
message: string;
|
|
||||||
ok: boolean;
|
|
||||||
rows?: Array<{
|
|
||||||
[key: string]: any;
|
|
||||||
}>;
|
|
||||||
tables?: Array<string>;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
export interface Uploaded {
|
|
||||||
bucket_url: string;
|
|
||||||
files: Array<string>;
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { Domain } from '../models/domain';
|
|
||||||
export interface UserCreate {
|
|
||||||
domains?: Array<Domain>;
|
|
||||||
email: string;
|
|
||||||
is_active?: (boolean | null);
|
|
||||||
is_superuser?: (boolean | null);
|
|
||||||
is_verified?: (boolean | null);
|
|
||||||
name?: string;
|
|
||||||
password: string;
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { Domain } from '../models/domain';
|
|
||||||
export interface UserRead {
|
|
||||||
domains?: Array<Domain>;
|
|
||||||
email: string;
|
|
||||||
id: string;
|
|
||||||
is_active?: boolean;
|
|
||||||
is_superuser?: boolean;
|
|
||||||
is_verified?: boolean;
|
|
||||||
name?: string;
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
|
||||||
|
|
||||||
import { Domain } from '../models/domain';
|
|
||||||
export interface UserUpdate {
|
|
||||||
domains?: (Array<Domain> | null);
|
|
||||||
email?: (string | null);
|
|
||||||
is_active?: (boolean | null);
|
|
||||||
is_superuser?: (boolean | null);
|
|
||||||
is_verified?: (boolean | null);
|
|
||||||
name?: (string | null);
|
|
||||||
password?: (string | null);
|
|
||||||
}
|
|
||||||
+6
-17
@@ -22,23 +22,12 @@
|
|||||||
} @else {
|
} @else {
|
||||||
<span class="title"></span>
|
<span class="title"></span>
|
||||||
}
|
}
|
||||||
@if (!onLogin()) {
|
<nav class="sections" aria-label="Secciones">
|
||||||
<nav class="sections" aria-label="Secciones">
|
<a routerLink="/indicadores/cacu" routerLinkActive="active">Indicadores</a>
|
||||||
<a [routerLink]="home()" routerLinkActive="active">Indicadores</a>
|
<a routerLink="/conectar" routerLinkActive="active">Conectar</a>
|
||||||
<a routerLink="/conectar" routerLinkActive="active">Conectar</a>
|
<a routerLink="/revision" routerLinkActive="active">Revisión</a>
|
||||||
<a routerLink="/revision" routerLinkActive="active">Revisión</a>
|
<a routerLink="/gobernanza" routerLinkActive="active">Gobernanza</a>
|
||||||
<a routerLink="/gobernanza" routerLinkActive="active">Gobernanza</a>
|
</nav>
|
||||||
</nav>
|
|
||||||
@if (auth.user(); as u) {
|
|
||||||
<button mat-button class="user" [matMenuTriggerFor]="account" aria-label="Cuenta">
|
|
||||||
<mat-icon>account_circle</mat-icon> {{ u.name || u.email }}
|
|
||||||
</button>
|
|
||||||
<mat-menu #account="matMenu">
|
|
||||||
<span class="who" mat-menu-item disabled>{{ u.email }}</span>
|
|
||||||
<button mat-menu-item (click)="logout()"><mat-icon>logout</mat-icon> Salir</button>
|
|
||||||
</mat-menu>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main class="main">
|
<main class="main">
|
||||||
|
|||||||
+15
-32
@@ -1,38 +1,21 @@
|
|||||||
import { Routes } from '@angular/router';
|
import { Routes } from '@angular/router';
|
||||||
import { domainAllowed, signedIn } from './auth/auth';
|
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
{ path: 'login', loadComponent: () => import('./auth/login').then((m) => m.Login) },
|
{ path: '', pathMatch: 'full', redirectTo: 'indicadores/cacu' },
|
||||||
{
|
{
|
||||||
path: '',
|
path: 'indicadores/:domain',
|
||||||
canActivateChild: [signedIn],
|
loadComponent: () => import('./indicadores/indicadores').then((m) => m.Indicadores),
|
||||||
children: [
|
|
||||||
{ path: '', pathMatch: 'full', redirectTo: 'indicadores/cacu' },
|
|
||||||
{
|
|
||||||
path: 'indicadores/:domain',
|
|
||||||
canActivate: [domainAllowed],
|
|
||||||
loadComponent: () => import('./indicadores/indicadores').then((m) => m.Indicadores),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'indicadores/:domain/pacientes/:id',
|
|
||||||
canActivate: [domainAllowed],
|
|
||||||
loadComponent: () => import('./paciente/paciente').then((m) => m.Paciente),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'conectar',
|
|
||||||
loadComponent: () => import('./conectar/conectar').then((m) => m.Conectar),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'revision',
|
|
||||||
loadComponent: () => import('./revision/revision').then((m) => m.Revision),
|
|
||||||
},
|
|
||||||
{ path: 'gobernanza', pathMatch: 'full', redirectTo: 'gobernanza/cacu' },
|
|
||||||
{
|
|
||||||
path: 'gobernanza/:domain',
|
|
||||||
canActivate: [domainAllowed],
|
|
||||||
loadComponent: () => import('./gobernanza/gobernanza').then((m) => m.Gobernanza),
|
|
||||||
},
|
|
||||||
{ path: '**', redirectTo: 'indicadores/cacu' },
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'indicadores/:domain/pacientes/:id',
|
||||||
|
loadComponent: () => import('./paciente/paciente').then((m) => m.Paciente),
|
||||||
|
},
|
||||||
|
{ path: 'conectar', loadComponent: () => import('./conectar/conectar').then((m) => m.Conectar) },
|
||||||
|
{ path: 'revision', loadComponent: () => import('./revision/revision').then((m) => m.Revision) },
|
||||||
|
{ path: 'gobernanza', pathMatch: 'full', redirectTo: 'gobernanza/cacu' },
|
||||||
|
{
|
||||||
|
path: 'gobernanza/:domain',
|
||||||
|
loadComponent: () => import('./gobernanza/gobernanza').then((m) => m.Gobernanza),
|
||||||
|
},
|
||||||
|
{ path: '**', redirectTo: 'indicadores/cacu' },
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -72,8 +72,3 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.user {
|
|
||||||
color: var(--color-text-secondary);
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|||||||
+2
-15
@@ -8,12 +8,11 @@ import { filter, map } from 'rxjs';
|
|||||||
import { Api } from './api/api';
|
import { Api } from './api/api';
|
||||||
import { domains } from './api/fn/operations/domains';
|
import { domains } from './api/fn/operations/domains';
|
||||||
import { Domain } from './api/models/domain';
|
import { Domain } from './api/models/domain';
|
||||||
import { Auth } from './auth/auth';
|
|
||||||
|
|
||||||
export const DOMAINS: Record<Domain, string> = {
|
export const DOMAINS: Record<Domain, string> = {
|
||||||
cacu: 'Cáncer cervicouterino',
|
cacu: 'Cáncer cervicouterino',
|
||||||
cama: 'Cáncer de mama',
|
cama: 'Cáncer de mama',
|
||||||
tea: 'Trastorno del espectro autista',
|
tea: 'TEA',
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The shell: header (logo, the domain's title and switcher, or the section), page, footer. */
|
/** The shell: header (logo, the domain's title and switcher, or the section), page, footer. */
|
||||||
@@ -33,7 +32,6 @@ export const DOMAINS: Record<Domain, string> = {
|
|||||||
export class App {
|
export class App {
|
||||||
private readonly api = inject(Api);
|
private readonly api = inject(Api);
|
||||||
private readonly router = inject(Router);
|
private readonly router = inject(Router);
|
||||||
protected readonly auth = inject(Auth);
|
|
||||||
protected readonly labels = DOMAINS;
|
protected readonly labels = DOMAINS;
|
||||||
protected readonly domains = resource({ loader: () => this.api.invoke(domains) });
|
protected readonly domains = resource({ loader: () => this.api.invoke(domains) });
|
||||||
private readonly url = toSignal(
|
private readonly url = toSignal(
|
||||||
@@ -48,17 +46,6 @@ export class App {
|
|||||||
() => /^\/indicadores\/(\w+)/.exec(this.url())?.[1] as Domain | undefined,
|
() => /^\/indicadores\/(\w+)/.exec(this.url())?.[1] as Domain | undefined,
|
||||||
);
|
);
|
||||||
protected readonly others = computed(() =>
|
protected readonly others = computed(() =>
|
||||||
(this.domains.value() ?? []).filter((d) => d !== this.domain() && this.auth.canSee(d)),
|
(this.domains.value() ?? []).filter((d) => d !== this.domain()),
|
||||||
);
|
);
|
||||||
/** The sign-in page shows only the brand. */
|
|
||||||
protected readonly onLogin = computed(() => this.url().startsWith('/login'));
|
|
||||||
/** Where "Indicadores" goes: the first domain this user may see. */
|
|
||||||
protected readonly home = computed(
|
|
||||||
() => `/indicadores/${this.auth.user()?.domains[0] ?? 'cacu'}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
protected async logout(): Promise<void> {
|
|
||||||
await this.auth.logout();
|
|
||||||
await this.router.navigateByUrl('/login');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
import { HttpClient, HttpErrorResponse, HttpParams } from '@angular/common/http';
|
|
||||||
import { Injectable, computed, inject, signal } from '@angular/core';
|
|
||||||
import { CanActivateFn, Router } from '@angular/router';
|
|
||||||
import { firstValueFrom } from 'rxjs';
|
|
||||||
import { ApiConfiguration } from '../api/api-configuration';
|
|
||||||
import type { Domain } from '../api/models/domain';
|
|
||||||
|
|
||||||
/** Who is signed in, and the domains the app shows them. */
|
|
||||||
export interface User {
|
|
||||||
id: string;
|
|
||||||
email: string;
|
|
||||||
name: string;
|
|
||||||
is_superuser: boolean;
|
|
||||||
domains: Domain[];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The web app's sign-in (the API's fastapi-users, a session cookie). It decides only what
|
|
||||||
* the app shows: the API answers without a session. */
|
|
||||||
@Injectable({ providedIn: 'root' })
|
|
||||||
export class Auth {
|
|
||||||
private readonly http = inject(HttpClient);
|
|
||||||
private readonly root = inject(ApiConfiguration).rootUrl;
|
|
||||||
/** undefined: not asked yet; null: nobody signed in. */
|
|
||||||
private readonly current = signal<User | null | undefined>(undefined);
|
|
||||||
readonly user = this.current.asReadonly();
|
|
||||||
readonly signedIn = computed(() => !!this.current());
|
|
||||||
|
|
||||||
/** Whether the signed-in user may see the domain (an administrator sees every one). */
|
|
||||||
canSee(domain: string): boolean {
|
|
||||||
const u = this.current();
|
|
||||||
return !!u && (u.is_superuser || u.domains.includes(domain as Domain));
|
|
||||||
}
|
|
||||||
|
|
||||||
async load(): Promise<User | null> {
|
|
||||||
try {
|
|
||||||
this.current.set(await firstValueFrom(this.http.get<User>(`${this.root}/users/me`)));
|
|
||||||
} catch {
|
|
||||||
this.current.set(null);
|
|
||||||
}
|
|
||||||
return this.current() ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Signs in; a wrong user or password comes back as words for the form. */
|
|
||||||
async login(email: string, password: string): Promise<string | null> {
|
|
||||||
const body = new HttpParams().set('username', email.trim()).set('password', password);
|
|
||||||
try {
|
|
||||||
await firstValueFrom(this.http.post(`${this.root}/auth/login`, body));
|
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof HttpErrorResponse && e.status === 400) {
|
|
||||||
return 'Usuario o contraseña incorrectos.';
|
|
||||||
}
|
|
||||||
return 'No hay conexión con la plataforma. Intente de nuevo.';
|
|
||||||
}
|
|
||||||
await this.load();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
async logout(): Promise<void> {
|
|
||||||
try {
|
|
||||||
await firstValueFrom(this.http.post(`${this.root}/auth/logout`, null));
|
|
||||||
} finally {
|
|
||||||
this.current.set(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Pages show only to someone signed in; the others go to the sign-in page and come back. */
|
|
||||||
export const signedIn: CanActivateFn = async (_route, state) => {
|
|
||||||
const auth = inject(Auth);
|
|
||||||
const router = inject(Router); // before any await: inject works only in the guard's first turn
|
|
||||||
const user = auth.user() === undefined ? await auth.load() : auth.user();
|
|
||||||
return user ? true : router.createUrlTree(['/login'], { queryParams: { next: state.url } });
|
|
||||||
};
|
|
||||||
|
|
||||||
/** A domain's pages show only to whom may see it. */
|
|
||||||
export const domainAllowed: CanActivateFn = (route) => {
|
|
||||||
const auth = inject(Auth);
|
|
||||||
const domain = route.paramMap.get('domain');
|
|
||||||
if (!domain || auth.canSee(domain)) return true;
|
|
||||||
const first = auth.user()?.domains[0];
|
|
||||||
return inject(Router).createUrlTree(first ? ['/indicadores', first] : ['/login']);
|
|
||||||
};
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
<section class="login" aria-labelledby="login-title">
|
|
||||||
<div class="box">
|
|
||||||
<img class="logo" src="assets/branding/isssteleon-logo.png" alt="ISSSTELEON" />
|
|
||||||
<h1 class="title" id="login-title">Inicio de sesión</h1>
|
|
||||||
<form class="form" (ngSubmit)="enter()" novalidate>
|
|
||||||
<mat-form-field appearance="outline" class="field" subscriptSizing="dynamic">
|
|
||||||
<input
|
|
||||||
matInput
|
|
||||||
name="email"
|
|
||||||
[(ngModel)]="email"
|
|
||||||
placeholder="Usuario"
|
|
||||||
aria-label="Usuario"
|
|
||||||
autocomplete="username"
|
|
||||||
autocapitalize="none"
|
|
||||||
spellcheck="false"
|
|
||||||
/>
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-form-field appearance="outline" class="field" subscriptSizing="dynamic">
|
|
||||||
<input
|
|
||||||
matInput
|
|
||||||
name="password"
|
|
||||||
[(ngModel)]="password"
|
|
||||||
[type]="show() ? 'text' : 'password'"
|
|
||||||
placeholder="Contraseña"
|
|
||||||
aria-label="Contraseña"
|
|
||||||
autocomplete="current-password"
|
|
||||||
/>
|
|
||||||
<button
|
|
||||||
mat-icon-button
|
|
||||||
matSuffix
|
|
||||||
type="button"
|
|
||||||
class="eye"
|
|
||||||
(click)="show.set(!show())"
|
|
||||||
[attr.aria-label]="show() ? 'Ocultar contraseña' : 'Mostrar contraseña'"
|
|
||||||
[attr.aria-pressed]="show()"
|
|
||||||
>
|
|
||||||
<mat-icon>{{ show() ? 'visibility_off' : 'visibility' }}</mat-icon>
|
|
||||||
</button>
|
|
||||||
</mat-form-field>
|
|
||||||
@if (error(); as message) {
|
|
||||||
<p class="error" role="alert">{{ message }}</p>
|
|
||||||
}
|
|
||||||
<button type="submit" class="enter" [disabled]="!email.trim() || !password || sending()">
|
|
||||||
{{ sending() ? 'Ingresando…' : 'Ingresar' }}
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
<p class="legal">©{{ year }} Todos los derechos reservados.</p>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
:host {
|
|
||||||
display: flex;
|
|
||||||
flex: 1;
|
|
||||||
min-width: 0;
|
|
||||||
--login-background: #f8f9fa;
|
|
||||||
--login-border: #e9ecef;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login {
|
|
||||||
align-items: center;
|
|
||||||
display: flex;
|
|
||||||
flex: 1;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 72px 24px 56px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.box {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 16px;
|
|
||||||
max-width: 340px;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The brand opens the screen and is the biggest thing on it. */
|
|
||||||
.logo {
|
|
||||||
align-self: center;
|
|
||||||
animation: logo-in 600ms ease-out both;
|
|
||||||
display: block;
|
|
||||||
width: 260px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes logo-in {
|
|
||||||
from {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY(-8px);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-reduced-motion: reduce) {
|
|
||||||
.logo {
|
|
||||||
animation: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The title between two rules. */
|
|
||||||
.title {
|
|
||||||
align-items: center;
|
|
||||||
color: var(--color-text);
|
|
||||||
display: flex;
|
|
||||||
font-family: var(--font-heading);
|
|
||||||
font-size: 1.375rem;
|
|
||||||
font-weight: 600;
|
|
||||||
gap: 16px;
|
|
||||||
margin: 0 0 8px;
|
|
||||||
white-space: nowrap;
|
|
||||||
|
|
||||||
&::before,
|
|
||||||
&::after {
|
|
||||||
background: var(--color-border);
|
|
||||||
content: '';
|
|
||||||
flex: 1;
|
|
||||||
height: 1px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.form {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.field {
|
|
||||||
--mat-form-field-container-height: 44px;
|
|
||||||
--mat-form-field-container-vertical-padding: 12px;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.eye {
|
|
||||||
color: var(--color-text-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.error {
|
|
||||||
color: var(--mat-sys-error);
|
|
||||||
font-size: 0.875rem;
|
|
||||||
margin: -4px 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* One column with the fields; its border turns to the action color once the form is complete. */
|
|
||||||
.enter {
|
|
||||||
align-items: center;
|
|
||||||
background: var(--login-background);
|
|
||||||
border: 1px solid var(--login-border);
|
|
||||||
border-radius: 10px;
|
|
||||||
color: var(--color-text-secondary);
|
|
||||||
cursor: default;
|
|
||||||
display: flex;
|
|
||||||
font: inherit;
|
|
||||||
font-size: 0.9375rem;
|
|
||||||
font-weight: 500;
|
|
||||||
justify-content: center;
|
|
||||||
margin-top: 8px;
|
|
||||||
min-height: 46px;
|
|
||||||
transition:
|
|
||||||
background-color 260ms ease,
|
|
||||||
border-color 260ms ease,
|
|
||||||
color 260ms ease;
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
&:not(:disabled) {
|
|
||||||
border-color: var(--color-action);
|
|
||||||
color: var(--color-text);
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover:not(:disabled) {
|
|
||||||
background: var(--color-action-hover);
|
|
||||||
}
|
|
||||||
|
|
||||||
&:focus-visible {
|
|
||||||
outline: 2px solid var(--color-action);
|
|
||||||
outline-offset: 2px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.legal {
|
|
||||||
color: var(--color-text-secondary);
|
|
||||||
font-size: 0.8125rem;
|
|
||||||
margin: 16px 0 0;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
.login {
|
|
||||||
padding: 48px 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo {
|
|
||||||
width: 208px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
import { Component, inject, input, signal } from '@angular/core';
|
|
||||||
import { FormsModule } from '@angular/forms';
|
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
|
||||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
|
||||||
import { MatInputModule } from '@angular/material/input';
|
|
||||||
import { Router } from '@angular/router';
|
|
||||||
import { Auth } from './auth';
|
|
||||||
|
|
||||||
/** "Inicio de sesión": the brand, two fields and one button. */
|
|
||||||
@Component({
|
|
||||||
selector: 'app-login',
|
|
||||||
imports: [FormsModule, MatButtonModule, MatFormFieldModule, MatIconModule, MatInputModule],
|
|
||||||
templateUrl: './login.html',
|
|
||||||
styleUrl: './login.scss',
|
|
||||||
})
|
|
||||||
export class Login {
|
|
||||||
private readonly auth = inject(Auth);
|
|
||||||
private readonly router = inject(Router);
|
|
||||||
/** Where to go once signed in (the page that asked for it). */
|
|
||||||
readonly next = input<string>('');
|
|
||||||
protected email = '';
|
|
||||||
protected password = '';
|
|
||||||
protected readonly show = signal(false);
|
|
||||||
protected readonly sending = signal(false);
|
|
||||||
protected readonly error = signal('');
|
|
||||||
protected readonly year = new Date().getFullYear();
|
|
||||||
|
|
||||||
protected async enter(): Promise<void> {
|
|
||||||
if (!this.email.trim() || !this.password || this.sending()) return;
|
|
||||||
this.sending.set(true);
|
|
||||||
this.error.set('');
|
|
||||||
const problem = await this.auth.login(this.email, this.password);
|
|
||||||
this.sending.set(false);
|
|
||||||
if (problem) {
|
|
||||||
this.error.set(problem);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const first = this.auth.user()?.domains[0] ?? 'cacu';
|
|
||||||
await this.router.navigateByUrl(this.next() || `/indicadores/${first}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -29,9 +29,7 @@
|
|||||||
</span>
|
</span>
|
||||||
@if (pipelineId()) {
|
@if (pipelineId()) {
|
||||||
@for (k of kinds; track k[0]) {
|
@for (k of kinds; track k[0]) {
|
||||||
<button mat-stroked-button (click)="add(k[0])" [matTooltip]="help[k[0]]">
|
<button mat-stroked-button (click)="add(k[0])"><mat-icon>add</mat-icon>{{ k[1] }}</button>
|
||||||
<mat-icon>add</mat-icon>{{ k[1] }}
|
|
||||||
</button>
|
|
||||||
}
|
}
|
||||||
<span class="spacer"></span>
|
<span class="spacer"></span>
|
||||||
<button mat-stroked-button (click)="save()">Guardar</button>
|
<button mat-stroked-button (click)="save()">Guardar</button>
|
||||||
@@ -72,7 +70,6 @@
|
|||||||
<mat-icon>delete</mat-icon>
|
<mat-icon>delete</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<p class="help">{{ help[d.kind ?? 'source'] }}</p>
|
|
||||||
<mat-form-field appearance="outline" subscriptSizing="dynamic" class="full">
|
<mat-form-field appearance="outline" subscriptSizing="dynamic" class="full">
|
||||||
<mat-label>Id</mat-label>
|
<mat-label>Id</mat-label>
|
||||||
<input matInput [value]="d.id" (change)="rename($any($event.target).value)" />
|
<input matInput [value]="d.id" (change)="rename($any($event.target).value)" />
|
||||||
@@ -89,35 +86,12 @@
|
|||||||
} @else if (d.kind !== 'source') {
|
} @else if (d.kind !== 'source') {
|
||||||
<p class="muted">Una flecha desde otro nodo le da su entrada.</p>
|
<p class="muted">Una flecha desde otro nodo le da su entrada.</p>
|
||||||
}
|
}
|
||||||
@if (guided(d); as g) {
|
<formly-form
|
||||||
<div class="source-summary">
|
[form]="form"
|
||||||
<p>
|
[fields]="fields()"
|
||||||
<mat-icon>check_circle</mat-icon>
|
[model]="model"
|
||||||
{{ d.label || d.id }}
|
(modelChange)="edited($event)"
|
||||||
</p>
|
/>
|
||||||
<button mat-flat-button (click)="connectSource(d.id)">
|
|
||||||
<mat-icon>edit</mat-icon> Editar conexión
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<mat-slide-toggle [checked]="advanced()" (change)="advanced.set($event.checked)">
|
|
||||||
Avanzado (para personal técnico)
|
|
||||||
</mat-slide-toggle>
|
|
||||||
} @else if (d.kind === 'source') {
|
|
||||||
<button mat-stroked-button (click)="connectSource(d.id)">
|
|
||||||
<mat-icon>cable</mat-icon> Conectar con ayuda
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
@if (!guided(d) || advanced()) {
|
|
||||||
@if (guided(d)) {
|
|
||||||
<p class="muted">Si cambia algo aquí, la fuente deja de editarse con ayuda.</p>
|
|
||||||
}
|
|
||||||
<formly-form
|
|
||||||
[form]="form"
|
|
||||||
[fields]="fields()"
|
|
||||||
[model]="model"
|
|
||||||
(modelChange)="edited($event)"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
@if (conceptMap(d); as cm) {
|
@if (conceptMap(d); as cm) {
|
||||||
<app-concept-map-editor [id]="cm" />
|
<app-concept-map-editor [id]="cm" />
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,34 +109,3 @@ h2 {
|
|||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.help {
|
|
||||||
color: var(--color-text-secondary);
|
|
||||||
font-size: 13px;
|
|
||||||
margin: 0 0 var(--space-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.source-summary {
|
|
||||||
align-items: center;
|
|
||||||
background: var(--color-background, #f7f8f6);
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
border-radius: 8px;
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: var(--space-2);
|
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: var(--space-2);
|
|
||||||
padding: var(--space-2);
|
|
||||||
|
|
||||||
p {
|
|
||||||
align-items: center;
|
|
||||||
display: flex;
|
|
||||||
font-weight: 500;
|
|
||||||
gap: 6px;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
p mat-icon {
|
|
||||||
color: var(--color-success, #2e7d32);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,10 +6,7 @@ import { MatFormFieldModule } from '@angular/material/form-field';
|
|||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import { MatInputModule } from '@angular/material/input';
|
import { MatInputModule } from '@angular/material/input';
|
||||||
import { MatListModule } from '@angular/material/list';
|
import { MatListModule } from '@angular/material/list';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
|
||||||
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
||||||
import { MatTableModule } from '@angular/material/table';
|
import { MatTableModule } from '@angular/material/table';
|
||||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
||||||
import { FormlyFieldConfig, FormlyForm, provideFormlyCore } from '@ngx-formly/core';
|
import { FormlyFieldConfig, FormlyForm, provideFormlyCore } from '@ngx-formly/core';
|
||||||
import { FormlyJsonschema } from '@ngx-formly/core/json-schema';
|
import { FormlyJsonschema } from '@ngx-formly/core/json-schema';
|
||||||
import { withFormlyMaterial } from '@ngx-formly/material';
|
import { withFormlyMaterial } from '@ngx-formly/material';
|
||||||
@@ -27,7 +24,6 @@ import type { Pipeline } from '../api/models/pipeline';
|
|||||||
import type { Source } from '../api/models/source';
|
import type { Source } from '../api/models/source';
|
||||||
import { ConceptMapEditor } from './concept-map-editor';
|
import { ConceptMapEditor } from './concept-map-editor';
|
||||||
import { FORMLY_TYPES, nodeSchema } from './schema-form';
|
import { FORMLY_TYPES, nodeSchema } from './schema-form';
|
||||||
import { SourceDialog, SourceDialogData, SourceDialogResult } from './source-dialog';
|
|
||||||
|
|
||||||
type Doc = Pipeline['nodes'][number];
|
type Doc = Pipeline['nodes'][number];
|
||||||
type Kind = NonNullable<Doc['kind']>;
|
type Kind = NonNullable<Doc['kind']>;
|
||||||
@@ -51,29 +47,16 @@ function canvasNode(id: string, point: { x: number; y: number }, label: string):
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Each step's name and what it does, in the operator's words (the canvas and its panel). */
|
|
||||||
export const KINDS: Record<Kind, string> = {
|
export const KINDS: Record<Kind, string> = {
|
||||||
source: 'Fuente de datos',
|
source: 'Fuente',
|
||||||
read: 'Leer documentos',
|
read: 'Leer',
|
||||||
route: 'Separar por tipo',
|
route: 'Filtrar',
|
||||||
map: 'Traducir códigos',
|
map: 'Mapear',
|
||||||
extract: 'Sacar datos',
|
extract: 'Extraer',
|
||||||
fhir: 'Leer FHIR',
|
fhir: 'FHIR',
|
||||||
join: 'Juntar',
|
join: 'Unir',
|
||||||
link: 'Identificar a la persona',
|
link: 'Vincular',
|
||||||
target: 'Guardar en la plataforma',
|
target: 'Destino',
|
||||||
};
|
|
||||||
export const HELP: Record<Kind, string> = {
|
|
||||||
source: 'De dónde vienen los datos: una base de datos, una carpeta, la nube o una API.',
|
|
||||||
read: 'Saca el texto de cada documento (PDF, Word, escaneos con OCR).',
|
|
||||||
route:
|
|
||||||
'Deja pasar solo los documentos o filas que cumplen una condición; por ejemplo, las citologías.',
|
|
||||||
map: 'Cambia los códigos del hospital por los de la plataforma, con una tabla de equivalencias.',
|
|
||||||
extract: 'Toma de cada documento los datos de un estudio: fechas, resultados, nombres.',
|
|
||||||
fhir: 'Lee paquetes FHIR que un sistema envió y saca de ellos los estudios.',
|
|
||||||
join: 'Junta dos entradas que hablan de lo mismo; por ejemplo, un resultado con su orden.',
|
|
||||||
link: 'Reconoce a qué paciente pertenece cada registro, aunque su nombre venga escrito distinto.',
|
|
||||||
target: 'Guarda los estudios ya revisados en la plataforma.',
|
|
||||||
};
|
};
|
||||||
const ID = /^[a-z][a-z0-9_]*$/;
|
const ID = /^[a-z][a-z0-9_]*$/;
|
||||||
|
|
||||||
@@ -90,9 +73,7 @@ const ID = /^[a-z][a-z0-9_]*$/;
|
|||||||
MatIconModule,
|
MatIconModule,
|
||||||
MatInputModule,
|
MatInputModule,
|
||||||
MatListModule,
|
MatListModule,
|
||||||
MatSlideToggleModule,
|
|
||||||
MatTableModule,
|
MatTableModule,
|
||||||
MatTooltipModule,
|
|
||||||
Vflow,
|
Vflow,
|
||||||
ConceptMapEditor,
|
ConceptMapEditor,
|
||||||
],
|
],
|
||||||
@@ -104,11 +85,7 @@ const ID = /^[a-z][a-z0-9_]*$/;
|
|||||||
export class Conectar {
|
export class Conectar {
|
||||||
private readonly api = inject(Api);
|
private readonly api = inject(Api);
|
||||||
private readonly jsonschema = inject(FormlyJsonschema);
|
private readonly jsonschema = inject(FormlyJsonschema);
|
||||||
private readonly dialog = inject(MatDialog);
|
|
||||||
protected readonly kinds = Object.entries(KINDS) as [Kind, string][];
|
protected readonly kinds = Object.entries(KINDS) as [Kind, string][];
|
||||||
protected readonly help = HELP;
|
|
||||||
/** The raw form of a source drawn with the dialog ("Avanzado"). */
|
|
||||||
protected readonly advanced = signal(false);
|
|
||||||
|
|
||||||
protected readonly list = resource({ loader: () => this.api.invoke(pipelines) });
|
protected readonly list = resource({ loader: () => this.api.invoke(pipelines) });
|
||||||
private readonly schema = resource({ loader: () => this.api.invoke(schema) });
|
private readonly schema = resource({ loader: () => this.api.invoke(schema) });
|
||||||
@@ -181,47 +158,10 @@ export class Conectar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected add(kind: Kind): void {
|
protected add(kind: Kind): void {
|
||||||
if (kind === 'source') {
|
|
||||||
void this.connectSource();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.place(kind, {});
|
|
||||||
}
|
|
||||||
|
|
||||||
/** "Fuente de datos": the dialog walks the operator through it; editing reopens it. */
|
|
||||||
protected async connectSource(id?: string): Promise<void> {
|
|
||||||
const doc = id ? (this.docs().find((d) => d.id === id) as Source | undefined) : undefined;
|
|
||||||
const data: SourceDialogData = {
|
|
||||||
pipeline: this.pipelineId(),
|
|
||||||
node: doc?.id,
|
|
||||||
guided: doc?.guided ?? null,
|
|
||||||
label: doc?.label ?? '',
|
|
||||||
};
|
|
||||||
const ref = this.dialog.open<SourceDialog, SourceDialogData, SourceDialogResult>(SourceDialog, {
|
|
||||||
data,
|
|
||||||
width: '760px',
|
|
||||||
maxWidth: '96vw',
|
|
||||||
maxHeight: '92vh',
|
|
||||||
autoFocus: false,
|
|
||||||
});
|
|
||||||
const result = await new Promise<SourceDialogResult | undefined>((done) =>
|
|
||||||
ref.afterClosed().subscribe(done),
|
|
||||||
);
|
|
||||||
if (!result) return;
|
|
||||||
if (doc) {
|
|
||||||
this.update(doc.id, (d) => ({ ...d, guided: result.guided, label: result.label }) as Doc);
|
|
||||||
this.select(doc.id);
|
|
||||||
} else {
|
|
||||||
this.place('source', { guided: result.guided, label: result.label });
|
|
||||||
}
|
|
||||||
this.message.set('Fuente lista. Guarde la canalización para conservarla.');
|
|
||||||
}
|
|
||||||
|
|
||||||
private place(kind: Kind, fields: Record<string, unknown>): void {
|
|
||||||
let n = 1;
|
let n = 1;
|
||||||
while (this.docs().some((d) => d.id === `${kind}_${n}`)) n++;
|
while (this.docs().some((d) => d.id === `${kind}_${n}`)) n++;
|
||||||
const id = `${kind}_${n}`;
|
const id = `${kind}_${n}`;
|
||||||
const doc = { id, kind, inputs: [], ...fields } as unknown as Doc;
|
const doc = { id, kind, inputs: [] } as unknown as Doc;
|
||||||
this.docs.update((ds) => [...ds, doc]);
|
this.docs.update((ds) => [...ds, doc]);
|
||||||
this.nodes.update((ns) => [
|
this.nodes.update((ns) => [
|
||||||
...ns,
|
...ns,
|
||||||
@@ -264,12 +204,6 @@ export class Conectar {
|
|||||||
);
|
);
|
||||||
this.form = new UntypedFormGroup({});
|
this.form = new UntypedFormGroup({});
|
||||||
this.preview.set(undefined);
|
this.preview.set(undefined);
|
||||||
this.advanced.set(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A source the dialog drew (its answers make its dlt fields). */
|
|
||||||
protected guided(d: Doc): Source['guided'] {
|
|
||||||
return d.kind === 'source' ? ((d as Source).guided ?? undefined) : undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The form's values into the selected node. */
|
/** The form's values into the selected node. */
|
||||||
@@ -279,7 +213,6 @@ export class Conectar {
|
|||||||
const values = Object.fromEntries(
|
const values = Object.fromEntries(
|
||||||
Object.entries(model).filter(([, v]) => v !== undefined && v !== null),
|
Object.entries(model).filter(([, v]) => v !== undefined && v !== null),
|
||||||
);
|
);
|
||||||
if (this.advanced()) delete values['guided']; // drawn by hand from here on
|
|
||||||
this.update(
|
this.update(
|
||||||
id,
|
id,
|
||||||
(d) => ({ ...values, id: d.id, kind: d.kind, inputs: d.inputs }) as unknown as Doc,
|
(d) => ({ ...values, id: d.id, kind: d.kind, inputs: d.inputs }) as unknown as Doc,
|
||||||
|
|||||||
@@ -1,369 +0,0 @@
|
|||||||
@if (!type()) {
|
|
||||||
<h2 mat-dialog-title>¿Dónde están los datos?</h2>
|
|
||||||
<mat-dialog-content>
|
|
||||||
@if (catalog.isLoading()) {
|
|
||||||
<div class="loading" role="status">
|
|
||||||
<mat-spinner diameter="32" /> <span>Cargando opciones…</span>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@for (g of groups(); track g.id) {
|
|
||||||
<section class="group">
|
|
||||||
<h3>{{ g.title }}</h3>
|
|
||||||
<p class="hint">{{ g.description }}</p>
|
|
||||||
<div class="types">
|
|
||||||
@for (t of g.types; track t.id) {
|
|
||||||
<button type="button" class="type" (click)="pick(t.id)" [attr.data-type]="t.id">
|
|
||||||
<mat-icon>{{ icon(t.icon) }}</mat-icon>
|
|
||||||
<span class="type-title">{{ t.title }}</span>
|
|
||||||
<span class="type-text">{{ t.description }}</span>
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
}
|
|
||||||
</mat-dialog-content>
|
|
||||||
<mat-dialog-actions align="end">
|
|
||||||
<button mat-button mat-dialog-close>Cancelar</button>
|
|
||||||
</mat-dialog-actions>
|
|
||||||
} @else {
|
|
||||||
<h2 mat-dialog-title class="with-icon">
|
|
||||||
<mat-icon>{{ icon(type()!.icon) }}</mat-icon> {{ type()!.title }}
|
|
||||||
</h2>
|
|
||||||
<mat-dialog-content>
|
|
||||||
<p class="hint">{{ type()!.description }}</p>
|
|
||||||
|
|
||||||
<ng-template #field let-name let-f="f">
|
|
||||||
@switch (f.type === 'server_file' ? 'folder' : f.type) {
|
|
||||||
@case ('password') {
|
|
||||||
<mat-form-field appearance="outline" class="full">
|
|
||||||
<mat-label>{{ f.label }}</mat-label>
|
|
||||||
<input
|
|
||||||
matInput
|
|
||||||
[type]="showPassword()[name] ? 'text' : 'password'"
|
|
||||||
[ngModel]="isMasked(name) ? '' : text(name)"
|
|
||||||
(ngModelChange)="set(name, $event)"
|
|
||||||
[placeholder]="isMasked(name) ? 'Guardada (escriba para cambiarla)' : f.placeholder"
|
|
||||||
[attr.data-field]="name"
|
|
||||||
autocomplete="off"
|
|
||||||
/>
|
|
||||||
<button
|
|
||||||
mat-icon-button
|
|
||||||
matSuffix
|
|
||||||
type="button"
|
|
||||||
(click)="togglePassword(name)"
|
|
||||||
[attr.aria-label]="showPassword()[name] ? 'Ocultar' : 'Mostrar'"
|
|
||||||
>
|
|
||||||
<mat-icon>{{ showPassword()[name] ? 'visibility_off' : 'visibility' }}</mat-icon>
|
|
||||||
</button>
|
|
||||||
@if (f.help) {
|
|
||||||
<mat-hint>{{ f.help }}</mat-hint>
|
|
||||||
}
|
|
||||||
</mat-form-field>
|
|
||||||
}
|
|
||||||
@case ('number') {
|
|
||||||
<mat-form-field appearance="outline" class="full">
|
|
||||||
<mat-label>{{ f.label }}</mat-label>
|
|
||||||
<input
|
|
||||||
matInput
|
|
||||||
type="number"
|
|
||||||
[ngModel]="text(name)"
|
|
||||||
(ngModelChange)="setNumber(name, $event)"
|
|
||||||
[attr.data-field]="name"
|
|
||||||
/>
|
|
||||||
@if (f.help) {
|
|
||||||
<mat-hint>{{ f.help }}</mat-hint>
|
|
||||||
}
|
|
||||||
</mat-form-field>
|
|
||||||
}
|
|
||||||
@case ('select') {
|
|
||||||
<mat-form-field appearance="outline" class="full">
|
|
||||||
<mat-label>{{ f.label }}</mat-label>
|
|
||||||
<mat-select [ngModel]="value(name)" (ngModelChange)="set(name, $event)">
|
|
||||||
@for (o of f.options; track o.value) {
|
|
||||||
<mat-option [value]="o.value">{{ o.label }}</mat-option>
|
|
||||||
}
|
|
||||||
</mat-select>
|
|
||||||
@if (f.help) {
|
|
||||||
<mat-hint>{{ f.help }}</mat-hint>
|
|
||||||
}
|
|
||||||
</mat-form-field>
|
|
||||||
}
|
|
||||||
@case ('format') {
|
|
||||||
<mat-form-field appearance="outline" class="full">
|
|
||||||
<mat-label>{{ f.label }}</mat-label>
|
|
||||||
<mat-select
|
|
||||||
[ngModel]="value(name)"
|
|
||||||
(ngModelChange)="set(name, $event)"
|
|
||||||
[attr.data-field]="name"
|
|
||||||
>
|
|
||||||
@for (o of formats(); track o.value) {
|
|
||||||
<mat-option [value]="o.value">{{ o.label }}</mat-option>
|
|
||||||
}
|
|
||||||
</mat-select>
|
|
||||||
</mat-form-field>
|
|
||||||
}
|
|
||||||
@case ('table') {
|
|
||||||
<mat-form-field appearance="outline" class="full">
|
|
||||||
<mat-label>{{ f.label }}</mat-label>
|
|
||||||
@if (tables().length) {
|
|
||||||
<mat-select
|
|
||||||
[ngModel]="value(name)"
|
|
||||||
(ngModelChange)="set(name, $event); test()"
|
|
||||||
[attr.data-field]="name"
|
|
||||||
>
|
|
||||||
@for (t of tables(); track t) {
|
|
||||||
<mat-option [value]="t">{{ t }}</mat-option>
|
|
||||||
}
|
|
||||||
</mat-select>
|
|
||||||
} @else {
|
|
||||||
<input
|
|
||||||
matInput
|
|
||||||
[ngModel]="text(name)"
|
|
||||||
(ngModelChange)="set(name, $event)"
|
|
||||||
[attr.data-field]="name"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
@if (f.help) {
|
|
||||||
<mat-hint>{{ f.help }}</mat-hint>
|
|
||||||
}
|
|
||||||
</mat-form-field>
|
|
||||||
}
|
|
||||||
@case ('folder') {
|
|
||||||
<div class="picker">
|
|
||||||
<mat-form-field appearance="outline" class="grow">
|
|
||||||
<mat-label>{{ f.label }}</mat-label>
|
|
||||||
<input
|
|
||||||
matInput
|
|
||||||
[ngModel]="text(name)"
|
|
||||||
(ngModelChange)="set(name, $event)"
|
|
||||||
[attr.data-field]="name"
|
|
||||||
/>
|
|
||||||
@if (f.help) {
|
|
||||||
<mat-hint>{{ f.help }}</mat-hint>
|
|
||||||
}
|
|
||||||
</mat-form-field>
|
|
||||||
<button mat-stroked-button type="button" (click)="openFolder(name, text(name) || null)">
|
|
||||||
<mat-icon>folder_open</mat-icon> Examinar…
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
@if (browsing(); as b) {
|
|
||||||
@if (b.field === name) {
|
|
||||||
<div class="browser" role="group" aria-label="Carpetas del servidor">
|
|
||||||
<div class="browser-head">
|
|
||||||
@if (b.at.path) {
|
|
||||||
<button
|
|
||||||
mat-icon-button
|
|
||||||
type="button"
|
|
||||||
(click)="openFolder(name, b.at.parent)"
|
|
||||||
aria-label="Subir"
|
|
||||||
>
|
|
||||||
<mat-icon>arrow_upward</mat-icon>
|
|
||||||
</button>
|
|
||||||
<code>{{ b.at.path }}</code>
|
|
||||||
} @else {
|
|
||||||
<span class="hint">Carpetas habilitadas en el servidor</span>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
<ul>
|
|
||||||
@for (e of b.at.entries; track e.path) {
|
|
||||||
<li>
|
|
||||||
@if (e.kind === 'folder') {
|
|
||||||
<button type="button" class="entry" (click)="openFolder(name, e.path)">
|
|
||||||
<mat-icon>folder</mat-icon> {{ e.name }}
|
|
||||||
</button>
|
|
||||||
} @else if (browsingFiles()) {
|
|
||||||
<button type="button" class="entry" (click)="chooseFile(e.path)">
|
|
||||||
<mat-icon>description</mat-icon> {{ e.name }}
|
|
||||||
</button>
|
|
||||||
} @else {
|
|
||||||
<span class="entry file"
|
|
||||||
><mat-icon>description</mat-icon> {{ e.name }}</span
|
|
||||||
>
|
|
||||||
}
|
|
||||||
</li>
|
|
||||||
} @empty {
|
|
||||||
<li class="hint">Vacía.</li>
|
|
||||||
}
|
|
||||||
</ul>
|
|
||||||
<div class="browser-actions">
|
|
||||||
<button mat-button type="button" (click)="browsing.set(undefined)">Cerrar</button>
|
|
||||||
@if (!browsingFiles()) {
|
|
||||||
<button
|
|
||||||
mat-flat-button
|
|
||||||
type="button"
|
|
||||||
[disabled]="!b.at.path"
|
|
||||||
(click)="chooseFolder()"
|
|
||||||
>
|
|
||||||
Elegir esta carpeta
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@case ('upload') {
|
|
||||||
<div
|
|
||||||
class="drop"
|
|
||||||
(dragover)="$event.preventDefault()"
|
|
||||||
(drop)="dropped(name, $event)"
|
|
||||||
[attr.data-field]="name"
|
|
||||||
>
|
|
||||||
<mat-icon>cloud_upload</mat-icon>
|
|
||||||
<p>Arrastre aquí los archivos, o</p>
|
|
||||||
<div class="drop-buttons">
|
|
||||||
<button mat-stroked-button type="button" (click)="files.click()">
|
|
||||||
Elegir archivos
|
|
||||||
</button>
|
|
||||||
<button mat-stroked-button type="button" (click)="folder.click()">
|
|
||||||
Elegir una carpeta
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<input #files type="file" multiple hidden (change)="upload(name, files.files)" />
|
|
||||||
<input
|
|
||||||
#folder
|
|
||||||
type="file"
|
|
||||||
webkitdirectory
|
|
||||||
hidden
|
|
||||||
(change)="upload(name, folder.files)"
|
|
||||||
/>
|
|
||||||
@if (uploading(); as u) {
|
|
||||||
@if (u.field === name) {
|
|
||||||
<mat-progress-bar mode="determinate" [value]="u.percent" />
|
|
||||||
<span class="hint">Subiendo… {{ u.percent }} %</span>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@if (uploaded()[name]?.length) {
|
|
||||||
<p class="ok">
|
|
||||||
<mat-icon>check_circle</mat-icon> {{ uploaded()[name].length }} archivos subidos
|
|
||||||
</p>
|
|
||||||
} @else if (text(name)) {
|
|
||||||
<p class="ok"><mat-icon>check_circle</mat-icon> Archivos ya subidos</p>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@case ('oauth') {
|
|
||||||
<div class="signin">
|
|
||||||
@if (account(name); as who) {
|
|
||||||
<p class="ok"><mat-icon>check_circle</mat-icon> Conectado como {{ who }}</p>
|
|
||||||
<button mat-button type="button" (click)="signIn(name, f.provider)">
|
|
||||||
Usar otra cuenta
|
|
||||||
</button>
|
|
||||||
} @else {
|
|
||||||
<button mat-flat-button type="button" (click)="signIn(name, f.provider)">
|
|
||||||
<mat-icon>login</mat-icon>
|
|
||||||
Iniciar sesión con {{ catalog.value()?.providers?.[f.provider]?.title }}
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
@if (f.help) {
|
|
||||||
<p class="hint">{{ f.help }}</p>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@default {
|
|
||||||
<mat-form-field appearance="outline" class="full">
|
|
||||||
<mat-label>{{ f.label }}</mat-label>
|
|
||||||
<input
|
|
||||||
matInput
|
|
||||||
[ngModel]="text(name)"
|
|
||||||
(ngModelChange)="set(name, $event)"
|
|
||||||
[placeholder]="f.placeholder"
|
|
||||||
[attr.data-field]="name"
|
|
||||||
/>
|
|
||||||
@if (f.help) {
|
|
||||||
<mat-hint>{{ f.help }}</mat-hint>
|
|
||||||
}
|
|
||||||
</mat-form-field>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</ng-template>
|
|
||||||
|
|
||||||
<div class="fields">
|
|
||||||
@for (e of fields(); track e[0]) {
|
|
||||||
<ng-container *ngTemplateOutlet="field; context: { $implicit: e[0], f: e[1] }" />
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
@if (more().length) {
|
|
||||||
<mat-expansion-panel class="more">
|
|
||||||
<mat-expansion-panel-header>Más opciones</mat-expansion-panel-header>
|
|
||||||
<div class="fields">
|
|
||||||
@for (e of more(); track e[0]) {
|
|
||||||
<ng-container *ngTemplateOutlet="field; context: { $implicit: e[0], f: e[1] }" />
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</mat-expansion-panel>
|
|
||||||
}
|
|
||||||
|
|
||||||
<div class="test">
|
|
||||||
<button
|
|
||||||
mat-stroked-button
|
|
||||||
type="button"
|
|
||||||
(click)="test()"
|
|
||||||
[disabled]="testing() || missing().length > 0"
|
|
||||||
>
|
|
||||||
<mat-icon>network_check</mat-icon> Probar conexión
|
|
||||||
</button>
|
|
||||||
@if (testing()) {
|
|
||||||
<mat-spinner diameter="24" /> <span role="status">Conectando…</span>
|
|
||||||
} @else if (missing().length) {
|
|
||||||
<span class="hint">Falta: {{ missing().join(', ') }}</span>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
@if (problem()) {
|
|
||||||
<p class="error" role="alert"><mat-icon>error</mat-icon> {{ problem() }}</p>
|
|
||||||
}
|
|
||||||
@if (tested(); as t) {
|
|
||||||
<div class="result" [class.bad]="!t.ok" role="status">
|
|
||||||
<p>
|
|
||||||
<mat-icon>{{ t.ok ? 'check_circle' : 'error' }}</mat-icon> {{ t.message }}
|
|
||||||
</p>
|
|
||||||
@if (t.detail) {
|
|
||||||
<details>
|
|
||||||
<summary>Lo que respondió el sistema</summary>
|
|
||||||
<pre>{{ t.detail }}</pre>
|
|
||||||
</details>
|
|
||||||
}
|
|
||||||
@if (t.tables?.length) {
|
|
||||||
<p class="hint">Elija una tabla arriba para ver sus primeras filas.</p>
|
|
||||||
}
|
|
||||||
@if (t.rows?.length) {
|
|
||||||
<p class="hint">
|
|
||||||
{{
|
|
||||||
t.rows!.length === 1
|
|
||||||
? 'La primera fila:'
|
|
||||||
: 'Las primeras ' + t.rows!.length + ' filas:'
|
|
||||||
}}
|
|
||||||
</p>
|
|
||||||
<div class="rows">
|
|
||||||
<table mat-table [dataSource]="t.rows!">
|
|
||||||
@for (c of columns(); track c) {
|
|
||||||
<ng-container [matColumnDef]="c">
|
|
||||||
<th mat-header-cell *matHeaderCellDef>{{ c }}</th>
|
|
||||||
<td mat-cell *matCellDef="let row">{{ cell(row[c]) }}</td>
|
|
||||||
</ng-container>
|
|
||||||
}
|
|
||||||
<tr mat-header-row *matHeaderRowDef="columns()"></tr>
|
|
||||||
<tr mat-row *matRowDef="let row; columns: columns()"></tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
<mat-form-field appearance="outline" class="full name">
|
|
||||||
<mat-label>Nombre de esta fuente</mat-label>
|
|
||||||
<input matInput [ngModel]="label()" (ngModelChange)="label.set($event)" />
|
|
||||||
<mat-hint>Cómo se verá en el diagrama.</mat-hint>
|
|
||||||
</mat-form-field>
|
|
||||||
</mat-dialog-content>
|
|
||||||
<mat-dialog-actions>
|
|
||||||
@if (!data.guided) {
|
|
||||||
<button mat-button type="button" (click)="back()">
|
|
||||||
<mat-icon>arrow_back</mat-icon> Otro tipo
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
<span class="spacer"></span>
|
|
||||||
<button mat-button mat-dialog-close>Cancelar</button>
|
|
||||||
<button mat-flat-button type="button" (click)="save()" [disabled]="!ready()">Guardar</button>
|
|
||||||
</mat-dialog-actions>
|
|
||||||
}
|
|
||||||
@@ -1,230 +0,0 @@
|
|||||||
:host {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.with-icon {
|
|
||||||
align-items: center;
|
|
||||||
display: flex;
|
|
||||||
gap: var(--space-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.hint {
|
|
||||||
color: var(--color-text-secondary);
|
|
||||||
font-size: 13px;
|
|
||||||
margin: 0 0 var(--space-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.loading,
|
|
||||||
.test {
|
|
||||||
align-items: center;
|
|
||||||
display: flex;
|
|
||||||
gap: var(--space-2);
|
|
||||||
margin: var(--space-2) 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.group h3 {
|
|
||||||
font-size: 15px;
|
|
||||||
font-weight: 600;
|
|
||||||
margin: var(--space-3) 0 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.types {
|
|
||||||
display: grid;
|
|
||||||
gap: var(--space-2);
|
|
||||||
grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
|
|
||||||
}
|
|
||||||
|
|
||||||
.type {
|
|
||||||
align-items: start;
|
|
||||||
background: var(--color-surface);
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
border-radius: 10px;
|
|
||||||
cursor: pointer;
|
|
||||||
display: grid;
|
|
||||||
font: inherit;
|
|
||||||
gap: 2px 10px;
|
|
||||||
grid-template-columns: auto 1fr;
|
|
||||||
padding: 12px;
|
|
||||||
text-align: left;
|
|
||||||
|
|
||||||
&:hover,
|
|
||||||
&:focus-visible {
|
|
||||||
border-color: var(--color-primary);
|
|
||||||
box-shadow: 0 0 0 1px var(--color-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
mat-icon {
|
|
||||||
color: var(--color-primary);
|
|
||||||
grid-row: span 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.type-title {
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.type-text {
|
|
||||||
color: var(--color-text-secondary);
|
|
||||||
font-size: 12.5px;
|
|
||||||
line-height: 1.35;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fields {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.full,
|
|
||||||
.grow {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.picker {
|
|
||||||
align-items: start;
|
|
||||||
display: flex;
|
|
||||||
gap: var(--space-2);
|
|
||||||
|
|
||||||
.grow {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.browser {
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: var(--space-2);
|
|
||||||
|
|
||||||
ul {
|
|
||||||
list-style: none;
|
|
||||||
margin: 0;
|
|
||||||
max-height: 220px;
|
|
||||||
overflow-y: auto;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.browser-head,
|
|
||||||
.browser-actions {
|
|
||||||
align-items: center;
|
|
||||||
display: flex;
|
|
||||||
gap: var(--space-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.browser-actions {
|
|
||||||
justify-content: flex-end;
|
|
||||||
}
|
|
||||||
|
|
||||||
.entry {
|
|
||||||
align-items: center;
|
|
||||||
background: none;
|
|
||||||
border: 0;
|
|
||||||
cursor: pointer;
|
|
||||||
display: flex;
|
|
||||||
font: inherit;
|
|
||||||
gap: 6px;
|
|
||||||
padding: 4px 2px;
|
|
||||||
text-align: left;
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
&.file {
|
|
||||||
color: var(--color-text-secondary);
|
|
||||||
cursor: default;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:not(.file):hover {
|
|
||||||
color: var(--color-primary);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.drop {
|
|
||||||
align-items: center;
|
|
||||||
border: 2px dashed var(--color-border);
|
|
||||||
border-radius: 10px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-1, 4px);
|
|
||||||
padding: var(--space-3);
|
|
||||||
text-align: center;
|
|
||||||
|
|
||||||
mat-progress-bar {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.drop-buttons {
|
|
||||||
display: flex;
|
|
||||||
gap: var(--space-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.signin {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: var(--space-1, 4px);
|
|
||||||
align-items: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ok,
|
|
||||||
.error,
|
|
||||||
.result p {
|
|
||||||
align-items: center;
|
|
||||||
display: flex;
|
|
||||||
gap: 6px;
|
|
||||||
margin: var(--space-1, 4px) 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ok mat-icon,
|
|
||||||
.result mat-icon {
|
|
||||||
color: var(--color-success, #2e7d32);
|
|
||||||
}
|
|
||||||
|
|
||||||
.error,
|
|
||||||
.result.bad p {
|
|
||||||
color: var(--color-error, #b3261e);
|
|
||||||
|
|
||||||
mat-icon {
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.result {
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
border-radius: 8px;
|
|
||||||
margin-top: var(--space-2);
|
|
||||||
padding: var(--space-2);
|
|
||||||
|
|
||||||
pre {
|
|
||||||
font-size: 12px;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.rows {
|
|
||||||
max-height: 260px;
|
|
||||||
overflow: auto;
|
|
||||||
|
|
||||||
td,
|
|
||||||
th {
|
|
||||||
font-size: 12px;
|
|
||||||
max-width: 260px;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.more {
|
|
||||||
margin: var(--space-2) 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.name {
|
|
||||||
margin-top: var(--space-3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.spacer {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
@@ -1,349 +0,0 @@
|
|||||||
import { NgTemplateOutlet } from '@angular/common';
|
|
||||||
import { HttpClient, HttpErrorResponse, HttpEventType } from '@angular/common/http';
|
|
||||||
import { Component, computed, inject, resource, signal } from '@angular/core';
|
|
||||||
import { FormsModule } from '@angular/forms';
|
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
|
||||||
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
|
||||||
import { MatExpansionModule } from '@angular/material/expansion';
|
|
||||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
|
||||||
import { MatInputModule } from '@angular/material/input';
|
|
||||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
|
||||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
||||||
import { MatSelectModule } from '@angular/material/select';
|
|
||||||
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
|
||||||
import { MatTableModule } from '@angular/material/table';
|
|
||||||
import { Api } from '../api/api';
|
|
||||||
import { ApiConfiguration } from '../api/api-configuration';
|
|
||||||
import { browse } from '../api/fn/ingest/browse';
|
|
||||||
import { oauthStart } from '../api/fn/ingest/oauth-start';
|
|
||||||
import { sourceTypes } from '../api/fn/ingest/source-types';
|
|
||||||
import { testSource } from '../api/fn/ingest/test-source';
|
|
||||||
import type { Browsed } from '../api/models/browsed';
|
|
||||||
import type { FieldSpec } from '../api/models/field-spec';
|
|
||||||
import type { Guided } from '../api/models/guided';
|
|
||||||
import type { SourceType } from '../api/models/source-type';
|
|
||||||
import type { Tested } from '../api/models/tested';
|
|
||||||
import type { Uploaded } from '../api/models/uploaded';
|
|
||||||
|
|
||||||
/** What the dialog is opened with: the source being edited, if any. */
|
|
||||||
export interface SourceDialogData {
|
|
||||||
pipeline?: string;
|
|
||||||
node?: string;
|
|
||||||
guided?: Guided | null;
|
|
||||||
label?: string;
|
|
||||||
}
|
|
||||||
/** What it gives back: the dialog's answers (the node's dlt fields are made from them). */
|
|
||||||
export interface SourceDialogResult {
|
|
||||||
guided: Guided;
|
|
||||||
label: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The catalog's generic icon words, as Material Symbols. */
|
|
||||||
const ICONS: Record<string, string> = {
|
|
||||||
database: 'database',
|
|
||||||
upload: 'upload_file',
|
|
||||||
folder: 'folder_open',
|
|
||||||
link: 'link',
|
|
||||||
'folder-network': 'lan',
|
|
||||||
server: 'dns',
|
|
||||||
cloud: 'cloud',
|
|
||||||
onedrive: 'cloud',
|
|
||||||
sharepoint: 'groups',
|
|
||||||
'google-drive': 'add_to_drive',
|
|
||||||
web: 'api',
|
|
||||||
fhir: 'local_hospital',
|
|
||||||
};
|
|
||||||
const MASK = '********';
|
|
||||||
|
|
||||||
/** "Nueva fuente": the operator picks what kind of source the data is in, answers only what
|
|
||||||
* that kind needs (in plain words, with pickers and sign-in buttons), tests the connection,
|
|
||||||
* picks a table if there are several, sees the first rows, and saves. No dlt, no JSON. */
|
|
||||||
@Component({
|
|
||||||
selector: 'app-source-dialog',
|
|
||||||
imports: [
|
|
||||||
FormsModule,
|
|
||||||
NgTemplateOutlet,
|
|
||||||
MatButtonModule,
|
|
||||||
MatDialogModule,
|
|
||||||
MatExpansionModule,
|
|
||||||
MatFormFieldModule,
|
|
||||||
MatIconModule,
|
|
||||||
MatInputModule,
|
|
||||||
MatProgressBarModule,
|
|
||||||
MatProgressSpinnerModule,
|
|
||||||
MatSelectModule,
|
|
||||||
MatSlideToggleModule,
|
|
||||||
MatTableModule,
|
|
||||||
],
|
|
||||||
templateUrl: './source-dialog.html',
|
|
||||||
styleUrl: './source-dialog.scss',
|
|
||||||
})
|
|
||||||
export class SourceDialog {
|
|
||||||
private readonly api = inject(Api);
|
|
||||||
private readonly http = inject(HttpClient);
|
|
||||||
private readonly root = inject(ApiConfiguration).rootUrl;
|
|
||||||
private readonly ref = inject(MatDialogRef<SourceDialog, SourceDialogResult>);
|
|
||||||
protected readonly data = inject<SourceDialogData>(MAT_DIALOG_DATA, { optional: true }) ?? {};
|
|
||||||
|
|
||||||
protected readonly catalog = resource({ loader: () => this.api.invoke(sourceTypes) });
|
|
||||||
protected readonly groups = computed(() => {
|
|
||||||
const c = this.catalog.value();
|
|
||||||
if (!c) return [];
|
|
||||||
return Object.entries(c.groups).map(([id, g]) => ({
|
|
||||||
id,
|
|
||||||
...g,
|
|
||||||
types: Object.entries(c.types)
|
|
||||||
.filter(([, t]) => t.group === id)
|
|
||||||
.map(([tid, t]) => ({ id: tid, ...t })),
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
protected readonly typeId = signal<string | undefined>(this.data.guided?.type);
|
|
||||||
protected readonly type = computed<SourceType | undefined>(() => {
|
|
||||||
const id = this.typeId();
|
|
||||||
return id ? this.catalog.value()?.types[id] : undefined;
|
|
||||||
});
|
|
||||||
protected readonly answers = signal<Record<string, unknown>>({
|
|
||||||
...(this.data.guided?.answers ?? {}),
|
|
||||||
});
|
|
||||||
protected readonly label = signal(this.data.label ?? '');
|
|
||||||
protected readonly fields = computed(() => entries(this.type()).filter(([, f]) => !f.advanced));
|
|
||||||
protected readonly more = computed(() => entries(this.type()).filter(([, f]) => f.advanced));
|
|
||||||
protected readonly showPassword = signal<Record<string, boolean>>({});
|
|
||||||
|
|
||||||
protected readonly testing = signal(false);
|
|
||||||
/** The tables the last listing found: kept while one is picked and its rows shown. */
|
|
||||||
protected readonly tableList = signal<string[]>([]);
|
|
||||||
protected readonly tested = signal<Tested | undefined>(undefined);
|
|
||||||
protected readonly columns = computed(() => Object.keys(this.tested()?.rows?.[0] ?? {}));
|
|
||||||
|
|
||||||
protected readonly browsing = signal<{ field: string; at: Browsed } | undefined>(undefined);
|
|
||||||
protected readonly uploading = signal<{ field: string; percent: number } | undefined>(undefined);
|
|
||||||
protected readonly uploaded = signal<Record<string, string[]>>({});
|
|
||||||
protected readonly problem = signal('');
|
|
||||||
|
|
||||||
icon(name: string): string {
|
|
||||||
return ICONS[name] ?? 'input';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected pick(id: string): void {
|
|
||||||
const t = this.catalog.value()!.types[id];
|
|
||||||
this.typeId.set(id);
|
|
||||||
this.answers.set(
|
|
||||||
Object.fromEntries(
|
|
||||||
Object.entries(t.fields)
|
|
||||||
.filter(([, f]) => f.default !== null && f.default !== undefined)
|
|
||||||
.map(([k, f]) => [k, f.default]),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (!this.label()) this.label.set(t.title);
|
|
||||||
this.tested.set(undefined);
|
|
||||||
this.problem.set('');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected back(): void {
|
|
||||||
this.typeId.set(undefined);
|
|
||||||
this.tested.set(undefined);
|
|
||||||
this.problem.set('');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected value(name: string): unknown {
|
|
||||||
return this.answers()[name];
|
|
||||||
}
|
|
||||||
protected text(name: string): string {
|
|
||||||
const v = this.answers()[name];
|
|
||||||
return v === null || v === undefined ? '' : String(v);
|
|
||||||
}
|
|
||||||
protected set(name: string, value: unknown): void {
|
|
||||||
this.answers.update((a) => ({ ...a, [name]: value }));
|
|
||||||
if (this.type()?.fields[name]?.type === 'table') return;
|
|
||||||
this.tested.set(undefined); // another connection: test again
|
|
||||||
this.tableList.set([]);
|
|
||||||
}
|
|
||||||
protected setNumber(name: string, value: string): void {
|
|
||||||
this.set(name, value === '' ? null : Number(value));
|
|
||||||
}
|
|
||||||
protected togglePassword(name: string): void {
|
|
||||||
this.showPassword.update((s) => ({ ...s, [name]: !s[name] }));
|
|
||||||
}
|
|
||||||
protected isMasked(name: string): boolean {
|
|
||||||
return this.answers()[name] === MASK;
|
|
||||||
}
|
|
||||||
protected formats() {
|
|
||||||
return this.catalog.value()?.formats ?? [];
|
|
||||||
}
|
|
||||||
protected account(name: string): string | undefined {
|
|
||||||
const a = this.answers()[name] as { user?: string } | undefined;
|
|
||||||
return a ? (a.user ?? 'cuenta conectada') : undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** "Probar conexión": what the source holds, in plain words. */
|
|
||||||
protected async test(): Promise<void> {
|
|
||||||
const type = this.typeId();
|
|
||||||
if (!type) return;
|
|
||||||
this.testing.set(true);
|
|
||||||
this.problem.set('');
|
|
||||||
try {
|
|
||||||
const found = await this.api.invoke(testSource, {
|
|
||||||
limit: 20,
|
|
||||||
body: {
|
|
||||||
type,
|
|
||||||
answers: this.cleaned(),
|
|
||||||
pipeline: this.data.pipeline,
|
|
||||||
node: this.data.node,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
this.tested.set(found);
|
|
||||||
if (found.tables?.length) this.tableList.set(found.tables);
|
|
||||||
} catch (e) {
|
|
||||||
this.problem.set(message(e));
|
|
||||||
} finally {
|
|
||||||
this.testing.set(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The tables a database listed, for its table field. */
|
|
||||||
protected tables(): string[] {
|
|
||||||
return this.tableList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Server folders, under the roots the operator mounted. */
|
|
||||||
protected async openFolder(field: string, path?: string | null): Promise<void> {
|
|
||||||
try {
|
|
||||||
const at = await this.api.invoke(browse, path ? { path } : {});
|
|
||||||
this.browsing.set({ field, at });
|
|
||||||
} catch (e) {
|
|
||||||
this.problem.set(message(e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected chooseFolder(): void {
|
|
||||||
const b = this.browsing();
|
|
||||||
if (b?.at.path) this.set(b.field, b.at.path);
|
|
||||||
this.browsing.set(undefined);
|
|
||||||
}
|
|
||||||
protected chooseFile(path: string): void {
|
|
||||||
const b = this.browsing();
|
|
||||||
if (b) this.set(b.field, path);
|
|
||||||
this.browsing.set(undefined);
|
|
||||||
}
|
|
||||||
/** Whether the field being browsed takes a file (else a folder). */
|
|
||||||
protected readonly browsingFiles = computed(() => {
|
|
||||||
const b = this.browsing();
|
|
||||||
return !!b && this.type()?.fields[b.field]?.type === 'server_file';
|
|
||||||
});
|
|
||||||
|
|
||||||
/** Files or a whole folder from this computer, sent with progress; a folder keeps its
|
|
||||||
* subfolders. More files can be added to the same set. */
|
|
||||||
protected upload(field: string, list: FileList | null): void {
|
|
||||||
if (!list?.length) return;
|
|
||||||
const body = new FormData();
|
|
||||||
for (const file of Array.from(list)) {
|
|
||||||
body.append('files', file, file.webkitRelativePath || file.name);
|
|
||||||
}
|
|
||||||
const folder = this.answers()[field];
|
|
||||||
if (typeof folder === 'string' && folder) body.append('folder', folder);
|
|
||||||
this.uploading.set({ field, percent: 0 });
|
|
||||||
this.problem.set('');
|
|
||||||
this.http
|
|
||||||
.post<Uploaded>(`${this.root}/ingest/uploads`, body, {
|
|
||||||
reportProgress: true,
|
|
||||||
observe: 'events',
|
|
||||||
})
|
|
||||||
.subscribe({
|
|
||||||
next: (event) => {
|
|
||||||
if (event.type === HttpEventType.UploadProgress && event.total) {
|
|
||||||
this.uploading.set({ field, percent: Math.round((100 * event.loaded) / event.total) });
|
|
||||||
} else if (event.type === HttpEventType.Response && event.body) {
|
|
||||||
this.set(field, event.body.bucket_url);
|
|
||||||
this.uploaded.update((u) => ({
|
|
||||||
...u,
|
|
||||||
[field]: [...(u[field] ?? []), ...event.body!.files],
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: (e) => {
|
|
||||||
this.uploading.set(undefined);
|
|
||||||
this.problem.set(message(e));
|
|
||||||
},
|
|
||||||
complete: () => this.uploading.set(undefined),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
protected dropped(field: string, event: DragEvent): void {
|
|
||||||
event.preventDefault();
|
|
||||||
this.upload(field, event.dataTransfer?.files ?? null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** "Iniciar sesión con …": the provider's page in a window; it hands the account back. */
|
|
||||||
protected async signIn(field: string, provider: string): Promise<void> {
|
|
||||||
this.problem.set('');
|
|
||||||
let started;
|
|
||||||
try {
|
|
||||||
started = await this.api.invoke(oauthStart, { provider, origin: location.origin });
|
|
||||||
} catch (e) {
|
|
||||||
this.problem.set(message(e));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const popup = window.open(started.url, 'isssteleon-oauth', 'width=520,height=680');
|
|
||||||
const listen = (event: MessageEvent) => {
|
|
||||||
const m = event.data as { type?: string; state?: string; account?: unknown; error?: string };
|
|
||||||
if (event.origin !== location.origin || m?.type !== 'isssteleon-oauth') return;
|
|
||||||
if (m.state !== started.state) return;
|
|
||||||
window.removeEventListener('message', listen);
|
|
||||||
if (m.error) this.problem.set(m.error);
|
|
||||||
else this.set(field, m.account);
|
|
||||||
popup?.close();
|
|
||||||
};
|
|
||||||
window.addEventListener('message', listen);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected cell(v: unknown): string {
|
|
||||||
return typeof v === 'object' && v !== null ? JSON.stringify(v) : String(v ?? '');
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Answers without empty ones (a default takes their place on the server). */
|
|
||||||
private cleaned(): Record<string, unknown> {
|
|
||||||
return Object.fromEntries(
|
|
||||||
Object.entries(this.answers()).filter(([, v]) => v !== '' && v !== null && v !== undefined),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected readonly missing = computed(() =>
|
|
||||||
entries(this.type())
|
|
||||||
.filter(([k, f]) => f.required && f.type !== 'table' && isEmpty(this.answers()[k]))
|
|
||||||
.filter(([, f]) => f.default === null || f.default === undefined)
|
|
||||||
.map(([, f]) => f.label),
|
|
||||||
);
|
|
||||||
protected readonly ready = computed(
|
|
||||||
() =>
|
|
||||||
!this.missing().length &&
|
|
||||||
entries(this.type())
|
|
||||||
.filter(([, f]) => f.type === 'table' && f.required)
|
|
||||||
.every(([k]) => !isEmpty(this.answers()[k])),
|
|
||||||
);
|
|
||||||
|
|
||||||
protected save(): void {
|
|
||||||
const type = this.typeId();
|
|
||||||
if (!type || !this.ready()) return;
|
|
||||||
this.ref.close({
|
|
||||||
guided: { type, answers: this.cleaned() },
|
|
||||||
label: this.label() || this.type()!.title,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function entries(t: SourceType | undefined): [string, FieldSpec][] {
|
|
||||||
return Object.entries(t?.fields ?? {});
|
|
||||||
}
|
|
||||||
function isEmpty(v: unknown): boolean {
|
|
||||||
return v === '' || v === null || v === undefined;
|
|
||||||
}
|
|
||||||
function message(e: unknown): string {
|
|
||||||
if (e instanceof HttpErrorResponse) {
|
|
||||||
const d = e.error?.detail;
|
|
||||||
if (typeof d === 'string') return d;
|
|
||||||
if (e.status === 0) return 'No hay conexión con la plataforma. Intente de nuevo.';
|
|
||||||
return JSON.stringify(d ?? e.message);
|
|
||||||
}
|
|
||||||
return String(e);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
|
||||||
|
import { firstValueFrom } from 'rxjs';
|
||||||
|
|
||||||
|
export interface ExportStage { state: string; provenance?: string; label?: string; date?: string; prev?: string; start?: string }
|
||||||
|
export interface ExportRiskScale { label: string; value?: number; low?: number; high?: number; outcome?: string; model?: string; horizon?: string }
|
||||||
|
export interface ExportDocument { title: string; parameters: string[][]; columns: string[]; rows: string[][]; timeline?: ExportStage[]; row_stages?: ExportStage[][]; risk_scales?: ExportRiskScale[]; }
|
||||||
|
export async function downloadDocument(http: HttpClient, format: 'pdf' | 'xlsx', doc: ExportDocument) {
|
||||||
|
let blob: Blob;
|
||||||
|
try { blob = await firstValueFrom(http.post(`/api/cacu/exports/${format}`, doc, {responseType:'blob'})); }
|
||||||
|
catch (error) {
|
||||||
|
if (error instanceof HttpErrorResponse && error.error instanceof Blob) {
|
||||||
|
try { const body = JSON.parse(await error.error.text()); if (typeof body.detail === 'string') throw new Error(body.detail); }
|
||||||
|
catch (parsed) { if (parsed instanceof Error && !(parsed instanceof SyntaxError)) throw parsed; }
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement('a'); a.href = url; a.download = `cacu-${format === 'pdf' ? 'reporte.pdf' : 'seguimiento.xlsx'}`; a.click();
|
||||||
|
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
||||||
|
}
|
||||||
@@ -211,8 +211,8 @@ export function interpretabilityFigures(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** One clinical scenario: Kaplan-Meier with its band, the classic and fractional Weibull,
|
/** One clinical scenario: Kaplan-Meier with its band, the classic and fractional Weibull,
|
||||||
* and the model's points with their bootstrap band (also a patient's, in her record). */
|
* and the model's points with their bootstrap band. */
|
||||||
export function scenarioFigure(
|
function scenarioFigure(
|
||||||
title: string,
|
title: string,
|
||||||
e: any,
|
e: any,
|
||||||
horizons: number[],
|
horizons: number[],
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@if (models.isLoading()) {
|
@if (models.isLoading()) {
|
||||||
<app-loading what="los modelos" />
|
<p class="muted">Cargando modelos…</p>
|
||||||
} @else if (!models.value()?.length) {
|
} @else if (!models.value()?.length) {
|
||||||
<p class="muted empty">Este dominio todavía no tiene modelos entrenados.</p>
|
<p class="muted empty">Este dominio todavía no tiene modelos entrenados.</p>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import type { Version } from '../api/models/version';
|
|||||||
import { DOMAINS } from '../app';
|
import { DOMAINS } from '../app';
|
||||||
import { Plot } from '../plot';
|
import { Plot } from '../plot';
|
||||||
import { interpretabilityFigures } from './figures';
|
import { interpretabilityFigures } from './figures';
|
||||||
import { Loading } from '../loading';
|
|
||||||
|
|
||||||
const REPORTS: Record<string, string> = {
|
const REPORTS: Record<string, string> = {
|
||||||
technical_validation: 'Validación técnica',
|
technical_validation: 'Validación técnica',
|
||||||
@@ -39,7 +38,6 @@ const REPORTS: Record<string, string> = {
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-gobernanza',
|
selector: 'app-gobernanza',
|
||||||
imports: [
|
imports: [
|
||||||
Loading,
|
|
||||||
DatePipe,
|
DatePipe,
|
||||||
DecimalPipe,
|
DecimalPipe,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import { biopsyDistribution, cytologyDistribution, hpvDistribution } from './cacu-results';
|
||||||
|
import { Reading } from './measures';
|
||||||
|
|
||||||
|
const report = (population: number, counts: Record<string, number>): Reading => ({
|
||||||
|
populations: { 'initial-population': population },
|
||||||
|
strata: { category: Object.fromEntries(Object.entries(counts).map(([k, n]) => [k, { 'initial-population': n }])) },
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('reportes clínicos', () => {
|
||||||
|
it('counts HPV reports and retains inconsistent and zero categories', () => {
|
||||||
|
const d = hpvDistribution(report(4, { negative: 2, positive_16: 1, inconsistent: 1 }))!;
|
||||||
|
expect(d.total).toBe(4);
|
||||||
|
expect(d.rows.map((r) => r.count)).toEqual([2, 1, 0, 0, 0, 0, 1]);
|
||||||
|
expect(d.outside).toBe(0);
|
||||||
|
});
|
||||||
|
it('excludes missing or unclassifiable histology from the denominator', () => {
|
||||||
|
const d = biopsyDistribution(report(5, { normal: 1, HSIL: 2, no_data: 1, unclassified: 1 }))!;
|
||||||
|
expect(d.total).toBe(3);
|
||||||
|
expect(d.noData).toBe(1);
|
||||||
|
expect(d.outside).toBe(2);
|
||||||
|
});
|
||||||
|
it('does not fabricate a report or accept mismatched counts', () => {
|
||||||
|
expect(hpvDistribution(undefined)).toBeUndefined();
|
||||||
|
expect(biopsyDistribution(report(2, { normal: 1 }))).toBeUndefined();
|
||||||
|
expect(hpvDistribution(report(0, {}))?.total).toBe(0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('citología EU7', () => {
|
||||||
|
it('uses eligible results as denominator and preserves outside counts and zero categories', () => {
|
||||||
|
const result = cytologyDistribution(report(10, { NILM: 6, HSIL: 2, no_data: 2 }))!;
|
||||||
|
expect(result.total).toBe(8);
|
||||||
|
expect(result.outside).toBe(2);
|
||||||
|
expect(result.rows.map((r) => r.count)).toEqual([6, 0, 0, 0, 2, 0]);
|
||||||
|
});
|
||||||
|
it('supports an empty population without inventing percentages', () => {
|
||||||
|
expect(cytologyDistribution(report(0, {}))).toMatchObject({ total: 0, max: 0, outside: 0 });
|
||||||
|
});
|
||||||
|
it('rejects absent or inconsistent distributions', () => {
|
||||||
|
expect(cytologyDistribution(undefined)).toBeUndefined();
|
||||||
|
expect(cytologyDistribution(report(3, { NILM: 2 }))).toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import { Reading } from './measures';
|
||||||
|
|
||||||
|
const CATEGORIES = [
|
||||||
|
['NILM', 'Normal', '#408651'],
|
||||||
|
['ASC-US', 'ASC-US', '#2778B8'],
|
||||||
|
['LSIL', 'LIEBG', '#B19525'],
|
||||||
|
['ASC-H', 'ASC-H', '#7955B1'],
|
||||||
|
['HSIL', 'LIEAG', '#CE4778'],
|
||||||
|
['CIS', 'Carcinoma in situ', '#AA394D'],
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
/** EU7 selects one sample per patient. Unknown categories stay outside the denominator. */
|
||||||
|
export function cytologyDistribution(reading: Reading | undefined) {
|
||||||
|
return distribution(reading, CATEGORIES);
|
||||||
|
}
|
||||||
|
|
||||||
|
const HPV = [
|
||||||
|
['negative', 'Negativo', '#42a77e'],
|
||||||
|
['positive_16', 'Positivo 16 exclusivamente', '#df8640'],
|
||||||
|
['positive_18', 'Positivo 18 exclusivamente', '#c29c42'],
|
||||||
|
['positive_16_18', 'Positivo 16 y 18', '#c24269'],
|
||||||
|
['positive_other', 'Positivo sin detección de 16/18', '#a8c243'],
|
||||||
|
['positive_incomplete', 'Positivo con genotipificación incompleta', '#9c42c2'],
|
||||||
|
['inconsistent', 'No clasificable o inconsistente', '#687786'],
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
const BIOPSY = [
|
||||||
|
['normal', 'Normal', '#408651'],
|
||||||
|
['LSIL', 'LIEBG (CIN 1)', '#B19525'],
|
||||||
|
['HSIL', 'LIEAG (CIN 2 y 3)', '#CE4778'],
|
||||||
|
['CIS', 'Carcinoma in situ', '#AA394D'],
|
||||||
|
['carcinoma', 'Carcinoma invasor', '#8D4C79'],
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export function hpvDistribution(reading: Reading | undefined) {
|
||||||
|
const result = distribution(reading, HPV);
|
||||||
|
return result && { ...result, total: result.total + result.outside };
|
||||||
|
}
|
||||||
|
export const biopsyDistribution = (reading: Reading | undefined) => distribution(reading, BIOPSY);
|
||||||
|
|
||||||
|
function distribution(reading: Reading | undefined, categories: readonly (readonly [string, string, string])[]) {
|
||||||
|
const cells = reading?.strata['category'];
|
||||||
|
const population = reading?.populations['initial-population'];
|
||||||
|
if (!cells || population === undefined) return undefined;
|
||||||
|
const counts = Object.values(cells).map((cell) => cell['initial-population']);
|
||||||
|
if (counts.some((n) => n === undefined || !Number.isInteger(n) || n < 0) ||
|
||||||
|
counts.reduce((a, b) => a + b, 0) !== population) return undefined;
|
||||||
|
const rows = categories.map(([code, label, color]) => ({
|
||||||
|
label, color, count: cells[code]?.['initial-population'] ?? 0,
|
||||||
|
}));
|
||||||
|
const total = rows.reduce((sum, row) => sum + row.count, 0);
|
||||||
|
const max = Math.max(0, ...rows.map((row) => row.count));
|
||||||
|
return { rows, total, outside: population - total, max,
|
||||||
|
noData: cells['no_data']?.['initial-population'] ?? 0 };
|
||||||
|
}
|
||||||
@@ -1,417 +0,0 @@
|
|||||||
import type { Figure } from '../plot';
|
|
||||||
import type { Reading } from './measures';
|
|
||||||
import type { Catalog, Category } from './pages';
|
|
||||||
|
|
||||||
const OLIVE = '#A8C243';
|
|
||||||
const ROSE = '#C24269';
|
|
||||||
|
|
||||||
const count = (n: number) => n.toLocaleString('es-MX');
|
|
||||||
const percent = (n: number) => (Math.round(n * 10) / 10).toLocaleString('es-MX');
|
|
||||||
function rgba(hex: string, alpha: number): string {
|
|
||||||
const v = parseInt(hex.slice(1), 16);
|
|
||||||
return `rgba(${v >> 16},${(v >> 8) & 255},${v & 255},${alpha})`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The screening route: each step's median days from the sample, with Q1–Q3. */
|
|
||||||
export function routeFigure(steps: { label: string; r: Reading | undefined }[]): Figure {
|
|
||||||
const shown = steps.filter((s) => s.r?.score !== undefined);
|
|
||||||
return {
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
type: 'bar',
|
|
||||||
orientation: 'h',
|
|
||||||
y: shown.map(
|
|
||||||
(s) => `${s.label}<br>n = ${count(s.r!.populations['measure-observation'] ?? 0)}`,
|
|
||||||
),
|
|
||||||
x: shown.map((s) => s.r!.score!),
|
|
||||||
marker: { color: OLIVE },
|
|
||||||
error_x: {
|
|
||||||
type: 'data',
|
|
||||||
symmetric: false,
|
|
||||||
thickness: 1.5,
|
|
||||||
width: 6,
|
|
||||||
array: shown.map((s) => (s.r!.high ?? s.r!.score!) - s.r!.score!),
|
|
||||||
arrayminus: shown.map((s) => s.r!.score! - (s.r!.low ?? s.r!.score!)),
|
|
||||||
},
|
|
||||||
hovertemplate: '%{y}<br>mediana %{x} días<extra></extra>',
|
|
||||||
} as Partial<Plotly.Data>,
|
|
||||||
],
|
|
||||||
layout: {
|
|
||||||
showlegend: false,
|
|
||||||
xaxis: { title: { text: 'Días' }, rangemode: 'tozero', zeroline: false },
|
|
||||||
yaxis: { autorange: 'reversed', type: 'category', automargin: true },
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A category's count in the report (the composition's `category` stratum). */
|
|
||||||
function counted(r: Reading, code: string): number {
|
|
||||||
return r.strata['category']?.[code]?.['initial-population'] ?? 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Groups inside, their categories outside, the total in the centre. */
|
|
||||||
export function nestedDonut(r: Reading, catalog: Catalog, center: string): Figure {
|
|
||||||
const values = catalog.categories.map((c) => counted(r, c.code));
|
|
||||||
const total = values.reduce((a, b) => a + b, 0);
|
|
||||||
const groups = catalog.groups.map((g) =>
|
|
||||||
catalog.categories.reduce((n, c, i) => n + (c.group === g.id ? values[i] : 0), 0),
|
|
||||||
);
|
|
||||||
const faded = new Set(catalog.faded ?? []);
|
|
||||||
const share = (n: number) => (total ? `${percent((100 * n) / total)} %` : '');
|
|
||||||
const common = {
|
|
||||||
type: 'pie',
|
|
||||||
sort: false,
|
|
||||||
direction: 'clockwise',
|
|
||||||
rotation: 0,
|
|
||||||
showlegend: false,
|
|
||||||
textinfo: 'text',
|
|
||||||
textposition: 'inside',
|
|
||||||
insidetextorientation: 'horizontal',
|
|
||||||
};
|
|
||||||
return {
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
...common,
|
|
||||||
name: 'centro',
|
|
||||||
values: [1],
|
|
||||||
labels: ['centro'],
|
|
||||||
domain: { x: [0.32, 0.68], y: [0.32, 0.68] },
|
|
||||||
text: [`<b>${count(total)}</b><br>${center}`],
|
|
||||||
marker: { colors: ['#FFFFFF'] },
|
|
||||||
hoverinfo: 'skip',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
...common,
|
|
||||||
name: 'grupos',
|
|
||||||
values: groups,
|
|
||||||
labels: catalog.groups.map((g) => g.label),
|
|
||||||
hole: 0.62,
|
|
||||||
domain: { x: [0.16, 0.84], y: [0.16, 0.84] },
|
|
||||||
text: groups.map((n, i) =>
|
|
||||||
total && n / total >= 0.05 ? `${catalog.groups[i].label}<br>${share(n)}` : '',
|
|
||||||
),
|
|
||||||
marker: {
|
|
||||||
colors: catalog.groups.map((g) =>
|
|
||||||
rgba(
|
|
||||||
g.color,
|
|
||||||
catalog.categories.some((c) => c.group === g.id && !faded.has(c.code)) ? 1 : 0.3,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
line: { color: '#FFFFFF', width: 2 },
|
|
||||||
},
|
|
||||||
hovertemplate: '%{label}<br>%{value} (%{percent})<extra></extra>',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
...common,
|
|
||||||
name: 'categorias',
|
|
||||||
values,
|
|
||||||
labels: catalog.categories.map((c) => c.label),
|
|
||||||
hole: 0.74,
|
|
||||||
domain: { x: [0, 1], y: [0, 1] },
|
|
||||||
text: values.map((n, i) => (total && n / total >= 0.05 ? catalog.categories[i].label : '')),
|
|
||||||
marker: {
|
|
||||||
colors: catalog.categories.map((c) => rgba(c.color, faded.has(c.code) ? 0.3 : 1)),
|
|
||||||
line: { color: '#FFFFFF', width: 2 },
|
|
||||||
},
|
|
||||||
hovertemplate: '%{label}<br>%{value} (%{percent})<extra></extra>',
|
|
||||||
},
|
|
||||||
] as Partial<Plotly.Data>[],
|
|
||||||
layout: { margin: { t: 10, l: 10, r: 10, b: 10 } },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Each clinical scenario's results as shares of its patients, one stacked bar each. */
|
|
||||||
export function scenarioBars(
|
|
||||||
r: Reading,
|
|
||||||
catalog: Catalog,
|
|
||||||
stratum: string,
|
|
||||||
label: (code: string) => string,
|
|
||||||
): Figure {
|
|
||||||
const cells = r.strata[`${stratum}-category`] ?? {};
|
|
||||||
const scenarios = [...new Set(Object.keys(cells).map((k) => k.split('|')[0]))].sort((a, b) =>
|
|
||||||
label(a).localeCompare(label(b), 'es'),
|
|
||||||
);
|
|
||||||
const n = (s: string, c: string) => cells[`${s}|${c}`]?.['initial-population'] ?? 0;
|
|
||||||
const totals = scenarios.map((s) => catalog.categories.reduce((t, c) => t + n(s, c.code), 0));
|
|
||||||
const y = scenarios.map(label);
|
|
||||||
return {
|
|
||||||
data: catalog.categories.map((c) => ({
|
|
||||||
type: 'bar',
|
|
||||||
orientation: 'h',
|
|
||||||
name: c.label,
|
|
||||||
y,
|
|
||||||
x: scenarios.map((s, i) => (totals[i] ? (100 * n(s, c.code)) / totals[i] : 0)),
|
|
||||||
customdata: scenarios.map((s) => n(s, c.code)),
|
|
||||||
marker: { color: c.color },
|
|
||||||
hovertemplate: `${c.label}<br>%{y}: %{customdata} (%{x:.1f} %)<extra></extra>`,
|
|
||||||
})) as Partial<Plotly.Data>[],
|
|
||||||
layout: {
|
|
||||||
barmode: 'stack',
|
|
||||||
xaxis: {
|
|
||||||
title: { text: '% de pacientes del escenario con resultado' },
|
|
||||||
ticksuffix: ' %',
|
|
||||||
range: [0, 100],
|
|
||||||
},
|
|
||||||
yaxis: {
|
|
||||||
type: 'category',
|
|
||||||
autorange: 'reversed',
|
|
||||||
categoryorder: 'array',
|
|
||||||
categoryarray: y,
|
|
||||||
automargin: true,
|
|
||||||
},
|
|
||||||
legend: { orientation: 'h', y: -0.25 },
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Wilson score interval at 95 %, in percent. */
|
|
||||||
export function wilson(k: number, n: number): [number, number] {
|
|
||||||
const z = 1.959963984540054;
|
|
||||||
const p = k / n;
|
|
||||||
const d = 1 + (z * z) / n;
|
|
||||||
const c = (p + (z * z) / (2 * n)) / d;
|
|
||||||
const h = (z * Math.sqrt((p * (1 - p)) / n + (z * z) / (4 * n * n))) / d;
|
|
||||||
return [100 * (c - h), 100 * (c + h)];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Per cytology result: of the women with a biopsy, the share whose biopsy is a positive,
|
|
||||||
* with its 95 % interval; a result nobody had a biopsy for is named, not drawn. */
|
|
||||||
export function rateDots(
|
|
||||||
r: Reading,
|
|
||||||
spec: { stratum: string; rows: Category[]; positive: string[]; axis: string; colored?: boolean },
|
|
||||||
): Figure {
|
|
||||||
const cells = r.strata[`${spec.stratum}-category`] ?? {};
|
|
||||||
const rows = spec.rows.map((row) => {
|
|
||||||
const of = Object.entries(cells).filter(([k]) => k.split('|')[0] === row.code);
|
|
||||||
const biopsied = of.filter(([k]) => !['no_biopsy', 'no_data'].includes(k.split('|')[1]));
|
|
||||||
const den = biopsied.reduce((t, [, c]) => t + (c['initial-population'] ?? 0), 0);
|
|
||||||
const k = biopsied
|
|
||||||
.filter(([key]) => spec.positive.includes(key.split('|')[1]))
|
|
||||||
.reduce((t, [, c]) => t + (c['initial-population'] ?? 0), 0);
|
|
||||||
const rate = den ? (100 * k) / den : null;
|
|
||||||
const [low, high] = den ? wilson(k, den) : [null, null];
|
|
||||||
return { row, k, den, rate, low, high };
|
|
||||||
});
|
|
||||||
const y = rows.map((x) => x.row.label);
|
|
||||||
return {
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
type: 'scatter',
|
|
||||||
mode: 'markers',
|
|
||||||
name: 'tasas',
|
|
||||||
y,
|
|
||||||
x: rows.map((x) => x.rate),
|
|
||||||
marker: { size: 12, color: spec.colored ? rows.map((x) => x.row.color) : ROSE },
|
|
||||||
cliponaxis: false,
|
|
||||||
error_x: {
|
|
||||||
type: 'data',
|
|
||||||
symmetric: false,
|
|
||||||
color: ROSE,
|
|
||||||
thickness: 2,
|
|
||||||
width: 6,
|
|
||||||
array: rows.map((x) => (x.rate === null ? 0 : x.high! - x.rate)),
|
|
||||||
arrayminus: rows.map((x) => (x.rate === null ? 0 : x.rate - x.low!)),
|
|
||||||
},
|
|
||||||
hovertemplate: '%{y}: %{x:.1f} %<extra></extra>',
|
|
||||||
} as Partial<Plotly.Data>,
|
|
||||||
],
|
|
||||||
layout: {
|
|
||||||
showlegend: false,
|
|
||||||
margin: { t: 24, r: 110, b: 56, l: 56 },
|
|
||||||
yaxis: {
|
|
||||||
type: 'category',
|
|
||||||
categoryorder: 'array',
|
|
||||||
categoryarray: [...y].reverse(),
|
|
||||||
automargin: true,
|
|
||||||
},
|
|
||||||
xaxis: { range: [0, 100], ticksuffix: ' %', zeroline: false, title: { text: spec.axis } },
|
|
||||||
annotations: rows.map((x) => ({
|
|
||||||
x: 1,
|
|
||||||
xref: 'paper',
|
|
||||||
xanchor: 'left',
|
|
||||||
xshift: 8,
|
|
||||||
y: x.row.label,
|
|
||||||
yref: 'y',
|
|
||||||
showarrow: false,
|
|
||||||
align: 'left',
|
|
||||||
text: x.den
|
|
||||||
? `<b>${percent(x.rate!)} %</b><br>${x.k}/${x.den}`
|
|
||||||
: spec.colored
|
|
||||||
? 'Sin pacientes'
|
|
||||||
: 'Sin biopsias',
|
|
||||||
})),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const decimal = (n: number) => n.toLocaleString('es-MX', { maximumFractionDigits: 2 });
|
|
||||||
|
|
||||||
/** A card's template filled from its measure's reading in the period: {n} counted, {obs}
|
|
||||||
* measured, {median} {q1} {q3} days, {num} {den} {pct}. */
|
|
||||||
export function fill(template: string, r: Reading): string {
|
|
||||||
const p = r.populations;
|
|
||||||
const values: Record<string, string> = {
|
|
||||||
n: count(p['initial-population'] ?? 0),
|
|
||||||
obs: count(p['measure-observation'] ?? 0),
|
|
||||||
median: r.score === undefined ? '' : decimal(r.score),
|
|
||||||
q1: decimal(r.low ?? r.score ?? 0),
|
|
||||||
q3: decimal(r.high ?? r.score ?? 0),
|
|
||||||
num: count(p['numerator'] ?? 0),
|
|
||||||
den: count(p['denominator'] ?? 0),
|
|
||||||
pct: r.score === undefined ? '' : percent(r.score * 100),
|
|
||||||
};
|
|
||||||
return template.replace(/\{(\w+)\}/g, (_, k) => values[k] ?? '');
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A duration's quartile box in the period. */
|
|
||||||
export function boxFigure(r: Reading, period: string): Figure {
|
|
||||||
const q1 = r.low ?? r.score!;
|
|
||||||
const q3 = r.high ?? r.score!;
|
|
||||||
return {
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
type: 'box',
|
|
||||||
name: 'Total',
|
|
||||||
x: [period],
|
|
||||||
q1: [q1],
|
|
||||||
median: [r.score!],
|
|
||||||
q3: [q3],
|
|
||||||
lowerfence: [q1],
|
|
||||||
upperfence: [q3],
|
|
||||||
marker: { color: '#4269C2' },
|
|
||||||
fillcolor: 'rgba(66,105,194,0.55)',
|
|
||||||
hovertemplate: `Q1 ${decimal(q1)} · mediana ${decimal(r.score!)} · Q3 ${decimal(q3)} días<extra></extra>`,
|
|
||||||
} as Partial<Plotly.Data>,
|
|
||||||
],
|
|
||||||
layout: { showlegend: false, yaxis: { title: { text: 'días' }, rangemode: 'tozero' } },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** One ring: the categories' shares, the total in the centre. */
|
|
||||||
export function shareDonut(r: Reading, catalog: Catalog, center: string): Figure {
|
|
||||||
const values = catalog.categories.map((c) => counted(r, c.code));
|
|
||||||
const total = values.reduce((a, b) => a + b, 0);
|
|
||||||
return {
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
type: 'pie',
|
|
||||||
hole: 0.54,
|
|
||||||
sort: false,
|
|
||||||
direction: 'clockwise',
|
|
||||||
labels: catalog.categories.map((c) => c.label),
|
|
||||||
values,
|
|
||||||
marker: {
|
|
||||||
colors: catalog.categories.map((c) => c.color),
|
|
||||||
line: { color: '#FFFFFF', width: 2 },
|
|
||||||
},
|
|
||||||
// an empty slice says nothing (its label would sit on its neighbours')
|
|
||||||
texttemplate: values.map((v) => (v ? '%{label}<br>%{percent}' : '')),
|
|
||||||
textposition: 'outside',
|
|
||||||
hovertemplate: '%{label}<br>%{value} (%{percent})<extra></extra>',
|
|
||||||
} as Partial<Plotly.Data>,
|
|
||||||
],
|
|
||||||
layout: {
|
|
||||||
showlegend: false,
|
|
||||||
margin: { t: 30, l: 60, r: 60, b: 30 },
|
|
||||||
annotations: [
|
|
||||||
{
|
|
||||||
text: `<b>${count(total)}</b><br>${center}`,
|
|
||||||
showarrow: false,
|
|
||||||
x: 0.5,
|
|
||||||
y: 0.5,
|
|
||||||
xref: 'paper',
|
|
||||||
yref: 'paper',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A category's count per bar, one bar each, in the period. */
|
|
||||||
export function countBars(r: Reading, catalog: Catalog, axis: string, period: string): Figure {
|
|
||||||
const y = catalog.categories.map((c) => c.label);
|
|
||||||
return {
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
type: 'bar',
|
|
||||||
orientation: 'h',
|
|
||||||
name: period,
|
|
||||||
y,
|
|
||||||
x: catalog.categories.map((c) => counted(r, c.code)),
|
|
||||||
marker: { color: catalog.categories.map((c) => c.color) },
|
|
||||||
texttemplate: '%{x}',
|
|
||||||
textposition: 'outside',
|
|
||||||
hovertemplate: '%{y}: %{x}<extra></extra>',
|
|
||||||
} as Partial<Plotly.Data>,
|
|
||||||
],
|
|
||||||
layout: {
|
|
||||||
showlegend: false,
|
|
||||||
xaxis: { title: { text: axis }, rangemode: 'tozero' },
|
|
||||||
yaxis: { type: 'category', autorange: 'reversed', automargin: true },
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const AGE_COLORS = ['#A8C243', '#42C29C', '#9C42C2', '#4269C2'];
|
|
||||||
/** "16-23" as the screens say it: "16 a 23 meses". */
|
|
||||||
export const ageLabel = (band: string) => band.replace(/^(\d+)-(\d+)$/, '$1 a $2 meses');
|
|
||||||
|
|
||||||
function ages(r: Reading): [string, Record<string, number>][] {
|
|
||||||
return Object.entries(r.strata['age_group'] ?? {}).sort(
|
|
||||||
([a], [b]) => parseInt(a, 10) - parseInt(b, 10),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** By age group: the numerator and the rest of the denominator, stacked. */
|
|
||||||
export function ageStack(r: Reading, names: [string, string]): Figure {
|
|
||||||
const rows = ages(r);
|
|
||||||
const x = rows.map(([a]) => ageLabel(a));
|
|
||||||
return {
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
type: 'bar',
|
|
||||||
name: names[0],
|
|
||||||
x,
|
|
||||||
y: rows.map(([, c]) => c['numerator'] ?? 0),
|
|
||||||
marker: { color: AGE_COLORS[0] },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'bar',
|
|
||||||
name: names[1],
|
|
||||||
x,
|
|
||||||
y: rows.map(([, c]) => (c['denominator'] ?? 0) - (c['numerator'] ?? 0)),
|
|
||||||
marker: { color: AGE_COLORS[1] },
|
|
||||||
},
|
|
||||||
] as Partial<Plotly.Data>[],
|
|
||||||
layout: {
|
|
||||||
barmode: 'stack',
|
|
||||||
xaxis: { title: { text: 'Grupo de edad' }, type: 'category' },
|
|
||||||
yaxis: { title: { text: 'Pacientes' }, rangemode: 'tozero' },
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** By age group: the numerator's share of the denominator, one bar each. */
|
|
||||||
export function ageShare(r: Reading, axis: string): Figure {
|
|
||||||
const rows = ages(r);
|
|
||||||
return {
|
|
||||||
data: [
|
|
||||||
{
|
|
||||||
type: 'bar',
|
|
||||||
x: rows.map(([a]) => ageLabel(a)),
|
|
||||||
y: rows.map(([, c]) =>
|
|
||||||
c['denominator'] ? (100 * (c['numerator'] ?? 0)) / c['denominator'] : 0,
|
|
||||||
),
|
|
||||||
marker: { color: rows.map((_, i) => AGE_COLORS[i % AGE_COLORS.length]) },
|
|
||||||
texttemplate: '%{y:.1f} %',
|
|
||||||
textposition: 'outside',
|
|
||||||
hovertemplate: '%{x}: %{y:.1f} %<extra></extra>',
|
|
||||||
} as Partial<Plotly.Data>,
|
|
||||||
],
|
|
||||||
layout: {
|
|
||||||
showlegend: false,
|
|
||||||
xaxis: { title: { text: 'Grupo de edad' }, type: 'category' },
|
|
||||||
yaxis: { title: { text: axis }, range: [0, 100], ticksuffix: ' %' },
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,32 @@
|
|||||||
import type { RiskAssessment } from 'fhir/r4';
|
import '@angular/compiler';
|
||||||
import { ageGroup, currentRisk, windowStart } from './follow-up';
|
import { describe, expect, it, vi } from 'vitest';
|
||||||
|
vi.mock('../plot', () => ({ PALETTE: [] }));
|
||||||
|
import type { Patient, RiskAssessment } from 'fhir/r4';
|
||||||
|
import { ageGroup, currentRisk, exactAge, patientLabel, patientName, rows, windowStart } from './follow-up';
|
||||||
import { periods } from './measures';
|
import { periods } from './measures';
|
||||||
|
|
||||||
describe('follow-up list', () => {
|
describe('follow-up list', () => {
|
||||||
|
it('uses synthetic FHIR names consistently and keeps the patient id as fallback', () => {
|
||||||
|
const patient: Patient = { resourceType: 'Patient', id: 'abcdef123456', name: [{ text: ' Ana Ejemplo ' }] };
|
||||||
|
const page = { resourceType: 'Bundle' as const, type: 'searchset' as const, entry: [{ resource: patient, search: { mode: 'match' as const } }] };
|
||||||
|
expect(rows(page, '2026-01-01', '2026-11-27', 5)[0].name).toBe('Ana Ejemplo');
|
||||||
|
expect(patientLabel(patient)).toBe('Ana Ejemplo');
|
||||||
|
expect(patientName({ ...patient, name: [{ given: ['Ana', 'María'], family: 'Ejemplo' }] })).toBe('Ana María Ejemplo');
|
||||||
|
expect(patientLabel({ ...patient, name: [{ text: ' ' }] })).toBe('abcdef1234');
|
||||||
|
});
|
||||||
|
it('calculates completed years only from valid full dates', () => {
|
||||||
|
expect(exactAge('1980-11-23', '2026-11-22')).toBe(45);
|
||||||
|
expect(exactAge('1980-11-23', '2026-11-23')).toBe(46);
|
||||||
|
expect(exactAge('2000-02-29', '2025-02-28')).toBe(24);
|
||||||
|
expect(exactAge('2000-02', '2026-01-01')).toBeUndefined();
|
||||||
|
expect(exactAge('2001-02-29', '2026-01-01')).toBeUndefined();
|
||||||
|
expect(exactAge('2027-01-01', '2026-01-01')).toBeUndefined();
|
||||||
|
});
|
||||||
|
it('keeps a missing prediction separate from zero', () => {
|
||||||
|
const risk = (p?: number): RiskAssessment => ({resourceType:'RiskAssessment', status:'final', subject:{}, occurrenceDateTime:'2026-01-01', method:{coding:[{code:'cacu.cin2_pim'}]}, prediction:[{probabilityDecimal:p,whenRange:{high:{value:5}}}]});
|
||||||
|
expect(currentRisk([risk()], 'cin2', 5)).toBeUndefined();
|
||||||
|
expect(currentRisk([risk(0)], 'cin2', 5)).toBe(0);
|
||||||
|
});
|
||||||
it('starts the window the day after the same day months before (core.follow_up)', () => {
|
it('starts the window the day after the same day months before (core.follow_up)', () => {
|
||||||
expect(windowStart('2026-11-22', 3)).toBe('2026-08-23');
|
expect(windowStart('2026-11-22', 3)).toBe('2026-08-23');
|
||||||
expect(windowStart('2026-05-31', 3)).toBe('2026-03-01'); // 2026-02-28, plus one
|
expect(windowStart('2026-05-31', 3)).toBe('2026-03-01'); // 2026-02-28, plus one
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { Bundle, DiagnosticReport, Observation, Patient, RiskAssessment } from 'fhir/r4';
|
import type { Bundle, DiagnosticReport, Observation, Patient, RiskAssessment } from 'fhir/r4';
|
||||||
import { code, ext, resources } from '../fhir';
|
import { code, ext, resources } from '../fhir';
|
||||||
|
import { routeFacts, StageFacts } from '../paciente/stages';
|
||||||
|
|
||||||
/** One row of the follow-up list: what the list shows of a patient at the cut-off. */
|
/** One row of the follow-up list: what the list shows of a patient at the cut-off. */
|
||||||
export interface Row {
|
export interface Row {
|
||||||
@@ -8,7 +9,9 @@ export interface Row {
|
|||||||
curp?: string;
|
curp?: string;
|
||||||
status: string;
|
status: string;
|
||||||
ageGroup: string;
|
ageGroup: string;
|
||||||
cytology?: { date: string; result?: string; adequacy?: string };
|
age?: number;
|
||||||
|
stageFacts: StageFacts;
|
||||||
|
cytology?: { date: string; reportDate?: string; result?: string; adequacy?: string };
|
||||||
hpv?: { date: string; positive: boolean; types1618?: boolean };
|
hpv?: { date: string; positive: boolean; types1618?: boolean };
|
||||||
daysToDiagnosis?: number;
|
daysToDiagnosis?: number;
|
||||||
biopsy?: { date: string; histology?: string };
|
biopsy?: { date: string; histology?: string };
|
||||||
@@ -17,6 +20,36 @@ export interface Row {
|
|||||||
|
|
||||||
export const CURP = 'https://isssteleon.org/fhir/sid/curp';
|
export const CURP = 'https://isssteleon.org/fhir/sid/curp';
|
||||||
|
|
||||||
|
/** Prefer the supplied FHIR display text, then a structured name, then the next name. */
|
||||||
|
export function patientName(patient: Patient | undefined): string | undefined {
|
||||||
|
for (const name of patient?.name ?? []) {
|
||||||
|
const text = name.text?.trim();
|
||||||
|
if (text) return text;
|
||||||
|
const parts = [...(name.given ?? []), name.family ?? ''].map(part => part.trim()).filter(Boolean);
|
||||||
|
if (parts.length) return parts.join(' ');
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function patientLabel(patient: Patient | undefined): string {
|
||||||
|
return patientName(patient) ?? patient?.id?.slice(0, 10) ?? 'No disponible';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Completed years on a full, valid calendar date; partial dates are unknown. */
|
||||||
|
export function exactAge(birth: string | undefined, cutoff: string | undefined): number | undefined {
|
||||||
|
const parse = (text?: string): [number, number, number] | undefined => {
|
||||||
|
if (!text || !/^\d{4}-\d{2}-\d{2}$/.test(text)) return undefined;
|
||||||
|
const [y, m, d] = text.split('-').map(Number);
|
||||||
|
if (y < 1 || m < 1 || m > 12 || d < 1) return undefined;
|
||||||
|
const leap = y % 4 === 0 && (y % 100 !== 0 || y % 400 === 0);
|
||||||
|
if (d > [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][m - 1]) return undefined;
|
||||||
|
return [y, m, d];
|
||||||
|
};
|
||||||
|
const b = parse(birth), c = parse(cutoff);
|
||||||
|
if (!b || !c || birth! > cutoff!) return undefined;
|
||||||
|
return c[0] - b[0] - (c[1] < b[1] || (c[1] === b[1] && c[2] < b[2]) ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
const AGE_GROUPS: [number, number][] = [
|
const AGE_GROUPS: [number, number][] = [
|
||||||
[25, 34],
|
[25, 34],
|
||||||
[35, 44],
|
[35, 44],
|
||||||
@@ -49,7 +82,7 @@ export function currentRisk(
|
|||||||
.filter((r) => code(r.method)?.startsWith(`cacu.${outcome}`))
|
.filter((r) => code(r.method)?.startsWith(`cacu.${outcome}`))
|
||||||
.flatMap((r) =>
|
.flatMap((r) =>
|
||||||
(r.prediction ?? [])
|
(r.prediction ?? [])
|
||||||
.filter((p) => p.whenRange?.high?.value === horizon)
|
.filter((p) => p.whenRange?.high?.value === horizon && p.probabilityDecimal !== undefined)
|
||||||
.map((p) => ({ r, p })),
|
.map((p) => ({ r, p })),
|
||||||
);
|
);
|
||||||
if (!mine.length) return undefined;
|
if (!mine.length) return undefined;
|
||||||
@@ -60,7 +93,7 @@ export function currentRisk(
|
|||||||
return Math.max(
|
return Math.max(
|
||||||
...mine
|
...mine
|
||||||
.filter((x) => x.r.occurrenceDateTime === latest)
|
.filter((x) => x.r.occurrenceDateTime === latest)
|
||||||
.map((x) => x.p.probabilityDecimal ?? 0),
|
.map((x) => x.p.probabilityDecimal!),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,12 +132,15 @@ export function rows(page: Bundle, start: string, cutoff: string, horizon: numbe
|
|||||||
const theirs = risks.filter((r) => r.subject?.reference === `Patient/${patient.id}`);
|
const theirs = risks.filter((r) => r.subject?.reference === `Patient/${patient.id}`);
|
||||||
return {
|
return {
|
||||||
patient,
|
patient,
|
||||||
name: patient.name?.[0]?.text,
|
name: patientName(patient),
|
||||||
curp: patient.identifier?.find((i) => i.system === CURP)?.value,
|
curp: patient.identifier?.find((i) => i.system === CURP)?.value,
|
||||||
status: ext(patient, 'follow-up-status')?.valueCoding?.code ?? '',
|
status: ext(patient, 'follow-up-status')?.valueCoding?.code ?? '',
|
||||||
ageGroup: ageGroup(patient.birthDate, cutoff),
|
ageGroup: ageGroup(patient.birthDate, cutoff),
|
||||||
|
age: exactAge(patient.birthDate, cutoff),
|
||||||
|
stageFacts: routeFacts(last),
|
||||||
cytology: last && {
|
cytology: last && {
|
||||||
date: last.effectiveDateTime!,
|
date: last.effectiveDateTime!,
|
||||||
|
reportDate: ext(last, 'report-date')?.valueDate,
|
||||||
result: code(lastResults.get('cervical_cytology.result')?.valueCodeableConcept),
|
result: code(lastResults.get('cervical_cytology.result')?.valueCodeableConcept),
|
||||||
adequacy: code(lastResults.get('cervical_cytology.adequacy')?.valueCodeableConcept),
|
adequacy: code(lastResults.get('cervical_cytology.adequacy')?.valueCodeableConcept),
|
||||||
},
|
},
|
||||||
@@ -186,7 +222,7 @@ export function camaRows(page: Bundle, cutoff: string): CamaRow[] {
|
|||||||
.at(-1);
|
.at(-1);
|
||||||
return {
|
return {
|
||||||
patient,
|
patient,
|
||||||
name: patient.name?.[0]?.text,
|
name: patientName(patient),
|
||||||
curp: patient.identifier?.find((i) => i.system === CURP)?.value,
|
curp: patient.identifier?.find((i) => i.system === CURP)?.value,
|
||||||
status: ext(patient, 'follow-up-status')?.valueCoding?.code ?? '',
|
status: ext(patient, 'follow-up-status')?.valueCoding?.code ?? '',
|
||||||
priority: ext(patient, 'follow-up-priority')?.valueCoding?.code ?? '',
|
priority: ext(patient, 'follow-up-priority')?.valueCoding?.code ?? '',
|
||||||
|
|||||||
@@ -6,37 +6,35 @@ import { Fhir, resources } from '../fhir';
|
|||||||
import { TabDefiniciones } from './tab-definiciones';
|
import { TabDefiniciones } from './tab-definiciones';
|
||||||
import { TabIndicadores } from './tab-indicadores';
|
import { TabIndicadores } from './tab-indicadores';
|
||||||
import { TabRiesgos } from './tab-riesgos';
|
import { TabRiesgos } from './tab-riesgos';
|
||||||
import { TabRiesgosTea } from './tab-riesgos-tea';
|
|
||||||
import { TabSeguimiento } from './tab-seguimiento';
|
import { TabSeguimiento } from './tab-seguimiento';
|
||||||
import { TabTrazabilidad } from './tab-trazabilidad';
|
import { TabTrazabilidad } from './tab-trazabilidad';
|
||||||
import { Loading } from '../loading';
|
|
||||||
|
|
||||||
/** A domain's indicator page: four tabs over its FHIR measures and patients. */
|
/** A domain's indicator page: four tabs over its FHIR measures and patients. */
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-indicadores',
|
selector: 'app-indicadores',
|
||||||
imports: [
|
imports: [
|
||||||
Loading,
|
|
||||||
MatTabsModule,
|
MatTabsModule,
|
||||||
TabIndicadores,
|
TabIndicadores,
|
||||||
TabTrazabilidad,
|
TabTrazabilidad,
|
||||||
TabRiesgos,
|
TabRiesgos,
|
||||||
TabRiesgosTea,
|
|
||||||
TabSeguimiento,
|
TabSeguimiento,
|
||||||
TabDefiniciones,
|
TabDefiniciones,
|
||||||
],
|
],
|
||||||
template: `
|
template: `
|
||||||
<section class="page">
|
<section class="page">
|
||||||
<h1>{{ title() }}</h1>
|
<h1>{{ title() }}</h1>
|
||||||
<p class="subtitle">Explora los indicadores de {{ title().toLowerCase() }}.</p>
|
<p class="subtitle">
|
||||||
|
Indicadores de calidad y oportunidad del tamizaje, a partir de los datos cargados.
|
||||||
|
</p>
|
||||||
@if (measures.isLoading()) {
|
@if (measures.isLoading()) {
|
||||||
<app-loading what="los indicadores" />
|
<p class="muted">Cargando indicadores…</p>
|
||||||
} @else if (measures.error()) {
|
} @else if (measures.error()) {
|
||||||
<p class="muted" role="alert">No se pudieron leer los indicadores.</p>
|
<p class="muted" role="alert">No se pudieron leer los indicadores.</p>
|
||||||
} @else if (!measures.value()?.length) {
|
} @else if (!measures.value()?.length) {
|
||||||
<p class="muted empty">Este dominio todavía no tiene indicadores publicados.</p>
|
<p class="muted empty">Este dominio todavía no tiene indicadores publicados.</p>
|
||||||
} @else {
|
} @else {
|
||||||
<mat-tab-group mat-stretch-tabs="false" mat-align-tabs="center" animationDuration="0ms">
|
<mat-tab-group mat-stretch-tabs="false" mat-align-tabs="center" animationDuration="0ms">
|
||||||
<mat-tab [label]="domain() === 'tea' ? 'Resumen' : 'Indicadores'">
|
<mat-tab label="Indicadores">
|
||||||
<app-tab-indicadores [domain]="domain()" [measures]="measures.value()!" />
|
<app-tab-indicadores [domain]="domain()" [measures]="measures.value()!" />
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
<mat-tab label="Trazabilidad">
|
<mat-tab label="Trazabilidad">
|
||||||
@@ -50,14 +48,8 @@ import { Loading } from '../loading';
|
|||||||
<app-tab-riesgos [domain]="domain()" />
|
<app-tab-riesgos [domain]="domain()" />
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</mat-tab>
|
</mat-tab>
|
||||||
} @else if (domain() === 'tea') {
|
|
||||||
<mat-tab label="Análisis de Riesgo">
|
|
||||||
<ng-template matTabContent>
|
|
||||||
<app-tab-riesgos-tea [domain]="domain()" />
|
|
||||||
</ng-template>
|
|
||||||
</mat-tab>
|
|
||||||
} @else if (domain() === 'cama') {
|
} @else if (domain() === 'cama') {
|
||||||
<mat-tab label="Análisis de riesgos">
|
<mat-tab label="Seguimiento">
|
||||||
<ng-template matTabContent>
|
<ng-template matTabContent>
|
||||||
<app-tab-seguimiento [domain]="domain()" />
|
<app-tab-seguimiento [domain]="domain()" />
|
||||||
</ng-template>
|
</ng-template>
|
||||||
@@ -76,27 +68,11 @@ import { Loading } from '../loading';
|
|||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
/* As the old page: the domain's name and a line under it, then a white tab bar under
|
|
||||||
an olive rule. */
|
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 28px;
|
text-align: center;
|
||||||
font-weight: 500;
|
|
||||||
margin: 16px 0 8px;
|
|
||||||
}
|
}
|
||||||
.subtitle {
|
.subtitle {
|
||||||
font-size: 16px;
|
text-align: center;
|
||||||
margin: 0 0 24px;
|
|
||||||
}
|
|
||||||
::ng-deep .mat-mdc-tab-header {
|
|
||||||
background: var(--color-surface);
|
|
||||||
border-top: 2px solid var(--color-primary);
|
|
||||||
}
|
|
||||||
::ng-deep .mat-mdc-tab .mdc-tab__text-label {
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 400;
|
|
||||||
}
|
|
||||||
::ng-deep .mat-mdc-tab.mdc-tab--active .mdc-tab__text-label {
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
}
|
||||||
.empty {
|
.empty {
|
||||||
padding: 48px 0;
|
padding: 48px 0;
|
||||||
|
|||||||
@@ -44,12 +44,14 @@ export function periodTypes(measure: Measure): PeriodType[] {
|
|||||||
|
|
||||||
/** What one report says: its counts, its score and interval, and its strata. */
|
/** What one report says: its counts, its score and interval, and its strata. */
|
||||||
export interface Reading {
|
export interface Reading {
|
||||||
|
error?: boolean;
|
||||||
populations: Record<string, number>;
|
populations: Record<string, number>;
|
||||||
score?: number;
|
score?: number;
|
||||||
low?: number;
|
low?: number;
|
||||||
high?: number;
|
high?: number;
|
||||||
unit?: string;
|
unit?: string;
|
||||||
strata: Record<string, Record<string, Record<string, number>>>;
|
strata: Record<string, Record<string, Record<string, number>>>;
|
||||||
|
stratumScores?: Record<string, Record<string, { median: number; low?: number; high?: number }>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function counts(group: {
|
function counts(group: {
|
||||||
@@ -65,17 +67,13 @@ export function reading(report: MeasureReport | undefined): Reading | undefined
|
|||||||
if (!group) return undefined;
|
if (!group) return undefined;
|
||||||
const score = group.measureScore;
|
const score = group.measureScore;
|
||||||
const strata: Reading['strata'] = {};
|
const strata: Reading['strata'] = {};
|
||||||
|
const stratumScores: NonNullable<Reading['stratumScores']> = {};
|
||||||
for (const s of group.stratifier ?? []) {
|
for (const s of group.stratifier ?? []) {
|
||||||
// A crossed stratifier (several codes) is keyed `a-b`, its strata `valueA|valueB`.
|
const name = code(s.code?.[0]) ?? s.code?.[0]?.text ?? '';
|
||||||
const name = (s.code ?? []).map((c) => code(c) ?? c.text ?? '').join('-');
|
|
||||||
strata[name] = Object.fromEntries(
|
strata[name] = Object.fromEntries(
|
||||||
(s.stratum ?? []).map((x) => [
|
(s.stratum ?? []).map((x) => [x.value?.text ?? '', counts(x)]),
|
||||||
x.component?.length
|
|
||||||
? x.component.map((c) => c.value?.text ?? '').join('|')
|
|
||||||
: (x.value?.text ?? ''),
|
|
||||||
counts(x),
|
|
||||||
]),
|
|
||||||
);
|
);
|
||||||
|
stratumScores[name] = Object.fromEntries((s.stratum ?? []).filter(x => x.measureScore?.value !== undefined).map(x => [x.value?.text ?? '', {median: x.measureScore!.value!, low: ext(x.measureScore, 'q1')?.valueDecimal, high: ext(x.measureScore, 'q3')?.valueDecimal}]));
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
populations: counts(group),
|
populations: counts(group),
|
||||||
@@ -84,6 +82,7 @@ export function reading(report: MeasureReport | undefined): Reading | undefined
|
|||||||
high: (ext(score, 'ic-alto') ?? ext(score, 'q3'))?.valueDecimal,
|
high: (ext(score, 'ic-alto') ?? ext(score, 'q3'))?.valueDecimal,
|
||||||
unit: score?.unit,
|
unit: score?.unit,
|
||||||
strata,
|
strata,
|
||||||
|
stratumScores,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,6 +121,13 @@ const LABELS: Record<string, string> = {
|
|||||||
good: 'Bueno',
|
good: 'Bueno',
|
||||||
bad: 'Malo',
|
bad: 'Malo',
|
||||||
not_analyzed: 'Sin analizar',
|
not_analyzed: 'Sin analizar',
|
||||||
|
'ASCUS+': 'Citología ASC-US o mayor',
|
||||||
|
'LSIL+': 'Citología LIEBG o mayor',
|
||||||
|
'HSIL+': 'Citología LIEAG o mayor',
|
||||||
|
'LIEBG+': 'Histología LIEBG o mayor',
|
||||||
|
'LIEAG+': 'Histología LIEAG o mayor',
|
||||||
|
initial: 'Tamizaje inicial',
|
||||||
|
subsequent: 'Tamizaje subsecuente',
|
||||||
...Object.fromEntries(
|
...Object.fromEntries(
|
||||||
['0', '1', '2', '3', '4', '4A', '4B', '4C', '5', '6'].map((c) => [c, `BI-RADS ${c}`]),
|
['0', '1', '2', '3', '4', '4A', '4B', '4C', '5', '6'].map((c) => [c, `BI-RADS ${c}`]),
|
||||||
),
|
),
|
||||||
@@ -134,7 +140,18 @@ export const STRATA: Record<string, string> = {
|
|||||||
follow_up_status: 'Estatus de seguimiento',
|
follow_up_status: 'Estatus de seguimiento',
|
||||||
result: 'Citología de alto grado',
|
result: 'Citología de alto grado',
|
||||||
birads: 'BI-RADS de la mastografía',
|
birads: 'BI-RADS de la mastografía',
|
||||||
|
referral_cytology: 'Citología previa asociada por fechas',
|
||||||
|
histology_level: 'Nivel de histología confirmado',
|
||||||
|
screening_round: 'Tamizaje inicial o subsecuente',
|
||||||
|
result_initial: 'Resultado en tamizaje inicial',
|
||||||
|
result_subsequent: 'Resultado en tamizaje subsecuente',
|
||||||
};
|
};
|
||||||
|
/** Measures whose server title says "referral": the data record procedures, not issued referrals. */
|
||||||
|
export const PPV_NOTES: Record<string, { title: string; note: string }> = {
|
||||||
|
CACU_VPP_COLPOSCOPIA: { title: 'VPP tras colposcopía registrada', note: 'De las pacientes con colposcopía registrada en el periodo (puede inferirse de notas clínicas), las que tienen histología LIEBG o mayor. Se muestra la citología previa más reciente en los 365 días anteriores: es una asociación por fechas, no un vínculo clínico confirmado ni una referencia emitida.' },
|
||||||
|
CACU_VPP_BIOPSIA: { title: 'VPP tras biopsia registrada', note: 'De las pacientes con biopsia reportada en el periodo, las que tienen histología LIEBG o mayor. La citología previa es una asociación por fechas, no un vínculo clínico confirmado ni una referencia emitida. Su denominador difiere del de las solicitudes de biopsia registradas.' },
|
||||||
|
};
|
||||||
|
export const measureTitle = (m: { name?: string; title?: string }) => PPV_NOTES[m.name ?? '']?.title ?? m.title ?? m.name ?? '';
|
||||||
export const name = (value: string) => LABELS[value] ?? value;
|
export const name = (value: string) => LABELS[value] ?? value;
|
||||||
|
|
||||||
export function formatScore(measure: Measure, r: Reading | undefined): string {
|
export function formatScore(measure: Measure, r: Reading | undefined): string {
|
||||||
|
|||||||
@@ -1,430 +0,0 @@
|
|||||||
/** A domain's Indicadores page as the old app showed it (tests/fixtures/reference/<domain>/ui):
|
|
||||||
* the timeliness cards with their own words, then the clinical sections and their figures.
|
|
||||||
* Measures are named by their code (`Measure.name`). */
|
|
||||||
export interface Page {
|
|
||||||
kpis: Kpi[];
|
|
||||||
/** Under the cards, before the clinical indicators (CaMa's timeliness boxes). */
|
|
||||||
opportunity?: Section[];
|
|
||||||
clinical: Section[];
|
|
||||||
/** The measure whose data decides the default period. */
|
|
||||||
anchor: string;
|
|
||||||
}
|
|
||||||
/** A card: its measure (none: not published yet), its title, and its value and note as
|
|
||||||
* templates (figures.fill). */
|
|
||||||
export interface Kpi {
|
|
||||||
measure?: string;
|
|
||||||
title: string;
|
|
||||||
value?: string;
|
|
||||||
note?: string;
|
|
||||||
}
|
|
||||||
export type Section =
|
|
||||||
| { kind: 'route'; title: string; steps: { label: string; measure: string }[] }
|
|
||||||
| { kind: 'figures'; title?: string; figures: FigureSpec[] }
|
|
||||||
| {
|
|
||||||
kind: 'boxes';
|
|
||||||
/** none: the boxes stand alone (TEA) */
|
|
||||||
title?: string;
|
|
||||||
cards: { measure?: string; title: string }[];
|
|
||||||
/** the measure's own title under each card's (CaMa) */
|
|
||||||
subtitles?: boolean;
|
|
||||||
}
|
|
||||||
/** Each figure in its own card, titled, two to a row (TEA). */
|
|
||||||
| { kind: 'grid'; figures: FigureSpec[] }
|
|
||||||
/** TEA's period summary in words, its numbers from the measures. */
|
|
||||||
| { kind: 'tea-summary' }
|
|
||||||
| ({ kind: 'card' } & Kpi);
|
|
||||||
/** Figure titles may carry `{p}`, the applied period. */
|
|
||||||
export type FigureSpec =
|
|
||||||
| {
|
|
||||||
kind: 'donut' | 'share-donut';
|
|
||||||
title: string;
|
|
||||||
measure: string;
|
|
||||||
catalog: Catalog;
|
|
||||||
center: string;
|
|
||||||
}
|
|
||||||
| { kind: 'scenario-bars'; title: string; measure: string; catalog: Catalog; stratum: string }
|
|
||||||
| { kind: 'counts'; title: string; measure: string; catalog: Catalog; axis: string }
|
|
||||||
| {
|
|
||||||
kind: 'age-stack' | 'age-share';
|
|
||||||
title: string;
|
|
||||||
measure: string;
|
|
||||||
/** the numerator's and the rest's names (stack), or the axis (share) */
|
|
||||||
names: [string, string];
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
kind: 'rates';
|
|
||||||
title: string;
|
|
||||||
measure: string;
|
|
||||||
stratum: string;
|
|
||||||
rows: Category[];
|
|
||||||
/** each row in its category's colour (else all rose) */
|
|
||||||
colored?: boolean;
|
|
||||||
/** the categories (of the measure) that count as a positive */
|
|
||||||
positive: string[];
|
|
||||||
axis: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface Category {
|
|
||||||
code: string;
|
|
||||||
label: string;
|
|
||||||
color: string;
|
|
||||||
group: string;
|
|
||||||
}
|
|
||||||
export interface Catalog {
|
|
||||||
groups: { id: string; label: string; color: string }[];
|
|
||||||
categories: Category[];
|
|
||||||
/** categories drawn faded (not the ones the figure is about) */
|
|
||||||
faded?: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
const OLIVE = '#A8C243';
|
|
||||||
const ROSE = '#C24269';
|
|
||||||
|
|
||||||
/** Bethesda results as the old app grouped and coloured them. */
|
|
||||||
const CYTOLOGY: Catalog = {
|
|
||||||
groups: [
|
|
||||||
{ id: 'normal', label: 'Sin anomalía', color: OLIVE },
|
|
||||||
{ id: 'abnormal', label: 'Anormal', color: ROSE },
|
|
||||||
],
|
|
||||||
categories: [
|
|
||||||
{ code: 'NILM', label: 'Normal', color: '#A8C243', group: 'normal' },
|
|
||||||
{ code: 'ASC-US', label: 'ASC-US', color: '#92324F', group: 'abnormal' },
|
|
||||||
{ code: 'LSIL', label: 'LIEBG', color: '#AA3A5C', group: 'abnormal' },
|
|
||||||
{ code: 'ASC-H', label: 'ASC-H', color: '#C24269', group: 'abnormal' },
|
|
||||||
{ code: 'HSIL', label: 'LIEAG', color: '#C54C71', group: 'abnormal' },
|
|
||||||
{ code: 'CIS', label: 'Carcinoma in situ', color: '#C9577A', group: 'abnormal' },
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Biopsy grades: below high grade, and high grade or worse (what confirmation counts). */
|
|
||||||
const BIOPSY: Catalog = {
|
|
||||||
groups: [
|
|
||||||
{ id: 'low', label: 'Menor que LIEAG', color: OLIVE },
|
|
||||||
{ id: 'high', label: 'LIEAG o más', color: ROSE },
|
|
||||||
],
|
|
||||||
categories: [
|
|
||||||
{ code: 'normal', label: 'Normal', color: '#7E9232', group: 'low' },
|
|
||||||
{ code: 'LSIL', label: 'LIEBG (CIN 1)', color: '#B2C958', group: 'low' },
|
|
||||||
{ code: 'HSIL', label: 'LIEAG (CIN 2 y 3)', color: '#92324F', group: 'high' },
|
|
||||||
{ code: 'CIS', label: 'Carcinoma in situ', color: '#C24269', group: 'high' },
|
|
||||||
{ code: 'carcinoma', label: 'Carcinoma invasor', color: '#C9577A', group: 'high' },
|
|
||||||
],
|
|
||||||
faded: ['normal', 'LSIL'],
|
|
||||||
};
|
|
||||||
|
|
||||||
const CACU_DAYS = {
|
|
||||||
value: '{median} días (mediana)',
|
|
||||||
note: '{obs} citologías; primer cuartil: {q1} días; tercer cuartil: {q3} días.',
|
|
||||||
};
|
|
||||||
const CAMA_DAYS = {
|
|
||||||
value: '{median} días (mediana)',
|
|
||||||
note: '{obs} mastografías; Q1 a Q3: {q1} a {q3} días.',
|
|
||||||
};
|
|
||||||
const PENDING = 'Este indicador aún no está publicado por el catálogo institucional.';
|
|
||||||
|
|
||||||
/** BI-RADS 4 to 6 as the old app named and coloured them. */
|
|
||||||
const BIRADS: Catalog = {
|
|
||||||
groups: [],
|
|
||||||
categories: [
|
|
||||||
{ code: '4', label: 'BI-RADS 4 (sin subcategoría)', color: '#C24269', group: '' },
|
|
||||||
{ code: '4A', label: 'BI-RADS 4A', color: '#9C42C2', group: '' },
|
|
||||||
{ code: '4B', label: 'BI-RADS 4B', color: '#5C42C2', group: '' },
|
|
||||||
{ code: '4C', label: 'BI-RADS 4C', color: '#C2429C', group: '' },
|
|
||||||
{ code: '5', label: 'BI-RADS 5', color: '#8E2F62', group: '' },
|
|
||||||
{ code: '6', label: 'BI-RADS 6', color: '#7A3496', group: '' },
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const BREAST_BIOPSY: Catalog = {
|
|
||||||
groups: [
|
|
||||||
{ id: 'benign', label: 'No maligno', color: '#42C29C' },
|
|
||||||
{ id: 'malignant', label: 'Maligno', color: ROSE },
|
|
||||||
],
|
|
||||||
categories: [
|
|
||||||
{ code: 'benign', label: 'Benigno', color: OLIVE, group: 'benign' },
|
|
||||||
{ code: 'in_situ', label: 'Carcinoma in situ', color: '#9C42C2', group: 'malignant' },
|
|
||||||
{ code: 'invasive', label: 'Carcinoma invasor', color: '#5C42C2', group: 'malignant' },
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
export const PAGES: Record<string, Page> = {
|
|
||||||
tea: {
|
|
||||||
anchor: 'M23_PACIENTES_EVALUADOS',
|
|
||||||
kpis: [],
|
|
||||||
opportunity: [
|
|
||||||
{ kind: 'tea-summary' },
|
|
||||||
{
|
|
||||||
kind: 'boxes',
|
|
||||||
cards: [
|
|
||||||
{ measure: 'M26_DIAS_MCHAT_ADOS2', title: 'Días de M-CHAT a ADOS-2' },
|
|
||||||
{ measure: 'M27_DIAS_ADOS2_DIAGNOSTICO', title: 'Días de ADOS-2 a diagnóstico' },
|
|
||||||
{ measure: 'M25_DIAS_MCHAT_DIAGNOSTICO', title: 'Días de M-CHAT a diagnóstico positivo' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
clinical: [
|
|
||||||
{
|
|
||||||
kind: 'grid',
|
|
||||||
figures: [
|
|
||||||
{
|
|
||||||
kind: 'counts',
|
|
||||||
title: 'Pacientes evaluados por resultado diagnóstico',
|
|
||||||
measure: 'M23_PACIENTES_EVALUADOS',
|
|
||||||
axis: 'Conteo (paciente)',
|
|
||||||
catalog: {
|
|
||||||
groups: [],
|
|
||||||
categories: [
|
|
||||||
{ code: 'confirmed', label: 'Diagnóstico confirmado', color: OLIVE, group: '' },
|
|
||||||
{ code: 'in_process', label: 'En proceso', color: '#B8433A', group: '' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: 'age-stack',
|
|
||||||
title: 'Porcentaje de confirmación diagnóstica',
|
|
||||||
measure: 'M24_CONFIRMACION_DIAGNOSTICO',
|
|
||||||
names: ['Diagnóstico confirmado', 'En proceso'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: 'age-share',
|
|
||||||
title: 'Porcentaje de pacientes con diagnóstico de TEA con EEG',
|
|
||||||
measure: 'M21_DIAGNOSTICADOS_CON_EEG',
|
|
||||||
names: ['% de pacientes con EEG', ''],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: 'age-share',
|
|
||||||
title: 'Porcentaje de pacientes con diagnóstico de TEA sin EEG',
|
|
||||||
measure: 'M22_DIAGNOSTICADOS_SIN_EEG',
|
|
||||||
names: ['% de pacientes sin EEG', ''],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: 'counts',
|
|
||||||
title: 'Casos por estatus',
|
|
||||||
measure: 'M28_CASOS_POR_ESTADO',
|
|
||||||
axis: 'Conteo (paciente)',
|
|
||||||
catalog: {
|
|
||||||
groups: [],
|
|
||||||
categories: [
|
|
||||||
{ code: 'mchat_only', label: 'Solo M-CHAT', color: '#B8433A', group: '' },
|
|
||||||
{
|
|
||||||
code: 'psychology',
|
|
||||||
label: 'Hasta evaluación psicológica',
|
|
||||||
color: '#42C29C',
|
|
||||||
group: '',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
code: 'neuropediatrics',
|
|
||||||
label: 'Hasta evaluación neuropediátrica',
|
|
||||||
color: '#7184A2',
|
|
||||||
group: '',
|
|
||||||
},
|
|
||||||
{ code: 'eeg', label: 'Con EEG', color: OLIVE, group: '' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: 'counts',
|
|
||||||
title: 'Calidad del EEG',
|
|
||||||
measure: 'M29_CALIDAD_EEG',
|
|
||||||
axis: 'Conteo (examen)',
|
|
||||||
catalog: {
|
|
||||||
groups: [],
|
|
||||||
categories: [
|
|
||||||
{ code: 'good', label: 'Bueno', color: OLIVE, group: '' },
|
|
||||||
{ code: 'bad', label: 'No aceptable', color: '#B8433A', group: '' },
|
|
||||||
{ code: 'not_analyzed', label: 'Sin analizar', color: '#C9CDD2', group: '' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
cama: {
|
|
||||||
anchor: 'CAMA_BIRADS456_PACIENTE',
|
|
||||||
kpis: [
|
|
||||||
{
|
|
||||||
measure: 'CAMA_BIRADS456_PACIENTE',
|
|
||||||
title: 'Pacientes evaluadas con BI-RADS 4, 5 o 6',
|
|
||||||
value: '{n} pacientes',
|
|
||||||
note: 'Pacientes con mastografía BI-RADS 4, 5 o 6 en el periodo.',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
measure: 'CAMA_TASA_DETECCION_HISTOPATOLOGICA',
|
|
||||||
title: 'Tasa de confirmación histopatológica',
|
|
||||||
value: '{pct} %',
|
|
||||||
note: '{num} de {den} biopsias con riesgo a carcinoma.',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
measure: 'CAMA_EU38A',
|
|
||||||
title: 'Tiempo de toma de mastografía a interpretación radiológica',
|
|
||||||
...CAMA_DAYS,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
measure: 'CAMA_DIAS_RESULTADO_DIAGNOSTICO',
|
|
||||||
title: 'Tiempo de interpretación radiológica a diagnóstico',
|
|
||||||
...CAMA_DAYS,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Tiempo de diagnóstico a tratamiento',
|
|
||||||
value: 'Indicador no disponible',
|
|
||||||
note: PENDING,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
opportunity: [
|
|
||||||
{
|
|
||||||
kind: 'boxes',
|
|
||||||
title: 'Tiempo de tamizaje a diagnóstico',
|
|
||||||
subtitles: true,
|
|
||||||
cards: [
|
|
||||||
{
|
|
||||||
measure: 'CAMA_EU38A',
|
|
||||||
title: 'Tiempo de toma de mastografía a interpretación radiológica',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
measure: 'CAMA_DIAS_RESULTADO_DIAGNOSTICO',
|
|
||||||
title: 'Tiempo de interpretación radiológica a diagnóstico',
|
|
||||||
},
|
|
||||||
{ title: 'Tiempo de interpretación radiológica a resultado de biopsia' },
|
|
||||||
{ title: 'Tiempo de diagnóstico a tratamiento' },
|
|
||||||
{ measure: 'CAMA_DIAS_TOMA_DIAGNOSTICO', title: 'Tiempo de tamizaje a diagnóstico' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
clinical: [
|
|
||||||
{
|
|
||||||
kind: 'figures',
|
|
||||||
figures: [
|
|
||||||
{
|
|
||||||
kind: 'share-donut',
|
|
||||||
title: 'Porcentaje de mastografías con resultado BI-RADS 4, 5 ó 6 en {p}',
|
|
||||||
measure: 'CAMA_BIRADS456_MASTOGRAFIA',
|
|
||||||
catalog: BIRADS,
|
|
||||||
center: 'mastografías',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: 'share-donut',
|
|
||||||
title: 'Porcentaje de pacientes con resultados BI-RADS 4, 5 ó 6 en {p}',
|
|
||||||
measure: 'CAMA_BIRADS456_PACIENTE',
|
|
||||||
catalog: BIRADS,
|
|
||||||
center: 'pacientes',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: 'figures',
|
|
||||||
title: 'Resultado histopatológico por categoría BI-RADS',
|
|
||||||
figures: [
|
|
||||||
{
|
|
||||||
kind: 'rates',
|
|
||||||
title: 'Por categoría BI-RADS, {p}',
|
|
||||||
measure: 'CAMA_HISTOPATOLOGIA_BIRADS',
|
|
||||||
stratum: 'birads',
|
|
||||||
rows: BIRADS.categories,
|
|
||||||
colored: true,
|
|
||||||
positive: ['in_situ', 'invasive'],
|
|
||||||
axis: 'Porcentaje con resultado maligno',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: 'donut',
|
|
||||||
title: 'Resultado de la biopsia, {p}',
|
|
||||||
measure: 'CAMA_HISTOPATOLOGIA_BIRADS',
|
|
||||||
catalog: BREAST_BIOPSY,
|
|
||||||
center: 'con resultado',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: 'card',
|
|
||||||
measure: 'CAMA_CONFIRMACION_BIRADS45',
|
|
||||||
title: 'Tasa de confirmación histopatológica',
|
|
||||||
value: '{pct} %',
|
|
||||||
note: '{num} de {den} mastografías BI-RADS 4 y 5 con reporte de biopsia.',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
cacu: {
|
|
||||||
anchor: 'CACU_EU7',
|
|
||||||
kpis: [
|
|
||||||
{
|
|
||||||
measure: 'CACU_EU7',
|
|
||||||
title: 'Pacientes evaluadas',
|
|
||||||
value: '{n} pacientes',
|
|
||||||
note: 'Pacientes con citología tomada en el periodo.',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
measure: 'CACU_EU_TIEMPO_REPORTE',
|
|
||||||
title: 'Tiempo desde la toma de muestra al resultado',
|
|
||||||
...CACU_DAYS,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
measure: 'CACU_DIAS_TOMA_DIAGNOSTICO',
|
|
||||||
title: 'Tiempo de tamizaje a diagnóstico',
|
|
||||||
...CACU_DAYS,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
measure: 'CACU_DIAS_TOMA_TRATAMIENTO',
|
|
||||||
title: 'Tiempo de tamizaje a tratamiento',
|
|
||||||
...CACU_DAYS,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
measure: 'CACU_DIAS_DIAGNOSTICO_TRATAMIENTO',
|
|
||||||
title: 'Tiempo de diagnóstico a tratamiento',
|
|
||||||
...CACU_DAYS,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
clinical: [
|
|
||||||
{
|
|
||||||
kind: 'route',
|
|
||||||
title: 'Tiempos de la ruta del tamizaje',
|
|
||||||
steps: [
|
|
||||||
{ label: 'Resultado de citología', measure: 'CACU_EU_TIEMPO_REPORTE' },
|
|
||||||
{ label: 'Resultado de colposcopía', measure: 'CACU_DIAS_TOMA_COLPOSCOPIA' },
|
|
||||||
{ label: 'Resultado de biopsia', measure: 'CACU_DIAS_TOMA_BIOPSIA' },
|
|
||||||
{ label: 'Diagnóstico', measure: 'CACU_DIAS_TOMA_DIAGNOSTICO' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: 'figures',
|
|
||||||
title: 'Distribución de resultados citológicos',
|
|
||||||
figures: [
|
|
||||||
{
|
|
||||||
kind: 'donut',
|
|
||||||
title: 'Distribución de resultados, {p}',
|
|
||||||
measure: 'CACU_EU7',
|
|
||||||
catalog: CYTOLOGY,
|
|
||||||
center: 'pacientes',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: 'scenario-bars',
|
|
||||||
title: 'TOTAL por escenario clínico, {p}',
|
|
||||||
measure: 'CACU_EU7',
|
|
||||||
catalog: CYTOLOGY,
|
|
||||||
stratum: 'follow_up_status',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: 'figures',
|
|
||||||
title: 'Tasa de confirmación histopatológica',
|
|
||||||
figures: [
|
|
||||||
{
|
|
||||||
kind: 'rates',
|
|
||||||
title: 'Por resultado de la citología, {p}',
|
|
||||||
measure: 'CACU_CONFIRMACION_CITOLOGIA',
|
|
||||||
stratum: 'result',
|
|
||||||
rows: CYTOLOGY.categories.filter((c) => ['ASC-H', 'HSIL', 'CIS'].includes(c.code)),
|
|
||||||
positive: ['HSIL', 'CIS', 'carcinoma'],
|
|
||||||
axis: 'Verdaderos positivos (valor predictivo positivo)',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
kind: 'donut',
|
|
||||||
title: 'Resultado de la biopsia, {p}',
|
|
||||||
measure: 'CACU_CONFIRMACION_CITOLOGIA',
|
|
||||||
catalog: BIOPSY,
|
|
||||||
center: 'con biopsia',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import { PPV_NOTES, STRATA, measureTitle, name } from './measures';
|
||||||
|
|
||||||
|
describe('referral PPV wording', () => {
|
||||||
|
it('never presents procedures or date associations as confirmed referrals', () => {
|
||||||
|
for (const measure of ['CACU_VPP_COLPOSCOPIA', 'CACU_VPP_BIOPSIA']) {
|
||||||
|
const { title, note } = PPV_NOTES[measure];
|
||||||
|
expect(title).toContain('registrada');
|
||||||
|
expect(title.toLowerCase()).not.toContain('referencia');
|
||||||
|
expect(note).toContain('asociación por fechas');
|
||||||
|
expect(note).toContain('no un vínculo clínico confirmado');
|
||||||
|
expect(measureTitle({ name: measure, title: 'VPP de la referencia' })).toBe(title);
|
||||||
|
}
|
||||||
|
expect(PPV_NOTES['CACU_VPP_COLPOSCOPIA'].note).toContain('inferirse de notas');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('keeps the server title for other measures', () => {
|
||||||
|
expect(measureTitle({ name: 'CACU_EU7', title: 'Pacientes evaluadas' })).toBe('Pacientes evaluadas');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('names the new strata and their values in Spanish', () => {
|
||||||
|
for (const code of ['referral_cytology', 'histology_level', 'screening_round', 'result_initial', 'result_subsequent'])
|
||||||
|
expect(STRATA[code]).toBeTruthy();
|
||||||
|
expect(name('ASCUS+')).toBe('Citología ASC-US o mayor');
|
||||||
|
expect(name('LSIL+')).toBe('Citología LIEBG o mayor');
|
||||||
|
expect(name('HSIL+')).toBe('Citología LIEAG o mayor');
|
||||||
|
expect(name('LIEBG+')).toBe('Histología LIEBG o mayor');
|
||||||
|
expect(name('LIEAG+')).toBe('Histología LIEAG o mayor');
|
||||||
|
expect(name('invasive')).toBe('Carcinoma invasor');
|
||||||
|
expect(name('initial')).toBe('Tamizaje inicial');
|
||||||
|
expect(name('subsequent')).toBe('Tamizaje subsecuente');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<div class="filters card">
|
<div class="filters card">
|
||||||
<h2 class="filters-title">Filtros</h2>
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<span class="label">Intervalo de análisis</span>
|
<span class="label">Intervalo de análisis</span>
|
||||||
<mat-button-toggle-group
|
<mat-button-toggle-group
|
||||||
@@ -15,7 +14,7 @@
|
|||||||
<mat-label>Periodo seleccionado</mat-label>
|
<mat-label>Periodo seleccionado</mat-label>
|
||||||
<mat-select [value]="chosen()" (selectionChange)="chosen.set($event.value)">
|
<mat-select [value]="chosen()" (selectionChange)="chosen.set($event.value)">
|
||||||
@for (p of options(); track p) {
|
@for (p of options(); track p) {
|
||||||
<mat-option [value]="p">{{ p }}</mat-option>
|
<mat-option [value]="p">{{ label(p) }}</mat-option>
|
||||||
}
|
}
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
@@ -26,239 +25,216 @@
|
|||||||
>
|
>
|
||||||
Aplicar
|
Aplicar
|
||||||
</button>
|
</button>
|
||||||
|
@if (applied(); as p) {
|
||||||
|
<span class="muted applied">Mostrando {{ label(p) }}</span>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (reports.isLoading()) {
|
@if (reports.isLoading()) {
|
||||||
<app-loading what="los indicadores" text="Calculando los indicadores…" />
|
<p class="muted">Calculando…</p>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (reports.error()) {
|
@if (kpis().length) {
|
||||||
<div class="load-error" role="alert">
|
<h2>Indicadores de oportunidad</h2>
|
||||||
<p>No se pudieron leer los indicadores del periodo. Vuelve a intentar.</p>
|
<div class="kpis">
|
||||||
<button mat-stroked-button (click)="reports.reload()">Reintentar</button>
|
@for (m of kpis(); track m.id) {
|
||||||
</div>
|
<mat-card appearance="outlined" class="kpi" [attr.data-measure]="m.name">
|
||||||
}
|
|
||||||
@if (page(); as pg) {
|
|
||||||
@if (applied(); as period) {
|
|
||||||
<section class="card opportunity" aria-labelledby="opportunity-title">
|
|
||||||
<div class="section-head">
|
|
||||||
<h2 id="opportunity-title">Indicadores de oportunidad</h2>
|
|
||||||
<span class="period">Periodo {{ period }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="kpis">
|
|
||||||
@for (k of pg.kpis; track k.title) {
|
|
||||||
<mat-card appearance="outlined" class="kpi" [attr.data-measure]="k.measure ?? null">
|
|
||||||
<mat-card-content>
|
|
||||||
<h3 class="kpi-title">{{ k.title }}</h3>
|
|
||||||
@if (reports.isLoading() && k.measure) {
|
|
||||||
<app-loading [what]="k.title.toLowerCase()" />
|
|
||||||
} @else {
|
|
||||||
<div class="kpi-value" [class.pending]="!k.measure">{{ kpiValue(k) }}</div>
|
|
||||||
<div class="kpi-detail">{{ kpiNote(k) }}</div>
|
|
||||||
}
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
@for (section of pg.opportunity ?? []; track $index) {
|
|
||||||
<ng-container
|
|
||||||
*ngTemplateOutlet="sectionView; context: { $implicit: section, period: period }"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="card clinical-page" aria-labelledby="clinical-title">
|
|
||||||
<h2 id="clinical-title">Indicadores clínicos</h2>
|
|
||||||
@for (section of pg.clinical; track $index) {
|
|
||||||
<ng-container
|
|
||||||
*ngTemplateOutlet="sectionView; context: { $implicit: section, period: period }"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
</section>
|
|
||||||
}
|
|
||||||
|
|
||||||
<ng-template #sectionView let-section let-period="period">
|
|
||||||
@switch (section.kind) {
|
|
||||||
@case ('route') {
|
|
||||||
<h3 class="route-title">{{ section.title }}</h3>
|
|
||||||
@if (reports.isLoading()) {
|
|
||||||
<app-loading what="los tiempos de la ruta" [figure]="true" />
|
|
||||||
} @else if (routeOf(section); as fig) {
|
|
||||||
<app-plot [figure]="fig" [height]="300" />
|
|
||||||
} @else {
|
|
||||||
<p class="state">Sin tiempos publicados en el periodo.</p>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@case ('tea-summary') {
|
|
||||||
@if (teaSummary(); as t) {
|
|
||||||
<mat-card appearance="outlined" class="summary">
|
|
||||||
<mat-card-content>
|
|
||||||
<h2 class="box-title">Resumen</h2>
|
|
||||||
<p>
|
|
||||||
Al cierre del periodo <mark>{{ period }}</mark>, se evaluaron
|
|
||||||
<mark>{{ t.evaluated }}</mark> niños entre 16 y 36 meses;
|
|
||||||
<mark>{{ t.mchatOnly }}</mark> únicamente tienen M-CHAT,
|
|
||||||
<mark>{{ t.psychology }}</mark> hasta la evaluación psicológica y
|
|
||||||
<mark>{{ t.neuropediatrics }}</mark> presentan evaluación neuropediátrica. En este
|
|
||||||
periodo el <mark>{{ t.confirmed }}</mark> de los pacientes tiene diagnóstico
|
|
||||||
confirmado de TEA (CIE-10 F84.0). Las ventanas de tiempo<sup>*</sup> de tamizaje
|
|
||||||
son: <mark>{{ t.toAdos }}</mark> de M-CHAT (psicología) a ADOS-2,
|
|
||||||
<mark>{{ t.toDiagnosis }}</mark> de ADOS-2 a diagnóstico. El tiempo<sup>*</sup> de
|
|
||||||
tamizaje completo de M-CHAT a diagnóstico fue de <mark>{{ t.whole }}</mark>.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
De los <mark>{{ t.diagnosed }}</mark> niños con diagnóstico confirmado en este
|
|
||||||
periodo, <mark>{{ t.eeg }}</mark> presentan estudio de EEG y faltan
|
|
||||||
<mark>{{ t.missing }}</mark> por realizarlo. <mark>{{ t.unusable }}</mark> estudios
|
|
||||||
de EEG no son aceptables para un análisis.
|
|
||||||
</p>
|
|
||||||
<p class="state">*tomando la mediana de los tiempos</p>
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
} @else if (reports.isLoading()) {
|
|
||||||
<app-loading what="el resumen del periodo" />
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@case ('grid') {
|
|
||||||
<div class="grid-figures">
|
|
||||||
@for (f of section.figures; track f.title) {
|
|
||||||
<mat-card appearance="outlined" class="figure-card" [attr.data-figure]="f.kind">
|
|
||||||
<mat-card-content>
|
|
||||||
<h2 class="box-title">{{ f.title }}</h2>
|
|
||||||
<p class="state">Filtro general aplicado: {{ period }}</p>
|
|
||||||
@if (reports.isLoading()) {
|
|
||||||
<app-loading what="la figura" [figure]="true" />
|
|
||||||
} @else if (figureOf(f); as fig) {
|
|
||||||
<app-plot [figure]="fig" [height]="320" />
|
|
||||||
} @else {
|
|
||||||
<div class="empty-figure">Sin datos publicados</div>
|
|
||||||
}
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@case ('boxes') {
|
|
||||||
@if (section.title) {
|
|
||||||
<h3 class="boxes-title">{{ section.title }}</h3>
|
|
||||||
}
|
|
||||||
<div class="box-grid" [class.standalone]="!section.title">
|
|
||||||
@for (b of section.cards; track b.title) {
|
|
||||||
<mat-card
|
|
||||||
appearance="outlined"
|
|
||||||
class="box-card"
|
|
||||||
[attr.data-measure]="b.measure ?? null"
|
|
||||||
>
|
|
||||||
<mat-card-content>
|
|
||||||
<h2 class="box-title">{{ b.title }}</h2>
|
|
||||||
@if (!b.measure) {
|
|
||||||
<p class="state"><strong>Integración pendiente.</strong> {{ pending }}</p>
|
|
||||||
<div class="empty-figure">Sin datos publicados</div>
|
|
||||||
} @else {
|
|
||||||
<p class="state">Filtro general aplicado: {{ period }}</p>
|
|
||||||
@if (section.subtitles) {
|
|
||||||
<h2 class="box-subtitle">{{ measureTitle(b.measure) }}</h2>
|
|
||||||
<p class="state">Figura: Caja de cuartiles</p>
|
|
||||||
}
|
|
||||||
@if (reports.isLoading()) {
|
|
||||||
<app-loading what="la figura" [figure]="true" />
|
|
||||||
} @else if (boxOf(b.measure); as fig) {
|
|
||||||
<app-plot [figure]="fig" [height]="320" />
|
|
||||||
} @else {
|
|
||||||
<div class="empty-figure">Sin datos publicados</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@case ('card') {
|
|
||||||
<mat-card appearance="outlined" class="kpi closing" [attr.data-measure]="section.measure">
|
|
||||||
<mat-card-content>
|
|
||||||
<h3 class="kpi-title">{{ section.title }}</h3>
|
|
||||||
<div class="kpi-value">{{ kpiValue(section) }}</div>
|
|
||||||
<div class="kpi-detail">{{ kpiNote(section) }}</div>
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
}
|
|
||||||
@default {
|
|
||||||
<mat-card appearance="outlined" class="figure-card">
|
|
||||||
<mat-card-content>
|
|
||||||
@if (section.title) {
|
|
||||||
<h2 class="figure-card-title">{{ section.title }}</h2>
|
|
||||||
}
|
|
||||||
<div class="figure-row">
|
|
||||||
@for (f of section.figures; track f.title) {
|
|
||||||
<div class="figure" [attr.data-figure]="f.kind">
|
|
||||||
<h3 [class.light]="f.kind === 'share-donut'">{{ titled(f.title) }}</h3>
|
|
||||||
@if (reports.isLoading()) {
|
|
||||||
<app-loading what="la figura" [figure]="true" />
|
|
||||||
} @else if (figureOf(f); as fig) {
|
|
||||||
<app-plot [figure]="fig" [height]="360" />
|
|
||||||
} @else {
|
|
||||||
<p class="state">Sin datos en el periodo.</p>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</ng-template>
|
|
||||||
} @else {
|
|
||||||
@if (kpis().length) {
|
|
||||||
<h2>Indicadores de oportunidad</h2>
|
|
||||||
<div class="kpis">
|
|
||||||
@for (m of kpis(); track m.id) {
|
|
||||||
<mat-card appearance="outlined" class="kpi" [attr.data-measure]="m.name">
|
|
||||||
<mat-card-content>
|
|
||||||
<div class="kpi-title">{{ m.title }}</div>
|
|
||||||
<div class="kpi-value">{{ score(m) }}</div>
|
|
||||||
<div class="kpi-detail muted">{{ detail(m) }}</div>
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
@if (layout().route.length) {
|
|
||||||
<mat-card appearance="outlined" class="route">
|
|
||||||
<mat-card-header>
|
|
||||||
<mat-card-title>Ruta del tamizaje</mat-card-title>
|
|
||||||
<mat-button-toggle-group
|
|
||||||
[value]="routeView()"
|
|
||||||
(change)="routeView.set($event.value)"
|
|
||||||
class="route-toggle"
|
|
||||||
>
|
|
||||||
<mat-button-toggle value="sample">Acumulado desde la toma</mat-button-toggle>
|
|
||||||
<mat-button-toggle value="step">Por pasos</mat-button-toggle>
|
|
||||||
</mat-button-toggle-group>
|
|
||||||
</mat-card-header>
|
|
||||||
<mat-card-content>
|
|
||||||
<app-plot [figure]="route()" [height]="260" />
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
}
|
|
||||||
|
|
||||||
<h2>Indicadores clínicos</h2>
|
|
||||||
<div class="clinical">
|
|
||||||
@for (m of clinical(); track m.id) {
|
|
||||||
<mat-card appearance="outlined" class="clinical-card" [attr.data-measure]="m.name">
|
|
||||||
<mat-card-header>
|
|
||||||
<mat-card-title>{{ m.title }}</mat-card-title>
|
|
||||||
<mat-card-subtitle>{{ score(m) }} · {{ detail(m) }}</mat-card-subtitle>
|
|
||||||
</mat-card-header>
|
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
@for (f of figureSets().get(m.name!) ?? []; track f.title) {
|
<div class="kpi-title">{{ m.title }}</div>
|
||||||
<h3 class="figure-title">{{ f.title }}</h3>
|
<div class="kpi-value">{{ score(m) }}</div>
|
||||||
<app-plot [figure]="f.figure" [height]="260" />
|
<div class="kpi-detail muted">{{ detail(m) }}</div>
|
||||||
} @empty {
|
|
||||||
<p class="muted">Sin datos en el periodo.</p>
|
|
||||||
}
|
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@if (layout().route.length) {
|
||||||
|
<mat-card appearance="outlined" class="route">
|
||||||
|
<mat-card-header>
|
||||||
|
<mat-card-title>{{ domain() === 'cacu' ? 'Tiempos de la ruta del tamizaje' : 'Ruta del tamizaje' }}</mat-card-title>
|
||||||
|
<mat-button-toggle-group
|
||||||
|
[value]="routeView()"
|
||||||
|
(change)="routeView.set($event.value)"
|
||||||
|
class="route-toggle"
|
||||||
|
>
|
||||||
|
<mat-button-toggle value="sample">Acumulado desde la toma</mat-button-toggle>
|
||||||
|
<mat-button-toggle value="step">Por pasos</mat-button-toggle>
|
||||||
|
@if (domain() === 'cacu') { <mat-button-toggle value="icd10">Desglose por CIE-10</mat-button-toggle> }
|
||||||
|
</mat-button-toggle-group>
|
||||||
|
</mat-card-header>
|
||||||
|
<mat-card-content>
|
||||||
|
@if (domain() !== 'cacu') { <app-plot [figure]="route()" [height]="260" /> }
|
||||||
|
@else if (routeView() === 'icd10') {
|
||||||
|
<p class="muted">Desglose exploratorio basado en la asociación temporal existente; no confirma un vínculo clínico entre la toma y el diagnóstico.</p>
|
||||||
|
@if (reports.isLoading()) { <p class="muted">Calculando…</p> }
|
||||||
|
@else if (icd(); as r) {
|
||||||
|
<p class="muted">{{ r.populations['measure-observation'] ?? 0 }} observaciones · escala 0 a {{ icdMax() }} días.</p>
|
||||||
|
<table class="distribution route-table" aria-label="Tiempos por CIE-10"><thead><tr><th>CIE-10 y descripción</th><th>Mediana</th><th>Observaciones</th><th>Q1–Q3</th></tr></thead><tbody>
|
||||||
|
@for (row of icdRows(); track row.label) {
|
||||||
|
<tr><th scope="row">{{ row.label }}<span class="bar-track duration-track" aria-hidden="true"><span class="bar" [style.width.%]="icdMax() ? 100 * row.median / icdMax() : 0"></span><span class="quartile" [style.left.%]="icdMax() ? 100 * (row.low ?? 0) / icdMax() : 0"></span><span class="quartile" [style.left.%]="icdMax() ? 100 * (row.high ?? 0) / icdMax() : 0"></span></span></th><td>{{ row.median }} días</td><td>{{ row.count }}</td><td>{{ row.low }}–{{ row.high }}</td></tr>
|
||||||
|
} @empty { <tr><td colspan="4">Sin observaciones en el periodo.</td></tr> }
|
||||||
|
</tbody></table>
|
||||||
|
} @else { <p class="muted">Desglose no disponible en este servidor o periodo.</p> }
|
||||||
|
} @else {
|
||||||
|
@if (routeView() === 'step') {
|
||||||
|
<p class="muted">Representación ilustrativa: las barras se desplazan según las medianas publicadas por tramo; no representan la duración acumulada observada de una misma cohorte.</p>
|
||||||
|
<app-plot [figure]="stepRoute()" [height]="stepRouteHeight()" />
|
||||||
|
<details class="route-values">
|
||||||
|
<summary>Cuartiles y valores por tramo</summary>
|
||||||
|
<p class="muted">Q1, mediana y Q3 corresponden a las observaciones disponibles de cada tramo. Los tramos sin datos se indican como no disponibles.</p>
|
||||||
|
<table class="distribution route-table" aria-label="Valores estadísticos de tiempos por tramo">
|
||||||
|
<thead><tr><th>Tramo</th><th>Mediana</th><th>Observaciones</th><th>Q1–Q3</th></tr></thead>
|
||||||
|
<tbody>@for (row of routeRows(); track row.label) {
|
||||||
|
<tr><th scope="row">{{ row.label }}</th><td>{{ row.reading?.score !== undefined ? row.reading!.score + ' días' : '—' }}</td>
|
||||||
|
<td>{{ row.reading?.score !== undefined ? (row.reading?.populations?.['measure-observation'] ?? '—') : '—' }}</td>
|
||||||
|
<td>{{ row.reading?.low !== undefined && row.reading?.high !== undefined ? row.reading!.low + '–' + row.reading!.high : '—' }}</td></tr>
|
||||||
|
}</tbody>
|
||||||
|
</table>
|
||||||
|
</details>
|
||||||
|
} @else {
|
||||||
|
<p class="muted">Escala: 0 a {{ routeMax() }} días. Las marcas indican el primer y tercer cuartil.</p>
|
||||||
|
<table class="distribution route-table" aria-label="Tiempos de la ruta del tamizaje">
|
||||||
|
<thead><tr><th>Etapa</th><th>Mediana</th><th>Observaciones</th><th>Q1–Q3</th></tr></thead>
|
||||||
|
<tbody>
|
||||||
|
@for (row of routeRows(); track row.label) {
|
||||||
|
<tr><th scope="row">{{ row.label }}
|
||||||
|
@if (row.reading?.score !== undefined) {
|
||||||
|
<span class="bar-track duration-track" aria-hidden="true">
|
||||||
|
<span class="bar" [style.width.%]="routeMax() ? 100 * row.reading!.score! / routeMax() : 0"></span>
|
||||||
|
@if (row.reading!.low !== undefined && row.reading!.high !== undefined) {
|
||||||
|
<span class="quartile" [style.left.%]="routeMax() ? 100 * row.reading!.low! / routeMax() : 0"></span>
|
||||||
|
<span class="quartile" [style.left.%]="routeMax() ? 100 * row.reading!.high! / routeMax() : 0"></span>
|
||||||
|
}
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
</th><td>{{ row.reading?.score !== undefined ? row.reading!.score + ' días' : '—' }}</td>
|
||||||
|
<td>{{ row.reading?.populations?.['measure-observation'] ?? '—' }}</td>
|
||||||
|
<td>{{ row.reading?.low !== undefined && row.reading?.high !== undefined ? row.reading!.low + '–' + row.reading!.high : '—' }}</td></tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
}
|
||||||
|
|
||||||
|
<h2>Indicadores clínicos</h2>
|
||||||
|
@if (domain() === 'cacu') {
|
||||||
|
<mat-card appearance="outlined" class="results-card">
|
||||||
|
<mat-card-header><mat-card-title>Resultados de citología, VPH y biopsia</mat-card-title></mat-card-header>
|
||||||
|
<mat-card-content class="results-grid">
|
||||||
|
<section aria-labelledby="cytology-title">
|
||||||
|
<h3 id="cytology-title">Distribución de resultados citológicos</h3>
|
||||||
|
@if (reports.isLoading()) {
|
||||||
|
<p class="muted">Calculando…</p>
|
||||||
|
} @else if (cytology(); as distribution) {
|
||||||
|
<p class="muted">{{ distribution.total }} pacientes con resultado elegible · {{ distribution.outside }} fuera de la distribución</p>
|
||||||
|
<p class="muted">Una muestra por paciente en el periodo; se prioriza la última válida. Los porcentajes usan los resultados elegibles.</p>
|
||||||
|
<p class="muted">Escala de las barras: 0 a {{ distribution.max }} pacientes.</p>
|
||||||
|
<table class="distribution" aria-label="Distribución de resultados citológicos">
|
||||||
|
<thead><tr><th>Categoría</th><th>Pacientes</th><th>%</th></tr></thead>
|
||||||
|
<tbody>
|
||||||
|
@for (row of distribution.rows; track row.label) {
|
||||||
|
<tr>
|
||||||
|
<th scope="row"><span class="distribution-label">{{ row.label }}</span><span class="bar-track" aria-hidden="true"><span class="bar" [style.width.%]="distribution.max ? 100 * row.count / distribution.max : 0" [style.background]="row.color"></span></span></th>
|
||||||
|
<td>{{ row.count }}</td>
|
||||||
|
<td>{{ distribution.total ? (100 * row.count / distribution.total).toFixed(1) + ' %' : '—' }}</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
@if (!distribution.total) { <p class="muted">Sin resultados elegibles en el periodo.</p> }
|
||||||
|
} @else {
|
||||||
|
<p class="muted">{{ hasCytologyMeasure() ? 'Distribución no disponible para este periodo.' : 'Medida no publicada por el servidor.' }}</p>
|
||||||
|
}
|
||||||
|
</section>
|
||||||
|
<section aria-labelledby="hpv-title">
|
||||||
|
<h3 id="hpv-title">Resultados de VPH por genotipo</h3>
|
||||||
|
@if (reports.isLoading()) { <p class="muted">Calculando…</p> }
|
||||||
|
@else if (hpv(); as d) {
|
||||||
|
<p class="muted">{{ d.total }} reportes VPH elegibles · periodo por fecha de toma. {{ d.outside }} fuera de las categorías mostradas.</p>
|
||||||
|
<p class="muted">Escala de las barras: 0 a {{ d.max }} reportes. El contrato actual no representa resultados indeterminados.</p>
|
||||||
|
<table class="distribution" aria-label="Resultados de VPH por genotipo">
|
||||||
|
<thead><tr><th>Categoría</th><th>Reportes</th><th>%</th></tr></thead>
|
||||||
|
<tbody>
|
||||||
|
@for (row of d.rows; track row.label) {
|
||||||
|
@if (row.label === 'No clasificable o inconsistente') { <tr><th scope="row">Indeterminado</th><td colspan="2">No disponible en el contrato actual</td></tr> }
|
||||||
|
<tr><th scope="row"><span class="distribution-label">{{ row.label }}</span><span class="bar-track" aria-hidden="true"><span class="bar" [style.width.%]="d.max ? 100 * row.count / d.max : 0" [style.background]="row.color"></span></span></th>
|
||||||
|
<td>{{ row.count }}</td><td>{{ d.total ? (100 * row.count / d.total).toFixed(1) + ' %' : '—' }}</td></tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
@if (!d.total) { <p class="muted">Sin reportes elegibles en el periodo.</p> }
|
||||||
|
} @else { <p class="muted">{{ hasHpvMeasure() ? 'Distribución no disponible para este periodo.' : 'Distribución no publicada por el servidor.' }}</p> }
|
||||||
|
</section>
|
||||||
|
<section class="biopsy" aria-labelledby="biopsy-title">
|
||||||
|
<h3 id="biopsy-title">Resultado de la biopsia</h3>
|
||||||
|
@if (reports.isLoading()) { <p class="muted">Calculando…</p> }
|
||||||
|
@else if (biopsy(); as d) {
|
||||||
|
<p class="muted">{{ d.total }} reportes con histología clasificable · periodo por fecha de reporte.</p>
|
||||||
|
<p class="muted">{{ d.noData }} reportes sin grado · {{ d.outside - d.noData }} con grado no clasificable. Las órdenes sin reporte no están incluidas.</p>
|
||||||
|
<p class="muted">Escala de las barras: 0 a {{ d.max }} reportes.</p>
|
||||||
|
<table class="distribution" aria-label="Resultados de biopsia cervical">
|
||||||
|
<thead><tr><th>Categoría</th><th>Reportes</th><th>%</th></tr></thead>
|
||||||
|
<tbody>
|
||||||
|
@for (row of d.rows; track row.label; let i = $index) {
|
||||||
|
@if (i === 0) { <tr class="group"><th scope="rowgroup" colspan="3">Menor que LIEAG · {{ d.rows[0].count + d.rows[1].count }}</th></tr> }
|
||||||
|
@if (i === 2) { <tr class="group"><th scope="rowgroup" colspan="3">LIEAG o más · {{ d.rows[2].count + d.rows[3].count + d.rows[4].count }}</th></tr> }
|
||||||
|
<tr><th scope="row"><span class="distribution-label">{{ row.label }}</span><span class="bar-track" aria-hidden="true"><span class="bar" [style.width.%]="d.max ? 100 * row.count / d.max : 0" [style.background]="row.color"></span></span></th>
|
||||||
|
<td>{{ row.count }}</td><td>{{ d.total ? (100 * row.count / d.total).toFixed(1) + ' %' : '—' }}</td></tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
@if (!d.total) { <p class="muted">Sin reportes con grado clasificable en el periodo.</p> }
|
||||||
|
} @else { <p class="muted">{{ hasBiopsyMeasure() ? 'Distribución no disponible para este periodo.' : 'Distribución general no publicada por el servidor.' }}</p> }
|
||||||
|
</section>
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
<div class="confirmation-cards">
|
||||||
|
<mat-card appearance="outlined"><mat-card-header><mat-card-title>Tasa de confirmación histopatológica de referencia a colposcopia</mat-card-title></mat-card-header>
|
||||||
|
<mat-card-content><p>No disponible: no se identifican las referencias emitidas a colposcopia. Las colposcopias inferidas no acreditan ese denominador.</p></mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
<mat-card appearance="outlined"><mat-card-header><mat-card-title>Tasa de confirmación histopatológica de referencia a biopsia</mat-card-title></mat-card-header>
|
||||||
|
<mat-card-content>
|
||||||
|
<p>La tasa de referencias emitidas no está disponible: no se acreditó la cobertura de referencias ni las cancelaciones.</p>
|
||||||
|
<p class="muted">Aproximación distinta: estudios con solicitud de biopsia registrada, por fecha de solicitud.</p>
|
||||||
|
@if (reports.isLoading()) { <p class="muted">Calculando…</p> }
|
||||||
|
@else if (!requestsMeasure()) { <p>No disponible: medida no publicada por el servidor.</p> }
|
||||||
|
@else if (requests()?.error) { <p role="alert">Error al consultar las solicitudes de biopsia.</p> }
|
||||||
|
@else if (requests(); as r) {
|
||||||
|
@if (validRequests()) {
|
||||||
|
@if (r.populations['initial-population']; as total) {
|
||||||
|
<p>Denominador: {{ total }} solicitudes registradas (no pacientes).</p>
|
||||||
|
<p>LIEAG o más: {{ category(r, 'high_grade') }} / {{ total }} · {{ (100 * category(r, 'high_grade') / total).toFixed(1) }} %</p>
|
||||||
|
<p>Menor que LIEAG: {{ category(r, 'below_high_grade') }} / {{ total }} · {{ (100 * category(r, 'below_high_grade') / total).toFixed(1) }} %</p>
|
||||||
|
<p class="muted">Pendientes: {{ category(r, 'pending') }} · Sin grado: {{ category(r, 'no_grade') }} · No clasificables: {{ category(r, 'unclassified') }} · Fechas inconsistentes: {{ category(r, 'inconsistent') }} · Registros fusionados ambiguos: {{ category(r, 'ambiguous') }}.</p>
|
||||||
|
} @else { <p>Sin solicitudes registradas en el periodo; porcentaje no calculable (denominador 0).</p> }
|
||||||
|
} @else { <p role="alert">Los datos de solicitudes recibidos están incompletos o son inconsistentes.</p> }
|
||||||
|
} @else { <p>No disponible para este periodo.</p> }
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<div class="clinical">
|
||||||
|
@for (m of clinical(); track m.id) {
|
||||||
|
<mat-card appearance="outlined" class="clinical-card" [attr.data-measure]="m.name">
|
||||||
|
<mat-card-header>
|
||||||
|
<mat-card-title>{{ measureTitle(m) }}</mat-card-title>
|
||||||
|
<mat-card-subtitle>{{ score(m) }} · {{ detail(m) }}</mat-card-subtitle>
|
||||||
|
@if (ppvNote(m); as note) { <mat-card-subtitle class="ppv-note">{{ note }}</mat-card-subtitle> }
|
||||||
|
@if (domain() === 'cacu' && m.name === 'CACU_EU7') { <mat-card-subtitle>El tamizaje inicial o subsecuente es el que declara el formulario o se deduce de la ruta; «Sin dato» si no consta.</mat-card-subtitle> }
|
||||||
|
@if (domain() === 'cacu' && m.name === 'CACU_CONFIRMACION_CITOLOGIA') { <mat-card-subtitle>Pacientes con citología ASC-H, LIEAG o carcinoma in situ; incluye casos sin biopsia.</mat-card-subtitle> }
|
||||||
|
</mat-card-header>
|
||||||
|
<mat-card-content>
|
||||||
|
@for (f of figureSets().get(m.name!) ?? []; track f.title) {
|
||||||
|
<h3 class="figure-title">{{ f.title }}</h3>
|
||||||
|
<app-plot [figure]="f.figure" [height]="260" />
|
||||||
|
} @empty {
|
||||||
|
<p class="muted">Sin datos en el periodo.</p>
|
||||||
|
}
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -78,11 +78,46 @@ h2 {
|
|||||||
gap: var(--space-3);
|
gap: var(--space-3);
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
.route-toggle { flex-wrap: wrap; max-width: 100%; }
|
||||||
|
.route-values summary { color: var(--color-text-secondary); cursor: pointer; padding: var(--space-2) 0; }
|
||||||
|
.route-values summary:focus-visible { outline: 2px solid var(--color-action); outline-offset: 2px; }
|
||||||
|
|
||||||
|
.route-table td { font-variant-numeric: tabular-nums; }
|
||||||
|
.route-table th:first-child { width: 70%; }
|
||||||
|
.duration-track { position: relative; }
|
||||||
|
.duration-track .bar { background: #42a77e; }
|
||||||
|
.quartile { position: absolute; top: -3px; width: 2px; height: 14px; background: #17324d; }
|
||||||
|
.confirmation-cards { display: grid; grid-template-columns: 1fr; gap: var(--space-4); margin-bottom: var(--space-4); }
|
||||||
|
.confirmation-cards { align-items: start; }
|
||||||
|
.confirmation-cards p { margin: var(--space-2) 0; }
|
||||||
|
@media (min-width: 850px) { .confirmation-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
||||||
|
|
||||||
.clinical {
|
.clinical {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: var(--space-4);
|
gap: var(--space-4);
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.results-card { margin-bottom: var(--space-4); }
|
||||||
|
.results-grid { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
|
||||||
|
.results-grid section { min-width: 0; }
|
||||||
|
.results-grid h3 { font-size: 1rem; font-weight: 500; margin: var(--space-3) 0; }
|
||||||
|
.results-grid p { font-size: 13px; margin: var(--space-2) 0; }
|
||||||
|
.distribution { border-collapse: collapse; width: 100%; font-size: 13px; }
|
||||||
|
.distribution th { font-weight: 500; text-align: left; }
|
||||||
|
.distribution td, .distribution thead th:not(:first-child) { text-align: right; white-space: nowrap; padding-left: 12px; }
|
||||||
|
.distribution tbody th { padding: 5px 0; }
|
||||||
|
.distribution .group th { background: #edf2f4; padding: 6px 8px; font-weight: 600; }
|
||||||
|
.bar-track { display: block; height: 8px; background: #eef1f3; margin-top: 3px; }
|
||||||
|
.bar { display: block; height: 100%; }
|
||||||
|
.results-grid .distribution tbody th:has(.distribution-label) { display: flex; align-items: center; gap: 10px; }
|
||||||
|
.results-grid .distribution-label { flex: 0 1 45%; min-width: 0; }
|
||||||
|
.results-grid .bar-track { flex: 1; min-width: 40px; height: 16px; margin: 0; }
|
||||||
|
.results-grid .distribution td { padding-left: 8px; }
|
||||||
|
@media (min-width: 850px) {
|
||||||
|
.results-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||||
|
.biopsy { grid-column: 1 / -1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 1304px) {
|
@media (min-width: 1304px) {
|
||||||
@@ -97,203 +132,3 @@ h2 {
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
margin: var(--space-3) 0 0;
|
margin: var(--space-3) 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The old app's page: white sections with a title, cards inside. */
|
|
||||||
.card.opportunity,
|
|
||||||
.card.clinical-page {
|
|
||||||
background: var(--color-surface);
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
border-radius: 8px;
|
|
||||||
margin-bottom: 24px;
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.section-head {
|
|
||||||
align-items: baseline;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
|
|
||||||
.period {
|
|
||||||
color: var(--color-text-secondary);
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.card h2 {
|
|
||||||
font-size: 20px;
|
|
||||||
font-weight: 500;
|
|
||||||
margin: 0 0 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h3.kpi-title {
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 500;
|
|
||||||
margin: 0;
|
|
||||||
min-height: 2.6em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.kpi-detail {
|
|
||||||
color: var(--color-text-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
h3.route-title {
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 700;
|
|
||||||
margin: 24px 0 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.figure-card {
|
|
||||||
margin-top: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2.figure-card-title {
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: 500;
|
|
||||||
margin: 0 0 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.figure-row {
|
|
||||||
display: grid;
|
|
||||||
gap: 24px;
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1100px) {
|
|
||||||
.figure-row {
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.figure h3 {
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 700;
|
|
||||||
margin: 0 0 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.state {
|
|
||||||
color: var(--color-text-secondary);
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filters {
|
|
||||||
background: var(--color-surface);
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2.filters-title {
|
|
||||||
flex-basis: 100%;
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 500;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
h3.boxes-title {
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: 500;
|
|
||||||
margin: 24px 0 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.box-grid {
|
|
||||||
display: grid;
|
|
||||||
gap: 16px;
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1000px) {
|
|
||||||
.box-grid {
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
h2.box-title {
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: 500;
|
|
||||||
margin: 0 0 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2.box-subtitle {
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 500;
|
|
||||||
margin: 8px 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.empty-figure {
|
|
||||||
align-items: center;
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
border-radius: 8px;
|
|
||||||
color: var(--color-text-secondary);
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
min-height: 120px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.kpi-value.pending {
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 400;
|
|
||||||
}
|
|
||||||
|
|
||||||
.figure h3.light {
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.kpi.closing {
|
|
||||||
margin-top: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.summary {
|
|
||||||
margin-bottom: 24px;
|
|
||||||
|
|
||||||
p {
|
|
||||||
font-size: 20px;
|
|
||||||
line-height: 2.1;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.state {
|
|
||||||
font-size: 14px;
|
|
||||||
line-height: 1.5;
|
|
||||||
margin-top: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
mark {
|
|
||||||
background: #f1f5df;
|
|
||||||
border: 1px solid #d8e3a8;
|
|
||||||
border-radius: 4px;
|
|
||||||
font-weight: 700;
|
|
||||||
padding: 1px 8px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid-figures {
|
|
||||||
display: grid;
|
|
||||||
gap: 24px;
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1100px) {
|
|
||||||
.grid-figures {
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1000px) {
|
|
||||||
.box-grid.standalone {
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.load-error {
|
|
||||||
align-items: center;
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
border-radius: 8px;
|
|
||||||
display: flex;
|
|
||||||
gap: 16px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
padding: 12px 16px;
|
|
||||||
|
|
||||||
p {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { Component, computed, effect, inject, input, resource, signal } from '@angular/core';
|
import { Component, computed, effect, inject, input, resource, signal } from '@angular/core';
|
||||||
import { NgTemplateOutlet } from '@angular/common';
|
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
||||||
@@ -9,19 +8,7 @@ import type { Measure, MeasureReport } from 'fhir/r4';
|
|||||||
import { Fhir, resources } from '../fhir';
|
import { Fhir, resources } from '../fhir';
|
||||||
import { Figure, Plot } from '../plot';
|
import { Figure, Plot } from '../plot';
|
||||||
import { LAYOUTS } from './layout';
|
import { LAYOUTS } from './layout';
|
||||||
import {
|
import { biopsyDistribution, cytologyDistribution, hpvDistribution } from './cacu-results';
|
||||||
ageShare,
|
|
||||||
ageStack,
|
|
||||||
boxFigure,
|
|
||||||
countBars,
|
|
||||||
fill,
|
|
||||||
nestedDonut,
|
|
||||||
rateDots,
|
|
||||||
routeFigure,
|
|
||||||
scenarioBars,
|
|
||||||
shareDonut,
|
|
||||||
} from './figures';
|
|
||||||
import { FigureSpec, Kpi, PAGES, Section } from './pages';
|
|
||||||
import {
|
import {
|
||||||
detail,
|
detail,
|
||||||
donut,
|
donut,
|
||||||
@@ -35,18 +22,17 @@ import {
|
|||||||
Reading,
|
Reading,
|
||||||
scoring,
|
scoring,
|
||||||
STRATA,
|
STRATA,
|
||||||
|
PPV_NOTES,
|
||||||
|
measureTitle,
|
||||||
strataBars,
|
strataBars,
|
||||||
} from './measures';
|
} from './measures';
|
||||||
import { Loading } from '../loading';
|
|
||||||
|
|
||||||
/** The period's indicators: the timeliness KPIs, the screening route, and a card per
|
/** The period's indicators: the timeliness KPIs, the screening route, and a card per
|
||||||
* clinical measure with its figures. */
|
* clinical measure with its figures. */
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-tab-indicadores',
|
selector: 'app-tab-indicadores',
|
||||||
imports: [
|
imports: [
|
||||||
Loading,
|
|
||||||
FormsModule,
|
FormsModule,
|
||||||
NgTemplateOutlet,
|
|
||||||
MatButtonModule,
|
MatButtonModule,
|
||||||
MatButtonToggleModule,
|
MatButtonToggleModule,
|
||||||
MatCardModule,
|
MatCardModule,
|
||||||
@@ -66,15 +52,11 @@ export class TabIndicadores {
|
|||||||
protected readonly chosen = signal<string | undefined>(undefined);
|
protected readonly chosen = signal<string | undefined>(undefined);
|
||||||
/** The period the figures show (set by Aplicar). */
|
/** The period the figures show (set by Aplicar). */
|
||||||
protected readonly applied = signal<string | undefined>(undefined);
|
protected readonly applied = signal<string | undefined>(undefined);
|
||||||
protected readonly routeView = signal<'sample' | 'step'>('sample');
|
protected readonly routeView = signal<'sample' | 'step' | 'icd10'>('sample');
|
||||||
|
|
||||||
protected readonly layout = computed(
|
protected readonly layout = computed(
|
||||||
() => LAYOUTS[this.domain()] ?? { kpis: [], route: [], anchor: '' },
|
() => LAYOUTS[this.domain()] ?? { kpis: [], route: [], anchor: '' },
|
||||||
);
|
);
|
||||||
protected readonly pending =
|
|
||||||
'Este indicador aún no está publicado por el catálogo institucional.';
|
|
||||||
/** The old app's page for this domain, when it is rebuilt as it was (else today's). */
|
|
||||||
protected readonly page = computed(() => PAGES[this.domain()]);
|
|
||||||
private readonly byName = computed(() => new Map(this.measures().map((m) => [m.name!, m])));
|
private readonly byName = computed(() => new Map(this.measures().map((m) => [m.name!, m])));
|
||||||
protected readonly kpis = computed(() =>
|
protected readonly kpis = computed(() =>
|
||||||
this.layout()
|
this.layout()
|
||||||
@@ -85,6 +67,7 @@ export class TabIndicadores {
|
|||||||
const placed = new Set([
|
const placed = new Set([
|
||||||
...this.layout().kpis,
|
...this.layout().kpis,
|
||||||
...this.layout().route.flatMap((s) => [s.fromSample, s.fromStep]),
|
...this.layout().route.flatMap((s) => [s.fromSample, s.fromStep]),
|
||||||
|
...(this.domain() === 'cacu' ? ['CACU_VPH_GENOTIPO', 'CACU_BIOPSIA_RESULTADOS', 'CACU_BIOPSIA_SOLICITUD_CONFIRMACION', 'CACU_TIEMPO_DIAGNOSTICO_CIE10'] : []),
|
||||||
]);
|
]);
|
||||||
return this.measures().filter((m) => !placed.has(m.name!));
|
return this.measures().filter((m) => !placed.has(m.name!));
|
||||||
});
|
});
|
||||||
@@ -93,7 +76,7 @@ export class TabIndicadores {
|
|||||||
private readonly latest = resource({
|
private readonly latest = resource({
|
||||||
params: () => ({
|
params: () => ({
|
||||||
domain: this.domain(),
|
domain: this.domain(),
|
||||||
anchor: this.byName().get(this.page()?.anchor ?? this.layout().anchor) ?? this.measures()[0],
|
anchor: this.byName().get(this.layout().anchor) ?? this.measures()[0],
|
||||||
all: this.options(),
|
all: this.options(),
|
||||||
}),
|
}),
|
||||||
loader: async ({ params }) => {
|
loader: async ({ params }) => {
|
||||||
@@ -115,23 +98,25 @@ export class TabIndicadores {
|
|||||||
if (!params.period) return new Map<string, Reading | undefined>();
|
if (!params.period) return new Map<string, Reading | undefined>();
|
||||||
const found = await Promise.all(
|
const found = await Promise.all(
|
||||||
params.measures.map(async (m) => {
|
params.measures.map(async (m) => {
|
||||||
const page = await this.fhir.search(params.domain, 'MeasureReport', {
|
try {
|
||||||
measure: m.id!,
|
const page = await this.fhir.search(params.domain, 'MeasureReport', {
|
||||||
'reporting-period': params.period,
|
measure: m.id!,
|
||||||
});
|
'reporting-period': params.period,
|
||||||
return [m.name!, reading(resources<MeasureReport>(page, 'MeasureReport')[0])] as const;
|
});
|
||||||
|
return [m.name!, reading(resources<MeasureReport>(page, 'MeasureReport')[0])] as const;
|
||||||
|
} catch (error) {
|
||||||
|
if (params.domain === 'cacu' && m.name === 'CACU_BIOPSIA_SOLICITUD_CONFIRMACION')
|
||||||
|
return [m.name, { populations: {}, strata: {}, error: true } as Reading] as const;
|
||||||
|
if (params.domain === 'cacu' && ['CACU_VPH_GENOTIPO', 'CACU_BIOPSIA_RESULTADOS', 'CACU_BIOPSIA_SOLICITUD_CONFIRMACION', 'CACU_TIEMPO_DIAGNOSTICO_CIE10'].includes(m.name!))
|
||||||
|
return [m.name!, undefined] as const;
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
return new Map(found);
|
return new Map(found);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
/** The period's readings; none while they load or when reading them failed (an errored
|
|
||||||
* resource throws on `value()`). */
|
|
||||||
protected loaded(): Map<string, Reading | undefined> | undefined {
|
|
||||||
return this.reports.hasValue() ? this.reports.value() : undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
effect(() => {
|
effect(() => {
|
||||||
const latest = this.latest.value();
|
const latest = this.latest.value();
|
||||||
@@ -145,7 +130,7 @@ export class TabIndicadores {
|
|||||||
protected readonly label = periodLabel;
|
protected readonly label = periodLabel;
|
||||||
protected readonly strataNames = STRATA;
|
protected readonly strataNames = STRATA;
|
||||||
protected r(m: Measure): Reading | undefined {
|
protected r(m: Measure): Reading | undefined {
|
||||||
return this.loaded()?.get(m.name!);
|
return this.reports.value()?.get(m.name!);
|
||||||
}
|
}
|
||||||
protected score(m: Measure): string {
|
protected score(m: Measure): string {
|
||||||
return formatScore(m, this.r(m));
|
return formatScore(m, this.r(m));
|
||||||
@@ -168,24 +153,95 @@ export class TabIndicadores {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
protected readonly routeRows = computed(() => {
|
||||||
|
const view = this.routeView();
|
||||||
|
return this.layout().route.map((s) => {
|
||||||
|
const m = this.byName().get(view === 'sample' ? s.fromSample : s.fromStep);
|
||||||
|
return { label: view === 'sample' ? s.label : s.step, reading: m && this.r(m) };
|
||||||
|
});
|
||||||
|
});
|
||||||
|
protected readonly routeMax = computed(() => Math.max(0, ...this.routeRows().map(({reading}) =>
|
||||||
|
Math.max(reading?.score ?? 0, reading?.high ?? 0))));
|
||||||
|
/** Illustrative cascade of the published step medians; missing steps do not advance the offset. */
|
||||||
|
protected readonly stepRoute = computed<Figure>(() => {
|
||||||
|
const rows = this.routeRows().filter(row => row.reading?.score !== undefined);
|
||||||
|
let offset = 0;
|
||||||
|
const bars = rows.map((row, index) => {
|
||||||
|
const score = row.reading!.score!;
|
||||||
|
const base = offset;
|
||||||
|
offset += score;
|
||||||
|
return { label: row.label, count: row.reading!.populations['measure-observation'] ?? 0, score, base,
|
||||||
|
color: index === 0 ? '#C9CDD2' : '#A8C243' };
|
||||||
|
});
|
||||||
|
const max = Math.max(1, offset);
|
||||||
|
return {
|
||||||
|
data: [{ type: 'bar', orientation: 'h', y: bars.map(row => `${row.label}<br>n = ${row.count}`),
|
||||||
|
x: bars.map(row => row.score), base: bars.map(row => row.base),
|
||||||
|
marker: { color: bars.map(row => row.color) }, text: bars.map(row => `+${row.score} d`),
|
||||||
|
textposition: 'inside', insidetextanchor: 'start', textfont: { color: '#081839' },
|
||||||
|
cliponaxis: false, hovertemplate: '%{y}<br>Mediana del tramo: %{x} días<extra></extra>' }],
|
||||||
|
layout: { autosize: true, showlegend: false, bargap: 0.48,
|
||||||
|
height: Math.max(210, bars.length * 76 + 94), margin: { t: 12, l: 8, r: 28, b: 52 },
|
||||||
|
xaxis: { title: { text: 'Días' }, range: [0, max * 1.12], nticks: 5, fixedrange: true, zeroline: false },
|
||||||
|
yaxis: { autorange: 'reversed', type: 'category', automargin: true, fixedrange: true } },
|
||||||
|
};
|
||||||
|
});
|
||||||
|
protected readonly stepRouteHeight = computed(() => Math.max(210,
|
||||||
|
this.routeRows().filter(row => row.reading?.score !== undefined).length * 76 + 94));
|
||||||
|
protected readonly icd = computed(() => this.reports.value()?.get('CACU_TIEMPO_DIAGNOSTICO_CIE10'));
|
||||||
|
protected readonly icdRows = computed(() => {
|
||||||
|
const r = this.icd();
|
||||||
|
return Object.entries(r?.stratumScores?.['diagnosis_code'] ?? {}).map(([label, score]) => ({
|
||||||
|
label: label.replace('sin_codigo', 'Sin código disponible').replace('ambiguo', 'Diagnóstico ambiguo'),
|
||||||
|
count: r?.strata['diagnosis_code']?.[label]?.['measure-observation'] ?? 0, ...score,
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
protected readonly icdMax = computed(() => Math.max(0, ...this.icdRows().map(r => Math.max(r.median, r.high ?? 0))));
|
||||||
|
protected readonly requestsMeasure = computed(() => this.byName().has('CACU_BIOPSIA_SOLICITUD_CONFIRMACION'));
|
||||||
|
protected readonly requests = computed(() => this.reports.value()?.get('CACU_BIOPSIA_SOLICITUD_CONFIRMACION'));
|
||||||
|
protected readonly validRequests = computed(() => {
|
||||||
|
const r = this.requests();
|
||||||
|
const total = r?.populations['initial-population'];
|
||||||
|
const cells = r?.strata['category'];
|
||||||
|
if (!r || r.error || total === undefined || !cells) return false;
|
||||||
|
const counts = Object.values(cells).map((cell) => cell['initial-population']);
|
||||||
|
return Number.isInteger(total) && total >= 0 && counts.every((n) => Number.isInteger(n) && n >= 0)
|
||||||
|
&& counts.reduce((sum, n) => sum + n, 0) === total;
|
||||||
|
});
|
||||||
|
protected category(r: Reading, key: string): number {
|
||||||
|
return r.strata['category']?.[key]?.['initial-population'] ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** Each clinical card's figures, built once per loaded period. */
|
/** Each clinical card's figures, built once per loaded period. */
|
||||||
protected readonly figureSets = computed(
|
protected readonly figureSets = computed(
|
||||||
() =>
|
() =>
|
||||||
new Map(this.clinical().map((m) => [m.name!, this.build(m, this.loaded()?.get(m.name!))])),
|
new Map(
|
||||||
|
this.clinical().map((m) => [m.name!, this.build(m, this.reports.value()?.get(m.name!))]),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
protected readonly cytology = computed(() =>
|
||||||
|
cytologyDistribution(this.reports.value()?.get('CACU_EU7')),
|
||||||
|
);
|
||||||
|
protected readonly hasCytologyMeasure = computed(() => this.byName().has('CACU_EU7'));
|
||||||
|
protected readonly hpv = computed(() => hpvDistribution(this.reports.value()?.get('CACU_VPH_GENOTIPO')));
|
||||||
|
protected readonly biopsy = computed(() => biopsyDistribution(this.reports.value()?.get('CACU_BIOPSIA_RESULTADOS')));
|
||||||
|
protected readonly hasHpvMeasure = computed(() => this.byName().has('CACU_VPH_GENOTIPO'));
|
||||||
|
protected readonly hasBiopsyMeasure = computed(() => this.byName().has('CACU_BIOPSIA_RESULTADOS'));
|
||||||
|
|
||||||
/** A clinical card's figures: the overall split, then one per stratum. */
|
/** A clinical card's figures: the overall split, then one per stratum. */
|
||||||
private build(m: Measure, r: Reading | undefined): { title: string; figure: Figure }[] {
|
private build(m: Measure, r: Reading | undefined): { title: string; figure: Figure }[] {
|
||||||
if (!r || !(r.populations['initial-population'] ?? 0)) return [];
|
if (!r || !(r.populations['initial-population'] ?? 0)) return [];
|
||||||
const strata = Object.keys(r.strata).filter(
|
const strata = Object.keys(r.strata).filter(
|
||||||
(s) => s !== 'category' && !s.includes('-') && Object.keys(r.strata[s]).length,
|
(s) => s !== 'category' && Object.keys(r.strata[s]).length,
|
||||||
);
|
);
|
||||||
const kind = scoring(m);
|
const kind = scoring(m);
|
||||||
if (kind === 'continuous-variable')
|
if (kind === 'continuous-variable')
|
||||||
return [{ title: 'Mediana y cuartiles', figure: medians([{ label: m.title!, r }]) }];
|
return [{ title: 'Mediana y cuartiles', figure: medians([{ label: m.title!, r }]) }];
|
||||||
return [
|
return [
|
||||||
{ title: kind === 'proportion' ? 'Numerador y resto' : 'Por categoría', figure: donut(m, r) },
|
...(this.domain() === 'cacu' && m.name === 'CACU_EU7' && this.cytology()
|
||||||
|
? []
|
||||||
|
: [{ title: kind === 'proportion' ? 'Numerador y resto' : 'Por categoría', figure: donut(m, r) }]),
|
||||||
...strata.map((s) => ({
|
...strata.map((s) => ({
|
||||||
title: `Por ${STRATA[s]?.toLowerCase() ?? s}`,
|
title: `Por ${STRATA[s]?.toLowerCase() ?? s}`,
|
||||||
figure: strataBars(m, r, s),
|
figure: strataBars(m, r, s),
|
||||||
@@ -193,96 +249,8 @@ export class TabIndicadores {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
protected readonly name = name;
|
protected readonly name = name;
|
||||||
|
protected readonly measureTitle = measureTitle;
|
||||||
/** A measure's reading in the applied period, by code. */
|
protected ppvNote(m: Measure): string | undefined {
|
||||||
protected rd(code: string): Reading | undefined {
|
return PPV_NOTES[m.name ?? '']?.note;
|
||||||
return this.loaded()?.get(code);
|
|
||||||
}
|
|
||||||
protected kpi(code: string): Measure | undefined {
|
|
||||||
return this.byName().get(code);
|
|
||||||
}
|
|
||||||
/** A card's value and note, from its templates (a card with no measure: its words). */
|
|
||||||
protected kpiValue(k: Kpi): string {
|
|
||||||
if (!k.measure) return k.value ?? '';
|
|
||||||
const r = this.rd(k.measure);
|
|
||||||
return r && r.score !== undefined && k.value ? fill(k.value, r) : '';
|
|
||||||
}
|
|
||||||
protected kpiNote(k: Kpi): string {
|
|
||||||
if (!k.measure) return k.note ?? '';
|
|
||||||
const r = this.rd(k.measure);
|
|
||||||
if (!r || r.score === undefined) return 'Sin valor disponible';
|
|
||||||
return k.note ? fill(k.note, r) : '';
|
|
||||||
}
|
|
||||||
/** A figure's title, with the applied period in it. */
|
|
||||||
protected titled(title: string): string {
|
|
||||||
return title.replace('{p}', this.applied() ?? '');
|
|
||||||
}
|
|
||||||
/** A duration's box, or nothing to draw. */
|
|
||||||
protected boxOf(measure: string | undefined): Figure | undefined {
|
|
||||||
const r = measure ? this.rd(measure) : undefined;
|
|
||||||
return r && r.score !== undefined ? boxFigure(r, this.applied() ?? '') : undefined;
|
|
||||||
}
|
|
||||||
/** TEA's summary of the period: its numbers from the measures (none: no summary). */
|
|
||||||
protected readonly teaSummary = computed(() => {
|
|
||||||
const rd = (c: string) => this.loaded()?.get(c);
|
|
||||||
const status = rd('M28_CASOS_POR_ESTADO');
|
|
||||||
if (!status) return undefined;
|
|
||||||
const n = (r: Reading | undefined, pop: string) => r?.populations[pop] ?? 0;
|
|
||||||
const cat = (r: Reading | undefined, c: string) =>
|
|
||||||
r?.strata['category']?.[c]?.['initial-population'] ?? 0;
|
|
||||||
const days = (c: string) => {
|
|
||||||
const v = rd(c)?.score;
|
|
||||||
return v === undefined
|
|
||||||
? '—'
|
|
||||||
: `${v.toLocaleString('es-MX', { maximumFractionDigits: 1 })} días`;
|
|
||||||
};
|
|
||||||
const confirmed = rd('M24_CONFIRMACION_DIAGNOSTICO')?.score;
|
|
||||||
const withEeg = rd('M21_DIAGNOSTICADOS_CON_EEG');
|
|
||||||
return {
|
|
||||||
evaluated: n(status, 'initial-population'),
|
|
||||||
mchatOnly: cat(status, 'mchat_only'),
|
|
||||||
psychology: cat(status, 'psychology'),
|
|
||||||
neuropediatrics: cat(status, 'neuropediatrics') + cat(status, 'eeg'),
|
|
||||||
confirmed:
|
|
||||||
confirmed === undefined
|
|
||||||
? '—'
|
|
||||||
: `${(confirmed * 100).toLocaleString('es-MX', { maximumFractionDigits: 1 })}%`,
|
|
||||||
toAdos: days('M26_DIAS_MCHAT_ADOS2'),
|
|
||||||
toDiagnosis: days('M27_DIAS_ADOS2_DIAGNOSTICO'),
|
|
||||||
whole: days('M25_DIAS_MCHAT_DIAGNOSTICO'),
|
|
||||||
diagnosed: n(withEeg, 'denominator'),
|
|
||||||
eeg: n(withEeg, 'numerator'),
|
|
||||||
missing: n(rd('M22_DIAGNOSTICADOS_SIN_EEG'), 'numerator'),
|
|
||||||
unusable: cat(rd('M29_CALIDAD_EEG'), 'bad'),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
protected measureTitle(code: string | undefined): string {
|
|
||||||
return (code && this.byName().get(code)?.title) || '';
|
|
||||||
}
|
|
||||||
/** A clinical section's route or figures, drawn from the applied period's reports. */
|
|
||||||
protected routeOf(section: Section): Figure | undefined {
|
|
||||||
if (section.kind !== 'route') return undefined;
|
|
||||||
const steps = section.steps.map((s) => ({ label: s.label, r: this.rd(s.measure) }));
|
|
||||||
return steps.some((s) => s.r?.score !== undefined) ? routeFigure(steps) : undefined;
|
|
||||||
}
|
|
||||||
protected figureOf(spec: FigureSpec): Figure | undefined {
|
|
||||||
const r = this.rd(spec.measure);
|
|
||||||
if (!r || !(r.populations['initial-population'] ?? 0)) return undefined;
|
|
||||||
switch (spec.kind) {
|
|
||||||
case 'donut':
|
|
||||||
return nestedDonut(r, spec.catalog, spec.center);
|
|
||||||
case 'share-donut':
|
|
||||||
return shareDonut(r, spec.catalog, spec.center);
|
|
||||||
case 'counts':
|
|
||||||
return countBars(r, spec.catalog, spec.axis, this.applied() ?? '');
|
|
||||||
case 'age-stack':
|
|
||||||
return ageStack(r, spec.names);
|
|
||||||
case 'age-share':
|
|
||||||
return ageShare(r, spec.names[0]);
|
|
||||||
case 'scenario-bars':
|
|
||||||
return scenarioBars(r, spec.catalog, spec.stratum, name);
|
|
||||||
case 'rates':
|
|
||||||
return rateDots(r, spec);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,169 +0,0 @@
|
|||||||
<section class="card risk-tea" aria-labelledby="tea-risk-title">
|
|
||||||
<h2 id="tea-risk-title" class="risk-title">Alteraciones de EEG relacionadas al TEA</h2>
|
|
||||||
<div class="filters">
|
|
||||||
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
|
||||||
<mat-label>Fecha de corte</mat-label>
|
|
||||||
<input matInput type="date" [ngModel]="cutoff()" (ngModelChange)="cutoff.set($event)" />
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
|
||||||
<mat-label>Ventana de meses</mat-label>
|
|
||||||
<mat-select [value]="window()" (selectionChange)="window.set($event.value)">
|
|
||||||
@for (m of [1, 3, 6, 12]; track m) {
|
|
||||||
<mat-option [value]="m">{{ m }} {{ m === 1 ? 'mes' : 'meses' }}</mat-option>
|
|
||||||
}
|
|
||||||
</mat-select>
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
|
||||||
<mat-label>Estatus de EEG</mat-label>
|
|
||||||
<mat-select [value]="eeg()" (selectionChange)="setFilter(eeg.set.bind(eeg), $event.value)">
|
|
||||||
<mat-option value="">Todos</mat-option>
|
|
||||||
@for (s of eegStatuses | keyvalue; track s.key) {
|
|
||||||
<mat-option [value]="s.key">{{ s.value }}</mat-option>
|
|
||||||
}
|
|
||||||
</mat-select>
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
|
||||||
<mat-label>Grupo de edad</mat-label>
|
|
||||||
<mat-select [value]="age()" (selectionChange)="setFilter(age.set.bind(age), $event.value)">
|
|
||||||
<mat-option value="">Todos</mat-option>
|
|
||||||
@for (a of ages(); track a) {
|
|
||||||
<mat-option [value]="a">{{ ageLabel(a) }}</mat-option>
|
|
||||||
}
|
|
||||||
</mat-select>
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
|
||||||
<mat-label>Puntaje M-CHAT</mat-label>
|
|
||||||
<mat-select
|
|
||||||
[value]="mchat()"
|
|
||||||
(selectionChange)="setFilter(mchat.set.bind(mchat), $event.value)"
|
|
||||||
>
|
|
||||||
<mat-option value="">Todos</mat-option>
|
|
||||||
@for (b of mchatBands; track b.id) {
|
|
||||||
<mat-option [value]="b.id">{{ b.label }}</mat-option>
|
|
||||||
}
|
|
||||||
</mat-select>
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
|
||||||
<mat-label>CSS ADOS-2</mat-label>
|
|
||||||
<mat-select [value]="css()" (selectionChange)="setFilter(css.set.bind(css), $event.value)">
|
|
||||||
<mat-option value="">Todos</mat-option>
|
|
||||||
@for (l of cssLevels; track l.id) {
|
|
||||||
<mat-option [value]="l.id">{{ l.label }}</mat-option>
|
|
||||||
}
|
|
||||||
</mat-select>
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
|
||||||
<mat-label>Estado del caso</mat-label>
|
|
||||||
<mat-select
|
|
||||||
[value]="caseState()"
|
|
||||||
(selectionChange)="setFilter(caseState.set.bind(caseState), $event.value)"
|
|
||||||
>
|
|
||||||
<mat-option value="">Todos</mat-option>
|
|
||||||
@for (c of cases | keyvalue; track c.key) {
|
|
||||||
<mat-option [value]="c.key">{{ c.value }}</mat-option>
|
|
||||||
}
|
|
||||||
</mat-select>
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
|
||||||
<mat-label>Tipo de alteración</mat-label>
|
|
||||||
<mat-select
|
|
||||||
[value]="altered()"
|
|
||||||
(selectionChange)="setFilter(altered.set.bind(altered), $event.value)"
|
|
||||||
>
|
|
||||||
<mat-option value="">Todas</mat-option>
|
|
||||||
@for (a of alterations(); track a) {
|
|
||||||
<mat-option [value]="a">{{ alteration(a) }}</mat-option>
|
|
||||||
}
|
|
||||||
</mat-select>
|
|
||||||
</mat-form-field>
|
|
||||||
<mat-form-field appearance="outline" subscriptSizing="dynamic" class="narrow">
|
|
||||||
<mat-label>Registros por página</mat-label>
|
|
||||||
<input
|
|
||||||
matInput
|
|
||||||
type="number"
|
|
||||||
min="10"
|
|
||||||
max="200"
|
|
||||||
[ngModel]="size()"
|
|
||||||
(ngModelChange)="size.set(+$event || 50); pageIndex.set(0)"
|
|
||||||
/>
|
|
||||||
</mat-form-field>
|
|
||||||
<button mat-stroked-button (click)="consult()">Consultar</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@if (loading()) {
|
|
||||||
<app-loading what="el seguimiento" />
|
|
||||||
} @else {
|
|
||||||
@let s = summary();
|
|
||||||
<div class="eeg-summary" aria-label="EEG de los pacientes filtrados">
|
|
||||||
<h3>EEG de los pacientes filtrados</h3>
|
|
||||||
<div class="counts">
|
|
||||||
<span
|
|
||||||
><strong>{{ s.normal }}</strong> Normales</span
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
><strong>{{ s.abnormal }}</strong> Anormales</span
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
><strong>{{ s.none }}</strong> Sin EEG válido</span
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
@if (s.alterations.length) {
|
|
||||||
<ul class="by-alteration">
|
|
||||||
@for (a of s.alterations; track a[0]) {
|
|
||||||
<li>
|
|
||||||
{{ alteration(a[0]) }}: <strong>{{ a[1] }}</strong>
|
|
||||||
</li>
|
|
||||||
}
|
|
||||||
</ul>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table class="worklist">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Paciente</th>
|
|
||||||
<th>Grupo de edad</th>
|
|
||||||
<th>Estado del caso</th>
|
|
||||||
<th>Último EEG</th>
|
|
||||||
<th class="num">Puntaje M-CHAT</th>
|
|
||||||
<th class="num">CSS ADOS-2</th>
|
|
||||||
<th>Estatus de EEG</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@for (r of shown(); track r.patient.id) {
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<a [routerLink]="['/indicadores', domain(), 'pacientes', r.patient.id]">{{
|
|
||||||
r.name
|
|
||||||
}}</a>
|
|
||||||
</td>
|
|
||||||
<td>{{ r.ageGroup ? ageLabel(r.ageGroup) : 'Sin dato' }}</td>
|
|
||||||
<td>{{ cases[r.case] ?? r.case }}</td>
|
|
||||||
<td>{{ r.lastEeg ?? '—' }}</td>
|
|
||||||
<td class="num">{{ r.mchat ?? '—' }}</td>
|
|
||||||
<td class="num">{{ r.css ?? '—' }}</td>
|
|
||||||
<td>{{ eegStatuses[r.eegStatus] ?? r.eegStatus }}</td>
|
|
||||||
</tr>
|
|
||||||
} @empty {
|
|
||||||
<tr>
|
|
||||||
<td colspan="7" class="muted">Nadie en la lista con estos filtros.</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="pager">
|
|
||||||
<button mat-button [disabled]="pageIndex() === 0" (click)="pageIndex.set(pageIndex() - 1)">
|
|
||||||
Anterior
|
|
||||||
</button>
|
|
||||||
<span>Página {{ pageIndex() + 1 }} de {{ pages() }} · {{ filtered().length }} pacientes</span>
|
|
||||||
<button
|
|
||||||
mat-button
|
|
||||||
[disabled]="pageIndex() + 1 >= pages()"
|
|
||||||
(click)="pageIndex.set(pageIndex() + 1)"
|
|
||||||
>
|
|
||||||
Siguiente
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</section>
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
.risk-tea {
|
|
||||||
background: var(--color-surface);
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
border-radius: 8px;
|
|
||||||
margin-top: 24px;
|
|
||||||
padding: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.risk-title {
|
|
||||||
font-family: var(--font-heading);
|
|
||||||
font-size: 24px;
|
|
||||||
font-weight: 700;
|
|
||||||
margin: 0 0 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filters {
|
|
||||||
align-items: center;
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 12px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
|
|
||||||
.narrow {
|
|
||||||
width: 160px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.eeg-summary {
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
border-radius: 8px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
padding: 12px 16px;
|
|
||||||
|
|
||||||
h3 {
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 500;
|
|
||||||
margin: 0 0 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.counts {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.by-alteration {
|
|
||||||
columns: 2;
|
|
||||||
margin: 8px 0 0;
|
|
||||||
padding-left: 18px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.pager {
|
|
||||||
align-items: center;
|
|
||||||
display: flex;
|
|
||||||
gap: 12px;
|
|
||||||
justify-content: flex-end;
|
|
||||||
margin-top: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.worklist {
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
th,
|
|
||||||
td {
|
|
||||||
border-bottom: 1px solid var(--color-border);
|
|
||||||
padding: 8px 10px;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
th {
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.num {
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,176 +0,0 @@
|
|||||||
import { KeyValuePipe } from '@angular/common';
|
|
||||||
import { Component, computed, inject, input, resource, signal } from '@angular/core';
|
|
||||||
import { FormsModule } from '@angular/forms';
|
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
|
||||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
||||||
import { MatInputModule } from '@angular/material/input';
|
|
||||||
import { MatSelectModule } from '@angular/material/select';
|
|
||||||
import { RouterLink } from '@angular/router';
|
|
||||||
import type { Patient } from 'fhir/r4';
|
|
||||||
import { EXT, Fhir, resources } from '../fhir';
|
|
||||||
import { Loading } from '../loading';
|
|
||||||
import { ageLabel } from './figures';
|
|
||||||
import { name } from './measures';
|
|
||||||
|
|
||||||
/** One child on TEA's list, as the list shows her (core.tea.follow_up). */
|
|
||||||
export interface TeaRow {
|
|
||||||
patient: Patient;
|
|
||||||
name: string;
|
|
||||||
ageGroup: string;
|
|
||||||
case: string;
|
|
||||||
status: string;
|
|
||||||
eegStatus: string;
|
|
||||||
alterations: string[];
|
|
||||||
lastEeg?: string;
|
|
||||||
mchat?: number;
|
|
||||||
css?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
const has = (p: Patient, n: string) => (p.extension ?? []).filter((e) => e.url === EXT + n);
|
|
||||||
|
|
||||||
export function teaRow(p: Patient): TeaRow {
|
|
||||||
const coded = (n: string) => has(p, n)[0]?.valueCoding?.code ?? '';
|
|
||||||
return {
|
|
||||||
patient: p,
|
|
||||||
name: p.name?.[0]?.text ?? (p.id ?? '').slice(0, 8),
|
|
||||||
ageGroup: has(p, 'tea-age-group')[0]?.valueString ?? '',
|
|
||||||
case: coded('tea-case'),
|
|
||||||
status: coded('follow-up-status'),
|
|
||||||
eegStatus: coded('tea-eeg-status'),
|
|
||||||
alterations: has(p, 'tea-eeg-alteration').map((e) => e.valueCoding?.code ?? ''),
|
|
||||||
lastEeg: has(p, 'tea-last-eeg')[0]?.valueDate,
|
|
||||||
mchat: has(p, 'mchat-score')[0]?.valueInteger,
|
|
||||||
css: has(p, 'ados2-css')[0]?.valueInteger,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** M-CHAT-R risk bands and ADOS-2 CSS levels, as the filters offer them. */
|
|
||||||
const MCHAT = [
|
|
||||||
{ id: 'low', label: 'Bajo (0 a 2)', test: (v: number) => v <= 2 },
|
|
||||||
{ id: 'medium', label: 'Medio (3 a 7)', test: (v: number) => v >= 3 && v <= 7 },
|
|
||||||
{ id: 'high', label: 'Alto (8 a 20)', test: (v: number) => v >= 8 },
|
|
||||||
];
|
|
||||||
const CSS = [
|
|
||||||
{ id: 'minimal', label: 'Mínimo (1 a 2)', test: (v: number) => v <= 2 },
|
|
||||||
{ id: 'low', label: 'Bajo (3 a 4)', test: (v: number) => v >= 3 && v <= 4 },
|
|
||||||
{ id: 'moderate', label: 'Moderado (5 a 7)', test: (v: number) => v >= 5 && v <= 7 },
|
|
||||||
{ id: 'high', label: 'Alto (8 a 10)', test: (v: number) => v >= 8 },
|
|
||||||
];
|
|
||||||
const EEG_STATUS: Record<string, string> = {
|
|
||||||
normal: 'Normal',
|
|
||||||
abnormal: 'Anormal',
|
|
||||||
no_valid_eeg: 'Sin EEG válido',
|
|
||||||
};
|
|
||||||
const CASE: Record<string, string> = {
|
|
||||||
confirmed: 'Diagnóstico confirmado',
|
|
||||||
in_process: 'En proceso',
|
|
||||||
not_confirmed: 'Sin TEA',
|
|
||||||
};
|
|
||||||
/** `theta_power:above` → "theta_power (aumentado)". */
|
|
||||||
export const alteration = (a: string) =>
|
|
||||||
a.replace(/:(above|below)$/, (_, s) => (s === 'above' ? ' (aumentado)' : ' (disminuido)'));
|
|
||||||
|
|
||||||
/** "Análisis de Riesgo" for TEA: the children active in the window, what their EEGs show,
|
|
||||||
* filtered as the old page filtered them. */
|
|
||||||
@Component({
|
|
||||||
selector: 'app-tab-riesgos-tea',
|
|
||||||
imports: [
|
|
||||||
FormsModule,
|
|
||||||
KeyValuePipe,
|
|
||||||
Loading,
|
|
||||||
MatButtonModule,
|
|
||||||
MatFormFieldModule,
|
|
||||||
MatInputModule,
|
|
||||||
MatSelectModule,
|
|
||||||
RouterLink,
|
|
||||||
],
|
|
||||||
templateUrl: './tab-riesgos-tea.html',
|
|
||||||
styleUrls: ['./tab-riesgos.scss', './tab-riesgos-tea.scss'],
|
|
||||||
})
|
|
||||||
export class TabRiesgosTea {
|
|
||||||
private readonly fhir = inject(Fhir);
|
|
||||||
readonly domain = input.required<string>();
|
|
||||||
|
|
||||||
protected readonly cutoff = signal('');
|
|
||||||
protected readonly window = signal(3);
|
|
||||||
protected readonly eeg = signal('');
|
|
||||||
protected readonly age = signal('');
|
|
||||||
protected readonly mchat = signal('');
|
|
||||||
protected readonly css = signal('');
|
|
||||||
protected readonly caseState = signal('');
|
|
||||||
protected readonly altered = signal('');
|
|
||||||
protected readonly size = signal(50);
|
|
||||||
protected readonly pageIndex = signal(0);
|
|
||||||
/** The query as last asked for ("Consultar"). */
|
|
||||||
private readonly asked = signal({ cutoff: '', window: 3 });
|
|
||||||
|
|
||||||
protected readonly mchatBands = MCHAT;
|
|
||||||
protected readonly cssLevels = CSS;
|
|
||||||
protected readonly eegStatuses = EEG_STATUS;
|
|
||||||
protected readonly cases = CASE;
|
|
||||||
protected readonly label = name;
|
|
||||||
protected readonly ageLabel = ageLabel;
|
|
||||||
protected readonly alteration = alteration;
|
|
||||||
|
|
||||||
private readonly list = resource({
|
|
||||||
params: () => ({ domain: this.domain(), ...this.asked() }),
|
|
||||||
loader: async ({ params: { domain, cutoff, window } }) => {
|
|
||||||
const pages = await this.fhir.all(domain, 'Patient', {
|
|
||||||
'follow-up-window': window,
|
|
||||||
...(cutoff ? { 'follow-up-cutoff': cutoff } : {}),
|
|
||||||
_count: 200,
|
|
||||||
});
|
|
||||||
return resources<Patient>(pages, 'Patient').map(teaRow);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
protected readonly loading = computed(() => this.list.isLoading());
|
|
||||||
protected readonly all = computed(() => this.list.value() ?? []);
|
|
||||||
protected readonly ages = computed(() => [...new Set(this.all().map((r) => r.ageGroup))].sort());
|
|
||||||
protected readonly alterations = computed(() =>
|
|
||||||
[...new Set(this.all().flatMap((r) => r.alterations))].sort(),
|
|
||||||
);
|
|
||||||
|
|
||||||
/** The children the filters keep. */
|
|
||||||
protected readonly filtered = computed(() => {
|
|
||||||
const band = MCHAT.find((b) => b.id === this.mchat());
|
|
||||||
const level = CSS.find((l) => l.id === this.css());
|
|
||||||
return this.all().filter(
|
|
||||||
(r) =>
|
|
||||||
(!this.eeg() || r.eegStatus === this.eeg()) &&
|
|
||||||
(!this.age() || r.ageGroup === this.age()) &&
|
|
||||||
(!band || (r.mchat !== undefined && band.test(r.mchat))) &&
|
|
||||||
(!level || (r.css !== undefined && level.test(r.css))) &&
|
|
||||||
(!this.caseState() || r.case === this.caseState()) &&
|
|
||||||
(!this.altered() || r.alterations.includes(this.altered())),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
protected readonly shown = computed(() =>
|
|
||||||
this.filtered().slice(this.pageIndex() * this.size(), (this.pageIndex() + 1) * this.size()),
|
|
||||||
);
|
|
||||||
protected readonly pages = computed(() =>
|
|
||||||
Math.max(1, Math.ceil(this.filtered().length / this.size())),
|
|
||||||
);
|
|
||||||
|
|
||||||
/** "EEG de los pacientes filtrados": how many normal, abnormal, without one, by alteration. */
|
|
||||||
protected readonly summary = computed(() => {
|
|
||||||
const rows = this.filtered();
|
|
||||||
const count = (s: string) => rows.filter((r) => r.eegStatus === s).length;
|
|
||||||
const by = new Map<string, number>();
|
|
||||||
for (const r of rows) for (const a of r.alterations) by.set(a, (by.get(a) ?? 0) + 1);
|
|
||||||
return {
|
|
||||||
normal: count('normal'),
|
|
||||||
abnormal: count('abnormal'),
|
|
||||||
none: count('no_valid_eeg'),
|
|
||||||
alterations: [...by.entries()].sort((a, b) => b[1] - a[1]),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
protected consult(): void {
|
|
||||||
this.pageIndex.set(0);
|
|
||||||
this.asked.set({ cutoff: this.cutoff(), window: this.window() });
|
|
||||||
}
|
|
||||||
protected setFilter(set: (v: string) => void, value: string): void {
|
|
||||||
set(value);
|
|
||||||
this.pageIndex.set(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,12 @@
|
|||||||
|
<div class="export-actions"><button mat-stroked-button (click)="exportList('xlsx')" [disabled]="exporting() || !page() || invalidAge() || queryLoading() || loading()">Exportar Excel (.xlsx)</button><button mat-stroked-button (click)="exportList('pdf')" [disabled]="exporting() || !page() || invalidAge() || queryLoading() || loading()">Exportar PDF</button></div>
|
||||||
|
@if (exportMessage()) { <p role="alert">{{ exportMessage() }}</p> }
|
||||||
<form class="filters card" (submit)="$event.preventDefault()">
|
<form class="filters card" (submit)="$event.preventDefault()">
|
||||||
|
@if (globalFilters()) {
|
||||||
|
<mat-form-field appearance="outline" subscriptSizing="dynamic"><mat-label>Buscar nombre o identificador</mat-label><input matInput [ngModel]="search()" (ngModelChange)="search.set($event)" name="search" /></mat-form-field>
|
||||||
|
<mat-form-field appearance="outline" subscriptSizing="dynamic"><mat-label>Edad mínima</mat-label><input matInput type="number" min="0" max="150" step="1" [ngModel]="ageMin()" (ngModelChange)="ageMin.set($event)" name="ageMin" /></mat-form-field>
|
||||||
|
<mat-form-field appearance="outline" subscriptSizing="dynamic"><mat-label>Edad máxima</mat-label><input matInput type="number" min="0" max="150" step="1" [ngModel]="ageMax()" (ngModelChange)="ageMax.set($event)" name="ageMax" /></mat-form-field>
|
||||||
|
<button mat-stroked-button type="button" (click)="ageMin.set(null); ageMax.set(null)">Limpiar edades</button>
|
||||||
|
}
|
||||||
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
||||||
<mat-label>Fecha de corte</mat-label>
|
<mat-label>Fecha de corte</mat-label>
|
||||||
<input
|
<input
|
||||||
@@ -38,7 +46,7 @@
|
|||||||
<mat-label>Orden</mat-label>
|
<mat-label>Orden</mat-label>
|
||||||
<mat-select [value]="sort()" (selectionChange)="sort.set($event.value)">
|
<mat-select [value]="sort()" (selectionChange)="sort.set($event.value)">
|
||||||
<mat-option value="-recent">Estudio más reciente</mat-option>
|
<mat-option value="-recent">Estudio más reciente</mat-option>
|
||||||
<mat-option value="-risk-cin2">Mayor riesgo de LIEAG+</mat-option>
|
<mat-option value="-risk-cin2">Mayor riesgo de CIN2+</mat-option>
|
||||||
<mat-option value="-risk-cancer">Mayor riesgo de cáncer</mat-option>
|
<mat-option value="-risk-cancer">Mayor riesgo de cáncer</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
@@ -51,6 +59,8 @@
|
|||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</form>
|
</form>
|
||||||
|
@if (invalidAge()) { <p role="alert">Indique edades enteras entre 0 y 150; la mínima no puede superar la máxima. El rango no está aplicado.</p> }
|
||||||
|
@if (!globalFilters() && !capabilities.isLoading()) { <p class="muted">El servidor no declara búsqueda global ni filtros de edad.</p> }
|
||||||
|
|
||||||
@if (error()) {
|
@if (error()) {
|
||||||
<p class="muted" role="alert">No se pudo leer la lista de seguimiento.</p>
|
<p class="muted" role="alert">No se pudo leer la lista de seguimiento.</p>
|
||||||
@@ -61,12 +71,13 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Paciente</th>
|
<th>Paciente</th>
|
||||||
<th>Grupo de edad</th>
|
<th>Edad</th>
|
||||||
<th>Estatus</th>
|
<th>Estatus</th>
|
||||||
|
<th>Etapas</th>
|
||||||
<th>Última citología</th>
|
<th>Última citología</th>
|
||||||
<th>VPH</th>
|
<th>VPH</th>
|
||||||
<th>Biopsia</th>
|
<th>Biopsia</th>
|
||||||
<th>Riesgo LIEAG+ ({{ horizon() }} a)</th>
|
<th>Riesgo CIN2+ ({{ horizon() }} a)</th>
|
||||||
<th>Riesgo cáncer ({{ horizon() }} a)</th>
|
<th>Riesgo cáncer ({{ horizon() }} a)</th>
|
||||||
<th>Días toma → diagnóstico</th>
|
<th>Días toma → diagnóstico</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -75,15 +86,16 @@
|
|||||||
@for (row of rows(); track row.patient.id) {
|
@for (row of rows(); track row.patient.id) {
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a [routerLink]="['/indicadores', domain(), 'pacientes', row.patient.id]">{{
|
<a [routerLink]="['/indicadores', domain(), 'pacientes', row.patient.id]" [queryParams]="{ corte: applied(), muestra: row.cytology?.date }">{{
|
||||||
row.name ?? row.patient.id!.slice(0, 10)
|
patientLabel(row.patient)
|
||||||
}}</a>
|
}}</a>
|
||||||
@if (row.curp) {
|
@if (row.curp) {
|
||||||
<div class="muted curp">{{ row.curp }}</div>
|
<div class="muted curp">{{ row.curp }}</div>
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ row.ageGroup }}</td>
|
<td>{{ row.age ?? 'No disponible' }}</td>
|
||||||
<td>{{ name(row.status) }}</td>
|
<td>{{ name(row.status) }}</td>
|
||||||
|
<td><div class="stage-compact"><app-stages [sample]="row.cytology?.date" [report]="row.cytology?.result ? row.cytology?.reportDate : undefined" [cutoff]="applied()" [facts]="row.stageFacts" /><button class="stage-toggle" type="button" [attr.aria-label]="expanded() === row.patient.id ? 'Ocultar etapas' : 'Mostrar etapas'" [attr.aria-expanded]="expanded() === row.patient.id" (click)="expanded.set(expanded() === row.patient.id ? undefined : row.patient.id)"><span [class.open]="expanded() === row.patient.id" aria-hidden="true">⌄</span></button></div></td>
|
||||||
<td>
|
<td>
|
||||||
@if (row.cytology; as c) {
|
@if (row.cytology; as c) {
|
||||||
{{ c.date }} ·
|
{{ c.date }} ·
|
||||||
@@ -122,9 +134,10 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="num">{{ row.daysToDiagnosis ?? '—' }}</td>
|
<td class="num">{{ row.daysToDiagnosis ?? '—' }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@if (expanded() === row.patient.id) { <tr><td colspan="10"><app-stages [sample]="row.cytology?.date" [report]="row.cytology?.result ? row.cytology?.reportDate : undefined" [cutoff]="applied()" [facts]="row.stageFacts" [detail]="true" /></td></tr> }
|
||||||
} @empty {
|
} @empty {
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="9" class="muted">
|
<td colspan="10" class="muted">
|
||||||
{{ page() ? 'Nadie en la lista con estos filtros.' : 'Cargando…' }}
|
{{ page() ? 'Nadie en la lista con estos filtros.' : 'Cargando…' }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -40,3 +40,8 @@ a {
|
|||||||
.pager .muted {
|
.pager .muted {
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
|
.export-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-bottom: 12px; }
|
||||||
|
.stage-compact { display:flex; align-items:center; gap:0; }
|
||||||
|
.stage-toggle { display:grid; place-items:center; flex:0 0 32px; width:32px; height:32px; border:0; background:transparent; color:#385c6c; cursor:pointer; padding:0; }
|
||||||
|
.stage-toggle:focus-visible { outline:2px solid #2778b8; outline-offset:2px; }
|
||||||
|
.stage-toggle span { display:block; font-size:18px; line-height:1; transition:transform 120ms ease; }.stage-toggle span.open { transform:rotate(180deg); }
|
||||||
|
|||||||
@@ -8,8 +8,13 @@ import { MatSelectModule } from '@angular/material/select';
|
|||||||
import { RouterLink } from '@angular/router';
|
import { RouterLink } from '@angular/router';
|
||||||
import type { Bundle } from 'fhir/r4';
|
import type { Bundle } from 'fhir/r4';
|
||||||
import { Fhir } from '../fhir';
|
import { Fhir } from '../fhir';
|
||||||
import { rows, windowStart } from './follow-up';
|
import { patientLabel, rows, windowStart } from './follow-up';
|
||||||
import { name } from './measures';
|
import { name } from './measures';
|
||||||
|
import { Stages } from '../paciente/stages';
|
||||||
|
import { stages } from '../paciente/stages';
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { firstValueFrom } from 'rxjs';
|
||||||
|
import { downloadDocument } from '../export-document';
|
||||||
|
|
||||||
const STATUSES = ['case', 'pre_colposcopy', 'post_colposcopy', 'post_treatment'];
|
const STATUSES = ['case', 'pre_colposcopy', 'post_colposcopy', 'post_treatment'];
|
||||||
|
|
||||||
@@ -25,12 +30,16 @@ const STATUSES = ['case', 'pre_colposcopy', 'post_colposcopy', 'post_treatment']
|
|||||||
MatInputModule,
|
MatInputModule,
|
||||||
MatSelectModule,
|
MatSelectModule,
|
||||||
RouterLink,
|
RouterLink,
|
||||||
|
Stages,
|
||||||
],
|
],
|
||||||
templateUrl: './tab-riesgos.html',
|
templateUrl: './tab-riesgos.html',
|
||||||
styleUrl: './tab-riesgos.scss',
|
styleUrl: './tab-riesgos.scss',
|
||||||
})
|
})
|
||||||
export class TabRiesgos {
|
export class TabRiesgos {
|
||||||
private readonly fhir = inject(Fhir);
|
private readonly fhir = inject(Fhir);
|
||||||
|
private readonly http = inject(HttpClient);
|
||||||
|
protected readonly exporting = signal(false);
|
||||||
|
protected readonly exportMessage = signal('');
|
||||||
readonly domain = input.required<string>();
|
readonly domain = input.required<string>();
|
||||||
|
|
||||||
protected readonly cutoff = signal<string>('');
|
protected readonly cutoff = signal<string>('');
|
||||||
@@ -39,11 +48,29 @@ export class TabRiesgos {
|
|||||||
protected readonly horizon = signal(5);
|
protected readonly horizon = signal(5);
|
||||||
protected readonly sort = signal('-recent');
|
protected readonly sort = signal('-recent');
|
||||||
protected readonly size = signal(20);
|
protected readonly size = signal(20);
|
||||||
|
protected readonly ageMin = signal<number | null>(null);
|
||||||
|
protected readonly ageMax = signal<number | null>(null);
|
||||||
|
protected readonly search = signal('');
|
||||||
|
protected readonly expanded = signal<string | undefined>(undefined);
|
||||||
|
protected readonly invalidAge = computed(() => {
|
||||||
|
const a = this.ageMin(), b = this.ageMax();
|
||||||
|
return [a,b].some(n => n !== null && (!Number.isInteger(n) || n < 0 || n > 150)) || (a !== null && b !== null && a > b);
|
||||||
|
});
|
||||||
|
protected readonly capabilities = resource({
|
||||||
|
params: () => this.domain(),
|
||||||
|
loader: async ({params}) => this.fhir.search(params, 'metadata') as Promise<any>,
|
||||||
|
});
|
||||||
|
protected readonly globalFilters = computed(() => {
|
||||||
|
const patient = this.capabilities.value()?.rest?.flatMap((r: any) => r.resource ?? []).find((r: any) => r.type === 'Patient');
|
||||||
|
const names = new Set<string>((patient?.searchParam ?? []).map((x: any) => x.name));
|
||||||
|
return ['follow-up-age-min','follow-up-age-max','follow-up-search'].every(n => names.has(n));
|
||||||
|
});
|
||||||
/** A page the user moved to (`next`/`previous`), else the first. */
|
/** A page the user moved to (`next`/`previous`), else the first. */
|
||||||
private readonly moved = signal<Bundle | undefined>(undefined);
|
private readonly moved = signal<Bundle | undefined>(undefined);
|
||||||
|
|
||||||
protected readonly statuses = STATUSES;
|
protected readonly statuses = STATUSES;
|
||||||
protected readonly name = name;
|
protected readonly name = name;
|
||||||
|
protected readonly patientLabel = patientLabel;
|
||||||
|
|
||||||
private readonly first = resource({
|
private readonly first = resource({
|
||||||
params: () => ({
|
params: () => ({
|
||||||
@@ -54,6 +81,9 @@ export class TabRiesgos {
|
|||||||
'risk-horizon': this.horizon(),
|
'risk-horizon': this.horizon(),
|
||||||
_sort: this.sort(),
|
_sort: this.sort(),
|
||||||
_count: this.size(),
|
_count: this.size(),
|
||||||
|
'follow-up-age-min': this.globalFilters() && !this.invalidAge() ? this.ageMin() ?? undefined : undefined,
|
||||||
|
'follow-up-age-max': this.globalFilters() && !this.invalidAge() ? this.ageMax() ?? undefined : undefined,
|
||||||
|
'follow-up-search': this.globalFilters() ? this.search().trim().replace(/\s+/g, ' ') || undefined : undefined,
|
||||||
}),
|
}),
|
||||||
loader: ({ params: { domain, ...params } }) => {
|
loader: ({ params: { domain, ...params } }) => {
|
||||||
this.moved.set(undefined);
|
this.moved.set(undefined);
|
||||||
@@ -65,6 +95,7 @@ export class TabRiesgos {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
protected readonly loading = signal(false);
|
protected readonly loading = signal(false);
|
||||||
|
protected readonly queryLoading = computed(() => this.first.isLoading());
|
||||||
protected readonly page = computed(() => this.moved() ?? this.first.value());
|
protected readonly page = computed(() => this.moved() ?? this.first.value());
|
||||||
/** The cut-off as applied (the server's default when none is given). */
|
/** The cut-off as applied (the server's default when none is given). */
|
||||||
protected readonly applied = computed(() => {
|
protected readonly applied = computed(() => {
|
||||||
@@ -84,6 +115,40 @@ export class TabRiesgos {
|
|||||||
});
|
});
|
||||||
protected readonly error = computed(() => this.first.error());
|
protected readonly error = computed(() => this.first.error());
|
||||||
|
|
||||||
|
protected async exportList(format: 'xlsx' | 'pdf'): Promise<void> {
|
||||||
|
if (!this.page() || this.invalidAge() || !this.applied() || this.queryLoading() || this.loading()) return;
|
||||||
|
const total = this.page()!.total ?? 0, limit = format === 'pdf' ? 1000 : 5000;
|
||||||
|
if (total > limit) { this.exportMessage.set(`La consulta tiene ${total} pacientes; el límite para ${format.toUpperCase()} es ${limit}. Ajuste los filtros.`); return; }
|
||||||
|
const cutoff = this.applied(), months = this.window(), horizon = this.horizon();
|
||||||
|
const params = {'follow-up-window': months, 'follow-up-cutoff': cutoff, 'follow-up-status': this.status() || undefined,
|
||||||
|
'risk-horizon': horizon, _sort: this.sort(), _count: 200,
|
||||||
|
'follow-up-age-min': this.globalFilters() ? this.ageMin() ?? undefined : undefined,
|
||||||
|
'follow-up-age-max': this.globalFilters() ? this.ageMax() ?? undefined : undefined,
|
||||||
|
'follow-up-search': this.globalFilters() ? this.search().trim().replace(/\s+/g,' ') || undefined : undefined,
|
||||||
|
_revinclude: ['DiagnosticReport:subject','RiskAssessment:subject'], '_include:iterate':'DiagnosticReport:result'};
|
||||||
|
this.exporting.set(true); this.exportMessage.set('');
|
||||||
|
try {
|
||||||
|
const caps = await firstValueFrom(this.http.get<{xlsx_limit:number;pdf_limit:number}>('/api/cacu/exports/capabilities'));
|
||||||
|
if (total > (format === 'pdf' ? caps.pdf_limit : caps.xlsx_limit)) throw new Error('La consulta supera el límite del servidor.');
|
||||||
|
const pages = await this.fhir.all(this.domain(), 'Patient', params);
|
||||||
|
const all = pages.flatMap(page => rows(page, windowStart(cutoff, months), cutoff, horizon));
|
||||||
|
if (all.length !== total || new Set(all.map(r => r.patient.id)).size !== total || pages.some(p => p.total !== total))
|
||||||
|
throw new Error('La consulta cambió durante la exportación; vuelva a intentarlo.');
|
||||||
|
const pct = (n?: number) => n === undefined ? 'No disponible' : `${(100*n).toFixed(1)} %`;
|
||||||
|
const sortLabels: Record<string,string> = {'-recent':'Estudio más reciente','-risk-cin2':'Mayor riesgo de CIN2+','-risk-cancer':'Mayor riesgo de cáncer'};
|
||||||
|
const routes = all.map(r => stages(r.cytology?.date,r.cytology?.result ? r.cytology.reportDate : undefined,cutoff,r.stageFacts));
|
||||||
|
await downloadDocument(this.http, format, {title:'Resultados de seguimiento', parameters:[['Fecha de corte',cutoff],['Ventana consultada',`${windowStart(cutoff,months)} al ${cutoff} (${months} ${months === 1 ? 'mes' : 'meses'})`],['Estatus de seguimiento',params['follow-up-status'] ? name(params['follow-up-status']) : 'Todos'],['Orden',sortLabels[params._sort] ?? params._sort],['Horizonte de la probabilidad',`${horizon} ${horizon === 1 ? 'año' : 'años'}`],['Nombre o identificador contiene',params['follow-up-search'] || 'Todos'],['Edad mínima (años)',String(params['follow-up-age-min'] ?? 'Sin límite')],['Edad máxima (años)',String(params['follow-up-age-max'] ?? 'Sin límite')],['Registros',String(total)]],
|
||||||
|
columns:['Paciente','Edad','Estatus','Etapas','Última citología','VPH','Biopsia','Riesgo CIN2+','Riesgo cáncer','Días a diagnóstico'],
|
||||||
|
row_stages: routes.map(route => route.map(s => ({state:s.state, ...(s.provenance ? {provenance:s.provenance} : {}), ...(s.date ? {date:s.date} : {})}))),
|
||||||
|
rows:all.map((r,i)=>[`${patientLabel(r.patient)}${r.curp ? '\n'+r.curp : ''}`,String(r.age ?? 'No disponible'),name(r.status),
|
||||||
|
routes[i].map(s=>`${s.label}: ${s.state}${s.date ? ' '+s.date : ''}${s.provenance ? ' ('+s.provenance+')' : ''}`).join('\n'),
|
||||||
|
r.cytology ? `${r.cytology.date} · ${r.cytology.result ? name(r.cytology.result) : r.cytology.adequacy === 'unsatisfactory' ? 'Insatisfactoria' : 'Pendiente'}` : '—',
|
||||||
|
r.hpv ? `${r.hpv.positive ? 'Positivo' : 'Negativo'}${r.hpv.types1618 ? ' (16/18)' : ''}` : '—',
|
||||||
|
r.biopsy ? `${r.biopsy.date} · ${name(r.biopsy.histology ?? '') || 'Sin dato'}` : '—',pct(r.risk.cin2),pct(r.risk.cancer),String(r.daysToDiagnosis ?? '—')])});
|
||||||
|
} catch (error) { this.exportMessage.set(error instanceof Error ? error.message : 'No se pudo generar la exportación.'); }
|
||||||
|
finally { this.exporting.set(false); }
|
||||||
|
}
|
||||||
|
|
||||||
protected has(relation: 'next' | 'previous'): boolean {
|
protected has(relation: 'next' | 'previous'): boolean {
|
||||||
return !!this.page()?.link?.some((l) => l.relation === relation);
|
return !!this.page()?.link?.some((l) => l.relation === relation);
|
||||||
}
|
}
|
||||||
@@ -93,8 +158,10 @@ export class TabRiesgos {
|
|||||||
const next = page && this.fhir.follow(this.domain(), page, relation);
|
const next = page && this.fhir.follow(this.domain(), page, relation);
|
||||||
if (!next) return;
|
if (!next) return;
|
||||||
this.loading.set(true);
|
this.loading.set(true);
|
||||||
|
const signature = JSON.stringify([this.cutoff(), this.window(), this.status(), this.horizon(), this.sort(), this.size(), this.ageMin(), this.ageMax(), this.search()]);
|
||||||
try {
|
try {
|
||||||
this.moved.set(await next);
|
const found = await next;
|
||||||
|
if (signature === JSON.stringify([this.cutoff(), this.window(), this.status(), this.horizon(), this.sort(), this.size(), this.ageMin(), this.ageMax(), this.search()])) this.moved.set(found);
|
||||||
} finally {
|
} finally {
|
||||||
this.loading.set(false);
|
this.loading.set(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,11 @@ import type { Measure, MeasureReport } from 'fhir/r4';
|
|||||||
import { Fhir, resources } from '../fhir';
|
import { Fhir, resources } from '../fhir';
|
||||||
import { Figure, Plot } from '../plot';
|
import { Figure, Plot } from '../plot';
|
||||||
import { history, periods, PeriodType, periodTypes, reading } from './measures';
|
import { history, periods, PeriodType, periodTypes, reading } from './measures';
|
||||||
import { Loading } from '../loading';
|
|
||||||
|
|
||||||
/** Each measure over time: every period of the chosen kind, oldest first. */
|
/** Each measure over time: every period of the chosen kind, oldest first. */
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-tab-trazabilidad',
|
selector: 'app-tab-trazabilidad',
|
||||||
imports: [Loading, MatButtonToggleModule, MatCardModule, Plot],
|
imports: [MatButtonToggleModule, MatCardModule, Plot],
|
||||||
template: `
|
template: `
|
||||||
<div class="bar">
|
<div class="bar">
|
||||||
<mat-button-toggle-group
|
<mat-button-toggle-group
|
||||||
@@ -23,7 +22,7 @@ import { Loading } from '../loading';
|
|||||||
</mat-button-toggle-group>
|
</mat-button-toggle-group>
|
||||||
</div>
|
</div>
|
||||||
@if (series.isLoading()) {
|
@if (series.isLoading()) {
|
||||||
<app-loading what="las series" text="Calculando las series del periodo…" />
|
<p class="muted">Calculando…</p>
|
||||||
}
|
}
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
@for (item of figures(); track item.measure.id) {
|
@for (item of figures(); track item.measure.id) {
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
import { Component, input } from '@angular/core';
|
|
||||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
|
||||||
|
|
||||||
/** What a page or a figure shows while its data comes, as the old app did: a progress bar
|
|
||||||
* named for what loads, "Cargando …" in words, and for a figure the place it will take. */
|
|
||||||
@Component({
|
|
||||||
selector: 'app-loading',
|
|
||||||
imports: [MatProgressBarModule],
|
|
||||||
template: `
|
|
||||||
<mat-progress-bar mode="indeterminate" [attr.aria-label]="'Cargando ' + what()" />
|
|
||||||
<p class="state" role="status">{{ text() || 'Cargando ' + what() + '…' }}</p>
|
|
||||||
@if (figure()) {
|
|
||||||
<div class="skeleton" aria-hidden="true"></div>
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
styles: `
|
|
||||||
:host {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
:host(.figure) {
|
|
||||||
min-height: 12rem;
|
|
||||||
}
|
|
||||||
.state {
|
|
||||||
color: var(--color-text-secondary);
|
|
||||||
font-size: 0.875rem;
|
|
||||||
margin: 8px 0;
|
|
||||||
}
|
|
||||||
.skeleton {
|
|
||||||
background: var(--color-border);
|
|
||||||
border-radius: 10px;
|
|
||||||
flex: 1;
|
|
||||||
min-height: 10rem;
|
|
||||||
opacity: 0.35;
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
host: { '[class.figure]': 'figure()' },
|
|
||||||
})
|
|
||||||
export class Loading {
|
|
||||||
/** What is loading, in words: "los indicadores", "la figura". */
|
|
||||||
readonly what = input.required<string>();
|
|
||||||
/** The whole line instead ("Calculando los indicadores…"). */
|
|
||||||
readonly text = input('');
|
|
||||||
/** A figure's skeleton under the bar. */
|
|
||||||
readonly figure = input(false);
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
<section class="page">
|
<section class="page">
|
||||||
|
@if (domain() === 'cacu' && patient()) { <div class="export-actions"><button mat-stroked-button [disabled]="exporting()" (click)="exportPatient()">Exportar ficha PDF</button></div> }
|
||||||
|
@if (exportError()) { <p role="alert">{{ exportError() }}</p> }
|
||||||
<a mat-button [routerLink]="['/indicadores', domain()]"
|
<a mat-button [routerLink]="['/indicadores', domain()]"
|
||||||
><mat-icon>arrow_back</mat-icon> Regresar</a
|
><mat-icon>arrow_back</mat-icon> Regresar</a
|
||||||
>
|
>
|
||||||
@@ -6,7 +8,8 @@
|
|||||||
<p class="muted" role="alert">No se encontró la paciente.</p>
|
<p class="muted" role="alert">No se encontró la paciente.</p>
|
||||||
} @else if (patient(); as p) {
|
} @else if (patient(); as p) {
|
||||||
<h1>
|
<h1>
|
||||||
{{ identity().name ?? 'Paciente' }} <code class="muted">{{ p.id!.slice(0, 10) }}</code>
|
{{ identity().name ?? p.id?.slice(0, 10) ?? 'No disponible' }} @if (identity().name && p.id) { <code class="muted">{{ p.id.slice(0, 10) }}</code> }
|
||||||
|
@if (domain() === 'cacu') { · Edad: {{ exactAge(p.birthDate, cutoff) ?? 'No disponible' }} }
|
||||||
</h1>
|
</h1>
|
||||||
<dl class="summary">
|
<dl class="summary">
|
||||||
<div>
|
<div>
|
||||||
@@ -43,6 +46,7 @@
|
|||||||
<mat-card appearance="outlined">
|
<mat-card appearance="outlined">
|
||||||
<mat-card-header><mat-card-title>Historial médico</mat-card-title></mat-card-header>
|
<mat-card-header><mat-card-title>Historial médico</mat-card-title></mat-card-header>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
|
@if (domain() === 'cacu') { <app-stages [sample]="sample" [report]="sampleReportDate()" [cutoff]="cutoff" [facts]="sampleFacts()" [detail]="true" /> }
|
||||||
<table class="plain">
|
<table class="plain">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -108,7 +112,24 @@
|
|||||||
><mat-card-title>Riesgos y recomendaciones</mat-card-title></mat-card-header
|
><mat-card-title>Riesgos y recomendaciones</mat-card-title></mat-card-header
|
||||||
>
|
>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
@if (models().length) {
|
@if (domain() === 'cacu') {
|
||||||
|
<p class="muted">Divisiones numéricas descriptivas; no representan umbrales clínicos.</p>
|
||||||
|
@for (model of riskScales(); track model.model) {
|
||||||
|
<h3>{{ model.outcome }} · {{ model.model }} · fecha índice {{ model.index }}</h3>
|
||||||
|
@for (scale of [{label: 'Riesgo inmediato (al índice)', value: model.immediate}, {label: 'Riesgo a 5 años', value: model.five}]; track scale.label) {
|
||||||
|
<div class="risk-scale">
|
||||||
|
<p><strong>{{ scale.label }}</strong> @if (scale.value; as v) { @if (v.low !== undefined && v.high !== undefined) { · IC 95 %: {{ v.low * 100 | number:'1.1-2' }}–{{ v.high * 100 | number:'1.1-2' }} % } } @else { · No disponible }</p>
|
||||||
|
<div class="risk-plot" [class.unavailable]="!scale.value"><div class="risk-line" aria-hidden="true"></div>@if (scale.value; as v) { <span class="risk-marker" [style.left.%]="v.value * 100" aria-hidden="true"></span><strong class="risk-value" [style.left]="'clamp(2.5rem, '+ (v.value * 100) +'%, calc(100% - 2.5rem))'">{{ v.value * 100 | number:'1.1-2' }} %</strong> }</div>
|
||||||
|
<div class="risk-labels"><span>0 %</span><span>25 %</span><span>50 %</span><span>75 %</span><span>100 %</span></div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
} @empty {
|
||||||
|
@for (label of ['Riesgo inmediato', 'Riesgo a 5 años']; track label) {
|
||||||
|
<div class="risk-scale"><p><strong>{{ label }}</strong> · No disponible</p><div class="risk-plot unavailable"><div class="risk-line" aria-hidden="true"></div></div><div class="risk-labels"><span>0 %</span><span>25 %</span><span>50 %</span><span>75 %</span><span>100 %</span></div></div>
|
||||||
|
}
|
||||||
|
<p class="muted">Ningún modelo vigente la ha evaluado.</p>
|
||||||
|
}
|
||||||
|
} @else if (models().length) {
|
||||||
<table class="plain">
|
<table class="plain">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -146,38 +167,8 @@
|
|||||||
}
|
}
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
|
||||||
@if (models().some((m) => m.scenarios.length)) {
|
|
||||||
<mat-card appearance="outlined" class="wide" data-section="supervivencia">
|
|
||||||
<mat-card-header
|
|
||||||
><mat-card-title>Análisis de supervivencia</mat-card-title></mat-card-header
|
|
||||||
>
|
|
||||||
<mat-card-content>
|
|
||||||
@if (survival.isLoading()) {
|
|
||||||
<app-loading what="las curvas de supervivencia" [figure]="true" />
|
|
||||||
} @else if (survival.value(); as s) {
|
|
||||||
<h3>Escenario clínico de la paciente</h3>
|
|
||||||
<ul class="scenarios">
|
|
||||||
@for (name of s.scenarios; track name) {
|
|
||||||
<li>{{ name }}</li>
|
|
||||||
}
|
|
||||||
</ul>
|
|
||||||
@for (f of s.figures; track f.title) {
|
|
||||||
<h4>{{ f.title }}</h4>
|
|
||||||
<app-plot [figure]="f.figure" [height]="340" />
|
|
||||||
} @empty {
|
|
||||||
<p class="muted">
|
|
||||||
Sus escenarios tienen menos fallecimientos de los necesarios para trazar curvas.
|
|
||||||
</p>
|
|
||||||
}
|
|
||||||
} @else if (survival.error()) {
|
|
||||||
<p class="muted" role="alert">No se pudo leer el informe del modelo.</p>
|
|
||||||
}
|
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
} @else if (loading()) {
|
} @else if (loading()) {
|
||||||
<app-loading what="el expediente" />
|
<p class="muted">Cargando…</p>
|
||||||
}
|
}
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -18,12 +18,12 @@
|
|||||||
.cards {
|
.cards {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: var(--space-4);
|
gap: var(--space-4);
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: minmax(0, 1fr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 1100px) {
|
@media (min-width: 1100px) {
|
||||||
.cards {
|
.cards {
|
||||||
grid-template-columns: repeat(2, 1fr);
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
}
|
}
|
||||||
.wide {
|
.wide {
|
||||||
grid-column: 1 / -1;
|
grid-column: 1 / -1;
|
||||||
@@ -33,20 +33,14 @@
|
|||||||
mat-card-content {
|
mat-card-content {
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
|
:host .risk-scale { max-width: 740px; margin: 8px 0 14px; }
|
||||||
|
:host .risk-scale p { margin: 0; }
|
||||||
|
:host .risk-plot { position: relative; padding-top: 24px; }
|
||||||
|
:host .risk-line { height: 16px; background: linear-gradient(to right, #42a77e 0 25%, #a8c243 25% 50%, #df8640 50% 75%, #c24269 75% 100%); }
|
||||||
|
:host .unavailable .risk-line { background: repeating-linear-gradient(to right, #d9dfe2 0, #d9dfe2 calc(25% - 1px), #fff calc(25% - 1px), #fff 25%); }
|
||||||
|
:host .risk-marker { position: absolute; bottom: -2px; width: 3px; height: 20px; background: #17324d; transform: translateX(-50%); }
|
||||||
|
:host .risk-value { position: absolute; top: 1px; transform: translateX(-50%); white-space: nowrap; color: #17324d; font-size: 13px; }
|
||||||
|
:host .risk-labels { display: flex; justify-content: space-between; font-size: 12px; margin-top: 3px; }
|
||||||
|
.export-actions { display: flex; justify-content: flex-end; margin-bottom: 12px; }
|
||||||
|
|
||||||
.scenarios {
|
:host .cards, :host .wide { min-width: 0; }
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 6px 8px;
|
|
||||||
list-style: none;
|
|
||||||
margin: 0 0 12px;
|
|
||||||
padding: 0;
|
|
||||||
|
|
||||||
li {
|
|
||||||
background: var(--color-action-hover, #f1f6f6);
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
border-radius: 999px;
|
|
||||||
font-size: 13px;
|
|
||||||
padding: 2px 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { MatButtonModule } from '@angular/material/button';
|
|||||||
import { MatCardModule } from '@angular/material/card';
|
import { MatCardModule } from '@angular/material/card';
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import { RouterLink } from '@angular/router';
|
import { RouterLink } from '@angular/router';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import type {
|
import type {
|
||||||
Condition,
|
Condition,
|
||||||
DiagnosticReport,
|
DiagnosticReport,
|
||||||
@@ -12,15 +13,15 @@ import type {
|
|||||||
Procedure,
|
Procedure,
|
||||||
RiskAssessment,
|
RiskAssessment,
|
||||||
} from 'fhir/r4';
|
} from 'fhir/r4';
|
||||||
import { Api } from '../api/api';
|
import { code, ext, Fhir, label, resources } from '../fhir';
|
||||||
import { readReport$Json } from '../api/fn/models/read-report-json';
|
import { CURP, exactAge, patientLabel, patientName } from '../indicadores/follow-up';
|
||||||
import type { Domain } from '../api/models/domain';
|
|
||||||
import { code, EXT, ext, Fhir, label, resources } from '../fhir';
|
|
||||||
import { scenarioFigure } from '../gobernanza/figures';
|
|
||||||
import { CURP } from '../indicadores/follow-up';
|
|
||||||
import { name } from '../indicadores/measures';
|
import { name } from '../indicadores/measures';
|
||||||
import { Figure, PALETTE, Plot } from '../plot';
|
import { Figure, PALETTE, Plot } from '../plot';
|
||||||
import { Loading } from '../loading';
|
import { horizonRisk } from './risk-scale';
|
||||||
|
import { daysBetween, routeFacts, stages, Stages } from './stages';
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { downloadDocument } from '../export-document';
|
||||||
|
import { firstValueFrom } from 'rxjs';
|
||||||
|
|
||||||
/** An Observation's value as the screens say it, whatever its type. */
|
/** An Observation's value as the screens say it, whatever its type. */
|
||||||
function shown(o: Observation): string {
|
function shown(o: Observation): string {
|
||||||
@@ -35,13 +36,19 @@ function shown(o: Observation): string {
|
|||||||
* champion models' risks with their curves. Everything read from the FHIR API. */
|
* champion models' risks with their curves. Everything read from the FHIR API. */
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-paciente',
|
selector: 'app-paciente',
|
||||||
imports: [Loading, DecimalPipe, MatButtonModule, MatCardModule, MatIconModule, RouterLink, Plot],
|
imports: [DecimalPipe, MatButtonModule, MatCardModule, MatIconModule, RouterLink, Plot, Stages],
|
||||||
templateUrl: './paciente.html',
|
templateUrl: './paciente.html',
|
||||||
styleUrl: './paciente.scss',
|
styleUrl: './paciente.scss',
|
||||||
})
|
})
|
||||||
export class Paciente {
|
export class Paciente {
|
||||||
|
private readonly route = inject(ActivatedRoute);
|
||||||
|
protected readonly exactAge = exactAge;
|
||||||
|
protected readonly cutoff = this.route.snapshot.queryParamMap.get('corte') ?? undefined;
|
||||||
|
protected readonly sample = this.route.snapshot.queryParamMap.get('muestra') ?? undefined;
|
||||||
private readonly fhir = inject(Fhir);
|
private readonly fhir = inject(Fhir);
|
||||||
private readonly api = inject(Api);
|
private readonly http = inject(HttpClient);
|
||||||
|
protected readonly exporting = signal(false);
|
||||||
|
protected readonly exportError = signal('');
|
||||||
readonly domain = input.required<string>();
|
readonly domain = input.required<string>();
|
||||||
readonly id = input.required<string>();
|
readonly id = input.required<string>();
|
||||||
|
|
||||||
@@ -50,10 +57,16 @@ export class Paciente {
|
|||||||
loader: async ({ params: { domain, id } }) => {
|
loader: async ({ params: { domain, id } }) => {
|
||||||
const subject = { subject: `Patient/${id}`, _count: 200 };
|
const subject = { subject: `Patient/${id}`, _count: 200 };
|
||||||
const [patient, conditions, procedures, reports, observations, risks] = await Promise.all([
|
const [patient, conditions, procedures, reports, observations, risks] = await Promise.all([
|
||||||
this.fhir.read<Patient>(domain, 'Patient', id),
|
domain === 'cacu' && this.cutoff
|
||||||
|
? this.fhir.search(domain, 'Patient', {_id:id, 'follow-up-cutoff':this.cutoff}).then(bundle => {
|
||||||
|
const patient = resources<Patient>(bundle, 'Patient', 'match')[0];
|
||||||
|
if (!patient) throw new Error('Paciente no encontrada');
|
||||||
|
return patient;
|
||||||
|
})
|
||||||
|
: this.fhir.read<Patient>(domain, 'Patient', id),
|
||||||
this.fhir.all(domain, 'Condition', subject),
|
this.fhir.all(domain, 'Condition', subject),
|
||||||
this.fhir.all(domain, 'Procedure', subject),
|
this.fhir.all(domain, 'Procedure', subject),
|
||||||
this.fhir.all(domain, 'DiagnosticReport', subject),
|
this.fhir.all(domain, 'DiagnosticReport', { ...subject, 'stage-cutoff': domain === 'cacu' ? this.cutoff : undefined }),
|
||||||
this.fhir.all(domain, 'Observation', subject),
|
this.fhir.all(domain, 'Observation', subject),
|
||||||
this.fhir.all(domain, 'RiskAssessment', subject),
|
this.fhir.all(domain, 'RiskAssessment', subject),
|
||||||
]);
|
]);
|
||||||
@@ -70,6 +83,53 @@ export class Paciente {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
protected readonly patient = computed(() => this.data.value()?.patient);
|
protected readonly patient = computed(() => this.data.value()?.patient);
|
||||||
|
protected readonly sampleReportDate = computed(() => {
|
||||||
|
const d = this.data.value();
|
||||||
|
const report = d?.reports.find(r => code(r.code) === 'cervical_cytology' && r.effectiveDateTime === this.sample);
|
||||||
|
const hasResult = (report?.result ?? []).some(ref => {
|
||||||
|
const observation = d?.observations.get(ref.reference?.split('/')[1] ?? '');
|
||||||
|
return code(observation?.code) === 'cervical_cytology.result' && !!code(observation?.valueCodeableConcept);
|
||||||
|
});
|
||||||
|
return hasResult ? ext(report, 'report-date')?.valueDate : undefined;
|
||||||
|
});
|
||||||
|
protected readonly sampleFacts = computed(() => routeFacts(this.data.value()?.reports.find(r => code(r.code) === 'cervical_cytology' && r.effectiveDateTime === this.sample)));
|
||||||
|
protected async exportPatient(): Promise<void> {
|
||||||
|
const patient = this.patient(); if (!patient) return;
|
||||||
|
this.exporting.set(true); this.exportError.set('');
|
||||||
|
try {
|
||||||
|
await firstValueFrom(this.http.get('/api/cacu/exports/capabilities'));
|
||||||
|
const timeline = stages(this.sample, this.sampleReportDate(), this.cutoff, this.sampleFacts());
|
||||||
|
const entries: string[][] = [
|
||||||
|
['Identificador', patient.id ?? 'No disponible'],
|
||||||
|
['Paciente', patientLabel(patient)],
|
||||||
|
['CURP', this.identity().curp ?? 'No disponible'],
|
||||||
|
['Expedientes', this.identity().numbers.join(', ') || 'No disponible'],
|
||||||
|
['Nacimiento', patient.birthDate ?? 'No disponible'],
|
||||||
|
['Edad al corte', String(exactAge(patient.birthDate,this.cutoff) ?? 'No disponible')],
|
||||||
|
['Estatus', this.status() || 'No disponible'],
|
||||||
|
...timeline.map((s,i) => ['Etapa', `${s.label}: ${s.state}${s.provenance ? ' · '+s.provenance : ''}; fecha ${s.date ?? '—'}; desde anterior ${daysBetween(i ? timeline[i-1].date : undefined,s.date) ?? '—'} días; desde toma ${daysBetween(timeline[0].date,s.date) ?? '—'} días`]),
|
||||||
|
...this.history().map(h => ['Historial', `${h.date} · ${h.kind} · ${h.text}${h.code ? ' ('+h.code+')' : ''}`]),
|
||||||
|
...this.tests().map(t => ['Pruebas', `${t.date} · ${t.kind} · ${t.reported ?? 'Pendiente'} · ${t.results.join(' · ') || '—'}`]),
|
||||||
|
];
|
||||||
|
const lastStage = timeline.map(s => s.date).filter((d): d is string => !!d).sort().at(-1);
|
||||||
|
if (lastStage) entries.splice(7 + timeline.length, 0, ['Etapas', `Tiempo transcurrido desde el último evento mostrado: ${daysBetween(lastStage,this.cutoff) ?? '—'} días (incluye asociaciones inferidas)`]);
|
||||||
|
const risk = this.riskScales();
|
||||||
|
if (!risk.length) entries.push(['Riesgo', 'Inmediato: No disponible · 5 años: No disponible']);
|
||||||
|
for (const r of risk) for (const [label, value] of [['Inmediato',r.immediate],['5 años',r.five]] as const)
|
||||||
|
entries.push(['Riesgo', `${r.outcome} · ${r.model} · ${label}: ${value ? (value.value*100).toFixed(2)+' %' : 'No disponible'}${value?.low !== undefined && value.high !== undefined ? ' · IC 95 % '+(value.low*100).toFixed(2)+'–'+(value.high*100).toFixed(2)+' %' : ''}`]);
|
||||||
|
const pct2 = (n: number) => (n*100).toFixed(2)+' %';
|
||||||
|
const scale = (r: (typeof risk)[number], label: string, v: (typeof risk)[number]['immediate']) => ({label:`${r.outcome} · ${r.model} · ${label}: ${v ? pct2(v.value) : 'No disponible'}`, outcome:r.outcome, model:r.model, horizon:label,
|
||||||
|
...(v ? {value:v.value, ...(v.low !== undefined && v.high !== undefined ? {low:v.low, high:v.high} : {})} : {})});
|
||||||
|
const scales = risk.length ? risk.flatMap(r => [scale(r,'Inmediato',r.immediate), scale(r,'5 años',r.five)]) : [{label:'Riesgo inmediato: No disponible'}, {label:'Riesgo a 5 años: No disponible'}];
|
||||||
|
const interval = (d?: number, inferred?: boolean) => d === undefined ? '—' : `${d} días${inferred ? ' (inferido)' : ''}`;
|
||||||
|
const isInferred = (x?: {provenance?: string}) => x?.provenance === 'Inferida temporalmente';
|
||||||
|
const route = timeline.map((s,i) => ({state:s.state, label:s.label, ...(s.provenance ? {provenance:s.provenance} : {}), ...(s.date ? {date:s.date} : {}),
|
||||||
|
prev: interval(daysBetween(i ? timeline[i-1].date : undefined, s.date), isInferred(s) || (i > 0 && isInferred(timeline[i-1]))),
|
||||||
|
start: interval(daysBetween(timeline[0].date, s.date), isInferred(s))}));
|
||||||
|
await downloadDocument(this.http,'pdf',{title:'Ficha individual',parameters:[['Corte (edad, estatus y etapas)',this.cutoff ?? 'No disponible'],['Historial y riesgos','Información longitudinal disponible; no filtrada por corte histórico']],columns:['Sección','Información'],rows:entries,timeline:route,risk_scales:scales});
|
||||||
|
} catch (error) { this.exportError.set(error instanceof Error ? `No se pudo generar la ficha PDF: ${error.message}` : 'No se pudo generar la ficha PDF.'); }
|
||||||
|
finally { this.exporting.set(false); }
|
||||||
|
}
|
||||||
protected readonly error = computed(() => this.data.error());
|
protected readonly error = computed(() => this.data.error());
|
||||||
protected readonly loading = computed(() => this.data.isLoading());
|
protected readonly loading = computed(() => this.data.isLoading());
|
||||||
protected readonly history = computed(() => {
|
protected readonly history = computed(() => {
|
||||||
@@ -120,12 +180,7 @@ export class Paciente {
|
|||||||
return [...latest.values()].map((r) => ({
|
return [...latest.values()].map((r) => ({
|
||||||
model: code(r.method) ?? '',
|
model: code(r.method) ?? '',
|
||||||
text: r.method?.text ?? '',
|
text: r.method?.text ?? '',
|
||||||
version: Number(/v(\d+)$/.exec(r.method?.text ?? '')?.[1] ?? 0),
|
|
||||||
index: r.occurrenceDateTime ?? '',
|
index: r.occurrenceDateTime ?? '',
|
||||||
// the clinical scenarios of the model's report she falls in
|
|
||||||
scenarios: (r.extension ?? [])
|
|
||||||
.filter((e) => e.url === EXT + 'escenario-clinico')
|
|
||||||
.map((e) => e.valueString ?? ''),
|
|
||||||
predictions: (r.prediction ?? []).map((p) => ({
|
predictions: (r.prediction ?? []).map((p) => ({
|
||||||
years: p.whenRange?.high?.value ?? 0,
|
years: p.whenRange?.high?.value ?? 0,
|
||||||
p: p.probabilityDecimal ?? 0,
|
p: p.probabilityDecimal ?? 0,
|
||||||
@@ -134,35 +189,16 @@ export class Paciente {
|
|||||||
})),
|
})),
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
/** "Análisis de supervivencia": the curves of her clinical scenarios, from the report of
|
protected readonly riskScales = computed(() => {
|
||||||
* the model version that scored her. */
|
const latest = new Map<string, RiskAssessment>();
|
||||||
protected readonly survival = resource({
|
for (const risk of this.data.value()?.risks ?? []) {
|
||||||
params: () => {
|
const key = code(risk.method) ?? '';
|
||||||
const m = this.models().find((x) => x.scenarios.length && x.version);
|
if (!key.startsWith('cacu.cin2') && !key.startsWith('cacu.cancer')) continue;
|
||||||
return m ? { m, domain: this.domain() } : undefined;
|
if (!latest.has(key) || (latest.get(key)!.occurrenceDateTime ?? '') < (risk.occurrenceDateTime ?? '')) latest.set(key, risk);
|
||||||
},
|
}
|
||||||
loader: async ({ params: { m, domain } }) => {
|
return [...latest.entries()].map(([model, risk]) => ({model, index: risk.occurrenceDateTime,
|
||||||
const report = await this.api.invoke(readReport$Json, {
|
outcome: model.startsWith('cacu.cin2') ? 'CIN2+' : 'Cáncer',
|
||||||
domain: domain as Domain,
|
immediate: horizonRisk(risk, 0), five: horizonRisk(risk, 5)}));
|
||||||
name: m.model.replace(`${domain}.`, ''),
|
|
||||||
version: m.version,
|
|
||||||
report: 'interpretability',
|
|
||||||
});
|
|
||||||
const drawn = ((report?.['escenarios'] ?? []) as any[]).filter((e) =>
|
|
||||||
m.scenarios.includes(e.escenario),
|
|
||||||
);
|
|
||||||
return {
|
|
||||||
scenarios: m.scenarios,
|
|
||||||
figures: drawn.map((e) =>
|
|
||||||
scenarioFigure(
|
|
||||||
`${e.escenario} (n = ${e.n.toLocaleString('es-MX')}, fallecidos = ${e.fallecidos.toLocaleString('es-MX')})`,
|
|
||||||
e,
|
|
||||||
e.horizons_months,
|
|
||||||
'Supervivencia S(t)',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
protected readonly shown = signal<string | undefined>(undefined);
|
protected readonly shown = signal<string | undefined>(undefined);
|
||||||
protected readonly curve = computed<Figure>(() => {
|
protected readonly curve = computed<Figure>(() => {
|
||||||
@@ -217,7 +253,7 @@ export class Paciente {
|
|||||||
protected readonly identity = computed(() => {
|
protected readonly identity = computed(() => {
|
||||||
const p = this.patient();
|
const p = this.patient();
|
||||||
return {
|
return {
|
||||||
name: p?.name?.[0]?.text,
|
name: patientName(p),
|
||||||
curp: p?.identifier?.find((i) => i.system === CURP)?.value,
|
curp: p?.identifier?.find((i) => i.system === CURP)?.value,
|
||||||
numbers: (p?.identifier ?? []).filter((i) => i.system !== CURP).map((i) => i.value),
|
numbers: (p?.identifier ?? []).filter((i) => i.system !== CURP).map((i) => i.value),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import type { RiskAssessment } from 'fhir/r4';
|
||||||
|
|
||||||
|
/** Only an explicitly published horizon is eligible; zero remains a real value. */
|
||||||
|
export function horizonRisk(risk: RiskAssessment, years: number) {
|
||||||
|
const p = (risk.prediction ?? []).find(x => x.whenRange?.high?.value === years &&
|
||||||
|
x.whenRange.high.code === 'a' && x.probabilityDecimal !== undefined &&
|
||||||
|
x.probabilityDecimal >= 0 && x.probabilityDecimal <= 1);
|
||||||
|
if (!p) return undefined;
|
||||||
|
const value = p.probabilityDecimal!;
|
||||||
|
const get = (suffix: string) => p.extension?.find(e => e.url.endsWith('/' + suffix))?.valueDecimal;
|
||||||
|
const low = get('ic-bajo'), high = get('ic-alto');
|
||||||
|
return {value, low: low !== undefined && low >= 0 && low <= 1 ? low : undefined,
|
||||||
|
high: high !== undefined && high >= 0 && high <= 1 ? high : undefined};
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import '@angular/compiler';
|
||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import type { RiskAssessment } from 'fhir/r4';
|
||||||
|
import { stages, daysBetween } from './stages';
|
||||||
|
import { horizonRisk } from './risk-scale';
|
||||||
|
|
||||||
|
describe('stages and explicit risk horizons', () => {
|
||||||
|
it('keeps zero day intervals and does not fill later stages', () => {
|
||||||
|
const s = stages('2026-01-01', '2026-01-01', '2026-02-01');
|
||||||
|
expect(daysBetween(s[0].date, s[1].date)).toBe(0);
|
||||||
|
expect(s.slice(2).every(x => x.date === undefined)).toBe(true);
|
||||||
|
expect(stages('2026-01-01', '2027-01-01', '2026-02-01')[1].date).toBeUndefined();
|
||||||
|
});
|
||||||
|
it('distinguishes inferred, structured, pending and ambiguous stages', () => {
|
||||||
|
const a = stages('2026-01-01', undefined, '2026-02-01', {
|
||||||
|
colposcopy: {state:'inferred',date:'2026-01-03'}, biopsy:{state:'pending'}, diagnosis:{state:'ambiguous'} });
|
||||||
|
expect(a.map(x => x.state)).toEqual(['Registrada','Desconocida','Registrada','Pendiente','Ambigua']);
|
||||||
|
expect(a[2].provenance).toBe('Inferida temporalmente');
|
||||||
|
expect(stages('2026-01-01',undefined,'2026-02-01',{biopsy:{state:'structured',date:'2026-01-04'}})[3].provenance).toBe('Vínculo estructurado');
|
||||||
|
});
|
||||||
|
it('uses only a published horizon and preserves zero', () => {
|
||||||
|
const r: RiskAssessment = {resourceType:'RiskAssessment', status:'final', subject:{},
|
||||||
|
prediction:[{probabilityDecimal:0,whenRange:{high:{value:0,code:'a'}}},
|
||||||
|
{probabilityDecimal:0.2,whenRange:{high:{value:3,code:'a'}}}]};
|
||||||
|
expect(horizonRisk(r,0)?.value).toBe(0);
|
||||||
|
expect(horizonRisk(r,5)).toBeUndefined();
|
||||||
|
expect(horizonRisk({...r,prediction:[]},0)).toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import { Component, computed, input } from '@angular/core';
|
||||||
|
import type { DiagnosticReport } from 'fhir/r4';
|
||||||
|
import { ext } from '../fhir';
|
||||||
|
|
||||||
|
export type StageFact = {state?: string; date?: string};
|
||||||
|
export type StageFacts = Record<string, StageFact>;
|
||||||
|
export function routeFacts(report?: DiagnosticReport): StageFacts {
|
||||||
|
return Object.fromEntries(['colposcopy','biopsy','diagnosis'].map(k => [k, {state: ext(report, `stage-${k}-state`)?.valueCode, date: ext(report, `stage-${k}-date`)?.valueDate}]));
|
||||||
|
}
|
||||||
|
export function stages(sample?: string, report?: string, cutoff?: string, facts: StageFacts = {}) {
|
||||||
|
const valid = (d?: string) => !!d && !!cutoff && /^\d{4}-\d{2}-\d{2}$/.test(d) && d <= cutoff;
|
||||||
|
const start = valid(sample) ? sample : undefined;
|
||||||
|
const result = start && valid(report) && report! >= start ? report : undefined;
|
||||||
|
const later = (label: string, key: string) => {
|
||||||
|
const f = facts[key];
|
||||||
|
const state = f?.state === 'pending' ? 'Pendiente' : f?.state === 'ambiguous' ? 'Ambigua' :
|
||||||
|
(f?.state === 'inferred' || f?.state === 'structured') && valid(f.date) && start && f.date! >= start ? 'Registrada' : 'Desconocida';
|
||||||
|
return {label, date: state === 'Registrada' ? f.date : undefined, state, provenance: state === 'Registrada' ? (f.state === 'inferred' ? 'Inferida temporalmente' : 'Vínculo estructurado') : undefined};
|
||||||
|
};
|
||||||
|
return [{label:'Toma de muestra',date:start,state:start?'Registrada':'Desconocida',provenance:undefined}, {label:'Resultado de citología',date:result,state:result?'Registrada':'Desconocida',provenance:undefined}, later('Colposcopia','colposcopy'),later('Reporte de biopsia','biopsy'),later('Diagnóstico','diagnosis')];
|
||||||
|
}
|
||||||
|
export function daysBetween(a?: string,b?: string): number | undefined {
|
||||||
|
if (!a || !b) return undefined;
|
||||||
|
const x=Date.parse(a+'T00:00:00Z'), y=Date.parse(b+'T00:00:00Z');
|
||||||
|
return Number.isFinite(x) && Number.isFinite(y) && y >= x ? (y-x)/86400000 : undefined;
|
||||||
|
}
|
||||||
|
@Component({selector:'app-stages', template: `
|
||||||
|
<div class="stage-line" [class.detailed]="detail()" [attr.aria-label]="summary()">
|
||||||
|
@for (s of items(); track s.label; let i = $index) {
|
||||||
|
<div class="stage"><span class="node" [class.registered]="s.state === 'Registrada'" [class.inferred]="s.provenance === 'Inferida temporalmente'" [class.pending]="s.state === 'Pendiente'" [class.ambiguous]="s.state === 'Ambigua'" [attr.title]="s.label + ': ' + s.state + (s.provenance ? ' · ' + s.provenance : '')"></span>
|
||||||
|
@if (detail()) { <div class="stage-detail"><strong>{{ s.label }}</strong><span>{{ s.state }}{{ s.provenance ? ' · ' + s.provenance : '' }}</span><span>{{ s.date ?? 'Sin fecha' }}</span><span class="interval">Desde anterior: {{ days(i ? items()[i-1].date : undefined, s.date) ?? '—' }}{{ i && days(items()[i-1].date, s.date) !== undefined && (s.provenance === 'Inferida temporalmente' || items()[i-1].provenance === 'Inferida temporalmente') ? ' días (inferido)' : (days(i ? items()[i-1].date : undefined, s.date) !== undefined ? ' días' : '') }}</span><span class="interval">Desde toma: {{ days(items()[0].date, s.date) ?? '—' }}{{ days(items()[0].date, s.date) !== undefined && s.provenance === 'Inferida temporalmente' ? ' días (inferido)' : (days(items()[0].date, s.date) !== undefined ? ' días' : '') }}</span></div> }
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
`, styles: `:host{display:block;min-width:150px}.stage-line{display:flex;align-items:flex-start}.stage{position:relative;flex:0 0 37px}.stage:not(:last-child)::after{content:'';position:absolute;top:9px;left:20px;right:0;border-top:1px solid #667b8a}.node{display:block;width:18px;height:18px;box-sizing:border-box;border:2px dashed #667b8a;border-radius:50%;background:white;position:relative;z-index:1}.registered{background:#387b66;border-style:solid}.inferred{background:#4269a0;border-style:double}.pending{background:#fff1c9;border-style:solid}.ambiguous{border-style:double;border-color:#a84460}.stage:last-child{flex-basis:18px}.detailed{background:#fff;border:1px solid #dce3e7;border-radius:8px;padding:18px 12px}.detailed .stage,.detailed .stage:last-child{flex:1;min-width:0;text-align:center}.detailed .node{margin:0 auto}.detailed .stage:not(:last-child)::after{left:calc(50% + 9px);right:calc(-50% + 9px)}.stage-detail{display:flex;flex-direction:column;gap:3px;padding:8px 4px 0;font-size:12px;color:#60717d;overflow-wrap:anywhere}.stage-detail strong{color:#243d4b}.interval{font-weight:600;color:#365b69}@media(max-width:700px){.detailed{display:block}.detailed .stage{display:flex;gap:12px;padding-bottom:10px}.detailed .stage::after{top:18px;left:9px;bottom:0;right:auto;border-top:0;border-left:1px solid #667b8a}.detailed .node{margin:0}.detailed .stage{text-align:left}.stage-detail{padding:0}.node{flex:none}}`})
|
||||||
|
export class Stages {
|
||||||
|
readonly sample = input<string>(); readonly report = input<string>(); readonly cutoff = input<string>(); readonly detail = input(false);
|
||||||
|
readonly facts = input<StageFacts>({});
|
||||||
|
protected readonly items = computed(() => stages(this.sample(),this.report(),this.cutoff(),this.facts()));
|
||||||
|
protected readonly summary = computed(() => this.items().map(x=>x.label+': '+x.state+(x.provenance?' · '+x.provenance:'')).join('; '));
|
||||||
|
protected readonly lastDate = computed(() => this.items().map(x=>x.date).filter((x):x is string=>!!x).sort().at(-1));
|
||||||
|
protected readonly days = daysBetween;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user