Closed FikriMilano closed 2 years ago
Some updates on this.
When a given questionnaire item tries to load:
{
"extension": [
{
"url": "http://doc-of-photo-capture",
"valueString": "photo-capture"
}
],
"linkId": "photo",
"text": "Photo of device",
"enableWhen": [
{
"question": "result_type",
"operator": "=",
"answerCoding": {
"system": "https://www.snomed.org",
"code": "410680006"
}
},
{
"question": "result_type",
"operator": "=",
"answerCoding": {
"system": "https://www.snomed.org",
"code": "385432009"
}
}
],
"enableBehavior": "any"
}
It will throw an NPE because the QuestionnaireViewModel on data capture library tries to validate it's type
.
Which for a custom widget indeed so supposed to be null
.
https://github.com/google/android-fhir/blob/5c879cc94f3fd64e36b3cad540552c2004a483a0/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt#L346
@f-odhiambo @ekigamba
So, in order to fix this:
Null check on questionnaire item type is needed (SDK) https://github.com/google/android-fhir/blob/817a5617161a1a0e62b371fbbfbfbd684c41389a/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt#L346
Refactor the matchers that will cause another error https://github.com/opensrp/fhircore/blob/eb0a3a9334bced804494240161c13385ee9fd241/android/engine/src/main/java/org/smartregister/fhircore/engine/ui/questionnaire/FhirCoreQuestionnaireFragment.kt#L48
Refactor the encoder because it actually returns the wrong String.
Should be something like this return@use byteStream.toString()
https://github.com/opensrp/fhircore/blob/eb0a3a9334bced804494240161c13385ee9fd241/android/engine/src/main/java/org/smartregister/fhircore/engine/util/extension/FileExtension.kt#L32
@f-odhiambo For the null check which is on datacapture library, where should I make the changes? on Android FHIR SDK or the preview version that FHIRCore use?
@f-odhiambo For the null check which is on datacapture library, where should I make the changes? on Android FHIR SDK or the preview version that FHIRCore use?
Is this a general issue w/the datacapture library? If so, you can do so in the google/android-fhir repo, we can cut a release from the branch and use that if needed before they merge it to main
@FikriMilano What happens if we set a type to prevent the NPE?
Is this a general issue w/the datacapture library? If so, you can do so in the google/android-fhir repo, we can cut a release from the branch and use that if needed before they merge it to main
Okay
@FikriMilano What happens if we set a type to prevent the NPE?
It will throw this error
Caused by: ca.uhn.fhir.parser.DataFormatException: [element="type"] Invalid attribute value "photo-capture": Unknown QuestionnaireItemType code 'photo-capture'
I meant setting a valid type eg. string
. Does it show a text input or the photo capture widget?
It works, it shows the photo capture widget :D But we still need this extension:
"extension": [
{
"url": "http://doc-of-photo-capture",
"valueString": "photo-capture"
}
]
I think this approach is a good choice, combining type
and extension
to get the result that we wanted.
Should the type be string
or attachment
? because we expect the response to be valueString according with the previous agreement with @pld
@FikriMilano It's a workaround while we try and get this fixed on the Android FHIR SDK. Ideally, this should have been attachment
but I don't know the impact of having it as string
or attachment
while string defining a custom widget extension. Test it out and see :smile:
Yeah I did test it, works fine either string
or attachment
.
We could use attachment
then response answer with valueString
. Since we want the simplicity over valueAttachment
.
But not sure if this is a good practice or will cause problems on HAPI or FHIR Web because it's not following the spec.
What do you think? Should we go with valueAttachment
instead?
FYI i think the SDK also plans to update their custom questionnaire sample. https://github.com/google/android-fhir/issues/936#issuecomment-977481518 https://github.com/google/android-fhir/pull/937#discussion_r755986493
Yes, I think valueAttachment
follows the spec better.
To test if this can be uploaded without an issue, you can create a sample QuestionnaieResponse
from this Questionnaire and see if the server rejects it due to the valueString
with base64.
On the FHIR SDK issue discussion, I think we might not be on the same page regarding how custom widget extensions should be authored. See if you can get clarity on this during the call/issue
Alright, let's use valueAttachment
for now since using valueString
seems to not make sense if the type is attachment
Describe the bug Quest app crashes when it tries to load a questionnaire from HAPI with photo capture widget in it.
To Reproduce Steps to reproduce the behavior:
Expected behavior Quest app should not crash and successfully loads the questionnaire
Screenshots
Smartphone (please complete the following information):
Additional context