hapifhir / org.hl7.fhir.core

Apache License 2.0
156 stars 163 forks source link

FHIRPath precedence operators of in and or not honored #1425

Closed oliveregger closed 3 weeks ago

oliveregger commented 1 year ago

The following FHIRPath expression gives an error in IG Publisher:

original: status in ('registered'|'cancelled') or value.exists() or hasMember.exists() or component.exists() or dataAbsentReason.exists()

HAPI-0389: Failed to call access method: org.hl7.fhir.exceptions.PathEngineException: Unable to evaluate as a boolean: registered,cancelled (@char 11)

according to operator precedence in should be before or and ('registered'|'cancelled') should not be evaulated to boolean.

making it explicit (status in ('registered'|'cancelled')) or value.exists() or hasMember.exists() or component.exists() or dataAbsentReason.exists()

it returns no errors.

see also https://github.com/hl7-eu/laboratory/issues/51, qa

javascript.js. Java (IBM) and the .NET (Firely) implementation are working with the original as expected in FHIRpath Lab:

resource to test:

{
    "resourceType": "Observation",
    "status": "final",
    "category": [
        {
            "coding": [
                {
                    "system": "http://terminology.hl7.org/CodeSystem/observation-category",
                    "code": "laboratory"
                }
            ]
        }
    ],
    "code": {
        "coding": [
            {
                "system": "http://hl7.eu/fhir/laboratory/CodeSystem/lab-localCs-eu-lab",
                "code": "3002989",
                "display": "Hepatitis Panel, Acute with Reflex to HBsAg Confirmation and Reflex to HCV by Quantitative NAAT"
            }
        ],
        "text": "Acute Hepatitis Panel, reflex to confirmation"
    },
    "subject": {
        "reference": "Patient/8472931c-fbd0-437b-9ed1-4f66472c78b5"
    },
    "effectiveDateTime": "2022-10-25T13:35:00+01:00",
    "performer": [
        {
            "display": "MUDr. Aleš Procházka"
        }
    ],
    "hasMember": [
        {
            "reference": "Observation/104a5829-565b-46a6-85d6-36751ef79a40"
        },
        {
            "reference": "Observation/01b8ec35-9b20-45a4-bd41-42eeae2fd521"
        },
        {
            "reference": "Observation/096e27da-0768-47e4-b33c-9f1be93e1f88"
        },
        {
            "reference": "Observation/861e7b48-5497-410a-bed8-2cde814e09fc"
        },
        {
            "reference": "Observation/cc96d499-3e0e-4588-a021-4fe576766112"
        }
    ]
}
stale[bot] commented 7 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

oliveregger commented 7 months ago

this is still an issue, at least it can be reproduced with FhirPathTester

stale[bot] commented 4 weeks ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.