Class: Renalware::HD::ProfilePresenter

Inherits:
DumbDelegator show all
Defined in:
app/presenters/renalware/hd/profile_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DumbDelegator

#inspect, #public_send, #send, #try, #try!

Constructor Details

#initialize(profile, preference_set: nil) ⇒ ProfilePresenter

Returns a new instance of ProfilePresenter.



45
46
47
48
# File 'app/presenters/renalware/hd/profile_presenter.rb', line 45

def initialize(profile, preference_set: nil)
  super(profile)
  @preference_set = preference_set
end

Instance Attribute Details

#preference_setObject (readonly)

Returns the value of attribute preference_set.



6
7
8
# File 'app/presenters/renalware/hd/profile_presenter.rb', line 6

def preference_set
  @preference_set
end

Instance Method Details

#anticoagulant_stop_timeObject



101
102
103
104
105
# File 'app/presenters/renalware/hd/profile_presenter.rb', line 101

def anticoagulant_stop_time
  return if anticoagulant.stop_time.blank?

  Duration.from_minutes(anticoagulant.stop_time).to_s
end

#blood_flowObject



97
98
99
# File 'app/presenters/renalware/hd/profile_presenter.rb', line 97

def blood_flow
  "#{dialysis.blood_flow} ml/min" if dialysis.blood_flow.present?
end

#current_scheduleObject



66
67
68
69
70
# File 'app/presenters/renalware/hd/profile_presenter.rb', line 66

def current_schedule
  return other_schedule if other_schedule.present?

  schedule_definition
end

#documentObject



50
51
52
# File 'app/presenters/renalware/hd/profile_presenter.rb', line 50

def document
  ProfileDocumentPresenter.new(__getobj__.document)
end

#formatted_prescribed_timeObject



91
92
93
94
95
# File 'app/presenters/renalware/hd/profile_presenter.rb', line 91

def formatted_prescribed_time
  return unless prescribed_time

  ::Renalware::Duration.from_minutes(prescribed_time).to_s
end

#hd_typeObject



83
84
85
# File 'app/presenters/renalware/hd/profile_presenter.rb', line 83

def hd_type
  document.dialysis.hd_type.try(:text)
end

#hospital_unit_hintObject



54
55
56
57
58
# File 'app/presenters/renalware/hd/profile_presenter.rb', line 54

def hospital_unit_hint
  if preference_set.hospital_unit.present?
    "Preference: #{@preference_set.hospital_unit}"
  end
end

#last_updateObject



79
80
81
# File 'app/presenters/renalware/hd/profile_presenter.rb', line 79

def last_update
  "#{::I18n.l(updated_at)} by #{updated_by}"
end

#prescribed_timesObject



87
88
89
# File 'app/presenters/renalware/hd/profile_presenter.rb', line 87

def prescribed_times
  (60..360).step(15).map { |mins| [Duration.from_minutes(mins).to_s, mins] }
end

#schedule_definitionsObject



72
73
74
75
76
77
# File 'app/presenters/renalware/hd/profile_presenter.rb', line 72

def schedule_definitions
  ScheduleDefinition
    .includes(:diurnal_period)
    .ordered
    .map { |definition| [definition.to_s, definition.id] }
end

#schedule_hintObject



60
61
62
63
64
# File 'app/presenters/renalware/hd/profile_presenter.rb', line 60

def schedule_hint
  return if preference_set.preferred_schedule.blank?

  "Preference: #{@preference_set.preferred_schedule}"
end

#transport_summaryObject



107
108
109
110
111
# File 'app/presenters/renalware/hd/profile_presenter.rb', line 107

def transport_summary
  return if transport.blank?

  [transport.has_transport&.text, transport.type&.text].compact.join(": ")
end