google / android-fhir

The Android FHIR SDK is a set of Kotlin libraries for building offline-capable, mobile-first healthcare applications using the HL7® FHIR® standard on Android.
https://google.github.io/android-fhir/
Apache License 2.0
458 stars 238 forks source link

Open choice missing string value #2520

Open FikriMilano opened 3 weeks ago

FikriMilano commented 3 weeks ago

Describe the bug There's a missing value when the user taps "Add another answer" but did not fill in the text box, then save the choices.

After submitting a Questionnaire Response with that missing value, then opening the Questionnaire again together with that Questionnaire Response, the app crashed with NPE of that missing value, which should not be missing.

Component SDC library

To Reproduce Steps to reproduce the behavior:

  1. Tap "Open choice" card
  2. Click the open-choice widget
  3. Scroll to bottom
  4. Tap "Other" checkbox
  5. Tap "Add another answer" button
  6. Do not fill in the text box
  7. Tap "Save" button
  8. Tap "Submit" button
  9. See the populated answer, but missing a value

Expected behavior The answer should not be populated if the value is missing

Recording

https://github.com/google/android-fhir/assets/62053304/8b67426d-a152-4956-bf08-51239cb41bae

Smartphone (please complete the following information):

Additional context N/A

Would you like to work on the issue? Yes

FikriMilano commented 3 weeks ago

@pld @f-odhiambo

santosh-pingle commented 3 weeks ago

@FikriMilano Is it happening with other widgets too?

FikriMilano commented 3 weeks ago

@santosh-pingle it's a very specific use case, only happens in this widget

FikriMilano commented 3 weeks ago

Let me clarify. The Answer object is saved to the QR item, but the Answer's value is missing

FikriMilano commented 3 weeks ago

See JSON below, note: the nested item is an flyover text.

{
  "linkId": "4a1c4c0d-158f-494c-a33f-1f7f8e41f21f",
  "answer": [
    {
      "valueCoding": {
        "code": "isolation",
        "display": "Isolation"
      },
      "item": [
        {
          "linkId": "d2a44529-9344-4ec1-ac7a-10dddbf27467",
          "text": "Behaviors"
        }
      ]
    },
    {
      "item": [
        {
          "linkId": "d2a44529-9344-4ec1-ac7a-10dddbf27467",
          "text": "Behaviors"
        }
      ]
    }
  ]
}