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

Many String FhirPath functions (e.g. startsWith) fail with extension only value #2960

Open
brianpos opened this issue Nov 6, 2024 · 0 comments

Comments

@brianpos
Copy link
Collaborator

brianpos commented Nov 6, 2024

Describe the bug
When an "extension only" value is provided to the startsWith('xxx') function, a null reference exception is thrown.
This is due to the code going direct to the system string functions without handling any of the null stuff.

t.Add("startsWith", (string f, string fragment) => f.StartsWith(fragment), doNullProp: true);

To Reproduce
Steps to reproduce the behavior:
Run the below expression on this test instance

{
    "resourceType": "Patient",
    "id": "example",

    "managingOrganization": {
        "_reference": { "id": "element id" }
    }
}

Can test this in the fhirpath lab too.

managingOrganization.trace('v').reference.startsWith('#')

🧪 Test with FHIRPath-Lab

Returns the error:
Invalid expression: Invocation of function 'startsWith' failed: Object reference not set to an instance of an object.

Expected behavior
This not throw an error and return an empty set as there is no primitive string.
(check the spec, there are some other issues around this at the moment also...)
https://chat.fhir.org/#narrow/channel/179266-fhirpath/topic/result.20of.20toString.20with.20extension.20only.20value

Version used:

  • FHIR Version: R4
  • Version: v5.10.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant