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

Fix refreshing profile data #2523

Merged
merged 16 commits into from
Jul 7, 2023
Merged

Fix refreshing profile data #2523

merged 16 commits into from
Jul 7, 2023

Conversation

ellykits
Copy link
Collaborator

@ellykits ellykits commented Jul 4, 2023

IMPORTANT: Where possible all PRs must be linked to a Github issue

Fixes https://github.com/opensrp/fhir-resources/issues/1940
Fixes https://github.com/opensrp/fhir-resources/issues/1695

Engineer Checklist

  • I have written Unit tests for any new feature(s) and edge cases for bug fixes
  • I have added any strings visible on UI components to the strings.xml file
  • I have updated the CHANGELOG.md file for any notable changes to the codebase
  • I have run ./gradlew spotlessApply and ./gradlew spotlessCheck to check my code follows the project's style guide
  • I have built and run the FHIRCore app to verify my change fixes the issue and/or does not break the app
  • I have checked that this PR does NOT introduce breaking changes that require an update to Content and/or Configs? If it does add a sample here or a link to exactly what changes need to be made to the content.

Code Reviewer Checklist

  • I have verified Unit tests have been written for any new feature(s) and edge cases
  • I have verified any strings visible on UI components are in the strings.xml file
  • I have verifed the CHANGELOG.md file has any notable changes to the codebase
  • I have verified the solution has been implemented in a configurable and generic way for reuseable components
  • I have built and run the FHIRCore app to verify the change fixes the issue and/or does not break the app

Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com>
@ellykits ellykits added Work In Progress Describes an items that is not complete. Mostly used for scoping issues of discussions DNM DO NOT MERGE 0.2.4 labels Jul 4, 2023
@codecov
Copy link

codecov bot commented Jul 4, 2023

Codecov Report

Merging #2523 (001628c) into main (2ea8fa1) will increase coverage by 0.5%.
The diff coverage is 65.8%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main   #2523     +/-   ##
=========================================
+ Coverage     64.8%   65.4%   +0.5%     
- Complexity    1050    1095     +45     
=========================================
  Files          209     213      +4     
  Lines         9156    9344    +188     
  Branches      1805    1860     +55     
=========================================
+ Hits          5942    6111    +169     
+ Misses        2059    2038     -21     
- Partials      1155    1195     +40     
Flag Coverage Δ
engine 73.1% <65.5%> (+<0.1%) ⬆️
geowidget 63.2% <ø> (ø)
quest 60.3% <66.1%> (+0.8%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...core/engine/configuration/view/ColumnProperties.kt 100.0% <ø> (ø)
...ore/engine/configuration/view/DividerProperties.kt 0.0% <0.0%> (ø)
...ngine/configuration/view/PersonalDataProperties.kt 0.0% <0.0%> (ø)
...hircore/engine/configuration/view/RowProperties.kt 0.0% <ø> (ø)
...ine/configuration/view/ViewPropertiesSerializer.kt 23.8% <0.0%> (-2.6%) ⬇️
...e/engine/ui/bottomsheet/RegisterBottomSheetView.kt 51.2% <0.0%> (-2.5%) ⬇️
...g/smartregister/fhircore/quest/QuestApplication.kt 44.2% <ø> (+0.8%) ⬆️
...org/smartregister/fhircore/quest/event/AppEvent.kt 100.0% <ø> (ø)
...g/smartregister/fhircore/quest/event/EventQueue.kt 100.0% <ø> (ø)
...r/fhircore/quest/ui/shared/QuestionnaireHandler.kt 12.5% <ø> (+12.5%) ⬆️
... and 52 more

... and 5 files with indirect coverage changes

ellykits added 3 commits July 4, 2023 16:09
Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com>
Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com>
@ellykits
Copy link
Collaborator Author

ellykits commented Jul 5, 2023

Breaking config changes

Removed

property: "refreshContent"
Affected config: QuestionnaireConfig

Added

Affected config: QuestionnaireConfig
New property: onSubmitActions
New property type: List<ActionConfig>

Sample

             "onSubmitActions": [
                  {
                    "trigger": "ON_QUESTIONNAIRE_SUBMISSION",
                    "workflow": "LAUNCH_REGISTER",
                    "id": "householdRegister",
                    "display": "All Households",
                    "popNavigationBackStack": true
                  }
            ]

ellykits added 2 commits July 5, 2023 18:35
Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com>
@ellykits ellykits marked this pull request as ready for review July 5, 2023 16:10
@ellykits ellykits removed the DNM DO NOT MERGE label Jul 5, 2023
Copy link
Member

@pld pld left a comment

Choose a reason for hiding this comment

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

lgtm! test failure looks related to missing fun call mock on eventBus

* Check in the task is part of another task and if so check if the parent task is
* completed,cancelled,failed or entered in error.
*/
private suspend fun Task.preReqConditionSatisfied() =
Copy link
Member

Choose a reason for hiding this comment

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

I think we can rename this fun and consolidate the precondition

Suggested change
private suspend fun Task.preReqConditionSatisfied() =
private suspend fun Task.preconditionSatisfied() =
this.executionStartIsBeforeOrToday() &&
this.status == Task.TaskStatus.REQUESTED &&

Comment on lines 138 to 141
if (task.executionStartIsBeforeOrToday() &&
task.status == Task.TaskStatus.REQUESTED &&
task.preReqConditionSatisfied()
) {
Copy link
Member

Choose a reason for hiding this comment

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

why not also consider the above 2 conditions part of the precondition, and add them to that function?

Suggested change
if (task.executionStartIsBeforeOrToday() &&
task.status == Task.TaskStatus.REQUESTED &&
task.preReqConditionSatisfied()
) {
if task.preReqConditionSatisfied() {

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see. I think the conditions here are breaking the functionality for marking Tasks as ready. The conditions for updating the dependent Tasks should be separate from the parent Task.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see. I think the conditions here are breaking the functionality for marking Tasks as ready. The conditions for updating the dependent Tasks should be separate from the parent Task.

ndegwamartin and others added 5 commits July 6, 2023 14:19
…i/profile/ProfileFragment.kt

Co-authored-by: Peter Lubell-Doughtie <peter@ona.io>
…/util/extension/ResourceExtension.kt

Co-authored-by: Peter Lubell-Doughtie <peter@ona.io>
…/util/extension/ResourceExtension.kt

Co-authored-by: Peter Lubell-Doughtie <peter@ona.io>
…/task/FhirTaskUtil.kt

Co-authored-by: Peter Lubell-Doughtie <peter@ona.io>
- Fix Failing tests
- Add unit tests ✅
@ndegwamartin
Copy link
Contributor

@dubdabasoduba before we split the PR for the 0.2.4 branch could you please confirm that the logic for updating task status is correct?

From the logic seems like we:

  1. Look for any tasks that are due with a task status of REQUESTED
  2. Look for the parent task they are a partOf
  3. If the parent task is found and it as the status CANCELLED, COMPLETE, FAILED or ENTEREDINERROR then we mark the (child)task status as READY

Note: The above logic was not added by this PR just refactored into it.

Also please review the code to confirm my assertions above.

@dubdabasoduba
Copy link
Member

@dubdabasoduba before we split the PR for the 0.2.4 branch could you please confirm that the logic for updating task status is correct?

From the logic seems like we:

  1. Look for any tasks that are due with a task status of REQUESTED
  2. Look for the parent task they are a partOf
  3. If the parent task is found and it as the status CANCELLED, COMPLETE, FAILED or ENTEREDINERROR then we mark the (child)task status as READY

Note: The above logic was not added by this PR just refactored into it.

Also please review the code to confirm my assertions above.

@ndegwamartin this is correct. We might want to check in with the PMs on enabling dependent tasks when the pre-requisite was CANCELLED, FAILED or ENTEREDINERROR

@dubdabasoduba
Copy link
Member

@ndegwamartin this works well.

  • The above config allows redirecting to a register.
    • It however breaks with redirecting to a profile.
  • The Profile refreshes correctly.

This PR is also needed to avoid a crash on remove family functionality

@ellykits
Copy link
Collaborator Author

ellykits commented Jul 7, 2023

@ndegwamartin this works well.

  • The above config allows redirecting to a register.

    • It however breaks with redirecting to a profile.
  • The Profile refreshes correctly.

This PR is also needed to avoid a crash on remove family functionality

Could you let me know which profile you tried opening here? if the profile is related to a household it would work with the Group resource being the base. Otherwise, the ResourceData would be null (ResourceData is required to open the profile).

ellykits added 2 commits July 7, 2023 10:55
Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com>
Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com>
@ellykits
Copy link
Collaborator Author

ellykits commented Jul 7, 2023

@dubdabasoduba I deleted the conditional checks that relied on the dependent Tasks, for which I needed confirmation from you.

@pld pld merged commit d32c982 into main Jul 7, 2023
@pld pld deleted the fix-profile-data-refresh branch July 7, 2023 13:42
qiarie pushed a commit that referenced this pull request Jan 15, 2025
* Fix refreshing profile data

Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com>

* Resolve list view not refreshing data

Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com>

* Handle questionnaire on submission actions

Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com>

* Fix failing tests

Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com>

* Update android/quest/src/main/java/org/smartregister/fhircore/quest/ui/profile/ProfileFragment.kt

Co-authored-by: Peter Lubell-Doughtie <peter@ona.io>

* Update android/engine/src/main/java/org/smartregister/fhircore/engine/util/extension/ResourceExtension.kt

Co-authored-by: Peter Lubell-Doughtie <peter@ona.io>

* Update android/engine/src/main/java/org/smartregister/fhircore/engine/util/extension/ResourceExtension.kt

Co-authored-by: Peter Lubell-Doughtie <peter@ona.io>

* Update android/engine/src/main/java/org/smartregister/fhircore/engine/task/FhirTaskUtil.kt

Co-authored-by: Peter Lubell-Doughtie <peter@ona.io>

* Fix Build 💚
- Fix Failing tests
- Add unit tests ✅

* Fix Build 💚

* Fix updating Task status to READY

Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com>

---------

Signed-off-by: Elly Kitoto <junkmailstoelly@gmail.com>
Co-authored-by: Peter Lubell-Doughtie <peter@ona.io>
Co-authored-by: Martin Ndegwa <ndegwamartin@users.noreply.github.com>
Co-authored-by: Martin Ndegwa <mndegwa@ona.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Work In Progress Describes an items that is not complete. Mostly used for scoping issues of discussions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants