Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add environment variables to FhirPath #2570

Closed
ewoutkramer opened this issue Aug 9, 2023 · 3 comments · Fixed by #2760
Closed

Add environment variables to FhirPath #2570

ewoutkramer opened this issue Aug 9, 2023 · 3 comments · Fixed by #2760
Assignees

Comments

@ewoutkramer
Copy link
Member

At this moment, it is possible to add constants to the SymbolTable so you can supply your own external values (just like functions) and refer to them from FhirPath.

However, it is also really useful to supply extrernal variables that can be different from invocation to invocation of a compiled fhirpath statement, variables that are specific for a single run of an expression.

We already pass in an EvaluationContext when we run an expression, so a natural extension point would be to make it possible to add context variables here, that can then be referenced from the FhirPath, e.g. with the normal % syntax.

Alternatively, we could introduce our own syntax in FhirPath, but that requires changes to the parser and brings little added value.

@brianpos
Copy link
Collaborator

brianpos commented Aug 9, 2023

I'd also love to see this too.
To date i've been just using a new Symbol table each time I need to do this, but that does mean it needs to be compiled each time.

@brianpos
Copy link
Collaborator

brianpos commented Aug 9, 2023

Also happy to contribute to this, as would love to see this type of capability also make implementing a proposed withVariable function...
https://chat.fhir.org/#narrow/stream/179266-fhirpath/topic/.22grouping.22.20elements

group.select(
  withVariable('grp')
  .select(
    element.select(
      withVariable('src')
      .target.select(
        %grp.source & '#' & %src.code
        & ' ' & equivalence & ' '
        & %grp.target & '#' & code
      )
    )
  )
)

🧪 Test with FHIRPath-Lab

@mmsmits
Copy link
Member

mmsmits commented Apr 4, 2024

  • How do other libraries this? Peak at an open source JavaScript library?
  • Also consider defineVariable, when designing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants