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
465 stars 245 forks source link

SDC library does not render valueSet widgets on the Questionnaire #928

Closed ndegwamartin closed 3 months ago

ndegwamartin commented 2 years ago

Describe the bug For Open Choice items configured with the answer format value sets i.e. answerValueSet, the widgets Do Not render successfully on the Questionnaire. This can be observed with the HIV Case Report questionnaire Occupation form field.

Component SDC library

To Reproduce Steps to reproduce the behavior:

  1. Go to the Data Capture Gallery home page
  2. Click on HIV Case Report
  3. Scroll down to Occupations or Risk Factors
  4. Confirm that the corresponding widgets do not render

Expected behavior The questionnaire should render the open-choice widget when the answer format is defined as a valueSet See the open-choice answerFormats in Questionnaire ticket with attached screenshot here #689

Screenshots See the Occupation and Risk Factor fields in the HIV Case Report questionnaire screenshot below Screenshot

Smartphone (please complete the following information):

Additional context This bug needs to be fixed before issue #552 can be implemented/closed

Would you like to work on the issue? @kevinmost contributed to the the working implementation as assigned here #801

jingtang10 commented 2 years ago

@wantingzhang77 will work on this

wantingzhang77 commented 2 years ago

@jingtang10 I am looking at this issue and just have a few questions:
Currently our library can't handle all Questionnaire.Items with attribute "type: choice" and attribute "answerValueSet" correctly. I put the questionnaire item resource screen shot below: image

I assume the answerValueSet are the answers should be rendered. I tried those url in my browser(for example: http://openhie.org/fhir/hiv-casereporting/ValueSet/vs-hiv-population) but the browser can not open it. I believe the resolveAnswerValueSet() from QuestionnaireViewModel.kt is used to resolve the answerValueSet. So what does this uri mean? How does it suppose to be resolved when browser can not open it?

jingtang10 commented 2 years ago

@wantingzhang77 thanks for looking into this. You're right answerValueSet is the field that contains the answers to be rendered. Please see more info here https://www.hl7.org/fhir/questionnaire-definitions.html#Questionnaire.item.answerValueSet

The URL in the answer value set does not necessarily correspond to a real URL. It can just be a unique identifier for the value set.

Looking at this implementation guide https://openhie.github.io/hiv-ig/ and especially the list of artifacts: https://openhie.github.io/hiv-ig/artifacts.html it appears to me the value set with url http://openhie.org/fhir/hiv-casereporting/ValueSet/vs-hiv-population is just missing. We need to find out from the IG authors if that's the case.

Once we locate the answer value set with the URL though, we need to either add this to the questionnaire as one of "contained" resources, or provide a custom answer value set provider (@aditya-07 can help with this).

wantingzhang77 commented 2 years ago

@jingtang10 I found this webpage: https://openhie.github.io/hiv-ig/ValueSet-vs-key-population.html. Looks like it contains answers that may corresponding to the hiv-population questionnaire.Item. Just not sure if this is the right way to go. If it is, is that the original URL incorrect for this questions item? How should we get the answerValueSet from the webpage?

costateixeira commented 2 years ago

Hi @wantingzhang77 Can you please point to where you found the reference to vs-key-population? I can only find the hiv-population and it may be an incomplete rename... I think indeed that the ValueSet is vs-key-population

As @jingtang10 says, the URL is not always expected to resolve. When it doesn't resolve, the ImplementationGuide that contains the Questionnaire should also contain the expanhttps://openhie.github.io/hiv-ig/expansions.jsonded ValueSet - but this is not always guaranteed and we're working on ways to fix it.

An detail hint that might help in the implementation: When the ImplementationGuide defines the value sets, there is a file called expansions.json that contains the expanded valuesets. For example, the ImplementationGuide https://openhie.github.io/hiv-ig has a file called https://openhie.github.io/hiv-ig/expansions.json where you can find the expanded valueset - for example search for http://openhie.org/fhir/hiv-casereporting/ValueSet/vs-key-population

jingtang10 commented 2 years ago

@costateixeira, we took the questionnaire from the URL: https://openhie.github.io/hiv-ig/Questionnaire-hiv-case-report-questionnaire.json.html but I think I'm getting 404 now so assuming it's been moved, but not have had luck finding it now in the artifact index on the IG home page.

What's important in this issue for us to verify is just that there IS a way to render these quetions with the answer value set -- once we can confirm that, we might be able to close this issue without code change because the data capture gallary app is due to be changed.

costateixeira commented 2 years ago

@jingtang10 if you want to use a questionnaire sample, you can use this one: https://openhie.github.io/case-reporting/Questionnaire-case-reporting-questionnaire.html (also at the end of that page you have notes about the several ways a ValueSet may appear - these were actually created for you to have some test cases): https://openhie.github.io/case-reporting/Questionnaire-case-reporting-questionnaire.html#notes in this Questionnaire, you can see for example the patient gender ValueSet available here: https://openhie.github.io/case-reporting/expansions.json This is because the Patient Gender is defined in this ImplementationGuide. For Ethnicity, the way the ValueSet is defined is not allowing the VS to be expanded.

I don't recall why the other one is 404'ing, there was a merge from Jembi team and I don't know if that is when we lost it..

jingtang10 commented 2 years ago

Thanks Jose.

So this does sound like a data issue with the previous version of the questionnaire. With @shelaghm working on revamping the demo app, I'm tempted to say let's not spend time on this questionnaire itself.

@wantingzhang77 - but I still think it's worth testing that the flow actually works, if you want to do some local testing to see the newer version of the questionnaire Jose provided works with the APIs in our code. If everything seems fine, I'm happy for us to close this issue.

@anita-vadverao this needs to be added to test scenarios as well.

vishnuravi commented 1 year ago

@jingtang10 I have noticed that the options defined in answerValueSet do not render even though they are defined in the Questionnaire itself, such as this example SDC-PHQ9 Questionnaire: http://build.fhir.org/ig/HL7/sdc/Questionnaire-questionnaire-sdc-profile-example-PHQ9.json.html. Is there something additionally I would need to do to render these options?

fredhersch commented 1 year ago

@jingtang10 I have noticed that the options defined in answerValueSet do not render even though they are defined in the Questionnaire itself, such as this example SDC-PHQ9 Questionnaire: http://build.fhir.org/ig/HL7/sdc/Questionnaire-questionnaire-sdc-profile-example-PHQ9.json.html. Is there something additionally I would need to do to render these options?

Thanks @vishnuravi can you send a screenshot of what happens when you render this

@jingtang10 Could this be an issue with the ordinalValue extension? Or is it the way the valueSet is defined.. appears to be an example of "contained" valueSet options

cc: @wantingzhang77

vishnuravi commented 1 year ago

Hi @fredhersch thanks for looking into this! When I render the Questionnaire, the questions appear, but the answer options don't.

Screen Shot 2022-08-16 at 11 47 28 AM

Appreciate any advice you have on this issue!

costateixeira commented 1 year ago

Hi

I see the valueset is done by listing the concepts in compose.include, perhaps what is needed is the expanded value set where the codes would show up in expansion.contains

see this example: https://build.fhir.org/valueset-example-expansion.json.html

Not sure this would be the issue but I expect that the tool needs to look at the final valueset, regardless of how the valueset is defined, and that is in expansion.

Cheers

José

On Tue, Aug 16, 2022 at 5:48 PM Vishnu Ravi @.***> wrote:

Hi @fredhersch https://github.com/fredhersch thanks for looking into this! When I render the Questionnaire, the questions appear, but the answer options don't.

[image: Screen Shot 2022-08-16 at 11 47 28 AM] https://user-images.githubusercontent.com/1212163/184922797-c9acdc61-21a5-4c9b-9fe4-1ca5717b1200.png

Appreciate any advice you have on this issue!

— Reply to this email directly, view it on GitHub https://github.com/google/android-fhir/issues/928#issuecomment-1216821723, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD3HUUHIZKJTRXA5FWGRCYDVZOZ3NANCNFSM5IJRK7KA . You are receiving this because you were mentioned.Message ID: @.***>

williamito commented 1 year ago

The core issue appears to be that the SDC Library can parse the .expansion version of codes, and not .compose.

Fully supporting .compose is complex as it can work by referencing/filtering other code systems or valuesets (see examples), but supporting the case where all codes are enumerated in an .include should be feasible.

From ValueSet:

Value sets have 2 aspects:

.compose: A definition of which codes are intended to be in the value set ("intension") .expansion: The list of codes that are actually in the value set under a given set of conditions ("extension") - see Value Set Expansion

The ValueSet resource can carry either the .compose or the .expansion, both of them, or neither of them (if only the metadata is being represented). There is an "$expand" operation which can be used to ask a server to generate an expansion given the composition rules, in a particular context, and a "$validate-code" operation which can be used to ask a server to check whether a given code or concept is in the value set in a particular context.

To my understanding these two questionnaires with included valuesets should be equivalent but only the first works.

Working:

{
  "resourceType": "Questionnaire",
  "contained":
  [
    {
      "resourceType": "ValueSet",
      "id": "yesnodontknow",
      "expansion":
      {
        "contains":
        [
          {
            "system": "http://terminology.hl7.org/CodeSystem/v2-0136",
            "code": "Y",
            "display": "Yes"
          },
          {
            "system": "http://terminology.hl7.org/CodeSystem/v2-0136",
            "code": "N",
            "display": "No"
          },
          {
            "system": "http://terminology.hl7.org/CodeSystem/v2-0136",
            "code": "asked-unknown",
            "display": "Don't Know"
          }
        ]
      }
    }
  ],
  "item":
  [
    {
      "linkId": "1",
      "type": "choice",
      "text": "Does this work?",
      "answerValueSet": "#yesnodontknow"
    }
  ]
}

Not Working:

{
  "resourceType": "Questionnaire",
  "contained":
  [
    {
      "resourceType": "ValueSet",
      "id": "yesnodontknow",
      "compose":
      {
        "include":
        [
          {
            "system": "http://terminology.hl7.org/CodeSystem/v2-0136",
            "concept":
            [
              {
                "code": "Y",
                "display": "Yes"
              },
              {
                "code": "N",
                "display": "No"
              },
              {
                "code": "asked-unknown",
                "display": "Don't Know"
              }
            ]
          }
        ]
      }
    }
  ],
  "item":
  [
    {
      "linkId": "1",
      "type": "choice",
      "text": "Does this work?",
      "answerValueSet": "#yesnodontknow"
    }
  ]
}
fredhersch commented 1 year ago

@jingtang10 My understanding was this is a small change. Is this still open?

jingtang10 commented 3 months ago

@ndegwamartin can you please confirm if this is still an issue?

costateixeira commented 3 months ago

Hi All

Just for scoping: If the expectation is that all valuesets need to be expanded for passing to the SDK, then this requirement would no longer apply, as at the end, even with compose, the valuesets would have the expansion.

Compose is used in defining valuesets I wouldn't set any tooling expectations on it, because some valuesets will be intensionally defined and there the .compose will not contain the codes. So at the end, what would matter is the .expand.

Cheers

José

On Mon, Feb 26, 2024 at 2:52 PM Jing Tang @.***> wrote:

@ndegwamartin https://github.com/ndegwamartin can you please confirm if this is still an issue?

— Reply to this email directly, view it on GitHub https://github.com/google/android-fhir/issues/928#issuecomment-1964198739, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD3HUUBZDV2LEZZ5X3QOF6LYVSHTFAVCNFSM5IJRK7KKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJWGQYTSOBXGM4Q . You are receiving this because you were mentioned.Message ID: @.***>

ndegwamartin commented 3 months ago

@jingtang10 I concur with @williamito and @costateixeira's findings and additionally with your observation that it is a data issue (retrieved a versioned copy of the HIV case report questionnaire json to review/test this out) which can be solved by re-authoring the questionnaire to use expansions.contains.

Given the above then this is no longer an issue and we can close this ticket cc @f-odhiambo

jingtang10 commented 3 months ago

thanks @ndegwamartin and all!