Skip to content

Commit

Permalink
Merge branch 'bugfix/LF-3223/fix-userInvocationTable-for-toString' in…
Browse files Browse the repository at this point in the history
…to 'master'

Fix bug with toString when userInvocationTable passed

See merge request lfor/fhirpath.js!24
  • Loading branch information
yuriy-sedinkin committed Jan 21, 2025
2 parents bfc60d4 + 38d1fde commit 90a2f39
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 4 additions & 1 deletion src/fhirpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 17 additions & 0 deletions test/user-invocation-table.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
});
});

0 comments on commit 90a2f39

Please sign in to comment.