@@ -4907,6 +4907,17 @@ var __extends = (this && this.__extends) || (function () {
49074907 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
49084908 };
49094909})();
4910+ var __assign = (this && this.__assign) || function () {
4911+ __assign = Object.assign || function(t) {
4912+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4913+ s = arguments[i];
4914+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
4915+ t[p] = s[p];
4916+ }
4917+ return t;
4918+ };
4919+ return __assign.apply(this, arguments);
4920+ };
49104921Object.defineProperty(exports, "__esModule", { value: true });
49114922exports.Retrieve = void 0;
49124923var expression_1 = require("./expression");
@@ -4927,21 +4938,28 @@ var Retrieve = /** @class */ (function (_super) {
49274938 Retrieve.prototype.exec = function (ctx) {
49284939 var _a;
49294940 var _this = this;
4930- var records = ctx.findRecords(this.templateId != null ? this.templateId : this.datatype);
4931- var codes = this.codes;
4932- if (this.codes && typeof this.codes.exec === 'function') {
4933- codes = this.codes.execute(ctx);
4934- if (codes == null) {
4941+ // Object with retrieve information to pass back to patient source
4942+ // Always assign datatype. Assign codeProperty and dateProperty if present
4943+ var retrieveDetails = __assign(__assign({ datatype: this.datatype }, (this.codeProperty ? { codeProperty: this.codeProperty } : {})), (this.dateProperty ? { dateProperty: this.dateProperty } : {}));
4944+ if (this.codes) {
4945+ var resolvedCodes = this.codes.execute(ctx);
4946+ if (resolvedCodes == null) {
49354947 return [];
49364948 }
4949+ retrieveDetails.codes = resolvedCodes;
4950+ }
4951+ if (this.dateRange) {
4952+ retrieveDetails.dateRange = this.dateRange.execute(ctx);
4953+ }
4954+ if (this.templateId) {
4955+ retrieveDetails.templateId = this.templateId;
49374956 }
4938- if (codes) {
4939- records = records.filter(function (r) { return _this.recordMatchesCodesOrVS(r, codes); });
4957+ var records = ctx.findRecords(this.templateId != null ? this.templateId : this.datatype, retrieveDetails);
4958+ if (retrieveDetails.codes) {
4959+ records = records.filter(function (r) { return _this.recordMatchesCodesOrVS(r, retrieveDetails.codes); });
49404960 }
4941- // TODO: Added @dateProperty check due to previous fix in cql4browsers in cql_qdm_patient_api hash: ddbc57
4942- if (this.dateRange && this.dateProperty) {
4943- var range_1 = this.dateRange.execute(ctx);
4944- records = records.filter(function (r) { return range_1.includes(r.getDateOrInterval(_this.dateProperty)); });
4961+ if (retrieveDetails.dateRange && this.dateProperty) {
4962+ records = records.filter(function (r) { var _a; return (_a = retrieveDetails.dateRange) === null || _a === void 0 ? void 0 : _a.includes(r.getDateOrInterval(_this.dateProperty)); });
49454963 }
49464964 if (Array.isArray(records)) {
49474965 (_a = ctx.evaluatedRecords).push.apply(_a, records);
@@ -9014,8 +9032,8 @@ var Context = /** @class */ (function () {
90149032 return this;
90159033 }
90169034 };
9017- Context.prototype.findRecords = function (profile) {
9018- return this.parent && this.parent.findRecords(profile);
9035+ Context.prototype.findRecords = function (profile, retrieveDetails ) {
9036+ return this.parent && this.parent.findRecords(profile, retrieveDetails );
90199037 };
90209038 Context.prototype.childContext = function (context_values) {
90219039 if (context_values === void 0) { context_values = {}; }
@@ -9360,8 +9378,8 @@ var PatientContext = /** @class */ (function (_super) {
93609378 }
93619379 return this.localId_context[localId];
93629380 };
9363- PatientContext.prototype.findRecords = function (profile) {
9364- return this.patient && this.patient.findRecords(profile);
9381+ PatientContext.prototype.findRecords = function (profile, retrieveDetails ) {
9382+ return this.patient && this.patient.findRecords(profile, retrieveDetails );
93659383 };
93669384 return PatientContext;
93679385}(Context));
0 commit comments