Paginated Questionnaires: Validate before going to the next page
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:
- Open the sample questionnaire
- 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
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
}
]
}
Would you like to work on the issue? Yes
Thanks for catching the bug @Aleem92. Are you working on this ?
@Aleem92 Can you try adding entryMode extension at questionnaire top level and set code to prior-edit. This will enforce validation.
@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.
is this still a valid issue?
Apk Version - opensrp-dc-v0.1.5-release.apk
Device - BLUG60
Android version - 9
This issue has been addressed in all the questionnaires/forms. A user can't proceed to the next page before filling in the mandatory fields. All the mandatory fields get highlighted in red when the Next/Save button is tapped before filling them.
Seems to be re-occuring, and validation fails for a repeated-group item do not prevent proceeding to the next page