Closed shoaibmushtaq25 closed 2 years ago
Hi @shoaibmushtaq25, thanks for raising the issue. Would you have some bandwidth to pick this up and fix it?
Hi @Tarun-Bhardwaj , As discussed with @f-odhiambo , I will pick this issue after my on-going task on ona/fhircore.
@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" } } ] }
Describe the bug Hidden questionnaires are not handled in the QuestionnaireResponseValidator, This issue was supposed to be fixed in https://github.com/google/android-fhir/issues/912 with PR https://github.com/google/android-fhir/pull/926 but looks like it was refactored later in this PR https://github.com/google/android-fhir/pull/982 , so the current implementation is not catering the hidden items.
Component SDC library
To Reproduce Steps to reproduce the behavior:
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):
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