UNPKG

cql-execution

Version:

An execution framework for the Clinical Quality Language (CQL)

148 lines (123 loc) 3.58 kB
// Generated by CoffeeScript 1.12.7 (function() { var Code, CodeSystem, Concept, ValueSet, codesInList, codesMatch, toCodeList, typeIsArray; typeIsArray = require('../util/util').typeIsArray; module.exports.Code = Code = (function() { function Code(code3, system, version, display) { this.code = code3; this.system = system; this.version = version; this.display = display; } Object.defineProperties(Code.prototype, { isCode: { get: function() { return true; } } }); Code.prototype.hasMatch = function(code) { if (typeof code === 'string') { return code === this.code; } else { return codesInList(toCodeList(code), [this]); } }; return Code; })(); module.exports.Concept = Concept = (function() { function Concept(codes, display) { this.codes = codes != null ? codes : []; this.display = display; } Object.defineProperties(Concept.prototype, { isConcept: { get: function() { return true; } } }); Concept.prototype.hasMatch = function(code) { return codesInList(toCodeList(code), this.codes); }; return Concept; })(); module.exports.ValueSet = ValueSet = (function() { function ValueSet(oid, version, codes) { this.oid = oid; this.version = version; this.codes = codes != null ? codes : []; } Object.defineProperties(ValueSet.prototype, { isValueSet: { get: function() { return true; } } }); ValueSet.prototype.hasMatch = function(code) { var codeItem, codesList, i, len, matchFound, multipleCodeSystemsExist, ref; codesList = toCodeList(code); if (codesList.length === 1 && typeof codesList[0] === 'string') { matchFound = false; multipleCodeSystemsExist = false; ref = this.codes; for (i = 0, len = ref.length; i < len; i++) { codeItem = ref[i]; if (codeItem.system !== this.codes[0].system) { multipleCodeSystemsExist = true; } if (codeItem.code === codesList[0]) { matchFound = true; } if (multipleCodeSystemsExist && matchFound) { throw new Error('In (valueset) is ambiguous -- multiple codes with multiple code systems exist in value set.'); } } return matchFound; } else { return codesInList(codesList, this.codes); } }; return ValueSet; })(); toCodeList = function(c) { var c2, i, len, list; if (c == null) { return []; } else if (typeIsArray(c)) { list = []; for (i = 0, len = c.length; i < len; i++) { c2 = c[i]; list = list.concat(toCodeList(c2)); } return list; } else if (typeIsArray(c.codes)) { return c.codes; } else { return [c]; } }; codesInList = function(cl1, cl2) { return cl1.some(function(c1) { return cl2.some(function(c2) { if (typeof c1 === 'string') { return c1 === c2.code; } else { return codesMatch(c1, c2); } }); }); }; codesMatch = function(code1, code2) { return code1.code === code2.code && code1.system === code2.system; }; module.exports.CodeSystem = CodeSystem = (function() { function CodeSystem(id, version) { this.id = id; this.version = version; } return CodeSystem; })(); }).call(this); //# sourceMappingURL=clinical.js.map