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

Repeated Group: Items within group are duplicated in the Questionnaire Response, if question depends on enableWhen condition. #1895

Closed
nsabale7 opened this issue Mar 2, 2023 · 8 comments · Fixed by #1940
Assignees
Labels
effort:small Small effort - 2 days P1 High priority issue type:bug Something isn't working

Comments

@nsabale7
Copy link
Collaborator

nsabale7 commented Mar 2, 2023

Describe the bug
If a question depends on enableWhen condition in a repeated group, it duplicates the items from the first response.

Component
SDC library

To Reproduce
Steps to reproduce the behavior:
Use component_repeated_group.txt as a questionnaire

Screenshots
https://user-images.githubusercontent.com/82660329/222439586-5edfd017-31bb-485b-88d3-622de7b0a80e.mp4

@jingtang10

@santosh-pingle
Copy link
Collaborator

looking into it, thanks!

@santosh-pingle
Copy link
Collaborator

The questionnaire response contains answers to all selected and enabled questionnaire items. However, when copying the questionnaire response, the use of 'getEnabledResponseItems' fails to copy the selected answers of enabled items.

@santosh-pingle
Copy link
Collaborator

In the QuestionnaireviewModel, getEnabledResponseItems API does not filter items correctly. It appears that the 'evaluate()' API is returning a false value for enabled items as well.

@santosh-pingle
Copy link
Collaborator

If you refer the attached video for steps :
In the second repeated group item, the evaluate() function returns true for the 12.6.3 item and false for the 12.6.4 item. Expected return value should be true for 12.6.4 and false for 12.6.3.

@santosh-pingle
Copy link
Collaborator

According to the existing code, the EnablementEvaluator class has a questionnaireResponseItemPreOrderList that stores collections of responseItemComponents. If the type is a repeated group item, then the questionnaireResponseItem can have the same linkId if the repeated group is added more than once.
When the evaluateEnableWhen() API is called to check whether the enable_when_constraint is passed for a questionnaire response item, it fails for the second and subsequent response items.
This is because the findEnableWhenQuestionnaireResponseItem() function always returns the first item that matches the link id, causing the evaluateEnableWhen() API to fail for the second and subsequent response items that have the same link id.

@santosh-pingle
Copy link
Collaborator

santosh-pingle commented Mar 24, 2023

Additionally, when the type is a repeated group item, the questionnaireResponseItemParentMap is always empty in the findEnableWhenQuestionnaireResponseItem() API. This is because the buildParentList logic in EnablementEvaluator fails to correctly build the parent list for repeated group items.

@santosh-pingle
Copy link
Collaborator

@nsabale7 Can you please confirm once?
https://user-images.githubusercontent.com/86107848/227518292-60df3139-f8db-4a27-8b72-bb9cff446baa.mov

@nsabale7
Copy link
Collaborator Author

@nsabale7 Can you please confirm once? https://user-images.githubusercontent.com/86107848/227518292-60df3139-f8db-4a27-8b72-bb9cff446baa.mov

Yes the above response was the expected behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort:small Small effort - 2 days P1 High priority issue type:bug Something isn't working
Projects
Status: Complete
3 participants