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

Hidden questionnaire items are not handled in the QuestionnaireResponseValidator #1051

Closed
shoaibmushtaq25 opened this issue Jan 20, 2022 · 3 comments · Fixed by #1214
Closed
Assignees
Labels
effort:small Small effort - 2 days P1 High priority issue type:bug Something isn't working

Comments

@shoaibmushtaq25
Copy link
Contributor

shoaibmushtaq25 commented Jan 20, 2022

Describe the bug
Hidden questionnaires are not handled in the QuestionnaireResponseValidator,
This issue was supposed to be fixed in #912 with PR #926 but looks like it was refactored later in this PR #982 , so the current implementation is not catering the hidden items.

Component
SDC library

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

  • Device: Pixel 3 emulator
  • Android version: 11
  • Build number: RSR1.201013.001
  • Version 30

Additional context
Sample Questionnaire (using for G6PD);
{ "resourceType": "Questionnaire", "id": "11687", "meta": { "versionId": "6", "lastUpdated": "2022-01-07T11:30:01.624+00:00", "source": "#33bcf067a3975d94" }, "language": "en", "extension": [ { "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-targetStructureMap", "valueCanonical": "https://fhir.labs.smartregister.org/StructureMap/5875" }, { "url": "http://hl7.org/fhir/StructureDefinition/cqf-library", "valueCanonical": "Library/4575" } ], "name": "G6PD Test Photo Result", "title": "G6PD Test Photo Result", "status": "active", "subjectType": [ "Patient" ], "publisher": "g6pd", "useContext": [ { "code": { "system": "http://hl7.org/fhir/codesystem-usage-context-type.html", "code": "focus" }, "valueCodeableConcept": { "coding": [ { "system": "http://fhir.ona.io", "code": "000002", "display": "G6PD Test Photo Results" } ] } } ], "item": [ { "extension": [ { "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/cpg-itemImage", "valueAttachment": { "id": "g6pdImage", "contentType": "image/png", } } ], "linkId": "result_capture_image", "text": "Add instructions for capturing G6PD test information", "type": "display" }, { "extension": [ { "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationExtract", "valueBoolean": true } ], "linkId": "result_type", "code": [ { "system": "http://fhir.ona.io", "code": "000001", "display": "G6PD Result Type" } ], "text": "G6PD Result Type", "type": "choice", "required": true, "answerOption": [ { "valueCoding": { "system": "https://www.snomed.org", "code": "410680006", "display": "Number" } }, { "valueCoding": { "system": "https://www.snomed.org", "code": "405358009", "display": "Error" } }, { "valueCoding": { "system": "https://www.snomed.org", "code": "385432009", "display": "N/A" } } ] }, { "extension": [ { "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationExtract", "valueBoolean": true } ], "linkId": "haemoglobin_level", "code": [ { "system": "https://www.snomed.org", "code": "104142005", "display": "Plasma haemoglobin level" } ], "text": "Hemoglobin Levels", "type": "choice", "enableWhen": [ { "question": "result_type", "operator": "=", "answerCoding": { "system": "https://www.snomed.org", "code": "385432009" } } ], "answerOption": [ { "valueCoding": { "system": "https://www.snomed.org", "code": "75540009", "display": "High" } }, { "valueCoding": { "system": "https://www.snomed.org", "code": "62482003", "display": "Low" } } ] }, { "extension": [ { "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationExtract", "valueBoolean": true }, { "url": "http://hl7.org/fhir/StructureDefinition/minValue", "valueDecimal": 1 }, { "url": "http://hl7.org/fhir/StructureDefinition/maxValue", "valueDecimal": 6.7 } ], "linkId": "g6pd", "code": [ { "system": "http://snomed.info/sct", "code": "86859003", "display": "G6PD Enzyme" } ], "text": "G6PD", "type": "decimal", "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", "required": true }, { "extension": [ { "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationExtract", "valueBoolean": true }, { "url": "http://hl7.org/fhir/StructureDefinition/minValue", "valueDecimal": 4 }, { "url": "http://hl7.org/fhir/StructureDefinition/maxValue", "valueDecimal": 19 } ], "linkId": "haemoglobin", "code": [ { "system": "http://snomed.info/sct", "code": "259695003", "display": "Hemoglobin" } ], "text": "Hemoglobin (Hb)", "type": "decimal", "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", "required": true }, { "extension": [ { "url": "http://doc-of-photo-capture", "valueString": "photo-capture" } ], "linkId": "photo", "text": "Photo of device", "type": "attachment", "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" } ] }

StackTrace from FHIR core app is here,
2022-01-20 14:35:08.058 17936-17936/org.smartregister.fhircore.quest E/AndroidRuntime: FATAL EXCEPTION: main Process: org.smartregister.fhircore.quest, PID: 17936 java.lang.IllegalArgumentException: Cannot compare different data types: Attachment and decimal at com.google.android.fhir.MoreTypesKt.compareTo(MoreTypes.kt:49) at com.google.android.fhir.datacapture.validation.MaxValueConstraintValidator$1.invoke(MaxValueConstraintValidator.kt:32) at com.google.android.fhir.datacapture.validation.MaxValueConstraintValidator$1.invoke(MaxValueConstraintValidator.kt:29) at com.google.android.fhir.datacapture.validation.ValueConstraintExtensionValidator.validate(ValueConstraintExtensionValidator.kt:40) at com.google.android.fhir.datacapture.validation.QuestionnaireResponseItemValidator.validate(QuestionnaireResponseItemValidator.kt:44) at com.google.android.fhir.datacapture.validation.QuestionnaireResponseValidator.validateQuestionnaireResponseAnswers(QuestionnaireResponseValidator.kt:49) at org.smartregister.fhircore.engine.ui.questionnaire.QuestionnaireActivity.validQuestionnaireResponse(QuestionnaireActivity.kt:274) at org.smartregister.fhircore.engine.ui.questionnaire.QuestionnaireActivity.handleQuestionnaireSubmit(QuestionnaireActivity.kt:235) at org.smartregister.fhircore.engine.ui.questionnaire.QuestionnaireActivity$onClick$1.invoke(QuestionnaireActivity.kt:209) at org.smartregister.fhircore.engine.ui.questionnaire.QuestionnaireActivity$onClick$1.invoke(QuestionnaireActivity.kt:209) at org.smartregister.fhircore.engine.ui.base.AlertDialogue.showAlert$lambda-7$lambda-4$lambda-3(AlertDialogue.kt:79) at org.smartregister.fhircore.engine.ui.base.AlertDialogue.$r8$lambda$cvLf6CgtkFWn06NT-8e1cRYrVTQ(Unknown Source:0) at org.smartregister.fhircore.engine.ui.base.AlertDialogue$$ExternalSyntheticLambda0.onClick(Unknown Source:2) at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:174) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Would you like to work on the issue?
cc: @aditya-07 @maimoonak @jingtang10

@Tarun-Bhardwaj Tarun-Bhardwaj added Triage effort:small Small effort - 2 days P1 High priority issue and removed Triage labels Jan 28, 2022
@Tarun-Bhardwaj
Copy link

Hi @shoaibmushtaq25, thanks for raising the issue. Would you have some bandwidth to pick this up and fix it?

@shoaibmushtaq25
Copy link
Contributor Author

Hi @Tarun-Bhardwaj , As discussed with @f-odhiambo , I will pick this issue after my on-going task on ona/fhircore.

@shoaibmushtaq25 shoaibmushtaq25 self-assigned this Feb 9, 2022
@shoaibmushtaq25 shoaibmushtaq25 changed the title Hidden questionnaires are not handled in the QuestionnaireResponseValidator Hidden questionnaire items are not handled in the QuestionnaireResponseValidator Feb 24, 2022
@shoaibmushtaq25
Copy link
Contributor Author

@jingtang10 @ekigamba
We have a hidden item in the above questionnaire which enables based on the enableWhen condition. So when we try to validate the questionnaireResponse with the above questionnaire having the hidden item, it throws the exception java.lang.IllegalArgumentException: Cannot compare different data types: Attachment and decimal probably due to a mismatch between indexes/order of items in questionnaire/questionnaireResponse

Here is this hidden item,
{ "extension": [ { "url": "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationExtract", "valueBoolean": true } ], "linkId": "haemoglobin_level", "code": [ { "system": "https://www.snomed.org", "code": "104142005", "display": "Plasma haemoglobin level" } ], "text": "Hemoglobin Levels", "type": "choice", "enableWhen": [ { "question": "result_type", "operator": "=", "answerCoding": { "system": "https://www.snomed.org", "code": "385432009" } } ], "answerOption": [ { "valueCoding": { "system": "https://www.snomed.org", "code": "75540009", "display": "High" } }, { "valueCoding": { "system": "https://www.snomed.org", "code": "62482003", "display": "Low" } } ] }

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 P1 High priority issue type:bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants