Stream: fhirpath
Topic: named functions
Grahame Grieve (Apr 11 2018 at 06:13):
I've been wondering whether we need to create the facility to define named functions to allow for query re-use...?
Ewout Kramer (Apr 13 2018 at 14:59):
Yes, I have been thinking about that - and the .NET fhirpath engine internally could handle custom functions. We don't have a syntax for it though. Would we want to parameterize the queries?
Grahame Grieve (Apr 13 2018 at 20:44):
don't know, probably
Brian Postlethwaite (Apr 17 2018 at 22:29):
The dotnet one does handle custom functions, I've added a few for my own use in my server.
Brian Postlethwaite (Apr 17 2018 at 22:30):
(and the fhirpath tester)
Without needing to change the actual engine too... thanks Ewout!
Grahame Grieve (Apr 17 2018 at 22:40):
so have I. But there needs to be a fhirpath syntax to do it
Brian Postlethwaite (Apr 17 2018 at 22:43):
really?
In the dotnet one it behaves as though its a native part of the grammar.
Brian Postlethwaite (Apr 17 2018 at 22:43):
We have access to add the function into the symbol table.
Grahame Grieve (Apr 17 2018 at 22:44):
but can you define a function without access to the code?
Brian Postlethwaite (Apr 17 2018 at 22:45):
(pseudocode) SymbolTable.Add("LuhnTest", (a) => { return StaticFunctons.LuhnTest(a);});
Brian Postlethwaite (Apr 17 2018 at 22:45):
Yes, have access to the symbol table to add the functionname, and callback for execution
Grahame Grieve (Apr 17 2018 at 22:46):
but you can only do that in code - that's my point. There should be a way to do in fhirpath syntax when defining invariants etc
Brian Postlethwaite (Apr 17 2018 at 22:47):
The actual code looks like this
// Custom LUHN Checksum algorithm // https://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers#C.23 Hl7.FhirPath.FhirPathCompiler.DefaultSymbolTable.Add("LuhnTest", (string str) => { return str.LuhnCheck(); });
Brian Postlethwaite (Apr 17 2018 at 22:47):
Yeah, in code, just not the fhirpath engine code.
Brian Postlethwaite (Apr 17 2018 at 22:48):
Do you mean define a custom function using fhirpath as its definition?
Brian Postlethwaite (Apr 17 2018 at 22:48):
(or similar)
Bryn Rhodes (Apr 22 2018 at 18:50):
To define functions, you need libraries, right?
Bryn Rhodes (Apr 22 2018 at 18:51):
CQL supports this already, would it work to use CQL as the container for FHIRPath function definitions?
Grahame Grieve (Apr 23 2018 at 00:30):
smells too heavy weight to me
Last updated: Apr 12 2022 at 19:14 UTC