TEA record: ADOS-2 items, CSS and classification from its one observation

This commit is contained in:
Roberto Treviño
2026-12-06 04:00:36 -06:00
parent 83a360aed1
commit ec3eeeef65
+19 -19
View File
@@ -15,7 +15,7 @@ import {
OUTCOME_NAMES, OUTCOME_NAMES,
ZONE_NAMES, ZONE_NAMES,
} from '../eeg-labels'; } from '../eeg-labels';
import { code, label } from '../fhir'; import { code, ext, label } from '../fhir';
import { name } from '../indicadores/labels'; import { name } from '../indicadores/labels';
import { Loading } from '../loading'; import { Loading } from '../loading';
import { Figure, PALETTE, Plot } from '../plot'; import { Figure, PALETTE, Plot } from '../plot';
@@ -34,28 +34,24 @@ export class TeaRecord {
protected readonly name = name; protected readonly name = name;
protected readonly levelNames = LEVEL_NAMES; protected readonly levelNames = LEVEL_NAMES;
/** TEA: her latest ADOS-2 (an encounter whose observations are the catalog's /** TEA: her latest ADOS-2 (one observation: its items as components, its CSS the value
* `ados2.*` fields), item by item, and its totals. */ * and its classification the interpretation), item by item. */
protected readonly ados2 = computed(() => { protected readonly ados2 = computed(() => {
const field = (o: Observation) => (code(o.code) ?? '').replace(/^ados2\./, ''); const latest = this.observations()
const scored = this.observations().filter( .filter((o) => code(o.code) === 'ados2')
(o) => (code(o.code) ?? '').startsWith('ados2.') && o.valueQuantity?.value !== undefined, .sort((a, b) => (a.effectiveDateTime ?? '').localeCompare(b.effectiveDateTime ?? ''))
);
const latest = scored
.map((o) => o.effectiveDateTime ?? '')
.sort()
.at(-1); .at(-1);
if (latest === undefined) return undefined; if (latest === undefined) return undefined;
const results = scored.filter((o) => (o.effectiveDateTime ?? '') === latest); const items = (latest.component ?? []).filter(
const totals = ['social_affect_total', 'restricted_repetitive_total', 'overall_total']; (c) => ext(c, 'ados2-domain') && c.valueQuantity?.value !== undefined,
const items = results.filter((o) => !totals.includes(field(o))); );
const figure: Figure = { const figure: Figure = {
data: [ data: [
{ {
type: 'bar', type: 'bar',
orientation: 'h', orientation: 'h',
y: items.map((o) => label(o.code)), y: items.map((c) => c.code.text ?? label(c.code)),
x: items.map((o) => o.valueQuantity!.value!), x: items.map((c) => c.valueQuantity!.value!),
marker: { color: PALETTE[0] }, marker: { color: PALETTE[0] },
hovertemplate: '%{y}: %{x}<extra></extra>', hovertemplate: '%{y}: %{x}<extra></extra>',
}, },
@@ -67,13 +63,17 @@ export class TeaRecord {
yaxis: { autorange: 'reversed', automargin: true, type: 'category' }, yaxis: { autorange: 'reversed', automargin: true, type: 'category' },
}, },
}; };
const classification = latest.interpretation?.[0];
return { return {
date: latest.slice(0, 10), date: (latest.effectiveDateTime ?? '').slice(0, 10),
figure, figure,
height: 60 + items.length * 22, height: 60 + items.length * 22,
totals: results totals: [
.filter((o) => totals.includes(field(o))) ...(latest.valueInteger !== undefined
.map((o) => ({ label: label(o.code), value: o.valueQuantity!.value! })), ? [{ label: 'CSS', value: latest.valueInteger }]
: []),
...(classification ? [{ label: 'Clasificación', value: label(classification) }] : []),
],
}; };
}); });