Skip to content

Commit ef9530a

Browse files
committed
Adjust vaccination source backfilling logic
This is a small change to the migration which adds source as a column to the VaccinationRecord table. For historically uploaded vaccination records with the outcome `already_had` created before the migration, we now backfill the source value as `historical_upload` rather than `consent_refusal`. This is consistent with how those records are treated after the migration. Jira-Issue: MAV-1603
1 parent 50eb0da commit ef9530a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

db/migrate/20250829172505_add_source_to_vaccination_record.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ class AddSourceToVaccinationRecord < ActiveRecord::Migration[8.0]
44
def up
55
add_column :vaccination_records, :source, :integer
66

7-
# Backfill values based on presence of session_id
87
VaccinationRecord.update_all(source: "historical_upload")
9-
VaccinationRecord.where(outcome: "already_had").update_all(
10-
source: "consent_refusal"
11-
)
8+
# This handles records which were created when a parent refused consent because the patient was already vaccinated
9+
VaccinationRecord.where(
10+
outcome: "already_had",
11+
immunisation_imports: []
12+
).update_all(source: "consent_refusal")
1213
VaccinationRecord.recorded_in_service.update_all(source: "service")
1314

1415
change_column_null :vaccination_records, :source, false

0 commit comments

Comments
 (0)