- move pipeline, queue, and config logic into runtime/domain modules - remove legacy client/routes/normalizers/pipeline wiring from core - update connector usage and instrument check to new domain entrypoints - document new structure and add translator engine overrides in configs - align package metadata name in lockfile
35 lines
951 B
JavaScript
35 lines
951 B
JavaScript
const parserMap = {
|
|
'http-json': require('../parsers/httpParser'),
|
|
'hl7-tcp': require('../parsers/hl7Parser'),
|
|
'astm-serial': require('../parsers/astmParser'),
|
|
hl7: require('../parsers/hl7Parser'),
|
|
astm: require('../parsers/astmParser'),
|
|
http: require('../parsers/httpParser')
|
|
};
|
|
|
|
function resolveCustomParser(parserName) {
|
|
if (!parserName || typeof parserName !== 'string') return null;
|
|
try {
|
|
const custom = require(`../../config/${parserName}`);
|
|
if (custom && typeof custom.parse === 'function') {
|
|
return custom;
|
|
}
|
|
} catch (error) {
|
|
return null;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function resolveParser(connector, instrumentEntry) {
|
|
const parserName = instrumentEntry?.translator?.parser || connector;
|
|
const parser = parserMap[parserName] || resolveCustomParser(parserName);
|
|
if (!parser) {
|
|
throw new Error(`no parser registered for ${parserName}`);
|
|
}
|
|
return parser;
|
|
}
|
|
|
|
module.exports = {
|
|
resolveParser
|
|
};
|