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

Items nested in group do not reflect in questionnaire-response with skip logic #1972

Closed
maimoonak opened this issue Apr 13, 2023 · 1 comment · Fixed by #1973
Closed

Items nested in group do not reflect in questionnaire-response with skip logic #1972

maimoonak opened this issue Apr 13, 2023 · 1 comment · Fixed by #1973

Comments

@maimoonak
Copy link
Collaborator

maimoonak commented Apr 13, 2023

Describe the bug
Item which are in group / repeat group are missed when getting final questionnaire-response if any item prior to them is skipped due to any enablement condition. This leads to a critical issue of data silently missed from final submitted response irrespective of that the user actually filled the data.
On close inspection and debugging of code it was noted that the MoreQuestionnaireResponsesKt#unpackRepeatedGroups is the real issue where it is using zip-indexing i.e. index to index mapping of items for unpacking. This leads to invalid mapping when one of the items was missed due to enablement condition and hence the next question does not map to the group and does not loop over its nested items.
The items which are not group although work fine for missed enablement condition items displayed prior to it. There is no issue in rendering and form views work fine.

Component
SDC library

To Reproduce
Replace skip-logic-behavior questionnaire with below and choose 'Yes' for first item. Then provide values for all questions. See the date is missing from final output because there are 2 other items which were not enabled on 'Yes'.

{
  "resourceType": "Questionnaire",
  "item": [
    {
      "extension": [ {
          "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
          "valueCodeableConcept": {
            "coding": [
              {
                "system": "http://hl7.org/fhir/questionnaire-item-control",
                "code": "radio-button",
                "display": "Radio Button"
              }
            ]
          }
        } ], 
      "linkId": "1.0",
      "type": "choice",
      "text": "Has the client received this year's seasonal flu vaccine?",
      "answerOption": [ {
          "valueCoding": {
            "code": "Y",
            "display": "Yes",
            "system": "custom"
          }
        }, {
          "valueCoding": {
            "code": "N",
            "display": "No",
            "system": "custom"
          }
        }, {
          "valueCoding": {
            "code": "unknown",
            "display": "Unknown",
            "system": "custom"
          }
        } ], 
      "item": [ {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-displayCategory",
              "valueCodeableConcept": {
                "coding": [
                  {
                    "system": "http://hl7.org/fhir/questionnaire-display-category",
                    "code": "instructions"
                  }
                ]
              }
            }
          ],
          "linkId": "1-select-one",
          "text": "Select one",
          "type": "display"
        }
      ]
    }, {
      "text": "Confirm that vaccine date is known",
      "type": "boolean",
      "linkId": "2",
      "enableWhen": [ {
          "question": "1.0",
          "operator": "=",
          "answerCoding": {
            "system": "custom",
            "code": "Y"
          }
        }
      ]
    }, {
      "text": "Confirm that vaccine date is unknown",
      "type": "choice",
      "linkId": "3",
      "answerOption": [ {
          "valueCoding": {
            "code": "Y",
            "display": "Yes"
          }
        }, {
          "valueCoding": {
            "code": "N",
            "display": "No"
          }
        } ], 
      "enableWhen": [ {
          "question": "1.0",
          "operator": "=",
          "answerCoding": {
            "system": "custom",
            "code": "unknown"
          }
        }
      ]
    }, {
      "text": "Confirm that vaccine date is not known",
      "type": "boolean",
      "linkId": "4",
      "enableWhen": [ {
          "question": "1.0",
          "operator": "=",
          "answerCoding": {
            "system": "custom",
            "code": "N"
          }
        }
      ]
    }, {
      "text": "Provide vaccine dates for 2 doses",
      "type": "group",
      "linkId": "5",
      "enableWhen": [ {
          "question": "1.0",
          "operator": "=",
          "answerCoding": {
            "system": "custom",
            "code": "Y"
          }
        } ], 
      "item": [ {
          "text": "Date of Vaccination?",
          "type": "date",
          "linkId": "3.1"
        }
      ]
    }, {
      "text": "Additional details",
      "type": "string",
      "linkId": "6"
    }
  ]
}

Expected behavior
The value should show in final response for date as well when provided

Screenshots

Would you like to work on the issue?

@maimoonak maimoonak changed the title Items nested in group do not reflect in questionnaire-response with slip logic Items nested in group do not reflect in questionnaire-response with skip logic Apr 13, 2023
@maimoonak
Copy link
Collaborator Author

maimoonak commented Apr 13, 2023

#1973 the PR has the fix for issue, however, it is failing one of the test should not modify other items while unpacking repeated groups which assumes that the function would not modify any items other than group. I could not understand the usage and figure out the need for that. Kindly review PR and suggest an alternate fix.

@jingtang10 @dubdabasoduba @f-odhiambo @pld

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

Successfully merging a pull request may close this issue.

1 participant