diff --git a/e2e/pages.spec.ts b/e2e/pages.spec.ts index 9db7863..483cdc2 100644 --- a/e2e/pages.spec.ts +++ b/e2e/pages.spec.ts @@ -51,7 +51,10 @@ test("indicators: the KPIs are the API's MeasureReports, every tab and the patie const count = eu7.entry[0].resource.group[0].population.find( (p: any) => p.code.coding[0].code === 'initial-population', ).count; - await expect(page.locator('[data-measure="CACU_EU7"] .kpi-value')).toHaveText(String(count)); + // the card says it as the old one did: " pacientes" + await expect(page.locator('[data-measure="CACU_EU7"] .kpi-value')).toHaveText( + `${count.toLocaleString('es-MX')} pacientes`, + ); await expect(page.locator('app-tab-indicadores app-plot').first()).toBeVisible(); await page.getByRole('tab', { name: 'Trazabilidad' }).click(); @@ -104,7 +107,7 @@ test('conectar: open the hospital pipeline, preview a source, run it to success' 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. await page.getByText('Traducir códigos · cytology', { exact: true }).click(); - await expect(page.getByText('Códigos del sitio')).toBeVisible(); + await expect(page.getByRole('heading', { name: /^Códigos del sitio/ })).toBeVisible(); await expect .poll(() => page @@ -165,7 +168,7 @@ test('conectar: someone who knows nothing of databases connects the SQL Server w 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 expect(page.getByText(/(Las primeras \d+ filas|La primera fila):/)).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(); diff --git a/openapi.json b/openapi.json index fb5c0c3..0577d59 100644 --- a/openapi.json +++ b/openapi.json @@ -1065,6 +1065,17 @@ "title": "Code", "type": "string" }, + "median": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Median" + }, "model": { "anyOf": [ { @@ -1087,6 +1098,28 @@ ], "title": "Outside" }, + "p5": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "P5" + }, + "p95": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "P95" + }, "value": { "title": "Value", "type": "number" diff --git a/src/app/api/models/metric.ts b/src/app/api/models/metric.ts index 476a4bc..fcbbafd 100644 --- a/src/app/api/models/metric.ts +++ b/src/app/api/models/metric.ts @@ -3,8 +3,11 @@ export interface Metric { code: string; + median?: (number | null); model: (string | null); outside: (number | null); + p5?: (number | null); + p95?: (number | null); value: number; z: (number | null); } diff --git a/src/app/paciente/paciente.html b/src/app/paciente/paciente.html index ed5fc49..8461815 100644 --- a/src/app/paciente/paciente.html +++ b/src/app/paciente/paciente.html @@ -147,6 +147,82 @@ + @if (domain() === 'tea') { + + ADOS-2 + + @if (ados2(); as a) { +

Puntajes por reactivo · {{ a.date }}

+ +

+ @for (t of a.totals; track t.label) { + {{ t.label }}: {{ t.value }} + } +

+ } @else { +

Sin evaluación ADOS-2.

+ } +
+
+ + + EEG + + @if (eeg.isLoading()) { + + } @else if (eeg.value()?.study; as st) { +

Calidad del EEG

+

+ Estudio del {{ st.study_date }}: + {{ st.valid ? 'aceptable para el análisis' : 'no aceptable' }} + @if (st.level) { + ({{ st.level }}) + } +

+

Alteraciones del EEG

+ @if (!st.valid) { +

Un EEG no aceptable no se compara con la norma por edad.

+ } @else if (!scored()) { +

+ Ninguna curva por edad vigente ha evaluado este EEG (se promueven en Gobernanza). +

+ } @else if (alterations().length) { + + + + + + + + + + + + + @for (m of alterations(); track m.code) { + + + + + + + + + } + +
MétricaValorNorma por edad (P5–P95)MedianaDesviación (z)Detalle
{{ m.code }}{{ m.value | number: '1.0-3' }}{{ m.p5 | number: '1.0-3' }} – {{ m.p95 | number: '1.0-3' }}{{ m.median | number: '1.0-3' }}{{ m.z | number: '1.1-2' }}{{ m.outside! > 0 ? 'Aumentado' : 'Disminuido' }}
+ } @else { +

Sin alteraciones: todas sus métricas están dentro de la norma por edad.

+ } + } @else { +

Sin EEG analizado.

+ } +
+
+ } + @if (models().some((m) => m.scenarios.length)) { { + const d = this.data.value(); + if (!d) return undefined; + const field = (o: Observation) => (code(o.code) ?? '').replace(/^ados2\./, ''); + const scored = [...d.observations.values()].filter( + (o) => (code(o.code) ?? '').startsWith('ados2.') && o.valueQuantity?.value !== undefined, + ); + const latest = scored + .map((o) => o.effectiveDateTime ?? '') + .sort() + .at(-1); + if (latest === undefined) return undefined; + const results = scored.filter((o) => (o.effectiveDateTime ?? '') === latest); + const totals = ['social_affect_total', 'restricted_repetitive_total', 'overall_total']; + const items = results.filter((o) => !totals.includes(field(o))); + const figure: Figure = { + data: [ + { + type: 'bar', + orientation: 'h', + y: items.map((o) => label(o.code)), + x: items.map((o) => o.valueQuantity!.value!), + marker: { color: PALETTE[0] }, + hovertemplate: '%{y}: %{x}', + }, + ], + layout: { + showlegend: false, + margin: { t: 10, r: 16, b: 40, l: 16 }, + xaxis: { title: { text: 'Puntaje (0 a 3)' }, range: [0, 3], dtick: 1 }, + yaxis: { autorange: 'reversed', automargin: true, type: 'category' }, + }, + }; + return { + date: latest.slice(0, 10), + figure, + height: 60 + items.length * 22, + totals: results + .filter((o) => totals.includes(field(o))) + .map((o) => ({ label: label(o.code), value: o.valueQuantity!.value! })), + }; + }); + + /** TEA: her EEG as analysed (the latest), its quality and its metrics against the age + * curves: those outside the band are its alterations. */ + protected readonly eeg = resource({ + params: () => (this.domain() === 'tea' ? this.id() : undefined), + loader: async ({ params: person }) => { + const mine = (await this.api.invoke(eegStudies)) + .filter((s) => s.person_id === person && s.analysed) + .sort((a, b) => b.study_date.localeCompare(a.study_date)); + if (!mine.length) return { study: undefined, analysis: undefined }; + return { + study: mine[0], + analysis: await this.api.invoke(eegStudy, { eeg_id: mine[0].id }), + }; + }, + }); + protected readonly alterations = computed(() => + (this.eeg.value()?.analysis?.metrics ?? []).filter((m) => m.outside), + ); + protected readonly scored = computed(() => + (this.eeg.value()?.analysis?.metrics ?? []).some((m) => m.z !== null && m.z !== undefined), + ); protected readonly shown = signal(undefined); protected readonly curve = computed
(() => { const models = this.models().filter((m) => m.predictions.length > 1);