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

Saving a questionnaire with nested repeatedGroup items fails with crash #3245

Closed
LZRS opened this issue May 8, 2024 · 2 comments · Fixed by #3267
Closed

Saving a questionnaire with nested repeatedGroup items fails with crash #3245

LZRS opened this issue May 8, 2024 · 2 comments · Fixed by #3267
Assignees
Labels
Bug Report Something isn't working as expected

Comments

@LZRS
Copy link
Contributor

LZRS commented May 8, 2024

To Reproduce
Steps to reproduce the behavior:

  1. Open a questionnaire with a repeated group item
  2. Repeatedly fill the group to at least 3 or more times
  3. Submit the questionnaire and it crashes

Additional context
Add any other context about the problem here.

java.lang.IllegalArgumentException: Missing questionnaire item for questionnaire response item blood-pressure-repeating-group
                                                                                                    	at com.google.android.fhir.datacapture.validation.QuestionnaireResponseValidator.validateQuestionnaireResponseItems(QuestionnaireResponseValidator.kt:120)
                                                                                                    	at com.google.android.fhir.datacapture.validation.QuestionnaireResponseValidator.validateQuestionnaireResponseItem(QuestionnaireResponseValidator.kt:160)
                                                                                                    	at com.google.android.fhir.datacapture.validation.QuestionnaireResponseValidator.validateQuestionnaireResponseItems(QuestionnaireResponseValidator.kt:133)
                                                                                                    	at com.google.android.fhir.datacapture.validation.QuestionnaireResponseValidator.validateQuestionnaireResponse(QuestionnaireResponseValidator.kt:93)
                                                                                                    	at com.google.android.fhir.datacapture.validation.QuestionnaireResponseValidator.validateQuestionnaireResponse$default(QuestionnaireResponseValidator.kt:57)
                                                                                                    	at org.smartregister.fhircore.quest.ui.questionnaire.QuestionnaireViewModel.validateQuestionnaireResponse(QuestionnaireViewModel.kt:731)
                                                                                                    	at org.smartregister.fhircore.quest.ui.questionnaire.QuestionnaireViewModel$handleQuestionnaireSubmission$1.invokeSuspend(QuestionnaireViewModel.kt:242)

experienced in WDF

@LZRS LZRS added the Bug Report Something isn't working as expected label May 8, 2024
@LZRS LZRS self-assigned this May 8, 2024
@pld
Copy link
Member

pld commented May 9, 2024

is this an Android FHIR SDK error?

@LZRS
Copy link
Contributor Author

LZRS commented May 10, 2024

is this an Android FHIR SDK error?

Yeah the error seems to be coming from the sdk's side. The QuestionnaireResponse we get from the sdk has the repeated groups unpacked here, which is what causes validation to fails here. An example

{
  "resourceType": "QuestionnaireResponse",
  "item": [
    {
      "linkId": "page-1",
      "item": [
        {
          "linkId": "blood-pressure-repeating-group",
          "item": [
            {
              "linkId": "systolic-bp",
              "answer": [
                {
                  "valueInteger": 124
                }
              ]
            }
          ]
        },
        {
          "linkId": "blood-pressure-repeating-group",
          "item": [
            {
              "linkId": "systolic-bp",
              "answer": [
                {
                  "valueInteger": 125
                }
              ]
            }
          ]
        },
        {
          "linkId": "blood-pressure-repeating-group",
          "item": [
            {
              "linkId": "systolic-bp",
              "answer": [
                {
                  "valueInteger": 126
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

Also, the sdk does it's own validation here on submit, and it uses its own internal representation of QuestionnaireResponse (which has the repeated groups packed together) and passes validation. Example

{
  "resourceType": "QuestionnaireResponse",
  "item": [
    {
      "linkId": "page-1",
      "item": [
        {
          "linkId": "blood-pressure-repeating-group",
          "answer": [
            {
              "item": [
                {
                  "linkId": "systolic-bp",
                  "answer": [
                    {
                      "valueInteger": 124
                    }
                  ]
                }
              ]
            },
            {
              "item": [
                {
                  "linkId": "systolic-bp",
                  "answer": [
                    {
                      "valueInteger": 125
                    }
                  ]
                }
              ]
            },
            {
              "item": [
                {
                  "linkId": "systolic-bp",
                  "answer": [
                    {
                      "valueInteger": 126
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

The validation from the sdk's side happens just before our fragment result listener is called. Maybe one way to resolve the error might be to remove the validation from our side and trust that sdk's alright.

@LZRS LZRS changed the title Saving a questionnaire with repeatedGroup items fails with crash Saving a questionnaire with nested repeatedGroup items fails with crash May 15, 2024
@ageryck ageryck added this to the Sprint 12 (Jun 3rd - Jun 17th) milestone Jun 3, 2024
@pld pld closed this as completed in #3267 Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Report Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants