diff --git a/CHANGELOG.md b/CHANGELOG.md index ee8c7bd..bbc1649 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ This log documents significant changes for each release. This project follows [Semantic Versioning](http://semver.org/). +## [3.16.2] - 2025-01-16 +### Fixed +- Bug with toString when userInvocationTable passed. + ## [3.16.1] - 2025-01-09 ### Fixed - Read environment variables only when they are used in an expression, avoiding diff --git a/package-lock.json b/package-lock.json index c7c6959..766823c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "fhirpath", - "version": "3.16.1", + "version": "3.16.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "fhirpath", - "version": "3.16.1", + "version": "3.16.2", "hasInstallScript": true, "license": "SEE LICENSE in LICENSE.md", "dependencies": { diff --git a/package.json b/package.json index 5e77dbd..f7d462e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fhirpath", - "version": "3.16.1", + "version": "3.16.2", "description": "A FHIRPath engine", "main": "src/fhirpath.js", "types": "src/fhirpath.d.ts", diff --git a/src/fhirpath.js b/src/fhirpath.js index 8b7fafc..66fba29 100644 --- a/src/fhirpath.js +++ b/src/fhirpath.js @@ -506,7 +506,10 @@ function makeParam(ctx, parentData, type, param) { } function doInvoke(ctx, fnName, data, rawParams){ - var invoc = ctx.userInvocationTable?.[fnName] + var invoc = + ctx.userInvocationTable + && Object.prototype.hasOwnProperty.call(ctx.userInvocationTable, fnName) + && ctx.userInvocationTable?.[fnName] || engine.invocationTable[fnName] || data.length === 1 && data[0]?.invocationTable[fnName]; var res; diff --git a/test/user-invocation-table.test.js b/test/user-invocation-table.test.js index 50cbdc1..bcaea0c 100644 --- a/test/user-invocation-table.test.js +++ b/test/user-invocation-table.test.js @@ -75,6 +75,23 @@ describe('concept', () => { expr = "next.concept().select($this | $this.next.concept()).display"; retrieved = fhirpath.evaluate(concepts.a, expr, null, null, options); expect(retrieved).toEqual(["B", "C"]); + }); +}); + +describe("toString", () => { + it("Works when userInvocationTable passed without overriding toString", () => { + const options = { + userInvocationTable: {}, + }; + + let result = fhirpath.evaluate( + { index: 0 }, + "index.toString()", + null, + null, + options + ); + expect(result).toEqual(["0"]); }); });