Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error for Path Selection of Attributes Named like Functions #17

Open
giuliabaldini opened this issue May 27, 2022 · 3 comments
Open

Error for Path Selection of Attributes Named like Functions #17

giuliabaldini opened this issue May 27, 2022 · 3 comments
Labels

Comments

@giuliabaldini
Copy link
Contributor

giuliabaldini commented May 27, 2022

Hi there,

there are sometimes problems if a path selection attribute has the same name as an existing operation. For example, div is the integer division, but it is also used in many generated public FHIR resources.
In this case, the path text.div will yield an error.

import json
from fhirpathpy import evaluate
from pathlib import Path

with Path("tests/resources/observation-example.json").open("r") as fp:
    resource = json.load(fp)

res = evaluate(resource, "Observation.text.div")

print(res)

returns

Exception: Infix invoke should have arity 2

I think that this error could be fixed by looking at whether there is a dot or not before the declaration.

Best,
Giulia

@ruscoder
Copy link
Member

According to the specification https://build.fhir.org/ig/HL7/FHIRPath/#keywords keyword like div must be wrapped with backticks, but it's not supported yet

@ruscoder ruscoder assigned ruscoder and unassigned ruscoder May 23, 2023
@ruscoder
Copy link
Member

@giuliabaldini you can use workaround for the old grammar like Patient.text."div".

But there's an issue #13 that will change quotes to backticks.

@ir4y
Copy link
Member

ir4y commented May 13, 2024

It should be fixed starting from 1.0.0 version @giuliabaldini
Could you please check?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants