@phema/cql-execution
Version:
An execution framework for the Clinical Quality Language (CQL)
64 lines (54 loc) • 2.1 kB
JavaScript
;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var Ratio = /*#__PURE__*/function () {
function Ratio(numerator, denominator) {
_classCallCheck(this, Ratio);
this.numerator = numerator;
this.denominator = denominator;
if (this.numerator == null) {
throw new Error('Cannot create a ratio with an undefined numerator');
}
if (this.denominator == null) {
throw new Error('Cannot create a ratio with an undefined denominator');
}
}
_createClass(Ratio, [{
key: "isRatio",
get: function get() {
return true;
}
}, {
key: "clone",
value: function clone() {
return new Ratio(this.numerator.clone(), this.denominator.clone());
}
}, {
key: "toString",
value: function toString() {
return "".concat(this.numerator.toString(), " : ").concat(this.denominator.toString());
}
}, {
key: "equals",
value: function equals(other) {
if (other != null && other.isRatio) {
var divided_this = this.numerator.dividedBy(this.denominator);
var divided_other = other.numerator.dividedBy(other.denominator);
return divided_this.equals(divided_other);
} else {
return false;
}
}
}, {
key: "equivalent",
value: function equivalent(other) {
var equal = this.equals(other);
return equal != null ? equal : false;
}
}]);
return Ratio;
}();
module.exports = {
Ratio: Ratio
};