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

Delete saved draft feature #3631

Merged
merged 26 commits into from
Dec 4, 2024
Merged

Delete saved draft feature #3631

merged 26 commits into from
Dec 4, 2024

Conversation

Rkareko
Copy link
Contributor

@Rkareko Rkareko commented Nov 22, 2024

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

Fixes #3605

Link to docs

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

@Rkareko Rkareko added the DNM DO NOT MERGE label Nov 22, 2024
@Rkareko Rkareko self-assigned this Nov 22, 2024
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 63.88889% with 26 lines in your changes missing coverage. Please review.

Project coverage is 27.4%. Comparing base (8ee171a) to head (eb0de4c).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...tregister/fhircore/engine/ui/base/AlertDialogue.kt 53.0% 14 Missing and 9 partials ⚠️
...er/fhircore/engine/data/local/DefaultRepository.kt 90.9% 0 Missing and 2 partials ⚠️
...gine/configuration/workflow/ApplicationWorkflow.kt 0.0% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main   #3631     +/-   ##
=========================================
+ Coverage     27.3%   27.4%   +0.1%     
- Complexity     787     789      +2     
=========================================
  Files          282     282             
  Lines        14699   14695      -4     
  Branches      2634    2632      -2     
=========================================
+ Hits          4023    4040     +17     
+ Misses       10132   10100     -32     
- Partials       544     555     +11     
Flag Coverage Δ
engine 63.7% <63.8%> (-0.2%) ⬇️
geowidget 16.0% <ø> (ø)

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

Files with missing lines Coverage Δ
.../fhircore/quest/navigation/MainNavigationScreen.kt 81.5% <ø> (ø)
...re/quest/ui/geowidget/GeoWidgetLauncherFragment.kt 0.0% <ø> (ø)
...register/fhircore/quest/ui/main/AppMainActivity.kt 5.2% <ø> (+<0.1%) ⬆️
...re/quest/ui/questionnaire/QuestionnaireActivity.kt 2.8% <ø> (+0.1%) ⬆️
...e/quest/ui/questionnaire/QuestionnaireViewModel.kt 5.1% <ø> (-0.3%) ⬇️
...fhircore/quest/util/extensions/ConfigExtensions.kt 0.0% <ø> (ø)
...gine/configuration/workflow/ApplicationWorkflow.kt 0.0% <0.0%> (ø)
...er/fhircore/engine/data/local/DefaultRepository.kt 59.6% <90.9%> (+1.0%) ⬆️
...tregister/fhircore/engine/ui/base/AlertDialogue.kt 68.4% <53.0%> (-11.3%) ⬇️

@Rkareko Rkareko removed the DNM DO NOT MERGE label Nov 29, 2024
@Rkareko Rkareko marked this pull request as ready for review November 29, 2024 09:38
@Rkareko Rkareko marked this pull request as draft November 29, 2024 09:57
@Rkareko Rkareko marked this pull request as ready for review November 29, 2024 12:08
@Rkareko Rkareko requested review from ellykits and removed request for ellykits November 29, 2024 12:09
@@ -43,6 +43,12 @@ enum class AlertIntent {

data class AlertDialogListItem(val key: String, val value: String)

data class AlertDialogButton(
Copy link
Contributor

Choose a reason for hiding this comment

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

nice refactor!

Comment on lines 72 to 73
defaultRepository.update(questionnaireResponse)
defaultRepository.addOrUpdate(
Copy link
Contributor

Choose a reason for hiding this comment

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

In the unlikely event that one passes and the other fails, might be best to wrap this with a DB transaction.

Copy link
Contributor

Choose a reason for hiding this comment

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

We'd probably want to create a new method in defaultRespository for this and then within it use the txn block

fhirEngine.withTransaction {  
  ...
}

Comment on lines 61 to 73
val questionnaireResponse =
defaultRepository.searchQuestionnaireResponse(
resourceId = questionnaireConfig.resourceIdentifier!!,
resourceType = questionnaireConfig.resourceType!!,
questionnaireId = questionnaireConfig.id,
encounterId = null,
questionnaireResponseStatus = QuestionnaireResponseStatus.INPROGRESS.toCode(),
)

if (questionnaireResponse != null) {
questionnaireResponse.status = QuestionnaireResponseStatus.STOPPED
defaultRepository.update(questionnaireResponse)
defaultRepository.addOrUpdate(
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless this is covered by another test we can add a unit test to verify that this method QuestionnaireDraftDialogViewModel.deleteDraft ,

  1. Searches for for the QuestionnaireResponse
  2. Updates the QuestionnaireResponse
  3. Creates the AuditEvent

ndegwamartin
ndegwamartin previously approved these changes Dec 3, 2024
@ndegwamartin ndegwamartin dismissed their stale review December 3, 2024 16:41

Missing change on adding the transaction block

@Rkareko Rkareko added this pull request to the merge queue Dec 4, 2024
@Rkareko Rkareko removed this pull request from the merge queue due to a manual request Dec 4, 2024
@Rkareko Rkareko merged commit bcff526 into main Dec 4, 2024
5 checks passed
@Rkareko Rkareko deleted the 3605-feature-delete-draft-form branch December 4, 2024 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Delete saved draft of QuestionnaireResponses when clicking "delete draft"
2 participants