FHIR Chat · named functions · fhirpath

Stream: fhirpath

Topic: named functions


view this post on Zulip 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...?

view this post on Zulip 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?

view this post on Zulip Grahame Grieve (Apr 13 2018 at 20:44):

don't know, probably

view this post on Zulip 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.

view this post on Zulip Brian Postlethwaite (Apr 17 2018 at 22:30):

(and the fhirpath tester)
Without needing to change the actual engine too... thanks Ewout!

view this post on Zulip Grahame Grieve (Apr 17 2018 at 22:40):

so have I. But there needs to be a fhirpath syntax to do it

view this post on Zulip Brian Postlethwaite (Apr 17 2018 at 22:43):

really?
In the dotnet one it behaves as though its a native part of the grammar.

view this post on Zulip Brian Postlethwaite (Apr 17 2018 at 22:43):

We have access to add the function into the symbol table.

view this post on Zulip Grahame Grieve (Apr 17 2018 at 22:44):

but can you define a function without access to the code?

view this post on Zulip Brian Postlethwaite (Apr 17 2018 at 22:45):

(pseudocode) SymbolTable.Add("LuhnTest", (a) => { return StaticFunctons.LuhnTest(a);});

view this post on Zulip Brian Postlethwaite (Apr 17 2018 at 22:45):

Yes, have access to the symbol table to add the functionname, and callback for execution

view this post on Zulip 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

view this post on Zulip 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();
});

view this post on Zulip Brian Postlethwaite (Apr 17 2018 at 22:47):

Yeah, in code, just not the fhirpath engine code.

view this post on Zulip Brian Postlethwaite (Apr 17 2018 at 22:48):

Do you mean define a custom function using fhirpath as its definition?

view this post on Zulip Brian Postlethwaite (Apr 17 2018 at 22:48):

(or similar)

view this post on Zulip Bryn Rhodes (Apr 22 2018 at 18:50):

To define functions, you need libraries, right?

view this post on Zulip 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?

view this post on Zulip Grahame Grieve (Apr 23 2018 at 00:30):

smells too heavy weight to me


Last updated: Apr 12 2022 at 19:14 UTC