Skip to content

Commit

Permalink
Merge branch 'bugfix/LF-3060/fix-changing-input-parameters' into 'mas…
Browse files Browse the repository at this point in the history
…ter'

Fixed a bug that could cause the context input parameter containing environment variables to change

See merge request lfor/fhirpath.js!18
  • Loading branch information
yuriy-sedinkin committed Jul 1, 2024
2 parents 374a37b + 4ed1ef4 commit cbdcdbc
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 100 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
This log documents significant changes for each release. This project follows
[Semantic Versioning](http://semver.org/).

## [3.13.4] - 2024-06-13
### Fixed
- a bug that could cause the context input parameter containing environment
variables to change.

## [3.13.3] - 2024-05-24
### Changed
- Added separate TypeScript type definition files for the main file and each
Expand Down
52 changes: 26 additions & 26 deletions demo/package-lock.json

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

116 changes: 44 additions & 72 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.13.3",
"version": "3.13.4",
"description": "A FHIRPath engine",
"main": "src/fhirpath.js",
"types": "src/fhirpath.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/fhirpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,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'};
let ctx = {dataRoot, processedVars: vars, vars: context || {}, model};
let ctx = {dataRoot, processedVars: vars, vars: {...context}, model};
if (options.traceFn) {
ctx.customTraceFn = options.traceFn;
}
Expand Down
11 changes: 11 additions & 0 deletions test/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,16 @@ describe('evaluate type() on a FHIRPath evaluation result', () => {
'Quantity', 'Quantity', 'Quantity', 'Quantity', 'Date'
]);
});

it('should not change the context input parameter containing environment variables', () => {
const originalVars = {a: 'abc'};
const vars = _.cloneDeep(originalVars);
expect(fhirpath.evaluate(
{},
'%a = \'abc\'',
vars
)).toStrictEqual([true]);
expect(originalVars).toStrictEqual(vars);
})
});

0 comments on commit cbdcdbc

Please sign in to comment.