forked from uwcirg/helloworld-confidential-client-sof
-
Notifications
You must be signed in to change notification settings - Fork 0
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
migration for surpassed deep future date #79
Open
pbugni
wants to merge
1
commit into
develop
Choose a base branch
from
feature/migration-for-surpassed-DEEP_FUTURE-date
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
migrations/versions/patch_DEEP_FUTURE_last_unfollowedup.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Migration script generated for patch_DEEP_FUTURE_last_unfollowedup | ||
revision = '7542b481-21cb-483c-b72a-6c1502375a65' | ||
down_revision = '17f3b60d-0777-4d0e-bb32-82e670b573a7' | ||
|
||
import logging | ||
from isacc_messaging.models.fhir import next_in_bundle | ||
from isacc_messaging.models.isacc_fhirdate import ( | ||
IsaccFHIRDate as FHIRDate, | ||
DEEP_FUTURE, | ||
) | ||
from isacc_messaging.models.isacc_patient import ( | ||
IsaccPatient as Patient, | ||
LAST_UNFOLLOWEDUP_URL, | ||
) | ||
|
||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') | ||
|
||
|
||
def upgrade(): | ||
# Passed up the DEEP_FUTURE date used on patients w/o pending outgoing | ||
# value; corrected in PR #77, but need to migrate any existing patients | ||
# with expired value in their extension. | ||
obsolete_DEEP_FUTURE = FHIRDate("2025-01-01T00:00:00Z") | ||
active_patients = Patient.active_patients() | ||
for json_patient in next_in_bundle(active_patients): | ||
patient = Patient(json_patient) | ||
if patient.get_extension(LAST_UNFOLLOWEDUP_URL, "valueDateTime") != obsolete_DEEP_FUTURE: | ||
continue | ||
patient.mark_followup_extension(persist_on_change=True) | ||
logging.info(f"migration corrected {patient.id} {LAST_UNFOLLOWEDUP_URL}") | ||
logging.info("migration complete") | ||
|
||
|
||
def downgrade(): | ||
# No value in reverting | ||
print('downgraded') | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, where do you get these values from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are UUIDs, built into the FHIR Migrations framework.
The most recent migration run is stored in a FHIR Basic object. To generate these automatically, run the following:
dc exec <service> flask migrate <name-of-migration-script-to-generate>
For example, I ran:
dc exec messagingservice flask migrate patch_DEEP_FUTURE_last_unfollowedup
and as it found the down_revision in the DB, fabricated a shell script in
migrations/version/<name>.py
which included those and boiler plate functions to extend.