FHIR Chat · FHIRPath Processor · fhirpath

Stream: fhirpath

Topic: FHIRPath Processor


view this post on Zulip Paul Lynch (Jul 18 2018 at 22:48):

I'm giving serious thought to writing an open source JavaScript FHIRPath processor (engine?). I am aware of the one https://github.com/jmandel/fhirpath.js, but was informed by Josh that that one is neither complete nor a good starting point. I was able to generate a working JavaScript parser from the ANTLR grammar, but before I get too far into what seems to be a big task that I probably don't fully understand, I would like to ask whether anyone else has worked on or is working on an open source JavaScript FHIRPath processor. If so, perhaps we could collaborate?

view this post on Zulip nicola (RIO/SS) (Jul 18 2018 at 22:50):

I hope, i will have time to help you with it - i promised David Hay sometimes to finish it :)

view this post on Zulip nicola (RIO/SS) (Jul 18 2018 at 22:50):

Year ago i did one in clojure

view this post on Zulip Chris Moesel (Jul 18 2018 at 22:55):

Given that fhirpath is a subset (of sorts) of CQL, it might be possible to leverage the cql-execution project, which is currently in CoffeeScript but published to npm as transpiled javascript. (We're also working on a port to ES6, but that's a little stalled right now.)

view this post on Zulip nicola (RIO/SS) (Jul 18 2018 at 22:56):

i would prefer to make it standalone

view this post on Zulip Chris Moesel (Jul 18 2018 at 22:58):

That said, there would be some effort involved there. Some things you'd want to be aware of:
1. It actually operates on the ELM JSON, so you'd still need the Java CQL-to-ELM translator -- which I think supports fhirpath? @Bryn Rhodes?
2. We don't have a FHIR STU3 (or R4) data binding yet -- although it would be fairly easy to update cql-exec-fhir to support it.
3. There might be some fhirpath operators that aren't implemented yet, as it's mainly been used w/ CQM and CDS use cases.

view this post on Zulip Chris Moesel (Jul 18 2018 at 22:58):

Ha. Yeah, with all of those caveats, I can understand if you'd like a smaller more focused implementation. But I thought I'd put it out there just in case.

view this post on Zulip nicola (RIO/SS) (Jul 18 2018 at 23:06):

FHIRpath implementation requires also some FHIR metadata, so i think we can provide this metadata not thro the code-generation, but directly as a data - so implementation will be version agnostic - less efforts to support.

view this post on Zulip Bryn Rhodes (Jul 18 2018 at 23:12):

@Chris Moesel , yes, the translator supports FHIRPath, and there are unit tests on the engine that flex that aspect.

view this post on Zulip Chris Moesel (Jul 18 2018 at 23:19):

Just to clarify: Regarding the unit tests, you're talking about the Java CQL engine. The CoffeeScript engine doesn't have unit tests for any fhirpath specific stuff. These guys are looking for a JavaScript implementation of fhirpath.

view this post on Zulip nicola (RIO/SS) (Jul 19 2018 at 00:19):

@Bryn Rhodes do we have good test cases for FHIRpath in JSON, covering most of specification?

view this post on Zulip nicola (RIO/SS) (Jul 19 2018 at 00:20):

Last time i was looking for test cases - they were only in XML :(

view this post on Zulip nicola (RIO/SS) (Jul 19 2018 at 00:21):

Ideally it can be just data like {resource: {....}, fhirpath: 'expression', result: value}

view this post on Zulip Grahame Grieve (Jul 19 2018 at 00:32):

good test data here:

view this post on Zulip Grahame Grieve (Jul 19 2018 at 00:33):

build\tests\resources\tests-fhir-r4.xml (in FHIR svn)

view this post on Zulip Grahame Grieve (Jul 19 2018 at 00:33):

tests themselves are in XML, but can be run on the json resources

view this post on Zulip Grahame Grieve (Jul 19 2018 at 00:34):

it's not that hard to read xml ;-)

view this post on Zulip Brian Postlethwaite (Jul 19 2018 at 00:34):

https://www.w3schools.com/xml/dom_intro.asp
if you really must do it from the JavaScript side.

view this post on Zulip Brian Postlethwaite (Jul 19 2018 at 00:34):

Its is only for testing afterall... :)

view this post on Zulip nicola (RIO/SS) (Jul 19 2018 at 00:35):

@Grahame Grieve why do not provide both xml & json versions like for other resources?

view this post on Zulip Grahame Grieve (Jul 19 2018 at 00:35):

because the tests are not a resource.

view this post on Zulip Grahame Grieve (Jul 19 2018 at 00:36):

they do nominate an xml file as input, but in no case is the outcome dependent on using the xml not the json as input

view this post on Zulip nicola (RIO/SS) (Jul 19 2018 at 00:38):

may be adopt https://www.hl7.org/fhir/testscript.html for that?

view this post on Zulip Grahame Grieve (Jul 19 2018 at 00:39):

maybe but it would be way overkill for what's a simple thing at the moment.

view this post on Zulip Grahame Grieve (Jul 19 2018 at 00:39):

just use an xml--> json translator on the fly ...

view this post on Zulip nicola (RIO/SS) (Jul 19 2018 at 00:39):

ok - but this is again JSON discrimination :)

view this post on Zulip Grahame Grieve (Jul 19 2018 at 00:40):

it's really simple: json doesn't have comments.

view this post on Zulip Grahame Grieve (Jul 19 2018 at 00:40):

like a car without doors

view this post on Zulip nicola (RIO/SS) (Jul 19 2018 at 00:41):

XML harassment: let's switch to yaml :)

view this post on Zulip nicola (RIO/SS) (Jul 19 2018 at 00:41):

it has comments

view this post on Zulip Brian Postlethwaite (Jul 19 2018 at 00:41):

Go plain text with pipe delimiters?
(kidding of course)

view this post on Zulip nicola (RIO/SS) (Jul 19 2018 at 00:43):

https://plus.google.com/+DouglasCrockfordEsq/posts/RK8qyGVaGSr

view this post on Zulip Grahame Grieve (Jul 19 2018 at 00:45):

yes he was wrong then and he's still wrong now. And JSMin is a javascript thing.

view this post on Zulip nicola (RIO/SS) (Jul 19 2018 at 00:46):

@Brian Postlethwaite no - next step is binary formats like protobuf, which go father then just pipe delimiters. And the whole IT industry is on JSON side - XML is dead.

view this post on Zulip Grahame Grieve (Jul 19 2018 at 00:48):

if we started using // for comments in JSON.... everyone not using javascript will need a new parser

view this post on Zulip nicola (RIO/SS) (Jul 19 2018 at 00:50):

https://github.com/FasterXML/jackson-core/wiki/JsonParser-Features#support-for-non-standard-data-format-constructs

view this post on Zulip nicola (RIO/SS) (Jul 19 2018 at 00:51):

https://stackoverflow.com/questions/10316997/how-can-i-read-json-with-comment-with-json-net

view this post on Zulip Grahame Grieve (Jul 19 2018 at 00:53):

I would also have to read the file with 2 other parsers

view this post on Zulip Paul Lynch (Jul 19 2018 at 20:21):

It should be easy enough to convert XML test cases to JSON,--or for that matter to parse the XML in JavaScript. I see the XML version at https://github.com/hl7-fhir/fhir-svn/blob/master/tests/resources/tests-fhir-r4.xml. It references a "patient-example.xml" which I don't see under tests/resources/. Where is that?

view this post on Zulip Bryn Rhodes (Jul 19 2018 at 20:25):

They are included here (at least for the STU2, looks like there ought to be STU3 and R4 versions included as well).

view this post on Zulip Grahame Grieve (Jul 19 2018 at 20:27):

those files are part of the FHIR Spec

view this post on Zulip Brian Postlethwaite (Jul 19 2018 at 21:58):

(therefore are available as both xml and json :) )


Last updated: Apr 12 2022 at 19:14 UTC