UNPKG

fume-fhir-converter

Version:

FHIR-Utilized Mapping Engine - Community

30 lines 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolve = void 0; const tslib_1 = require("tslib"); /** * © Copyright Outburn Ltd. 2022-2024 All Rights Reserved * Project name: FUME-COMMUNITY */ const fhirServer_1 = require("../fhirServer"); const thrower_1 = tslib_1.__importDefault(require("../thrower")); const resolve = async (reference) => { // TODO: enable input to be a reference object, and handle logical references (search by identifier) // TODO: handle internal bundle and contained references if (reference.includes('?')) return thrower_1.default.throwRuntimeError(`The $resolve function only supports literal references. Got: '${reference}'`); let resource; try { resource = await (0, fhirServer_1.getFhirClient)().read(reference); } catch (error) { return thrower_1.default.throwRuntimeError(`Failed to resolve reference '${reference}'. ${JSON.stringify(error)}`); } if ((resource.resourceType === 'Bundle' && !reference.startsWith('Bundle'))) { return thrower_1.default.throwRuntimeError(`The $resolve function can only resolve a reference to a single resource. Response from FHIR server is a Bundle. Reference: '${reference}'`); } ; return resource; }; exports.resolve = resolve; //# sourceMappingURL=resolve.js.map