LHNCBC / formbuilder-lhcforms

Build LHC-Forms and FHIR Questionnaires
Other
28 stars 22 forks source link

FhirPath update? #20

Closed giacomodeliberali closed 3 years ago

giacomodeliberali commented 3 years ago

Hi, I'm having some troubles with the FHIRPath expressions.

{
  "resourceType": "QuestionnaireResponse",
  "questionnaire": "Questionnaire/0631bd02-e8ac-4f24-9969-aeee03c00988",
  "status": "completed",
  "authored": "2021-07-05T13:09:39.102Z",
  "item": [
    {
      "linkId": "199",
      "text": "Scala condizionale",
      "item": [
        {
          "linkId": "/922",
          "text": "9.2.2",
          "answer": [
            {
              "valueBoolean": true
            }
          ]
        },
        {
          "linkId": "/8511",
          "text": "8.5.11",
          "answer": [
            {
              "valueCoding": {
                "code": "F",
                "display": "F"
              }
            }
          ]
        },
        {
          "linkId": "/192",
          "text": "Parziale condizionale",
          "answer": [
            {
              "valueDecimal": 13
            }
          ]
        }
      ]
    }
  ]
}

Using the online demo tool i would expect:

but the builder expression engine does not support the .value (it only supports the typed value, such as valueCoding, not anymore in the FhirPath spec). Is there any chance that you can update it to the latest version? Or at least guide me on how to update it locally?

Edit: Actually expressions not evaluating properly seem to be only the ones which use valueDecimal.

example

plynchnlm commented 3 years ago

Your test case examples work fine in the online demo. The case that is failing is using some other example (the linkIds do not match the example you provided). Can you provide an updated sample quesitionnaire that shows the issue? I tried using https://lforms-smart-fhir.nlm.nih.gov/v/r4/fhir/Questionnaire/44249-1-x (which has scored answers), and the expression item.answerOption.extension.where(url='http://hl7.org/fhir/StructureDefinition/ordinalValue').value finds the valueDecimals.

giacomodeliberali commented 3 years ago

Using the provided questionnaire:

The same expression evaluated in the demo item.where(linkId = '/44250-9').answerOption.where(value.code='LA6569-3').extension.where(url='http://hl7.org/fhir/StructureDefinition/ordinalValue').value correctly returns the value decimal 1.

giacomodeliberali commented 3 years ago

Hi @plynchnlm , were you be able to reproduce the issue? We continue having some difficulties running the expressions created in the builder in our .NET backend

plynchnlm commented 3 years ago

Sorry for the delay. I've been out. I have confirmed the problem. The expression "%questionnaire.item.where(linkId = '/44250-9').answerOption[1].extension[1].value" does not work in LHC-Forms, but does in fhirpath.js (if you define %questionnaire, or replace it with %context). It looks like it will be fixed by updating fhirpath.js in our "lforms" package, on which formbuilder-lhcforms depends for rendering forms. (At least, I tried updating lforms, and it fixed the issue there.) We will try to get this out soon.

plynchnlm commented 3 years ago

This should be fixed in the current version which we just made live.