UNPKG

cql-execution

Version:

An execution framework for the Clinical Quality Language (CQL)

131 lines (116 loc) 3.73 kB
// Generated by CoffeeScript 1.12.7 (function() { var ThreeValuedLogic, Uncertainty; ThreeValuedLogic = require('./logic').ThreeValuedLogic; module.exports.Uncertainty = Uncertainty = (function() { Uncertainty.from = function(obj) { if (obj instanceof Uncertainty) { return obj; } else { return new Uncertainty(obj); } }; function Uncertainty(low, high) { var gt, isNonEnumerable, ref; this.low = low != null ? low : null; this.high = high; gt = function(a, b) { if (typeof a !== typeof b) { return false; } if (typeof a.after === 'function') { return a.after(b); } else { return a > b; } }; isNonEnumerable = function(val) { return (val != null) && (val.isCode || val.isConcept || val.isValueSet); }; if (typeof this.high === 'undefined') { this.high = this.low; } if (isNonEnumerable(this.low) || isNonEnumerable(this.high)) { this.low = this.high = null; } if ((this.low != null) && (this.high != null) && gt(this.low, this.high)) { ref = [this.high, this.low], this.low = ref[0], this.high = ref[1]; } } Uncertainty.prototype.copy = function() { var newHigh, newLow; newLow = this.low; newHigh = this.high; if (typeof this.low.copy === 'function') { newLow = this.low.copy(); } if (typeof this.high.copy === 'function') { newHigh = this.high.copy(); } return new Uncertainty(newLow, newHigh); }; Uncertainty.prototype.isPoint = function() { var gte, lte; lte = function(a, b) { if (typeof a !== typeof b) { return false; } if (typeof a.sameOrBefore === 'function') { return a.sameOrBefore(b); } else { return a <= b; } }; gte = function(a, b) { if (typeof a !== typeof b) { return false; } if (typeof a.sameOrBefore === 'function') { return a.sameOrAfter(b); } else { return a >= b; } }; return (this.low != null) && (this.high != null) && lte(this.low, this.high) && gte(this.low, this.high); }; Uncertainty.prototype.equals = function(other) { other = Uncertainty.from(other); return ThreeValuedLogic.not(ThreeValuedLogic.or(this.lessThan(other), this.greaterThan(other))); }; Uncertainty.prototype.lessThan = function(other) { var bestCase, lt, worstCase; lt = function(a, b) { if (typeof a !== typeof b) { return false; } if (typeof a.before === 'function') { return a.before(b); } else { return a < b; } }; other = Uncertainty.from(other); bestCase = (this.low == null) || (other.high == null) || lt(this.low, other.high); worstCase = (this.high != null) && (other.low != null) && lt(this.high, other.low); if (bestCase === worstCase) { return bestCase; } else { return null; } }; Uncertainty.prototype.greaterThan = function(other) { other = Uncertainty.from(other); return other.lessThan(this); }; Uncertainty.prototype.lessThanOrEquals = function(other) { other = Uncertainty.from(other); return ThreeValuedLogic.not(this.greaterThan(other)); }; Uncertainty.prototype.greaterThanOrEquals = function(other) { other = Uncertainty.from(other); return ThreeValuedLogic.not(this.lessThan(other)); }; return Uncertainty; })(); }).call(this); //# sourceMappingURL=uncertainty.js.map