Class: Renalware::HD::DiarySlotPresenter

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
app/presenters/renalware/hd/diary_slot_presenter.rb

Instance Method Summary collapse

Instance Method Details

#patient_search_optionsObject

rubocop:disable Metrics/MethodLength



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/presenters/renalware/hd/diary_slot_presenter.rb', line 36

def patient_search_options
  hospital_unit = Renalware::Hospitals::Unit.find(diary.hospital_unit_id)
  [
    OpenStruct.new(
      id: :dialysing_on_day_and_period,
      name: "Dialysing #{day_of_week_name} #{diurnal_period_code.to_s.upcase}"
    ),
    OpenStruct.new(
      id: :dialysing_on_day,
      name: "Dialysing on #{day_of_week_name}"
    ),
    OpenStruct.new(
      id: :dialysing_at_unit,
      name: "All #{hospital_unit.unit_code} HD patients"
    ),
    OpenStruct.new(
      id: :dialysing_at_hospital,
      name: "All HD patients"
    )
  ]
end

#patients_preferring_to_dialyse_todayObject

Patients who prefer to dialyse on this day e.g. Mon Flag those already assigned so they cannot be chosen.



26
27
28
29
30
31
32
33
# File 'app/presenters/renalware/hd/diary_slot_presenter.rb', line 26

def patients_preferring_to_dialyse_today
  patients = Renalware::HD::PatientsDialysingByDayQuery
  .new(
    diary.hospital_unit_id,
    day_of_week
  ).call.all
  simplify(patients)
end

#patients_preferring_to_dialyse_today_in_this_periodObject

Patients who prefer to dialyse on this day e.g. Mon and in this period e.g. AM. Flag those already assigned so they cannot be chosen.



14
15
16
17
18
19
20
21
22
# File 'app/presenters/renalware/hd/diary_slot_presenter.rb', line 14

def patients_preferring_to_dialyse_today_in_this_period
  patients = Renalware::HD::PatientsDialysingByDayAndPeriodQuery
    .new(
      diary.hospital_unit_id,
      day_of_week,
      diurnal_period_code.code
    ).call.all
  simplify(patients)
end