fume-fhir-converter
Version:
FHIR-Utilized Mapping Engine - Community
32 lines • 1.09 kB
JavaScript
;
/**
* © Copyright Outburn Ltd. 2022-2024 All Rights Reserved
* Project name: FUME-COMMUNITY
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getJsonElementName = void 0;
const getInitCapKey = (code, lastNode) => {
const typeCodeInitCap = code.slice(0, 1).toUpperCase() + code.slice(1);
return lastNode.split('[x]')[0] + typeCodeInitCap;
};
const getJsonElementName = async (element, fshKey) => {
const path = element.path;
const lastNode = path.split('.')[path.split('.').length - 1];
if (lastNode.slice(-3) === '[x]') {
if (element.type.length > 1) {
const possibleKeys = element.type.map(t => getInitCapKey(t.code, lastNode));
if (possibleKeys.includes(fshKey)) {
return fshKey;
}
}
else {
const typeCode = element.type[0].code;
return getInitCapKey(typeCode, lastNode);
}
}
else {
return fshKey;
}
};
exports.getJsonElementName = getJsonElementName;
//# sourceMappingURL=getJsonElementName.js.map