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

Response validity feedback from renderer #622

Open
nielmdrec opened this issue Feb 7, 2024 · 10 comments
Open

Response validity feedback from renderer #622

nielmdrec opened this issue Feb 7, 2024 · 10 comments

Comments

@nielmdrec
Copy link

When we receive the QuestionnaireResponse from the renderer (e.g. via getResponse()), it would be quite helpful to know if the response form is valid in terms of having answers for each of the questions (items) which are required in the Questionnaire.

For example, if our Questionnaire has 5 questions and 4 of those questions have item.required = true,
we would like to know if those 4 required questions (at least) are answered before saving the QuestionnaireResponse to our database.

In theory we could do this by adding our own variable in the Questionnaire and setting it to 'true' ourselves when all required questions are answered. However this would mean each of our Questionnaires needs to support this variable (and it becomes a proprietary feature for our Questionnaires only).

@fongsean
Copy link
Collaborator

Hi Niel, that's definitely a good feature to have and honestly should have been included early.
I'll start working on it and hope it can be delivered before the end of the week.

@nielmdrec
Copy link
Author

Thanks, Sean.
We look forward to having this feature.
Glad you think it would be useful too.

@nielmdrec
Copy link
Author

BTW, Sean, for this feature would it be possible to have the mandatory questions marked by say an asterisk (*)?
(Or should I raise that in a separate item?)

@fongsean
Copy link
Collaborator

Hi Niel, that's definitely a part of my consideration! I'm trying to think of a best way to present visual cues. No need to raise in a separate item.

To extend my thoughts further.... instead of retrieving the "validated" status via getResponse(), I think it will be more robust if it an be exposed via the state event listeners i.e. const isValid = useQuestionnaireResponseStore.use.isValid(). That way, it won't be tied to a button click.

I might also expose a listener to see what linkIds are failing validation if that is beneficial. Might also help verify if the required check is working properly on all items (it can get a bit complicated when working with repeat groups with further nested items)

@fongsean fongsean mentioned this issue Feb 19, 2024
@fongsean
Copy link
Collaborator

Feel free to refer to #634 (comment) for changes up until now.
It's deployed as @aehrc/smart-forms-renderer v0.13.1.

Any thoughts on the bugs + future tasks?

@adha-admin
Copy link

adha-admin commented Apr 9, 2024

Hi Sean,
Been chatting with Brian and he suggests you return the linkIds are failing validation using an OperationOutcome Resource.
Code example here:

https://github.com/brianpos/fhir-net-web-api/blob/develop/src/Hl7.Fhir.StructuredDataCapture/QuestionnaireResponseValidator.cs

Cheers
Philip Wilford
ADHA

@fongsean
Copy link
Collaborator

fongsean commented Apr 9, 2024

Hi Phil,

Thanks for that. That definitely is a good idea to align more with FHIR.

Will replace the invalid items array with an array of operationOutcomes. I'll have to track down which business rules/validation errors the UI is currently enforcing and get that in as well i.e regex, minLength, maxLength, etc

@adha-admin
Copy link

Hi Sean,

  1. Can we have a <- Previous Tab button?

  2. Do you do any validation on decimals?

     					"extension": [
     						{
     							"url": "http://hl7.org/fhir/StructureDefinition/maxDecimalPlaces",
     							"valueInteger": 2
     						},
     						{
     							"url": "http://hl7.org/fhir/StructureDefinition/minValue",
     							"valueInteger": 0
     						},
     						{
     							"url": "http://hl7.org/fhir/StructureDefinition/maxValue",
     							"valueInteger": 300
     						}
     					],
     					"linkId": "group-1-check-1",
     					"text": "Height (cm)",
     					"type": "decimal"
    

Cheers
Philip Wilford
ADHA

@fongsean
Copy link
Collaborator

fongsean commented Apr 9, 2024

Hi Phil,

  1. Yes, I'll add that to the feature list. It should be using the same logic as next tab, except going for a -1 instead of a +1.
  2. I don't think there is validation for maxDecimalPlaces. Happy to add that as another upcoming feature.

Cheers
Sean

@fongsean
Copy link
Collaborator

fongsean commented Apr 21, 2024

Hi all, made a few changes over the past week + weekend:

  • Exposed invalid items as OperationOutcomes
  • Added button to go to previous tab
  • Added maxDecimalPlaces validation check
  • Added debug bar in Playground (requested by Heath)

@nielmdrec if you are consuming the invalidItems for validation, you might need to tweak up your implementation for a bit.
Old invalidItems is a key value pair of <linkId, type-of-error (string)> where type of error can be "required", "regex", "maxLength" or "minLength". It's now <linkId, OperationOutcome>.

Will continue to make progress on other feature requests/bugs early this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

No branches or pull requests

3 participants