@phema/cql-execution
Version:
An execution framework for the Clinical Quality Language (CQL)
73 lines (51 loc) • 3.78 kB
JavaScript
;
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
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 Results = /*#__PURE__*/function () {
function Results() {
_classCallCheck(this, Results);
this.patientResults = {};
this.unfilteredResults = {};
this.localIdPatientResultsMap = {};
this.patientEvaluatedRecords = {};
} // Expose an evaluatedRecords array for backwards compatibility
_createClass(Results, [{
key: "evaluatedRecords",
get: function get() {
var _ref;
return (_ref = []).concat.apply(_ref, _toConsumableArray(Object.values(this.patientEvaluatedRecords)));
}
}, {
key: "recordPatientResults",
value: function recordPatientResults(patient_ctx, resultMap) {
var _this = this;
var p = patient_ctx.patient; // NOTE: From now on prefer getId() over id() because some data models may have an id property
// that is not a string (e.g., FHIR) -- so reserve getId() for the API (and expect a string
// representation) but leave id() for data-model specific formats.
var patientId = typeof p.getId === 'function' ? p.getId() : p.id(); // Record the results
this.patientResults[patientId] = resultMap; // Record the local IDs
this.localIdPatientResultsMap[patientId] = patient_ctx.getAllLocalIds(); // Record the evaluatedRecords, merging with an aggregated array across all libraries
this.patientEvaluatedRecords[patientId] = _toConsumableArray(patient_ctx.evaluatedRecords);
Object.values(patient_ctx.library_context).forEach(function (ctx) {
var _this$patientEvaluate;
(_this$patientEvaluate = _this.patientEvaluatedRecords[patientId]).push.apply(_this$patientEvaluate, _toConsumableArray(ctx.evaluatedRecords));
});
}
}, {
key: "recordUnfilteredResults",
value: function recordUnfilteredResults(resultMap) {
this.unfilteredResults = resultMap;
}
}]);
return Results;
}();
module.exports = {
Results: Results
};