Stream: fhirpath
Topic: Math functions
Bryn Rhodes (Feb 01 2019 at 06:32):
GF#18501, GF#17842, GF#17507 suggest adding round(), sqrt(), log(), exp(), and pow(). For completeness we would also need floor(), ceiling(), truncate(), abs(), and ln(). Thoughts?
nicola (RIO/SS) (Feb 01 2019 at 08:24):
- max min
Bryn Rhodes (Feb 01 2019 at 15:12):
It's a never ending list, it seems like it would be better in the core FHIRPath spec to say that libraries can be included for this kind of thing.
Bryn Rhodes (Feb 01 2019 at 15:26):
Note that we can express max and min already with the aggregate function, so really I'm talking about the Math library functions here.
Paul Lynch (Feb 01 2019 at 16:41):
I don't know that we need to include everything all at once, but at least for fhirpath.js, it would be trivial to support any of the functions in the browser's Math library (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math). I have heard Clem McDonald ask about things like sin(x), cos(x), but I don't know offhand what would use those.
To another point, saying "libraries can be included" makes me wonder how a Questionnaire author would include the libraries needed, or if that was not something the Questionnaire could control, whether there would be a point in writing a Questionnaire whose correct functioning depending on the choice by the system to include libraries.
Grahame Grieve (Feb 01 2019 at 20:02):
libraries are problematic because of what Paul says
Bryn Rhodes (Feb 01 2019 at 20:29):
I agree the implementation is straightforward, and I'm not even concerned about specifying the semantics for this limited set, CQL already specifies exactly that set of operators. I'd just like to see some answer for how libraries are included because there will be requests for other operators. It'd be nice to be able to support that without having to change the spec.
Grahame Grieve (Feb 01 2019 at 20:46):
specifying how libraries are included will be an even bigger change...
Grahame Grieve (Feb 01 2019 at 20:46):
agree that's worth doing but think it's a bigger problem than we should handle at this point in the cycle
Bryn Rhodes (Feb 01 2019 at 23:01):
Okay, so I'm hearing persuasive as the proposed disposition here. One more consideration though, should we add a "Math" section and mark it STU? I'm concerned that adding this many completely new functions to a spec going normative would be a challenge. Is there room to say, yes, but next cycle?
Grahame Grieve (Feb 02 2019 at 21:15):
right. add it as STU for fll stnadardization next time
Bryn Rhodes (Oct 05 2019 at 23:33):
I'd like to include as many examples as I can of the use of the Math functions. Any examples involving the Math functions? .round(), .sqrt(), .exp(), .pow(), .log(), .ln(), etc.
Paul Lynch (Oct 07 2019 at 18:08):
BMI, with height & weight variables, rounded to 1 decimal place:
(%weight/(%height.power(2))).round(1)
Bryn Rhodes (Oct 07 2019 at 18:09):
Thanks @Paul Lynch !
Last updated: Apr 12 2022 at 19:14 UTC