Skip to content

added undo-replace-references operation #7097

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

Merged
merged 2 commits into from
Jul 14, 2025

Conversation

mrdnctrk
Copy link
Collaborator

@mrdnctrk mrdnctrk commented Jul 2, 2025

closes: #7101

In this PR

  1. I added a new system level operation, named $hapi.fhir.undo-replace-references. This operation
    restores the resources that were updated by a $hapi.fhir.replace-references operation to their previous versions.

Current limitations:

  • It fails if any resources to be restored have been subsequently changed since the $hapi.fhir.replace-references operation was performed.
  • It can only run synchronously.
  • It fails if the number of resources to restore exceeds a specified resource limit (currently set by the Provider class to the same size as getInternalSynchronousSearchSize of JPAStorageSettings , which defaults to 10000).
  1. I noticed that replace-references operation was creating a Provenance resource even when no resource was updated, so I added logic to prevent it.

  2. Also added logic for replace-references Provenances to not add a resource reference to the Provenance if patch for that resource was a no-op ( so the resource was't really updated by the operation). This is not likely to happen under normal conditions but just added as a precaution, since we don't want to revert the resource a previous version if that resource wasn't really updated by replace-references.

  3. I refactored the ReplaceReferencesTestHelper by extracting the test data generation and the validation specific to that test data into a separate class called ReplaceReferencesLargeTestData. The reasons for doing this:
    a. make tests more efficient: ReplaceReferencesTestHelper is used by various different test suites, including the tests for replace-references, merge and undo-replace-references operations. However not all tests require the large amount of data created by default in this class.
    b. increase code maintainability/readability.

@robogary
Copy link
Contributor

robogary commented Jul 2, 2025

Formatting check succeeded!

@mrdnctrk mrdnctrk force-pushed the emre-undo-replace-references-rebased-2 branch 3 times, most recently from 63b9a65 to cbed965 Compare July 3, 2025 20:37
@mrdnctrk mrdnctrk marked this pull request as ready for review July 3, 2025 20:55
@mrdnctrk mrdnctrk force-pushed the emre-undo-replace-references-rebased-2 branch 2 times, most recently from 7eae37d to f169380 Compare July 4, 2025 16:54
Copy link

codecov bot commented Jul 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.80%. Comparing base (112cec3) to head (f169380).
Report is 68 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7097      +/-   ##
============================================
+ Coverage     83.41%   83.80%   +0.38%     
- Complexity    29193    29367     +174     
============================================
  Files          1843     1803      -40     
  Lines        113422   113602     +180     
  Branches      14251    14309      +58     
============================================
+ Hits          94608    95201     +593     
+ Misses        12730    12290     -440     
- Partials       6084     6111      +27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mrdnctrk mrdnctrk force-pushed the emre-undo-replace-references-rebased-2 branch from f169380 to c54fd1b Compare July 8, 2025 15:08
@mrdnctrk mrdnctrk force-pushed the emre-undo-replace-references-rebased-2 branch from c54fd1b to b046d98 Compare July 10, 2025 12:20
Copy link
Collaborator

@volodymyr-korzh volodymyr-korzh left a comment

Choose a reason for hiding this comment

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

Looks good, approved

@mrdnctrk mrdnctrk enabled auto-merge (squash) July 14, 2025 15:00
@mrdnctrk mrdnctrk merged commit da0025c into master Jul 14, 2025
66 of 67 checks passed
@mrdnctrk mrdnctrk deleted the emre-undo-replace-references-rebased-2 branch July 14, 2025 17:32
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.

add operation for undoing replace-references
3 participants