LHNCBC / formbuilder-lhcforms

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

!= operator bug within formbuilder #23

Open abdullah-git1 opened 2 years ago

abdullah-git1 commented 2 years ago

When trying to use the != operator within the form builder in the conditional show logic section, there seems to be no way to specify a specific value. When uploading a questionnaire json that contains a != associated with a value, the json output changes it to =

plynchnlm commented 2 years ago

Please look at the following Questionnaire, built with the formbuilder, which uses != and which still has != when imported from a file.

{
  "status": "draft",
  "resourceType": "Questionnaire",
  "meta": {
    "profile": [
      "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire|2.7"
    ],
    "tag": [
      {
        "code": "lformsVersion: 29.1.2"
      }
    ]
  },
  "item": [
    {
      "type": "string",
      "code": [
        {
          "code": "q1",
          "display": "q1"
        }
      ],
      "required": false,
      "linkId": "q1",
      "text": "q1"
    },
    {
      "type": "string",
      "code": [
        {
          "code": "q2",
          "display": "q2"
        }
      ],
      "required": false,
      "linkId": "q2",
      "text": "q2",
      "enableWhen": [
        {
          "answerString": "z",
          "question": "q1",
          "operator": "!="
        }
      ]
    }
  ]
}

If you can make a small test case that shows the problem you are describing, please post it here.

ruscoder commented 2 years ago

@plynchnlm I confirm that there is a bug with that when the question (q1) has type choice.

{
  "meta": {
    "profile": [
      "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire|2.7"
    ],
    "tag": [
      {
        "code": "lformsVersion: 29.2.1"
      }
    ]
  },
  "status": "draft",
  "resourceType": "Questionnaire",
  "item": [
    {
      "type": "choice",
      "code": [
        {
          "code": "q1",
          "display": "q1"
        }
      ],
      "extension": [
        {
          "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
          "valueCodeableConcept": {
            "coding": [
              {
                "system": "http://hl7.org/fhir/questionnaire-item-control",
                "code": "drop-down",
                "display": "Drop down"
              }
            ],
            "text": "Drop down"
          }
        }
      ],
      "required": false,
      "linkId": "q1",
      "text": "q1",
      "answerOption": [
        {
          "valueCoding": {
            "code": "test",
            "display": "Test"
          }
        },
        {
          "valueCoding": {
            "code": "test2",
            "display": "Test2"
          }
        }
      ]
    },
    {
      "type": "string",
      "code": [
        {
          "code": "q2",
          "display": "q2"
        }
      ],
      "required": false,
      "linkId": "q2",
      "text": "q2",
      "enableWhen": [
        {
          "answerCoding": {
            "code": "test"
          },
          "question": "q1",
          "operator": "="
        }
      ]
    }
  ]
}

Try to switch between = and != for q2

plynchnlm commented 2 years ago

Thanks for the test case. We've confirmed the bug, and found that it also exists in the new version (a rewrite) that are planning to release soon.