fume-fhir-converter
Version:
FHIR-Utilized Mapping Engine - Community
171 lines • 6.45 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
/**
* © Copyright Outburn Ltd. 2022-2024 All Rights Reserved
* Project name: FUME-COMMUNITY
*/
const globals_1 = require("@jest/globals");
const supertest_1 = tslib_1.__importDefault(require("supertest"));
const fhirHelpers_1 = require("../utils/fhirHelpers");
const getResourceFileContents_1 = require("../utils/getResourceFileContents");
const mockInput_1 = require("../utils/mockInput");
describe('using a concept map', () => {
let fumeConceptMapId;
let genderConceptMapId;
beforeAll(async () => {
// load concept map
fumeConceptMapId = await (0, fhirHelpers_1.addConcept)('concept-fume-aliases.json');
genderConceptMapId = await (0, fhirHelpers_1.addConcept)('gender.json', 'gender');
await (0, fhirHelpers_1.addPractitioner)('practitioner.json', 'cc829d28-3b32-43df-af57-e72035d98e18');
await (0, supertest_1.default)(globalThis.app).get('/recache');
});
afterAll(async () => {
await (0, fhirHelpers_1.deleteConcept)(fumeConceptMapId);
await (0, fhirHelpers_1.deleteConcept)(genderConceptMapId);
await (0, fhirHelpers_1.deletePractitioner)('cc829d28-3b32-43df-af57-e72035d98e18');
await (0, supertest_1.default)(globalThis.app).get('/recache');
});
(0, globals_1.test)('Case 12 - aliases stopped working', async () => {
const mapping = `
Instance: $pid := '584afafb-c979-44bd-a821-fb232721480e'
InstanceOf: Patient
* identifier
* system = $urn
* value = 'urn:uuid:' & $pid
* identifier
* system = $exampleMrn
* value = mrn
* identifier
* system = $ssn
* value = ssn
* identifier
* system = $passportPrefix & passport_country
* value = passport_number
`;
const requestBody = {
input: mockInput_1.mockInput,
fume: mapping
};
const res = await (0, supertest_1.default)(globalThis.app).post('/').send(requestBody);
expect(res.body).toStrictEqual({
resourceType: 'Patient',
id: '584afafb-c979-44bd-a821-fb232721480e',
identifier: [
{
system: 'urn:ietf:rfc:3986',
value: 'urn:uuid:584afafb-c979-44bd-a821-fb232721480e'
},
{
system: 'http://this.is.an.example.uri/mrn',
value: 'PP875023983'
},
{
system: 'http://hl7.org/fhir/sid/us-ssn',
value: '123-45-6789'
},
{
system: 'http://hl7.org/fhir/sid/passport-USA',
value: '7429184766'
}
]
});
});
(0, globals_1.test)('Default example mapping from Designer', async () => {
const fume = (0, getResourceFileContents_1.getResourceFileContents)('mappings', 'flash-script-fhir-4.0-patient.txt');
const requestBody = {
input: mockInput_1.mockInput,
fume
};
const res = await (0, supertest_1.default)(globalThis.app).post('/').send(requestBody);
expect(res.body).toStrictEqual({
resourceType: 'Patient',
id: '356a192b-7913-504c-9457-4d18c28d46e6',
identifier: [
{
system: 'urn:ietf:rfc:3986',
value: 'urn:uuid:356a192b-7913-504c-9457-4d18c28d46e6'
},
{
system: 'http://this.is.an.example.uri/mrn',
value: 'PP875023983'
},
{
system: 'http://hl7.org/fhir/sid/us-ssn',
value: '123-45-6789'
},
{
system: 'http://hl7.org/fhir/sid/passport-USA',
value: '7429184766'
}
],
active: true,
name: [
{
given: [
'Jessica'
],
family: 'Rabbit'
}
],
birthDate: '1988-06-22',
gender: 'female',
address: [
{
city: 'Orlando',
state: 'FL',
country: 'USA',
line: [
'1375 Buena Vista'
],
postalCode: '3456701',
extension: [
{
url: 'http://hl7.org/fhir/StructureDefinition/geolocation',
extension: [
{
url: 'latitude',
valueDecimal: 28.3519592
},
{
url: 'longitude',
valueDecimal: -81.417283
}
]
}
]
}
],
telecom: [
{
system: 'phone',
value: '+1 (407) 8372859',
use: 'home'
},
{
system: 'phone',
value: '+1 (305) 9831195',
use: 'mobile'
}
],
generalPractitioner: [
{
identifier: {
value: '1-820958',
type: {
coding: [
{
system: 'http://terminology.hl7.org/CodeSystem/v2-0203',
code: 'MD'
}
]
}
},
display: 'Dr. Dolittle',
reference: 'Practitioner/cc829d28-3b32-43df-af57-e72035d98e18'
}
]
});
});
});
//# sourceMappingURL=concept-map.test.js.map