Giter Club home page Giter Club logo

fhirpath.js's Introduction

fhirpath.js

To use it, npm install fhirpath.js. Then:

   var fp = require('fhirpath.js')
   var result = fp.evaluate({      // the target to evaluate against
     "a": 1,
     "b": [2, 3]
   }, "a | b | a")                    // the path expression to evaluate

   assert.deepEqual(result, [1, 2, 3, 1])

To add you own custom constants to the lookup table, pass along a third argument like:

   var result = fp.evaluate({      // the target to evaluate against
     "a": "some great value",
     "b": [2, 3]
   }, "a=%my-constant", {
     "my-constant": "some great value"
   })
   
   assert.deepEqual(result, [true])

If passing a lookup table with every call gets tedious, you can create a new execution context with the table baked in:

   var myfp = fp.withConstants({"my-constant": "some great value"})
   
   var result = myfp.evaluate({      // the target to evaluate against
     "a": "some great value",
     "b": [2, 3]
   }, "a=%my-constant")
   
   assert.deepEqual(result, [true])

Try it

Live demo at https://niquola.github.io/fhirpath-demo/#/

Develop it

Generate the lexer and parser from the included Antlr grammer via:

sh ./setup.sh

Run tests:

npm  test

Regenerate test case file:

npm run-script generate-test-cases

fhirpath.js's People

Contributors

jmandel avatar

Watchers

James Cloos avatar Cedricoode avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.