Skip to content

Commit

Permalink
Add migration to recalculate the next-outgoing extension for all active
Browse files Browse the repository at this point in the history
patients.
  • Loading branch information
pbugni committed Jan 8, 2025
1 parent 5a2de54 commit eb4e448
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions migrations/versions/recalculate-next-outgoing-times.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Migration script generated for recalculate-next-outgoing-times
revision = '17f3b60d-0777-4d0e-bb32-82e670b573a7'
down_revision = 'None'

import logging
from isacc_messaging.models.fhir import next_in_bundle
from isacc_messaging.models.isacc_patient import IsaccPatient as Patient

logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')


def upgrade():
# iterate over active patients; confirm/set next-outgoing extension
active_patients = Patient.active_patients()
for json_patient in next_in_bundle(active_patients):
patient = Patient(json_patient)
patient.mark_next_outgoing(persist_on_change=True)
logging.info('corrected next-outgoing-times')


def downgrade():
# Nothing to undo
logging.info('downgraded')

0 comments on commit eb4e448

Please sign in to comment.