Module: Renalware::PDRegimesHelper

Defined in:
app/helpers/renalware/pd_regimes_helper.rb

Instance Method Summary collapse

Instance Method Details

#available_pd_treatments_for(regime) ⇒ Object

The list of treatment options, stored in I18n



24
25
26
27
28
# File 'app/helpers/renalware/pd_regimes_helper.rb', line 24

def available_pd_treatments_for(regime)
  scope = "renalware.pd.treatments"
  key = regime.capd? ? "capd" : "apd"
  I18n.t(key, scope: scope)
end

#bag_typesObject



15
16
17
# File 'app/helpers/renalware/pd_regimes_helper.rb', line 15

def bag_types
  Renalware::PD::BagType.all.map { |bt| [bt.full_description, bt.id] }
end

#capd_apd_title(regime) ⇒ Object



30
31
32
# File 'app/helpers/renalware/pd_regimes_helper.rb', line 30

def capd_apd_title(regime)
  regime.pd_type.to_s.upcase
end

#default_daily_glucose_average(glucose) ⇒ Object



19
20
21
# File 'app/helpers/renalware/pd_regimes_helper.rb', line 19

def default_daily_glucose_average(glucose)
  glucose.presence || 0
end

#pd_regime_bag_days(bag) ⇒ Object



34
35
36
37
38
39
40
# File 'app/helpers/renalware/pd_regimes_helper.rb', line 34

def pd_regime_bag_days(bag)
  days = []
  Date::DAYNAMES.each_with_index do |day, index|
    days << Date::ABBR_DAYNAMES[index] if bag.public_send(day.downcase.to_sym)
  end
  days.join(", ")
end

#system_options_for(regime) ⇒ Object



5
6
7
# File 'app/helpers/renalware/pd_regimes_helper.rb', line 5

def system_options_for(regime)
  PD::System.for_pd_type(regime.pd_type) { |system| [system.name, system.id] }
end

#therapy_timesObject



9
10
11
12
13
# File 'app/helpers/renalware/pd_regimes_helper.rb', line 9

def therapy_times
  PD::APDRegime::VALID_RANGES.therapy_times.map do |minutes|
    [Duration.from_minutes(minutes).to_s, minutes]
  end
end