Conectar dialog by kind of source; plain-language canvas; login page and guard; loading indicators as the old app; survival curves of her clinical scenarios in the CaMa record
This commit is contained in:
@@ -6,7 +6,10 @@ import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
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 { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { FormlyFieldConfig, FormlyForm, provideFormlyCore } from '@ngx-formly/core';
|
||||
import { FormlyJsonschema } from '@ngx-formly/core/json-schema';
|
||||
import { withFormlyMaterial } from '@ngx-formly/material';
|
||||
@@ -24,6 +27,7 @@ import type { Pipeline } from '../api/models/pipeline';
|
||||
import type { Source } from '../api/models/source';
|
||||
import { ConceptMapEditor } from './concept-map-editor';
|
||||
import { FORMLY_TYPES, nodeSchema } from './schema-form';
|
||||
import { SourceDialog, SourceDialogData, SourceDialogResult } from './source-dialog';
|
||||
|
||||
type Doc = Pipeline['nodes'][number];
|
||||
type Kind = NonNullable<Doc['kind']>;
|
||||
@@ -47,16 +51,29 @@ 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> = {
|
||||
source: 'Fuente',
|
||||
read: 'Leer',
|
||||
route: 'Filtrar',
|
||||
map: 'Mapear',
|
||||
extract: 'Extraer',
|
||||
fhir: 'FHIR',
|
||||
join: 'Unir',
|
||||
link: 'Vincular',
|
||||
target: 'Destino',
|
||||
source: 'Fuente de datos',
|
||||
read: 'Leer documentos',
|
||||
route: 'Separar por tipo',
|
||||
map: 'Traducir códigos',
|
||||
extract: 'Sacar datos',
|
||||
fhir: 'Leer FHIR',
|
||||
join: 'Juntar',
|
||||
link: 'Identificar a la persona',
|
||||
target: 'Guardar en la plataforma',
|
||||
};
|
||||
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_]*$/;
|
||||
|
||||
@@ -73,7 +90,9 @@ const ID = /^[a-z][a-z0-9_]*$/;
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatListModule,
|
||||
MatSlideToggleModule,
|
||||
MatTableModule,
|
||||
MatTooltipModule,
|
||||
Vflow,
|
||||
ConceptMapEditor,
|
||||
],
|
||||
@@ -85,7 +104,11 @@ const ID = /^[a-z][a-z0-9_]*$/;
|
||||
export class Conectar {
|
||||
private readonly api = inject(Api);
|
||||
private readonly jsonschema = inject(FormlyJsonschema);
|
||||
private readonly dialog = inject(MatDialog);
|
||||
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) });
|
||||
private readonly schema = resource({ loader: () => this.api.invoke(schema) });
|
||||
@@ -158,10 +181,47 @@ export class Conectar {
|
||||
}
|
||||
|
||||
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;
|
||||
while (this.docs().some((d) => d.id === `${kind}_${n}`)) n++;
|
||||
const id = `${kind}_${n}`;
|
||||
const doc = { id, kind, inputs: [] } as unknown as Doc;
|
||||
const doc = { id, kind, inputs: [], ...fields } as unknown as Doc;
|
||||
this.docs.update((ds) => [...ds, doc]);
|
||||
this.nodes.update((ns) => [
|
||||
...ns,
|
||||
@@ -204,6 +264,12 @@ export class Conectar {
|
||||
);
|
||||
this.form = new UntypedFormGroup({});
|
||||
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. */
|
||||
@@ -213,6 +279,7 @@ export class Conectar {
|
||||
const values = Object.fromEntries(
|
||||
Object.entries(model).filter(([, v]) => v !== undefined && v !== null),
|
||||
);
|
||||
if (this.advanced()) delete values['guided']; // drawn by hand from here on
|
||||
this.update(
|
||||
id,
|
||||
(d) => ({ ...values, id: d.id, kind: d.kind, inputs: d.inputs }) as unknown as Doc,
|
||||
|
||||
Reference in New Issue
Block a user