From ef851e2032d8fae12244ba08605da981526c6dd3 Mon Sep 17 00:00:00 2001 From: sedinkinya Date: Wed, 24 Apr 2024 11:31:54 -0400 Subject: [PATCH 1/5] Fixed an issue with evaluating an expression for a resource passed through an environment variable LF-3005 --- CHANGELOG.md | 5 +++ package-lock.json | 4 +- package.json | 2 +- src/fhirpath.js | 4 +- test/api.test.js | 16 +++++++ .../questionnaire-response-example.json | 42 +++++++++++++++++++ 6 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 test/resources/questionnaire-response-example.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ddf3ea..2aaffe7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ This log documents significant changes for each release. This project follows [Semantic Versioning](http://semver.org/). +## [3.13.1] - 2024-04-24 +### Fixed +- an issue with evaluating an expression for a resource passed through an + environment variable. + ## [3.13.0] - 2024-04-10 ### Added - Function `defineVariable(name: String [, expr: expression])`. diff --git a/package-lock.json b/package-lock.json index 016e682..647100a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "fhirpath", - "version": "3.13.0", + "version": "3.13.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "fhirpath", - "version": "3.13.0", + "version": "3.13.1", "license": "SEE LICENSE in LICENSE.md", "dependencies": { "@lhncbc/ucum-lhc": "^5.0.0", diff --git a/package.json b/package.json index e241ca4..9063331 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fhirpath", - "version": "3.13.0", + "version": "3.13.1", "description": "A FHIRPath engine", "main": "src/fhirpath.js", "dependencies": { diff --git a/src/fhirpath.js b/src/fhirpath.js index 8a43d82..4ef31f4 100644 --- a/src/fhirpath.js +++ b/src/fhirpath.js @@ -666,12 +666,12 @@ function applyParsedPath(resource, parsedPath, context, model, options) { i => i?.__path__ ? makeResNode(i, i.__path__.path || null, null, i.__path__.fhirNodeDataType || null) - : i ); + : makeResNode(i, null, null) ); } else { restoredContext[key] = context[key]?.__path__ ? makeResNode(context[key], context[key].__path__.path || null, null, context[key].__path__.fhirNodeDataType || null) - : context[key]; + : makeResNode(context[key], null, null); } return restoredContext; }, {}); diff --git a/test/api.test.js b/test/api.test.js index 4c613ea..46f9eef 100644 --- a/test/api.test.js +++ b/test/api.test.js @@ -10,6 +10,13 @@ const input = { ); }, + get questionnaireResponseExample() { + // Clone input file contents to avoid one test affecting another + return _.cloneDeep( + require('../test/resources/questionnaire-response-example.json') + ); + }, + get quantityExample() { // Clone input file contents to avoid one test affecting another return _.cloneDeep( @@ -33,6 +40,15 @@ describe('compile', () => { .toStrictEqual(['2 year']); }); + it('should accept a resource as a environment variable', () => { + let f = fhirpath.compile( + '%resource.descendants().where(linkId = \'answersFromParentQR\').answer.value', + r4_model + ); + expect(f({}, {resource: input.questionnaireResponseExample})) + .toStrictEqual(['Blue', 'Green']); + }); + it('should evaluate type() on a part of a resource', () => { let f = fhirpath.compile({ base: 'QuestionnaireResponse.item', diff --git a/test/resources/questionnaire-response-example.json b/test/resources/questionnaire-response-example.json new file mode 100644 index 0000000..674a7d4 --- /dev/null +++ b/test/resources/questionnaire-response-example.json @@ -0,0 +1,42 @@ +{ + "resourceType": "QuestionnaireResponse", + "meta": { + "profile": [ + "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaireresponse|3.0" + ], + "tag": [ + { + "code": "lformsVersion: 36.0.2" + } + ] + }, + "status": "completed", + "authored": "2024-04-23T13:49:53.827Z", + "questionnaire": "http://hl7.org/fhir/us/sirb/Questionnaire/sirb-adverse-event-questionnaire-populate", + "item": [ + { + "linkId": "mae4", + "text": "Tests I", + "item": [ + { + "linkId": "mae4.1", + "text": "Where Adverse Medical Event Occurred", + "item": [ + { + "linkId": "answersFromParentQR", + "text": "LinkID: answersFromParentQR [Getting data from parent questionnnaire - will be hidden with questionnaire-hidden extension later] initialExpression: %lookupInitiateStudy.descendants().where(linkId = 'in8.9').answer.value", + "answer": [ + { + "valueString": "Blue" + }, + { + "valueString": "Green" + } + ] + } + ] + } + ] + } + ] +} From 4efd8b9fb94c7e5b052a2d546d74525ab2479b97 Mon Sep 17 00:00:00 2001 From: sedinkinya Date: Fri, 3 May 2024 17:04:46 -0400 Subject: [PATCH 2/5] Fixed an issue with "statusShift" during performance tests LF-3005 --- CHANGELOG.md | 1 + package-lock.json | 11 +++++------ package.json | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2aaffe7..697d7bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This log documents significant changes for each release. This project follows ### Fixed - an issue with evaluating an expression for a resource passed through an environment variable. +- an issue with "statusShift" during performance tests. ## [3.13.0] - 2024-04-10 ### Added diff --git a/package-lock.json b/package-lock.json index 647100a..27f0672 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "@babel/eslint-parser": "^7.17.0", "@babel/preset-env": "^7.16.11", "babel-loader": "^8.2.3", - "benny": "^3.7.1", + "benny": "github:caderek/benny#pull/40", "bestzip": "^2.2.0", "copy-webpack-plugin": "^6.0.3", "cypress": "^13.7.2", @@ -4253,9 +4253,9 @@ }, "node_modules/benny": { "version": "3.7.1", - "resolved": "https://registry.npmjs.org/benny/-/benny-3.7.1.tgz", - "integrity": "sha512-USzYxODdVfOS7JuQq/L0naxB788dWCiUgUTxvN+WLPt/JfcDURNNj8kN/N+uK6PDvuR67/9/55cVKGPleFQINA==", + "resolved": "git+ssh://git@github.com/caderek/benny.git#0ad058d3c7ef0b488a8fe9ae3519159fc7f36bb6", "dev": true, + "license": "ISC", "dependencies": { "@arrows/composition": "^1.0.0", "@arrows/dispatch": "^1.0.2", @@ -16865,10 +16865,9 @@ } }, "benny": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/benny/-/benny-3.7.1.tgz", - "integrity": "sha512-USzYxODdVfOS7JuQq/L0naxB788dWCiUgUTxvN+WLPt/JfcDURNNj8kN/N+uK6PDvuR67/9/55cVKGPleFQINA==", + "version": "git+ssh://git@github.com/caderek/benny.git#0ad058d3c7ef0b488a8fe9ae3519159fc7f36bb6", "dev": true, + "from": "benny@git+ssh://git@github.com:caderek/benny.git#pull/40", "requires": { "@arrows/composition": "^1.0.0", "@arrows/dispatch": "^1.0.2", diff --git a/package.json b/package.json index 9063331..d8e1883 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "@babel/eslint-parser": "^7.17.0", "@babel/preset-env": "^7.16.11", "babel-loader": "^8.2.3", - "benny": "^3.7.1", + "benny": "github:caderek/benny#pull/40", "bestzip": "^2.2.0", "copy-webpack-plugin": "^6.0.3", "cypress": "^13.7.2", @@ -41,6 +41,7 @@ "node": ">=8.9.0" }, "scripts": { + "postinstall": "echo \"Building the Benny package based on a pull request which fixes an issue with 'statusShift'... \" && (cd node_modules/benny && npm i && npm run build > /dev/null) || echo \"Building the Benny package is completed.\"", "generateParser": "cd src/parser; rimraf ./generated/*; java -Xmx500M -cp \"../../antlr-4.9.3-complete.jar:$CLASSPATH\" org.antlr.v4.Tool -o generated -Dlanguage=JavaScript FHIRPath.g4; grunt updateParserRequirements", "build": "cd browser-build && webpack && rimraf fhirpath.zip && bestzip fhirpath.zip LICENSE.md fhirpath.min.js fhirpath.r5.min.js fhirpath.r4.min.js fhirpath.stu3.min.js fhirpath.dstu2.min.js && rimraf LICENSE.md", "test:unit": "node --use_strict node_modules/.bin/jest && TZ=America/New_York node --use_strict node_modules/.bin/jest && TZ=Europe/Paris node --use_strict node_modules/.bin/jest", From 35ac9c91c7f5e5be63fe90442c8388f11f0b7c15 Mon Sep 17 00:00:00 2001 From: sedinkinya Date: Wed, 8 May 2024 18:06:18 -0400 Subject: [PATCH 3/5] Fixed some performance issues LF-3005 --- fhir-context/dstu2/index.js | 8 ++-- fhir-context/general-additions.js | 17 ++++++++ fhir-context/r4/index.js | 9 ++--- fhir-context/r5/index.js | 8 ++-- fhir-context/stu3/index.js | 8 ++-- package-lock.json | 7 +++- package.json | 2 +- src/fhirpath.js | 54 ++++++++++++++----------- src/misc.js | 2 +- src/types.js | 66 +++++++++++++++++-------------- src/utilities.js | 7 +++- 11 files changed, 109 insertions(+), 79 deletions(-) create mode 100644 fhir-context/general-additions.js diff --git a/fhir-context/dstu2/index.js b/fhir-context/dstu2/index.js index 853aeaf..35d9e1c 100644 --- a/fhir-context/dstu2/index.js +++ b/fhir-context/dstu2/index.js @@ -1,3 +1,4 @@ +const updateWithGeneratedData = require('../general-additions'); /** * Exports the FHIR model data for DSTU2. This is an internal structure that * will likely evolve as more FHIR specific processing is added. @@ -24,10 +25,7 @@ const modelInfo = { path2Type: require('./path2Type.json') }; -// Generate a set of available data types -modelInfo.availableTypes = new Set(); -// IE11 probably doesn't support `new Set(iterable)` -Object.keys(modelInfo.type2Parent).forEach(i => modelInfo.availableTypes.add(i)); -Object.values(modelInfo.type2Parent).forEach(i => modelInfo.availableTypes.add(i)); +// Update with generated data +updateWithGeneratedData(modelInfo) module.exports = modelInfo; diff --git a/fhir-context/general-additions.js b/fhir-context/general-additions.js new file mode 100644 index 0000000..fd61a40 --- /dev/null +++ b/fhir-context/general-additions.js @@ -0,0 +1,17 @@ +// Update the model with generated data +module.exports = (modelInfo) => { + // Generate a set of available data types + modelInfo.availableTypes = new Set(); + // IE11 probably doesn't support `new Set(iterable)` + Object.keys(modelInfo.type2Parent).forEach(i => modelInfo.availableTypes.add(i)); + Object.values(modelInfo.type2Parent).forEach(i => modelInfo.availableTypes.add(i)); + + // Generate a hash map to map paths to data types excluding "BackboneElement" and "Element". + modelInfo.path2TypeWithoutElements = {}; + for(let i in modelInfo.path2Type) { + if (modelInfo.path2Type[i] === 'Element' || modelInfo.path2Type[i] === 'BackboneElement') { + continue; + } + modelInfo.path2TypeWithoutElements[i] = modelInfo.path2Type[i]; + } +}; diff --git a/fhir-context/r4/index.js b/fhir-context/r4/index.js index f36aa10..8779628 100644 --- a/fhir-context/r4/index.js +++ b/fhir-context/r4/index.js @@ -1,3 +1,5 @@ +const updateWithGeneratedData = require('../general-additions'); + /** * Exports the FHIR model data for R4. This is an internal structure that * will likely evolve as more FHIR specific processing is added. @@ -24,10 +26,7 @@ const modelInfo = { path2Type: require('./path2Type.json') }; -// Generate a set of available data types -modelInfo.availableTypes = new Set(); -// IE11 probably doesn't support `new Set(iterable)` -Object.keys(modelInfo.type2Parent).forEach(i => modelInfo.availableTypes.add(i)); -Object.values(modelInfo.type2Parent).forEach(i => modelInfo.availableTypes.add(i)); +// Update with generated data +updateWithGeneratedData(modelInfo) module.exports = modelInfo; diff --git a/fhir-context/r5/index.js b/fhir-context/r5/index.js index f746200..ea700a9 100644 --- a/fhir-context/r5/index.js +++ b/fhir-context/r5/index.js @@ -1,3 +1,4 @@ +const updateWithGeneratedData = require('../general-additions'); /** * Exports the FHIR model data for R5. This is an internal structure that * will likely evolve as more FHIR specific processing is added. @@ -24,10 +25,7 @@ const modelInfo = { path2Type: require('./path2Type.json') }; -// Generate a set of available data types -modelInfo.availableTypes = new Set(); -// IE11 probably doesn't support `new Set(iterable)` -Object.keys(modelInfo.type2Parent).forEach(i => modelInfo.availableTypes.add(i)); -Object.values(modelInfo.type2Parent).forEach(i => modelInfo.availableTypes.add(i)); +// Update with generated data +updateWithGeneratedData(modelInfo) module.exports = modelInfo; diff --git a/fhir-context/stu3/index.js b/fhir-context/stu3/index.js index 7c11b62..7ef072a 100644 --- a/fhir-context/stu3/index.js +++ b/fhir-context/stu3/index.js @@ -1,3 +1,4 @@ +const updateWithGeneratedData = require('../general-additions'); /** * Exports the FHIR model data for STU3. This is an internal structure that * will likely evolve as more FHIR specific processing is added. @@ -24,11 +25,8 @@ const modelInfo = { path2Type: require('./path2Type.json') }; -// Generate a set of available data types -modelInfo.availableTypes = new Set(); -// IE11 probably doesn't support `new Set(iterable)` -Object.keys(modelInfo.type2Parent).forEach(i => modelInfo.availableTypes.add(i)); -Object.values(modelInfo.type2Parent).forEach(i => modelInfo.availableTypes.add(i)); +// Update with generated data +updateWithGeneratedData(modelInfo) module.exports = modelInfo; diff --git a/package-lock.json b/package-lock.json index 27f0672..8c3a29b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "": { "name": "fhirpath", "version": "3.13.1", + "hasInstallScript": true, "license": "SEE LICENSE in LICENSE.md", "dependencies": { "@lhncbc/ucum-lhc": "^5.0.0", @@ -23,7 +24,7 @@ "@babel/eslint-parser": "^7.17.0", "@babel/preset-env": "^7.16.11", "babel-loader": "^8.2.3", - "benny": "github:caderek/benny#pull/40", + "benny": "github:caderek/benny#0ad058d3c7ef0b488a8fe9ae3519159fc7f36bb6", "bestzip": "^2.2.0", "copy-webpack-plugin": "^6.0.3", "cypress": "^13.7.2", @@ -4254,6 +4255,7 @@ "node_modules/benny": { "version": "3.7.1", "resolved": "git+ssh://git@github.com/caderek/benny.git#0ad058d3c7ef0b488a8fe9ae3519159fc7f36bb6", + "integrity": "sha512-E6Hn7OIXBdxjgl6yKBTL7fEp143s2+5tQyks9DMzsoT9dMuN+jQTsmlaE9QbjuyUH2N+NrxslWdcGlN8B/xrcw==", "dev": true, "license": "ISC", "dependencies": { @@ -16866,8 +16868,9 @@ }, "benny": { "version": "git+ssh://git@github.com/caderek/benny.git#0ad058d3c7ef0b488a8fe9ae3519159fc7f36bb6", + "integrity": "sha512-E6Hn7OIXBdxjgl6yKBTL7fEp143s2+5tQyks9DMzsoT9dMuN+jQTsmlaE9QbjuyUH2N+NrxslWdcGlN8B/xrcw==", "dev": true, - "from": "benny@git+ssh://git@github.com:caderek/benny.git#pull/40", + "from": "benny@git+ssh://git@github.com:caderek/benny.git#0ad058d3c7ef0b488a8fe9ae3519159fc7f36bb6", "requires": { "@arrows/composition": "^1.0.0", "@arrows/dispatch": "^1.0.2", diff --git a/package.json b/package.json index d8e1883..204447e 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "@babel/eslint-parser": "^7.17.0", "@babel/preset-env": "^7.16.11", "babel-loader": "^8.2.3", - "benny": "github:caderek/benny#pull/40", + "benny": "github:caderek/benny#0ad058d3c7ef0b488a8fe9ae3519159fc7f36bb6", "bestzip": "^2.2.0", "copy-webpack-plugin": "^6.0.3", "cypress": "^13.7.2", diff --git a/src/fhirpath.js b/src/fhirpath.js index 4ef31f4..b7c4407 100644 --- a/src/fhirpath.js +++ b/src/fhirpath.js @@ -251,8 +251,36 @@ engine.ExternalConstantTerm = function(ctx, parentData, node) { var identifier = extConstant.children[0]; var varName = engine.Identifier(ctx, parentData, identifier)[0]; - var value = ctx.vars[varName]; - if (!(varName in ctx.vars)) { + var value; + // Check the user-defined environment variables first as the user can override + // the "context" variable like we do in unit tests. In this case, the user + // environment variable can replace the system environment variable in "processedVars". + if (varName in ctx.vars) { + // Restore the ResourceNodes for the top-level objects of the environment + // variables. The nested objects will be converted to ResourceNodes + // in the MemberInvocation method. + value = ctx.vars[varName]; + if (Array.isArray(value)) { + value = value.map( + i => i?.__path__ + ? makeResNode(i, i.__path__.path || null, null, + i.__path__.fhirNodeDataType || null) + : i?.resourceType + ? makeResNode(i, null, null) + : i ); + } else { + value = value?.__path__ + ? makeResNode(value, value.__path__.path || null, null, + value.__path__.fhirNodeDataType || null) + : value?.resourceType + ? makeResNode(value, null, null) + : value; + } + ctx.processedVars[varName] = value; + delete ctx.vars[varName]; + } else if (varName in ctx.processedVars) { + value = ctx.processedVars[varName]; + } else { if (ctx.definedVars && varName in ctx.definedVars) value = ctx.definedVars[varName]; else @@ -656,27 +684,7 @@ function applyParsedPath(resource, parsedPath, context, model, options) { // Set up default standard variables, and allow override from the variables. // However, we'll keep our own copy of dataRoot for internal processing. let vars = {context: dataRoot, ucum: 'http://unitsofmeasure.org'}; - // Restore the ResourceNodes for the top-level objects of the context - // variables. The nested objects will be converted to ResourceNodes - // in the MemberInvocation method. - if (context) { - context = Object.keys(context).reduce((restoredContext, key) => { - if (Array.isArray(context[key])) { - restoredContext[key] = context[key].map( - i => i?.__path__ - ? makeResNode(i, i.__path__.path || null, null, - i.__path__.fhirNodeDataType || null) - : makeResNode(i, null, null) ); - } else { - restoredContext[key] = context[key]?.__path__ - ? makeResNode(context[key], context[key].__path__.path || null, null, - context[key].__path__.fhirNodeDataType || null) - : makeResNode(context[key], null, null); - } - return restoredContext; - }, {}); - } - let ctx = {dataRoot, vars: Object.assign(vars, context), model}; + let ctx = {dataRoot, processedVars: vars, vars: context || {}, model}; if (options.traceFn) { ctx.customTraceFn = options.traceFn; } diff --git a/src/misc.js b/src/misc.js index 5a3d6a5..e13dfe9 100644 --- a/src/misc.js +++ b/src/misc.js @@ -55,7 +55,7 @@ engine.defineVariable = function (x, label, expr) { // Just in time initialization of definedVars if (!this.definedVars) this.definedVars = {}; - if (Object.keys(this.vars).includes(label)) { + if (label in this.vars || label in this.processedVars) { throw new Error("Environment Variable %" + label + " already defined"); } diff --git a/src/types.js b/src/types.js index 09eca0b..1419c5d 100644 --- a/src/types.js +++ b/src/types.js @@ -1315,23 +1315,26 @@ class ResourceNode { * @return {TypeInfo} */ getTypeInfo() { - let result; - - if (TypeInfo.model) { - if (/^System\.(.*)$/.test(this.fhirNodeDataType)) { - result = new TypeInfo({namespace: TypeInfo.System, name: RegExp.$1}); - } else if (this.fhirNodeDataType) { - result = new TypeInfo({ - namespace: TypeInfo.FHIR, - name: this.fhirNodeDataType - }); + if (!this.typeInfo) { + let typeInfo; + + if (TypeInfo.model) { + if (/^System\.(.*)$/.test(this.fhirNodeDataType)) { + typeInfo = new TypeInfo({namespace: TypeInfo.System, name: RegExp.$1}); + } else if (this.fhirNodeDataType) { + typeInfo = new TypeInfo({ + namespace: TypeInfo.FHIR, + name: this.fhirNodeDataType + }); + } } - } - return result - // Resource object properties that are not defined in the model now have - // System.* data types: - || TypeInfo.createByValueInSystemNamespace(this.data); + this.typeInfo = typeInfo + // Resource object properties that are not defined in the model now have + // System.* data types: + || TypeInfo.createByValueInSystemNamespace(this.data); + } + return this.typeInfo; } toJSON() { @@ -1350,24 +1353,27 @@ class ResourceNode { * @return {FP_Type|any} */ convertData() { - var data = this.data; - const cls = TypeInfo.typeToClassWithCheckString[this.path]; - if (cls) { - data = cls.checkString(data) || data; - } else if (TypeInfo.isType(this.path, 'Quantity')) { - if (data?.system === ucumSystemUrl) { - if (typeof data.value === 'number' && typeof data.code === 'string') { - if (data.comparator !== undefined) - throw new Error('Cannot convert a FHIR.Quantity that has a comparator'); - data = new FP_Quantity( - data.value, - FP_Quantity.mapUCUMCodeToTimeUnits[data.code] || '\'' + data.code + '\'' - ); + if (!this.convertedData) { + var data = this.data; + const cls = TypeInfo.typeToClassWithCheckString[this.path]; + if (cls) { + data = cls.checkString(data) || data; + } else if (TypeInfo.isType(this.path, 'Quantity')) { + if (data?.system === ucumSystemUrl) { + if (typeof data.value === 'number' && typeof data.code === 'string') { + if (data.comparator !== undefined) + throw new Error('Cannot convert a FHIR.Quantity that has a comparator'); + data = new FP_Quantity( + data.value, + FP_Quantity.mapUCUMCodeToTimeUnits[data.code] || '\'' + data.code + '\'' + ); + } } } - } - return data; + this.convertedData = data; + } + return this.convertedData; } } diff --git a/src/utilities.js b/src/utilities.js index e68cee0..d8861c0 100644 --- a/src/utilities.js +++ b/src/utilities.js @@ -162,8 +162,11 @@ util.makeChildResNodes = function(parentResNode, childProperty, model) { } } - const fhirNodeDataType = model && model.path2Type[childPath] || null; - childPath = fhirNodeDataType === 'BackboneElement' || fhirNodeDataType === 'Element' ? childPath : fhirNodeDataType || childPath; + let fhirNodeDataType = null; + if (model) { + fhirNodeDataType = model.path2Type[childPath] || null; + childPath = model.path2TypeWithoutElements[childPath] || childPath; + } let result; if (util.isSome(toAdd) || util.isSome(_toAdd)) { From 172cf3505fe4e3a56dcd751b97aeb6aa01981dc3 Mon Sep 17 00:00:00 2001 From: sedinkinya Date: Tue, 14 May 2024 16:26:17 -0400 Subject: [PATCH 4/5] Changes as per review LF-3005 --- src/fhirpath.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/fhirpath.js b/src/fhirpath.js index b7c4407..76bb165 100644 --- a/src/fhirpath.js +++ b/src/fhirpath.js @@ -279,14 +279,16 @@ engine.ExternalConstantTerm = function(ctx, parentData, node) { ctx.processedVars[varName] = value; delete ctx.vars[varName]; } else if (varName in ctx.processedVars) { + // "processedVars" are variables with ready-to-use values that have already + // been converted to ResourceNodes if necessary. value = ctx.processedVars[varName]; + } else if (ctx.definedVars && varName in ctx.definedVars) { + // "definedVars" are variables defined with the "defineVariable" function. + value = ctx.definedVars[varName]; } else { - if (ctx.definedVars && varName in ctx.definedVars) - value = ctx.definedVars[varName]; - else - throw new Error( - "Attempting to access an undefined environment variable: " + varName - ); + throw new Error( + "Attempting to access an undefined environment variable: " + varName + ); } // For convenience, we all variable values to be passed in without their array // wrapper. However, when evaluating, we need to put the array back in. From 7273e8fd5e0493dbb3479ac65df3e9fcc198acee Mon Sep 17 00:00:00 2001 From: sedinkinya Date: Wed, 15 May 2024 13:37:30 -0400 Subject: [PATCH 5/5] Resolved merge conflicts LF-3005 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index f56e204..2bff4f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16870,7 +16870,7 @@ "version": "git+ssh://git@github.com/caderek/benny.git#0ad058d3c7ef0b488a8fe9ae3519159fc7f36bb6", "integrity": "sha512-E6Hn7OIXBdxjgl6yKBTL7fEp143s2+5tQyks9DMzsoT9dMuN+jQTsmlaE9QbjuyUH2N+NrxslWdcGlN8B/xrcw==", "dev": true, - "from": "benny@git+ssh://git@github.com:caderek/benny.git#0ad058d3c7ef0b488a8fe9ae3519159fc7f36bb6", + "from": "benny@github:caderek/benny#0ad058d3c7ef0b488a8fe9ae3519159fc7f36bb6", "requires": { "@arrows/composition": "^1.0.0", "@arrows/dispatch": "^1.0.2", diff --git a/package.json b/package.json index 204447e..e09ff50 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fhirpath", - "version": "3.13.1", + "version": "3.13.2", "description": "A FHIRPath engine", "main": "src/fhirpath.js", "dependencies": {