TEA indicators, EEG section in governance

This commit is contained in:
Roberto Treviño
2026-11-26 07:06:52 -06:00
parent 53a6393cb2
commit 471ed3a18c
23 changed files with 614 additions and 20 deletions
+30
View File
@@ -0,0 +1,30 @@
/* 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 { Study } from '../../models/study';
export interface Studies$Params {
}
export function studies(http: HttpClient, rootUrl: string, params?: Studies$Params, context?: HttpContext): Observable<StrictHttpResponse<Array<Study>>> {
const rb = new RequestBuilder(rootUrl, studies.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<Array<Study>>;
})
);
}
studies.PATH = '/tea/eegs';
+32
View File
@@ -0,0 +1,32 @@
/* 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 { Analysis } from '../../models/analysis';
export interface Study$Params {
eeg_id: string;
}
export function study(http: HttpClient, rootUrl: string, params: Study$Params, context?: HttpContext): Observable<StrictHttpResponse<Analysis>> {
const rb = new RequestBuilder(rootUrl, study.PATH, 'get');
if (params) {
rb.path('eeg_id', params.eeg_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<Analysis>;
})
);
}
study.PATH = '/tea/eegs/{eeg_id}';
+36
View File
@@ -0,0 +1,36 @@
/* 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 { Domain } from '../../models/domain';
export interface Analyze$Params {
domain: Domain;
}
export function analyze(http: HttpClient, rootUrl: string, params: Analyze$Params, context?: HttpContext): Observable<StrictHttpResponse<{
[key: string]: string;
}>> {
const rb = new RequestBuilder(rootUrl, analyze.PATH, 'post');
if (params) {
rb.path('domain', params.domain, {});
}
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<{
[key: string]: string;
}>;
})
);
}
analyze.PATH = '/models/{domain}/analyze';
+1 -1
View File
@@ -9,7 +9,7 @@ import { RequestBuilder } from '../../request-builder';
export interface Conflicts$Params {
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death';
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
}
export function conflicts(http: HttpClient, rootUrl: string, params: Conflicts$Params, context?: HttpContext): Observable<StrictHttpResponse<Array<{
+1 -1
View File
@@ -9,7 +9,7 @@ import { RequestBuilder } from '../../request-builder';
export interface Held$Params {
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death';
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
}
export function held(http: HttpClient, rootUrl: string, params: Held$Params, context?: HttpContext): Observable<StrictHttpResponse<Array<{
+6
View File
@@ -31,6 +31,8 @@ export type { Upload$Params as Upload$Params } from './fn/ingest/upload';
export { upload as upload } from './fn/ingest/upload';
export type { Models$Params as Models$Params } from './fn/models/models';
export { models as models } from './fn/models/models';
export type { Analyze$Params as Analyze$Params } from './fn/models/analyze';
export { analyze as analyze } from './fn/models/analyze';
export type { Score$Params as Score$Params } from './fn/models/score';
export { score as score } from './fn/models/score';
export type { Train$Params as Train$Params } from './fn/models/train';
@@ -59,6 +61,10 @@ export type { Reject$Params as Reject$Params } from './fn/review/reject';
export { reject as reject } from './fn/review/reject';
export type { RunStatus$Params as RunStatus$Params } 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 { studies as studies } from './fn/eeg/studies';
export type { Study$Params as Study$Params } from './fn/eeg/study';
export { study as study } from './fn/eeg/study';
export type { PostBundle$Params as PostBundle$Params } 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';
+3
View File
@@ -1,6 +1,7 @@
/* eslint-disable */
/* Code generated by ng-openapi-gen DO NOT EDIT. */
export type { Analysis } from './models/analysis';
export type { BodyAddClinicalValidation } from './models/body-add-clinical-validation';
export type { BodyUpload } from './models/body-upload';
export type { Condition } from './models/condition';
@@ -12,6 +13,7 @@ export type { HttpValidationError } from './models/http-validation-error';
export type { Join } from './models/join';
export type { Link } from './models/link';
export type { Map } from './models/map';
export type { Metric } from './models/metric';
export type { PersonDecision } from './models/person-decision';
export type { Pipeline } from './models/pipeline';
export type { Position } from './models/position';
@@ -22,6 +24,7 @@ export type { RunRequest } from './models/run-request';
export type { SavedPipeline } from './models/saved-pipeline';
export type { Source } from './models/source';
export type { SourceRef } from './models/source-ref';
export type { Study } from './models/study';
export type { Target } from './models/target';
export type { Training } from './models/training';
export type { ValidationError } from './models/validation-error';
+11
View File
@@ -0,0 +1,11 @@
/* eslint-disable */
/* Code generated by ng-openapi-gen DO NOT EDIT. */
import { Metric } from '../models/metric';
export interface Analysis {
age_months: (number | null);
id: string;
level: (string | null);
metrics: Array<Metric>;
valid: (boolean | null);
}
+1 -1
View File
@@ -14,7 +14,7 @@ import { Position } from '../models/position';
export interface Extract {
column: string;
concept_map?: (string | null);
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death';
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
formats?: {
[key: string]: string;
};
+1 -1
View File
@@ -11,7 +11,7 @@ import { Position } from '../models/position';
export interface Fhir {
column?: string;
concept_map?: (string | null);
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death';
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
id: string;
inputs?: Array<string>;
kind?: 'fhir';
+3
View File
@@ -20,4 +20,7 @@ export interface Map {
kind?: 'map';
label?: string;
position?: (Position | null);
values?: {
[key: string]: string;
};
}
+10
View File
@@ -0,0 +1,10 @@
/* eslint-disable */
/* Code generated by ng-openapi-gen DO NOT EDIT. */
export interface Metric {
code: string;
model: (string | null);
outside: (number | null);
value: number;
z: (number | null);
}
+1 -1
View File
@@ -2,7 +2,7 @@
/* Code generated by ng-openapi-gen DO NOT EDIT. */
export interface Rejection {
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death';
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
reason: string;
record: string;
}
+12
View File
@@ -0,0 +1,12 @@
/* eslint-disable */
/* Code generated by ng-openapi-gen DO NOT EDIT. */
export interface Study {
analysed: boolean;
id: string;
lab_record_id: (string | null);
level: (string | null);
person_id: string;
study_date: string;
valid: (boolean | null);
}
+1 -1
View File
@@ -8,7 +8,7 @@ import { Position } from '../models/position';
* one `link` node among the inputs. Rule breaks are held for review.
*/
export interface Target {
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death';
entity: 'identity' | 'cervical_cytology' | 'cervical_biopsy' | 'mammography' | 'breast_biopsy' | 'clinical_note' | 'death' | 'mchat' | 'ados2' | 'eeg';
id: string;
inputs?: Array<string>;
kind?: 'target';
+1
View File
@@ -3,4 +3,5 @@
export interface Training {
as_of?: (string | null);
models?: Array<string>;
}
+63
View File
@@ -19,6 +19,9 @@
</mat-form-field>
<button mat-flat-button type="button" (click)="start('train')">Entrenar</button>
<button mat-stroked-button type="button" (click)="start('score')">Calcular riesgos</button>
@if (domain() === 'tea') {
<button mat-stroked-button type="button" (click)="analyzeEegs()">Analizar EEG</button>
}
@if (run(); as r) {
<span class="muted" role="status">{{ r.kind }}: {{ r.status }}</span>
}
@@ -113,4 +116,64 @@
}
</div>
}
@if (domain() === 'tea') {
<div class="card model">
<h2>Electroencefalogramas</h2>
<table class="plain eegs">
<thead>
<tr>
<th>Fecha</th>
<th>Registro</th>
<th>Análisis</th>
</tr>
</thead>
<tbody>
@for (e of eegs.value() ?? []; track e.id) {
<tr>
<td>
<button mat-button type="button" (click)="eeg.set(e.id)">{{ e.study_date }}</button>
</td>
<td>{{ e.lab_record_id ?? '—' }}</td>
<td>
{{ !e.analysed ? 'Sin analizar' : e.valid ? 'Válido' : 'No válido' }}
{{ e.level ? '(' + e.level + ')' : '' }}
</td>
</tr>
} @empty {
<tr>
<td colspan="3" class="muted">Sin EEG cargados.</td>
</tr>
}
</tbody>
</table>
@if (eegMetrics.value(); as m) {
<h3>EEG {{ m.id }} · {{ m.age_months ?? '—' }} meses</h3>
<table class="plain">
<thead>
<tr>
<th>Métrica</th>
<th>Valor</th>
<th>z</th>
<th>Curva</th>
</tr>
</thead>
<tbody>
@for (x of m.metrics; track x.code) {
<tr>
<td>{{ metricNames[x.code] ?? x.code }}</td>
<td class="num">{{ x.value | number: '1.2-2' }}</td>
<td class="num">{{ x.z === null ? '—' : (x.z | number: '1.2-2') }}</td>
<td>{{ x.model ?? 'sin curva en producción' }}</td>
</tr>
} @empty {
<tr>
<td colspan="4" class="muted">Sin métricas (EEG no válido).</td>
</tr>
}
</tbody>
</table>
}
</div>
}
</section>
+35 -7
View File
@@ -9,6 +9,7 @@ import { RouterLink } from '@angular/router';
import { Api } from '../api/api';
import { ApiConfiguration } from '../api/api-configuration';
import { addClinicalValidation } from '../api/fn/models/add-clinical-validation';
import { analyze } from '../api/fn/models/analyze';
import { models } from '../api/fn/models/models';
import { promote } from '../api/fn/models/promote';
import { readReport$Json } from '../api/fn/models/read-report-json';
@@ -16,6 +17,8 @@ import { score } from '../api/fn/models/score';
import { train } from '../api/fn/models/train';
import { versions } from '../api/fn/models/versions';
import { domains } from '../api/fn/operations/domains';
import { studies } from '../api/fn/eeg/studies';
import { study } from '../api/fn/eeg/study';
import { runStatus } from '../api/fn/runs/run-status';
import type { Domain } from '../api/models/domain';
import type { Version } from '../api/models/version';
@@ -78,6 +81,23 @@ export class Gobernanza {
const found = this.report.value();
return found ? interpretabilityFigures(found as Record<string, unknown>) : [];
});
/** TEA: its EEGs and their analysis. */
protected readonly eegs = resource({
params: () => (this.domain() === 'tea' ? this.refreshed() + 1 : undefined),
loader: () => this.api.invoke(studies),
});
protected readonly eeg = signal<string | undefined>(undefined);
protected readonly eegMetrics = resource({
params: () => this.eeg(),
loader: ({ params }) => this.api.invoke(study, { eeg_id: params }),
});
protected readonly metricNames: Record<string, string> = {
posterior_rhythm: 'Ritmo posterior (Hz)',
spindles_n2: 'Husos de sueño N2 (por min)',
spindles_n3: 'Husos de sueño N3 (por min)',
paroxysmal_spikes: 'Picos paroxísticos (por min)',
anteroposterior_gradient: 'Gradiente anteroposterior',
};
protected readonly asOf = signal('');
protected readonly run = signal<{ kind: string; status: string } | undefined>(undefined);
protected readonly message = signal('');
@@ -115,13 +135,12 @@ export class Gobernanza {
}
}
protected async start(kind: 'train' | 'score'): Promise<void> {
const domain = this.domain() as Domain;
const { run_id } =
kind === 'train'
? await this.api.invoke(train, { domain, body: this.asOf() ? { as_of: this.asOf() } : {} })
: await this.api.invoke(score, { domain });
const label = kind === 'train' ? 'Entrenamiento' : 'Cálculo de riesgos';
protected async analyzeEegs(): Promise<void> {
const { run_id } = await this.api.invoke(analyze, { domain: this.domain() as Domain });
await this.follow(run_id, 'Análisis de EEG');
}
private async follow(run_id: string, label: string): Promise<void> {
for (;;) {
const status = (await this.api.invoke(runStatus, { run_id }))['status'] as string;
this.run.set({ kind: label, status });
@@ -130,4 +149,13 @@ export class Gobernanza {
}
this.refreshed.update((n) => n + 1);
}
protected async start(kind: 'train' | 'score'): Promise<void> {
const domain = this.domain() as Domain;
const { run_id } =
kind === 'train'
? await this.api.invoke(train, { domain, body: this.asOf() ? { as_of: this.asOf() } : {} })
: await this.api.invoke(score, { domain });
await this.follow(run_id, kind === 'train' ? 'Entrenamiento' : 'Cálculo de riesgos');
}
}
+24
View File
@@ -68,4 +68,28 @@ export const LAYOUTS: Record<string, Layout> = {
],
anchor: 'CAMA_BIRADS',
},
tea: {
kpis: [
'M23_PACIENTES_EVALUADOS',
'M24_CONFIRMACION_DIAGNOSTICO',
'M25_DIAS_MCHAT_DIAGNOSTICO',
'M21_DIAGNOSTICADOS_CON_EEG',
'M29_CALIDAD_EEG',
],
route: [
{
label: 'ADOS-2',
step: 'Del M-CHAT al ADOS-2',
fromSample: 'M26_DIAS_MCHAT_ADOS2',
fromStep: 'M26_DIAS_MCHAT_ADOS2',
},
{
label: 'Valoración neuropediátrica',
step: 'Del ADOS-2 a la valoración neuropediátrica',
fromSample: 'M25_DIAS_MCHAT_DIAGNOSTICO',
fromStep: 'M27_DIAS_ADOS2_DIAGNOSTICO',
},
],
anchor: 'M23_PACIENTES_EVALUADOS',
},
};
+10
View File
@@ -106,6 +106,16 @@ const LABELS: Record<string, string> = {
pending_biopsy: 'Pendiente de biopsia',
biopsy_no_result: 'Biopsia sin resultado',
benign_biopsy: 'Biopsia benigna',
confirmed: 'Diagnóstico confirmado',
in_process: 'En proceso',
not_confirmed: 'Sin TEA',
mchat_only: 'Solo M-CHAT',
psychology: 'Psicología (ADOS-2)',
neuropediatrics: 'Neuropediatría',
eeg: 'EEG',
good: 'Bueno',
bad: 'Malo',
not_analyzed: 'Sin analizar',
...Object.fromEntries(
['0', '1', '2', '3', '4', '4A', '4B', '4C', '5', '6'].map((c) => [c, `BI-RADS ${c}`]),
),
+3
View File
@@ -32,6 +32,9 @@ const ENTITIES: Record<Entity, string> = {
identity: 'Identidad',
mammography: 'Mastografía',
breast_biopsy: 'Biopsia de mama',
mchat: 'M-CHAT',
ados2: 'ADOS-2',
eeg: 'Electroencefalograma',
};
const IDENTITY_FIELDS: Correction['field'][] = [
'record_number',