Class: Renalware::HD::Scheduling::DiaryRange
- Inherits:
-
Object
- Object
- Renalware::HD::Scheduling::DiaryRange
- Defined in:
- app/models/renalware/hd/scheduling/diary_range.rb
Overview
Represents a range of WeekPeriods and their diaries for a hospital unit
Instance Method Summary collapse
-
#create_missing_weekly_diaries(by:) ⇒ Object
If there are any missing weekly diaries in the date range, create them.
- #from_date ⇒ Object
- #log_weekly_diary_creation(period) ⇒ Object
- #to_date ⇒ Object
Instance Method Details
#create_missing_weekly_diaries(by:) ⇒ Object
If there are any missing weekly diaries in the date range, create them
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/models/renalware/hd/scheduling/diary_range.rb', line 15 def create_missing_weekly_diaries(by:) week_periods_in_range.each do |period| WeeklyDiary.find_or_create_by!( hospital_unit_id: unit.id, week_number: period.week_number, year: period.year ) do |diary| log_weekly_diary_creation(period) diary.master_diary = master_diary_for(unit, by) diary.by = by end end end |
#from_date ⇒ Object
36 37 38 |
# File 'app/models/renalware/hd/scheduling/diary_range.rb', line 36 def from_date from_week_period.date_on_first_day_of_week end |
#log_weekly_diary_creation(period) ⇒ Object
29 30 31 32 33 34 |
# File 'app/models/renalware/hd/scheduling/diary_range.rb', line 29 def log_weekly_diary_creation(period) Rails.logger.debug( "DEBUG: Creating weekly diary for unit #{unit.id} period "\ "#{period.week_number}/#{period.year}" ) end |
#to_date ⇒ Object
40 41 42 |
# File 'app/models/renalware/hd/scheduling/diary_range.rb', line 40 def to_date to_week_period.date_on_first_day_of_week end |