-
Notifications
You must be signed in to change notification settings - Fork 302
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
Add safe call in validateQuestionnaireResponseItems to handle custom widget #936
Comments
this is not a valid questionnaire item. see https://www.hl7.org/fhir/questionnaire-definitions.html#Questionnaire.item.type. type is mandatory. |
i.e.
https://github.com/google/android-fhir/blob/master/datacapturegallery/src/main/assets/hl7-questionnaire-example-f201-lifelines.json#L52..L60 . Based on the issue raised, the feature seems to have broken due to this check. I tested this on FHIR Core and it causes a crash. However, this doesn't crash on |
I think according to the spec we should be using the attachment type for storing images as answers. https://www.hl7.org/fhir/codesystem-item-type.html#item-type-attachment We need to fix that questionnaire in the repo and put the right type. Since it is a number picker, the right type is probably integer. |
For giving example of questionnaires that has custom widget in it. |
Well Im not sure if its the responsibility of the datacapture library to check if questionnaire item has a type or not for custom widgets. I am surprised that HAPI FHIR is not throwing an error due to missing type, since that is the library that we are using to parse the questionnaire JSON. In the case of canonical widgets , if item.type is missing , the datacapture library throws a FYI I am working on improving the function validateQuestionnaireResponseItems in PR #926 Also using tools like https://lhcformbuilder.nlm.nih.gov/ helps author valid questionnaires. |
To summarise our discussion today, every questionnaire item needs to have a type. Custom widget doesn't mean custom data type. So you could define a custom widget to collect data in a custom way (for example, you might tap the screen to increment an integer and collect that integer rather than typing in an integer) but the answer you collect still needs to be one of the defined fhir questionnaire item data types. With this clarified, we still have the question of how we should deal with errors like this. We already have the validation API which @joiskash worked on. We probably should consider providing developers with a more consistent experience (for example, but not necessarily this, making a checked exception). |
Is your feature request related to a problem? Please describe.
When validating a custom questionnaire widget which has null item type it will throw an NPE.
For example:
Related problem: opensrp/fhircore#761
Describe the solution you'd like
Add safe call on this part
android-fhir/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt
Line 346 in 817a561
Describe alternatives you've considered
N/A
Additional context
N/A
Would you like to work on the issue?
Yes
The text was updated successfully, but these errors were encountered: