class PatientLocation
Schema Information
Table name: patient_locations
id :bigint not null, primary key academic_year :integer not null date_range :daterange default(-Infinity...Infinity), not null created_at :datetime not null updated_at :datetime not null location_id :bigint not null patient_id :bigint not null
Indexes
idx_on_location_id_academic_year_patient_id_3237b32fa0 (location_id,academic_year,patient_id) UNIQUE idx_on_patient_id_location_id_academic_year_08a1dc4afe (patient_id,location_id,academic_year) UNIQUE index_patient_locations_on_location_id (location_id) index_patient_locations_on_location_id_and_academic_year (location_id,academic_year)
Foreign Keys
fk_rails_... (location_id => locations.id) fk_rails_... (patient_id => patients.id)
Public Instance Methods
Source
# File app/models/patient_location.rb, line 81 def begin_date value = date_range.begin return nil if value.nil? || value == -Float::INFINITY value end
Source
# File app/models/patient_location.rb, line 93 def begin_date=(value) self.date_range = Range.new(value, end_date) end
Source
# File app/models/patient_location.rb, line 87 def end_date value = date_range.end return nil if value.nil? || value == Float::INFINITY date_range.exclude_end? ? value - 1.day : value end
Source
# File app/models/patient_location.rb, line 97 def end_date=(value) self.date_range = Range.new(begin_date, value) end
Source
# File app/models/patient_location.rb, line 107 def extend_date_range_to(date) self.begin_date = [date, begin_date].min unless begin_date.nil? self.end_date = [date, end_date].max unless end_date.nil? end
Extend the date range of this patient location to ensure that the date is within the range.
If the begin_date or end_date are nil, they will be left alone since the date would already be considered within the range.