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

Paginated Questionnaires: Validate before going to the next page #2646

Open
Aleem92 opened this issue Jul 28, 2024 · 3 comments
Open

Paginated Questionnaires: Validate before going to the next page #2646

Aleem92 opened this issue Jul 28, 2024 · 3 comments
Assignees
Labels
effort:small Small effort - 2 days P2 Medium priority issue

Comments

@Aleem92
Copy link

Aleem92 commented Jul 28, 2024

Describe the bug
In a paginated questionnaire where the first item on the first page is autofilled and the second item on this page fetches data from the database using a query, users can proceed from the first screen to the second screen without filling out all required fields on the first screen. This results in an error message appearing when submitting the form on the second screen.

Component
SDC library

To Reproduce
Steps to reproduce the behavior:

  1. Open the sample questionnaire
  2. Clicking on the next button without filling in the required fields will move to the next page without validating the current page.

Expected behavior
Display an error message to block users from proceeding to the next page if the current form is incomplete or incorrect.

Screenshots
Screenshot_1722204951
Screenshot_1722204976

Additional context
The questionnaire has the following extension:

 {
      "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-entryMode",
      "valueCode": "prior-edit"
 }

But it does not validate the required fields when the first item on the page has initial values and the second item fetches data from the database. In the sample questionnaire, there is an item with the link Id visit-date, which is a date type containing today's date as a value. The next item has the link Id medicine and is a reference type that fetches medicines from the database.

        {
          "extension": [
            {
              "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression",
              "valueExpression": {
                "language": "text/fhirpath",
                "expression": "today()"
              }
            }
          ],
          "linkId": "visit-date",
          "text": "Visit date",
          "type": "date",
          "required": false,
          "item": [
            {
              "linkId": "visit-date-hint",
              "text": "Visit date",
              "type": "display",
              "extension": [
                {
                  "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
                  "valueCodeableConcept": {
                    "coding": [
                      {
                        "system": "http://hl7.org/fhir/questionnaire-item-control",
                        "code": "flyover",
                        "display": "Fly-over"
                      }
                    ],
                    "text": "Flyover"
                  }
                }
              ]
            }
          ]
        },
        {
          "linkId": "medicine",
          "type": "reference",
          "required": true,
          "item": [
            {
              "linkId": "medicine-hint",
              "text": "Medicine",
              "type": "display",
              "extension": [
                {
                  "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
                  "valueCodeableConcept": {
                    "coding": [
                      {
                        "system": "http://hl7.org/fhir/questionnaire-item-control",
                        "code": "flyover",
                        "display": "Fly-over"
                      }
                    ],
                    "text": "Flyover"
                  }
                }
              ]
            }
          ],
          "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"
              }
            },
            {
              "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-answerExpression",
              "valueExpression": {
                "expression": "Medication",
                "language": "application/x-fhir-query"
              }
            },
            {
              "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-choiceColumn",
              "extension": [
                {
                  "url": "path",
                  "valueString": "Medication.code.coding.display"
                },
                {
                  "url": "forDisplay",
                  "valueBoolean": true
                }
              ]
            }
          ]
        },

It has been observed that when the following extensions are removed from the item medicine, it does not move to the next page if the required fields are not filled, and it shows the validation errors.

            {
              "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-answerExpression",
              "valueExpression": {
                "expression": "Medication",
                "language": "application/x-fhir-query"
              }
            },
            {
              "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-choiceColumn",
              "extension": [
                {
                  "url": "path",
                  "valueString": "Medication.code.coding.display"
                },
                {
                  "url": "forDisplay",
                  "valueBoolean": true
                }
              ]
            }

Sample Questionnaire

Would you like to work on the issue?
Yes

@MJ1998
Copy link
Collaborator

MJ1998 commented Jul 30, 2024

Thanks for catching the bug @Aleem92.
Are you working on this ?

@MJ1998 MJ1998 added P2 Medium priority issue effort:small Small effort - 2 days labels Jul 30, 2024
@MJ1998
Copy link
Collaborator

MJ1998 commented Aug 5, 2024

@Aleem92
Can you try adding entryMode extension at questionnaire top level and set code to prior-edit.
This will enforce validation.

@Aleem92
Copy link
Author

Aleem92 commented Aug 12, 2024

@Aleem92 Can you try adding entryMode extension at questionnaire top level and set code to prior-edit. This will enforce validation.

As mentioned above, I am already using the entryMode extension. You can refer to the sample questionnaire for reference.

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 P2 Medium priority issue
Projects
Status: New
Development

No branches or pull requests

2 participants