UNPKG

cql-execution

Version:

An execution framework for the Clinical Quality Language (CQL)

139 lines (105 loc) 3.67 kB
// Generated by CoffeeScript 1.12.7 (function() { var BooleanLiteral, DecimalLiteral, Expression, IntegerLiteral, Literal, StringLiteral, 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; Expression = require('./expression').Expression; module.exports.Literal = Literal = (function(superClass) { extend(Literal, superClass); Literal.from = function(json) { switch (json.valueType) { case "{urn:hl7-org:elm-types:r1}Boolean": return new BooleanLiteral(json); case "{urn:hl7-org:elm-types:r1}Integer": return new IntegerLiteral(json); case "{urn:hl7-org:elm-types:r1}Decimal": return new DecimalLiteral(json); case "{urn:hl7-org:elm-types:r1}String": return new StringLiteral(json); default: return new Literal(json); } }; function Literal(json) { Literal.__super__.constructor.apply(this, arguments); this.valueType = json.valueType; this.value = json.value; } Literal.prototype.exec = function(ctx) { return this.value; }; return Literal; })(Expression); module.exports.BooleanLiteral = BooleanLiteral = (function(superClass) { extend(BooleanLiteral, superClass); function BooleanLiteral(json) { BooleanLiteral.__super__.constructor.apply(this, arguments); this.value = this.value === 'true'; } Object.defineProperties(BooleanLiteral.prototype, { isBooleanLiteral: { get: function() { return true; } } }); BooleanLiteral.prototype.exec = function(ctx) { return this.value; }; return BooleanLiteral; })(Literal); module.exports.IntegerLiteral = IntegerLiteral = (function(superClass) { extend(IntegerLiteral, superClass); function IntegerLiteral(json) { IntegerLiteral.__super__.constructor.apply(this, arguments); this.value = parseInt(this.value, 10); } Object.defineProperties(IntegerLiteral.prototype, { isIntegerLiteral: { get: function() { return true; } } }); IntegerLiteral.prototype.exec = function(ctx) { return this.value; }; return IntegerLiteral; })(Literal); module.exports.DecimalLiteral = DecimalLiteral = (function(superClass) { extend(DecimalLiteral, superClass); function DecimalLiteral(json) { DecimalLiteral.__super__.constructor.apply(this, arguments); this.value = parseFloat(this.value); } Object.defineProperties(DecimalLiteral.prototype, { isDecimalLiteral: { get: function() { return true; } } }); DecimalLiteral.prototype.exec = function(ctx) { return this.value; }; return DecimalLiteral; })(Literal); module.exports.StringLiteral = StringLiteral = (function(superClass) { extend(StringLiteral, superClass); function StringLiteral(json) { StringLiteral.__super__.constructor.apply(this, arguments); } Object.defineProperties(StringLiteral.prototype, { isStringLiteral: { get: function() { return true; } } }); StringLiteral.prototype.exec = function(ctx) { return this.value.replace(/\\'/g, "'").replace(/\\"/g, "\""); }; return StringLiteral; })(Literal); }).call(this); //# sourceMappingURL=literal.js.map