UNPKG

fume-fhir-converter

Version:

FHIR-Utilized Mapping Engine - Community

44 lines 1.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.translateCode = void 0; const tslib_1 = require("tslib"); /** * © Copyright Outburn Ltd. 2022-2024 All Rights Reserved * Project name: FUME-COMMUNITY */ const cache_1 = require("../cache"); const conformance_1 = require("../conformance"); const jsonataExpression_1 = tslib_1.__importDefault(require("../jsonataExpression")); const logger_1 = require("../logger"); const translateCode = async (input, tableId) => { const { tables } = (0, cache_1.getCache)(); try { let map = tables.get(tableId); if (map === undefined) { (0, logger_1.getLogger)().info(`Table ${tableId} not cached, trying to fetch from server...`); const table = await (0, conformance_1.getTable)(tableId); if (table) { map = table[tableId]; tables.set(tableId, map); } } ; const mapFiltered = map[input]; let result; if (mapFiltered) { if (mapFiltered.length === 1) { result = mapFiltered[0].code; } else { result = await jsonataExpression_1.default.translateCodeExtract.evaluate({}, { mapFiltered }); } } return result; } catch (error) { (0, logger_1.getLogger)().error({ error }); return undefined; } }; exports.translateCode = translateCode; //# sourceMappingURL=translateCode.js.map