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

Check if previous/next page is hidden to show previous/next buttons #2569

Merged
merged 4 commits into from
Dec 20, 2024

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
  }
}

@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

@FikriMilano
Copy link
Collaborator

@MJ1998 @jingtang10 have you decided whether we should make the implementation more relaxed?

@LZRS LZRS changed the title Only select QuestionnaireItem with 'page' extension as page Check if previous/next page is hidden to show previous/next buttons Dec 18, 2024
@LZRS LZRS marked this pull request as ready for review December 19, 2024 09:31
@LZRS LZRS requested a review from a team as a code owner December 19, 2024 09:31
@LZRS LZRS requested a review from jingtang10 December 19, 2024 09:31
@LZRS
Copy link
Collaborator Author

LZRS commented Dec 19, 2024

@FikriMilano @MJ1998 Reviewing the current existing implementation, Sibling items to a page extension group are treated as page even though they may not be of typegroup.

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

The spec has also been updated

If a group item has this itemControl value, then all sibling items SHALL also be of type group and also have an itemControl value of 'page', 'header', or 'footer'. Form fillers SHOULD raise an error if a Questionnaire fails to adhere to this requirement.

IMO, it feels the current implementation is already relaxed and wouldn't necessarily crash

In the PR, I have just updated to check that the previous or next button is not hidden, to show the previous/next button

@LZRS LZRS requested a review from MJ1998 December 19, 2024 10:03
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.

LGTM. Approving with one small NIT.

@LZRS LZRS requested a review from MJ1998 December 20, 2024 13:00
@MJ1998 MJ1998 merged commit 69b8ebf into google:master Dec 20, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

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