class SchoolMove
Schema Information
Table name: school_moves
id :bigint not null, primary key academic_year :integer not null source :integer not null created_at :datetime not null updated_at :datetime not null patient_id :bigint not null school_id :bigint not null
Indexes
index_school_moves_on_patient_id (patient_id) UNIQUE index_school_moves_on_patient_id_and_school_id (patient_id,school_id) index_school_moves_on_school_id (school_id)
Foreign Keys
fk_rails_... (patient_id => patients.id) fk_rails_... (school_id => locations.id)
Public Instance Methods
Source
# File app/models/school_move.rb, line 58 def confirm!(user: nil) ActiveRecord::Base.transaction do move_across_teams = from_another_team? update_patient! update_archive_reasons!(user:) update_locations! log_entry = create_log_entry!(user:) update_patient_teams! update_patient_statuses! if move_across_teams create_important_notice!(log_entry) update_important_notices! end destroy! if persisted? end end
Source
# File app/models/school_move.rb, line 84 def from_another_team? current_teams = patient.teams_via_patient_locations return false if current_teams.empty? (teams & current_teams).empty? end