Record: Relación con el ADOS-2 and Análisis de recurrencia; Gobernanza draws the association
This commit is contained in:
@@ -21,7 +21,15 @@ 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 { byDeviation, headMap, METRIC_NAMES, ZONE_NAMES } from '../eeg-labels';
|
||||
import {
|
||||
BIOMARKER_NAMES,
|
||||
byDeviation,
|
||||
headMap,
|
||||
METRIC_NAMES,
|
||||
OUTCOME_NAMES,
|
||||
ZONE_NAMES,
|
||||
} from '../eeg-labels';
|
||||
import type { Relation } from '../api/models/relation';
|
||||
import { Figure, PALETTE, Plot } from '../plot';
|
||||
import { Loading } from '../loading';
|
||||
|
||||
@@ -137,36 +145,58 @@ export class Paciente {
|
||||
})),
|
||||
}));
|
||||
});
|
||||
/** "Análisis de supervivencia": the curves of her clinical scenarios, from the report of
|
||||
* the model version that scored her. */
|
||||
protected readonly survival = resource({
|
||||
params: () => {
|
||||
const m = this.models().find((x) => x.scenarios.length && x.version);
|
||||
return m ? { m, domain: this.domain() } : undefined;
|
||||
},
|
||||
loader: async ({ params: { m, domain } }) => {
|
||||
const report = await this.api.invoke(readReport$Json, {
|
||||
domain: domain as Domain,
|
||||
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)',
|
||||
/** "Análisis de supervivencia" and "Análisis de recurrencia": the curves of her clinical
|
||||
* scenarios, from the report of the model version that scored her. */
|
||||
protected readonly survival = this.analysis('survival');
|
||||
protected readonly recurrence = this.analysis('recurrence');
|
||||
protected readonly recurrenceModel = computed(() =>
|
||||
this.models().find((m) => m.model.endsWith('.recurrence') && m.version),
|
||||
);
|
||||
|
||||
private analysis(name: 'survival' | 'recurrence') {
|
||||
return resource({
|
||||
params: () => {
|
||||
const m = this.models().find(
|
||||
(x) => x.model === `${this.domain()}.${name}` && x.scenarios.length && x.version,
|
||||
);
|
||||
return m ? { m, domain: this.domain() } : undefined;
|
||||
},
|
||||
loader: async ({ params: { m, domain } }) => {
|
||||
const report = await this.api.invoke(readReport$Json, {
|
||||
domain: domain as Domain,
|
||||
name,
|
||||
version: m.version,
|
||||
report: 'interpretability',
|
||||
});
|
||||
const mine = (all: any[]) => all.filter((e) => m.scenarios.includes(e.escenario));
|
||||
if (name === 'recurrence') {
|
||||
const r = (report?.['recurrencia'] ?? {}) as any;
|
||||
return {
|
||||
scenarios: m.scenarios,
|
||||
figures: mine(r['escenarios'] ?? []).map((e) =>
|
||||
scenarioFigure(
|
||||
`${e.escenario} (n = ${e.n.toLocaleString('es-MX')}, recaídas = ${e.recaidas.toLocaleString('es-MX')})`,
|
||||
e,
|
||||
r['horizons_months'],
|
||||
'Supervivencia libre de recaída',
|
||||
),
|
||||
),
|
||||
};
|
||||
}
|
||||
return {
|
||||
scenarios: m.scenarios,
|
||||
figures: mine((report?.['escenarios'] ?? []) as any[]).map((e) =>
|
||||
scenarioFigure(
|
||||
`${e.escenario} (n = ${e.n.toLocaleString('es-MX')}, fallecidos = ${e.fallecidos.toLocaleString('es-MX')})`,
|
||||
e,
|
||||
e.horizons_months,
|
||||
'Supervivencia S(t)',
|
||||
),
|
||||
),
|
||||
),
|
||||
};
|
||||
},
|
||||
});
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
/** TEA: her latest ADOS-2 (an encounter whose observations are the catalog's
|
||||
* `ados2.*` fields), item by item, and its totals. */
|
||||
protected readonly ados2 = computed(() => {
|
||||
@@ -247,6 +277,32 @@ export class Paciente {
|
||||
(s) => s.z !== null && s.z !== undefined,
|
||||
),
|
||||
);
|
||||
protected readonly biomarkerNames = BIOMARKER_NAMES;
|
||||
protected readonly outcomeNames = OUTCOME_NAMES;
|
||||
/** "Relación con el ADOS-2": her altered zones (|z| ≥ 2) with a clear association in the
|
||||
* cohort (q < 0.05), clearest first, as the old summary showed them. */
|
||||
protected readonly related = computed(() =>
|
||||
(this.eeg.value()?.analysis?.relation ?? [])
|
||||
.filter((f) => Math.abs(f.z) >= 2 && f.q !== null && f.q !== undefined && f.q < 0.05)
|
||||
.sort((a, b) => (a.q ?? 1) - (b.q ?? 1)),
|
||||
);
|
||||
protected qText(q?: number | null): string {
|
||||
return q === null || q === undefined ? '—' : q < 0.001 ? '< 0.001' : `= ${q.toFixed(3)}`;
|
||||
}
|
||||
protected observed(f: Relation): string {
|
||||
if (f.observed === null || f.observed === undefined) return 'Sin dato';
|
||||
if (f.kind === 'item')
|
||||
return f.observed >= 1 ? `Alterado (${f.observed})` : 'Sin anormalidad (0)';
|
||||
return `CSS ${f.observed}`;
|
||||
}
|
||||
/** Whether what she shows is what the model leans to (above or below one half). */
|
||||
protected matches(f: Relation): string | undefined {
|
||||
if (f.observed === null || f.observed === undefined) return undefined;
|
||||
const present = f.kind === 'item' ? f.observed >= 1 : f.observed >= 8;
|
||||
return present === f.probability >= 0.5
|
||||
? 'Coincide con lo que el modelo esperaba'
|
||||
: 'No coincide con lo que el modelo esperaba';
|
||||
}
|
||||
protected readonly zoneOrder = computed(() => byDeviation(this.zoned()?.zones ?? []));
|
||||
protected readonly head = computed(() => headMap(this.zoned()?.electrodes ?? []));
|
||||
protected readonly curve = computed<Figure>(() => {
|
||||
|
||||
Reference in New Issue
Block a user