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

FHIRPath nested extention issue #82

Open
tstrass opened this issue Mar 22, 2021 · 0 comments
Open

FHIRPath nested extention issue #82

tstrass opened this issue Mar 22, 2021 · 0 comments

Comments

@tstrass
Copy link

tstrass commented Mar 22, 2021

If you attempt to evaluate a FHIRPath that has an extension somewhere other than the root object, the following error is thrown:

Extension function not applicable to NilClass:

To reproduce:

With this Patient

{
  "telecom": [
    {
      "system": "phone",
      "value": "(333) 333-3333",
      "extension": [
          {
            "url": "http://example.com/phone-type",
            "valueString": "Smartphone"
          }
      ]
    }
  ],
  "resourceType": "Patient"
}

If I call:

FHIRPath.evaluate("Patient.telecom[0].extension('http://example.com/phone-type')", patient_json)

I get the following output:

D, [2021-03-22T18:44:27.444782 #97061] DEBUG -- : TOKENS: ["Patient", "telecom[0]", "extension", "(", "'phone-type'", ")"]
D, [2021-03-22T18:44:27.445396 #97061] DEBUG -- : TREE: ["Patient", "telecom[0]", :extension, ["'phone-type'"]]
D, [2021-03-22T18:44:27.445681 #97061] DEBUG -- : DATA: ["Patient", "telecom[0]", :extension, ["'phone-type'"]]
D, [2021-03-22T18:44:27.456356 #97061] DEBUG -- : V===> [{"telecom"=>[{"system"=>"phone", "value"=>"(333) 333-3333", "rank"=>1, "extension"=>[{"url"=>"http://example.com/phone-type", "valueString"=>"Smartphone"}]}], "resourceType"=>"Patient"}, "telecom[0]", :extension, ["'phone-type'"]]
D, [2021-03-22T18:44:27.456710 #97061] DEBUG -- : V===> [nil, {"system"=>"phone", "value"=>"(333) 333-3333", "rank"=>1, "extension"=>[{"url"=>"http://example.com/phone-type", "valueString"=>"Smartphone"}]}, :extension, ["'phone-type'"]]
D, [2021-03-22T18:44:27.456932 #97061] DEBUG -- : Evaling Extension Block....
*** RuntimeError Exception: Extension function not applicable to NilClass:

As another example, I have also seen an error thrown when attempting to eval a FHIRPath to a US Core ethnicity code, since it is an extension nested within an extension.

@tstrass tstrass changed the title FHIRPath nested extention bug FHIRPath nested extention issue Mar 23, 2021
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