integrating latest dashboard changes
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { TargetMeta } from '../api/api.types';
|
||||
import { suggestTarget, words } from './target-suggester';
|
||||
|
||||
const targets = ['Paciente', 'OrdenesEstudio', 'NotaMedica', 'BiopsiaCervical', 'BiometriaHematica'].map(
|
||||
const targets = ['Paciente', 'OrdenesEstudio', 'CitologiaCervical', 'NotaMedica', 'BiopsiaCervical', 'BiometriaHematica'].map(
|
||||
(table) => ({ key: `cacu.${table}`, domain: 'cacu', table, conflict_fields: null, fields: [] }) as TargetMeta,
|
||||
);
|
||||
|
||||
@@ -19,6 +19,10 @@ describe('suggestTarget', () => {
|
||||
// Nothing in the table's own name — fall back to the connection's.
|
||||
['Tabla 1 · pág. 1', 'cacu_biopsias_reporte.pdf', 'BiopsiaCervical'],
|
||||
['Regiones 1', 'pacientes_escaneados.pdf', 'Paciente'],
|
||||
// Hospital tables named without separators.
|
||||
['citologiacervical', 'hospital_cacu', 'CitologiaCervical'],
|
||||
['biopsiacervical', 'hospital_cacu', 'BiopsiaCervical'],
|
||||
['notamedica', 'hospital_cacu', 'NotaMedica'],
|
||||
])('%s (%s) → %s', (table, connection, expected) => {
|
||||
expect(suggestTarget(table, targets, connection)?.table).toBe(expected);
|
||||
});
|
||||
|
||||
@@ -25,9 +25,13 @@ function forms(word: string): string[] {
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Run-together names ("citologiacervical") count a target word found inside them. */
|
||||
function overlap(sourceText: string, targetText: string): number {
|
||||
const source = new Set(words(sourceText).flatMap(forms));
|
||||
return words(targetText).filter((word) => forms(word).some((form) => source.has(form))).length;
|
||||
const sourceWords = words(sourceText);
|
||||
const source = new Set(sourceWords.flatMap(forms));
|
||||
const matches = (form: string) =>
|
||||
source.has(form) || (form.length > 3 && sourceWords.some((word) => word.includes(form)));
|
||||
return words(targetText).filter((word) => forms(word).some(matches)).length;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user