Skip to content

Commit

Permalink
refactor: change if behaviour to match fhirpath's iif
Browse files Browse the repository at this point in the history
  • Loading branch information
ruscoder committed May 24, 2024
1 parent 35441b4 commit 4809e3d
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions ts/server/src/utils/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,7 @@ function matchIfBlock(resource: Resource, node: any, context: any, model: any) {
const matches = ifKey.match(ifRegExp);
const expr = matches[1];

const answers = fhirpath.evaluate(resource, expr, context, model);
if (answers.length !== 1) {
throw new Error('If block must accept expression that returns single boolean value');
}

const answer = answers[0];
if (typeof answer !== 'boolean') {
throw new Error('If block must accept expression that returns single boolean value');
}
const answer = fhirpath.evaluate(resource, `iif(${expr}, true, false)`, context, model)[0];

return {
node: answer
Expand Down

0 comments on commit 4809e3d

Please sign in to comment.