FHIR Chat · power() function not evaluated · fhirpath

Stream: fhirpath

Topic: power() function not evaluated


view this post on Zulip Shoaib Mushtaq (Mar 31 2022 at 20:39):

Hey guys, When I am trying to evaluate this expression fhirPathEngine.evaluate(testQuestionnaireResponse, "(50/(5.power(2))).round(1)"), It gives me an error around org.hl7.fhir.r4.utils.FHIRLexer$FHIRLexerException: Error in ?? at 1, 1: The name power is not a valid function name.
Let me know If I am doing anything wrong here?

view this post on Zulip Paul Lynch (Mar 31 2022 at 20:54):

Which JavaScript engine are you using? That expression works at https://hl7.github.io/fhirpath.js/

view this post on Zulip Grahame Grieve (Mar 31 2022 at 22:33):

I have not added that to the R4 engine in java. It's in the R5 engine.

view this post on Zulip Shoaib Mushtaq (Apr 01 2022 at 06:17):

@Paul Lynch I am using fhirPathEngine in Android SDK and using this version Gradle: ca.uhn.hapi.fhir:org.hl7.fhir.r4:5.4.0.
So as per @Grahame Grieve 's comment, looks like, I need to upgrade the version from R4 to R5. What are your thoughts?

view this post on Zulip Paul Lynch (Apr 01 2022 at 21:30):

Alternatively, you might be able to modify your expression so it doesn't need "power", e.g. (50/(5*5)).round(1)

view this post on Zulip Shoaib Mushtaq (Apr 04 2022 at 10:41):

Paul Lynch said:

Alternatively, you might be able to modify your expression so it doesn't need "power", e.g. (50/(5*5)).round(1)

Got it. But the same error The name round is not a valid function name happens for the round() function.

view this post on Zulip Grahame Grieve (Apr 04 2022 at 11:51):

looks like, I need to upgrade the version from R4 to R5

I think that's probably not a good idea - that's a very long piece of string to pull on


Last updated: Apr 12 2022 at 19:14 UTC