integration layer; merge work on indicators from forks with existing ingestion pipeline

This commit is contained in:
Roberto Treviño Cervantes
2026-10-23 00:00:14 -06:00
parent b0608fdc70
commit d9245fe9b7
194 changed files with 21773 additions and 848 deletions
+84
View File
@@ -0,0 +1,84 @@
import { Observable, of } from 'rxjs';
import { PreviewResponse, SourceLocator, TargetMeta } from '../api/api.types';
import { SourceGateway } from '../api/source-gateway';
import { DataConnection, SourceTable } from '../domain/data-source';
/** Test doubles for the domain layer, with no HTTP or Angular DI. */
export const PACIENTE: TargetMeta = {
key: 'cacu.Paciente',
domain: 'cacu',
table: 'Paciente',
conflict_fields: ['pac_id_hospital'],
fields: [
{ name: 'pac_id_hospital', required: true, type: 'string' },
{ name: 'pac_sexo', required: false, type: 'string' },
{ name: 'pac_parentesco', required: false, type: 'string' },
],
};
export const NOTA: TargetMeta = {
key: 'cacu.NotaMedica',
domain: 'cacu',
table: 'NotaMedica',
conflict_fields: null,
fields: [
{ name: 'pac_id_hospital', required: true, type: 'string' },
{ name: 'nm_id_hospital', required: true, type: 'string' },
],
};
export function preview(overrides: Partial<PreviewResponse> = {}): PreviewResponse {
return {
columns: [
{ name: 'Clave', inferred_type: 'string' },
{ name: 'Sexo', inferred_type: 'string' },
],
sample_rows: [
{ Clave: 'H-1', Sexo: 'F' },
{ Clave: 'H-2', Sexo: 'X' },
],
total_rows: 2,
suggested_mapping: [
{ source_column: 'Clave', target_field: null, confidence: 0, reason: 'none' },
{ source_column: 'Sexo', target_field: 'pac_sexo', confidence: 0.8, reason: 'synonym' },
],
...overrides,
};
}
export class FakeConnection extends DataConnection {
readonly icon = 'table_view';
readonly typeLabel = 'Fake';
constructor(
label = 'fake.csv',
private readonly discovered: () => SourceTable[] = () => [],
) {
super(label);
}
override get singleTable(): boolean {
return true;
}
protected discover(): Observable<SourceTable[]> {
return of(this.discovered());
}
}
export class FakeTable extends SourceTable {
readonly icon = 'table_view';
readonly kindLabel = 'Fake';
constructor(
connection: DataConnection,
name = 'fake',
private readonly response: () => Observable<PreviewResponse> = () => of(preview()),
) {
super(connection, name);
}
preview(): Observable<PreviewResponse> {
return this.response();
}
async locator(): Promise<SourceLocator> {
return { source_type: 'csv', payload: { file_base64: 'QQ==' } };
}
}
export const NO_GATEWAY = {} as SourceGateway;