UNPKG

cql-execution

Version:

An execution framework for the Clinical Quality Language (CQL)

119 lines (95 loc) 3.74 kB
// Generated by CoffeeScript 1.12.7 (function() { var Expression, Property, Tuple, TupleElement, TupleElementDefinition, UnimplementedExpression, build, ref, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; ref = require('./expression'), Expression = ref.Expression, UnimplementedExpression = ref.UnimplementedExpression; build = require('./builder').build; module.exports.Property = Property = (function(superClass) { extend(Property, superClass); function Property(json) { Property.__super__.constructor.apply(this, arguments); this.scope = json.scope; this.source = build(json.source); this.path = json.path; } Property.prototype.exec = function(ctx) { var _obj, curr_obj, curr_val, i, len, obj, part, parts, ref1, ref2, val; obj = this.scope != null ? ctx.get(this.scope) : this.source; if (obj instanceof Expression) { obj = obj.execute(ctx); } val = (ref1 = obj != null ? obj[this.path] : void 0) != null ? ref1 : obj != null ? typeof obj.get === "function" ? obj.get(this.path) : void 0 : void 0; if (!val) { parts = this.path.split("."); curr_obj = obj; curr_val = null; for (i = 0, len = parts.length; i < len; i++) { part = parts[i]; _obj = (ref2 = curr_obj != null ? curr_obj[part] : void 0) != null ? ref2 : curr_obj != null ? typeof curr_obj.get === "function" ? curr_obj.get(part) : void 0 : void 0; curr_obj = _obj instanceof Function ? _obj.call(curr_obj) : _obj; } val = curr_obj != null ? curr_obj : null; } if (val instanceof Function) { return val.call(obj); } else { return val; } }; return Property; })(Expression); module.exports.Tuple = Tuple = (function(superClass) { extend(Tuple, superClass); function Tuple(json) { var el; Tuple.__super__.constructor.apply(this, arguments); this.elements = (function() { var i, len, ref1, results; ref1 = json.element; results = []; for (i = 0, len = ref1.length; i < len; i++) { el = ref1[i]; results.push({ name: el.name, value: build(el.value) }); } return results; })(); } Object.defineProperties(Tuple.prototype, { isTuple: { get: function() { return true; } } }); Tuple.prototype.exec = function(ctx) { var el, i, len, ref1, ref2, val; val = {}; ref1 = this.elements; for (i = 0, len = ref1.length; i < len; i++) { el = ref1[i]; val[el.name] = (ref2 = el.value) != null ? ref2.execute(ctx) : void 0; } return val; }; return Tuple; })(Expression); module.exports.TupleElement = TupleElement = (function(superClass) { extend(TupleElement, superClass); function TupleElement() { return TupleElement.__super__.constructor.apply(this, arguments); } return TupleElement; })(UnimplementedExpression); module.exports.TupleElementDefinition = TupleElementDefinition = (function(superClass) { extend(TupleElementDefinition, superClass); function TupleElementDefinition() { return TupleElementDefinition.__super__.constructor.apply(this, arguments); } return TupleElementDefinition; })(UnimplementedExpression); }).call(this); //# sourceMappingURL=structured.js.map