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

Only select QuestionnaireItem with 'page' extension as page #2569

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LZRS
Copy link
Collaborator

@LZRS LZRS commented Jun 12, 2024

IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).

Fixes #2568

Description
Change getQuestionnairePages to only return questionnaire pages from QuestionnaireItems that have extension

        {
          "url": "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl",
          "valueCodeableConcept": {
            "coding": [
              {
                "system": "http://hl7.org/fhir/questionnaire-item-control",
                "code": "page",
                "display": "Page"
              }
            ]
          }
        }

Alternative(s) considered
Have you considered any alternatives? And if so, why have you chosen the approach in this PR?

Type
Bug fix

Screenshots (if applicable)

Checklist

  • I have read and acknowledged the Code of conduct.
  • I have read the Contributing page.
  • I have signed the Google Individual CLA, or I am covered by my company's Corporate CLA.
  • I have discussed my proposed solution with code owners in the linked issue(s) and we have agreed upon the general approach.
  • I have run ./gradlew spotlessApply and ./gradlew spotlessCheck to check my code follows the style guide of this project.
  • I have run ./gradlew check and ./gradlew connectedCheck to test my changes locally.
  • I have built and run the demo app(s) to verify my change fixes the issue and/or does not break the demo app(s).

Copy link
Collaborator

@MJ1998 MJ1998 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to include contiguous set of items not with page extension into another page.

"If there are items at the same level as a 'page' group that are listed before the 'page' group, they will be treated as a separate page"
Reference - https://build.fhir.org/ig/HL7/fhir-extensions//CodeSystem-questionnaire-item-control.html

So if the questionnaire looks like -

{
  itemWithNoPageExtension1, 
  itemWithPageExtension2, // have nested items
  itemWithPageExtension3,
  itemWithNoPageExtension4,
  itemWithNoPageExtension5,
  itemWithNoPageExtension6,
  itemWithPageExtension7,
}

The pages would look like following:-

{
  page1: {
  	itemWithNoPageExtension1,
  },
  page2: {
  	itemWithPageExtension2
  },
  page3: {
  	itemWithPageExtension3
  },
  page4: {
  	itemWithNoPageExtension4,
  	itemWithNoPageExtension5,
  	itemWithNoPageExtension6
  },
  page5: {
  	itemWithPageExtension7
  }
}

Comment on lines -483 to +484
pages!!.indexOfLast {
it.index < currentPageIndexFlow.value!! && it.enabled && !it.hidden
}
pages!!.last { it.index < currentPageIndexFlow.value!! && it.enabled && !it.hidden }.index
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are these 2 different ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second one is using index as defined and set in https://github.com/google/android-fhir/blob/10165589c4e7617b3bdd3a426d037f639c135342/datacapture/src/main/java/com/google/android/fhir/datacapture/QuestionnaireViewModel.kt#L933C11-L933C16

While the previous one was using index of the page from pages list, although they'll essentially be the same if our pages are contigous as you mentioned in your comment

@LZRS
Copy link
Collaborator Author

LZRS commented Jun 13, 2024

We need to include contiguous set of items not with page extension into another page.

"If there are items at the same level as a 'page' group that are listed before the 'page' group, they will be treated as a separate page" Reference - https://build.fhir.org/ig/HL7/fhir-extensions//CodeSystem-questionnaire-item-control.html

So if the questionnaire looks like -

{
  itemWithNoPageExtension1, 
  itemWithPageExtension2, // have nested items
  itemWithPageExtension3,
  itemWithNoPageExtension4,
  itemWithNoPageExtension5,
  itemWithNoPageExtension6,
  itemWithPageExtension7,
}

The pages would look like following:-

{
  page1: {
  	itemWithNoPageExtension1,
  },
  page2: {
  	itemWithPageExtension2
  },
  page3: {
  	itemWithPageExtension3
  },
  page4: {
  	itemWithNoPageExtension4,
  	itemWithNoPageExtension5,
  	itemWithNoPageExtension6
  },
  page5: {
  	itemWithPageExtension7
  }
}

Ah okay, makes sense. Probably we'd then need to make changes to our questionnaires, thanks

@FikriMilano
Copy link
Collaborator

@LZRS does this change handle the following use case?

if the first page is by default, hidden using an extension, while the user is in the second page, the previous button should be hidden

@LZRS
Copy link
Collaborator Author

LZRS commented Oct 2, 2024

@LZRS does this change handle the following use case?

if the first page is by default, hidden using an extension, while the user is in the second page, the previous button should be hidden

Yes, so far the changes in this PR handle that but the ongoing discussions were on whether it should be hidden, since it's also treated as a 'page', or if we should instead handle it by throwing an exception

@FikriMilano
Copy link
Collaborator

@LZRS
I mean, what if the first page has the page extension? but the page item is hidden using an extension.

In the second page, which also has a page extension, the previous button needs to be hidden.

Can this change handle that?

@LZRS
Copy link
Collaborator Author

LZRS commented Oct 2, 2024

@LZRS I mean, what if the first page has the page extension? but the page item is hidden using an extension.

In the second page, which also has a page extension, the previous button needs to be hidden.

Can this change handle that?

Yeah, it handles that

@FikriMilano
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: PR under Review
Development

Successfully merging this pull request may close these issues.

Handling previous button when first item has no ‘page’ and hidden
3 participants