Class: Renalware::PD::Regime
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Renalware::PD::Regime
- Extended by:
- Enumerize
- Defined in:
- app/models/renalware/pd/regime.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#total_potential_fluid_available_for_overnight_exchanges ⇒ Object
Returns the value of attribute total_potential_fluid_available_for_overnight_exchanges.
Class Method Summary collapse
Instance Method Summary collapse
-
#anything_changed? ⇒ Boolean
changed_for_autosave? is an AR method that will recursively check the in-memory regime and its bags for changes or any bags marked for destruction.
- #apd? ⇒ Boolean
- #capd? ⇒ Boolean
- #current? ⇒ Boolean
- #deep_dup ⇒ Object
- #deep_restore_attributes ⇒ Object
- #has_additional_manual_exchange_bag? ⇒ Boolean
- #pd_type ⇒ Object
- #terminate(by:, terminated_on: Date.current) ⇒ Object
- #terminated? ⇒ Boolean
- #with_bag_destruction_marks_removed ⇒ Object
Instance Attribute Details
#total_potential_fluid_available_for_overnight_exchanges ⇒ Object
Returns the value of attribute total_potential_fluid_available_for_overnight_exchanges.
109 110 111 |
# File 'app/models/renalware/pd/regime.rb', line 109 def total_potential_fluid_available_for_overnight_exchanges @total_potential_fluid_available_for_overnight_exchanges end |
Class Method Details
.current ⇒ Object
49 50 51 |
# File 'app/models/renalware/pd/regime.rb', line 49 def self.current Regime.order("pd_regimes.created_at DESC").limit(1).with_bags.first end |
.policy_class ⇒ Object
61 62 63 |
# File 'app/models/renalware/pd/regime.rb', line 61 def self.policy_class RegimePolicy end |
Instance Method Details
#anything_changed? ⇒ Boolean
changed_for_autosave? is an AR method that will recursively check the in-memory regime and its bags for changes or any bags marked for destruction.
95 96 97 |
# File 'app/models/renalware/pd/regime.rb', line 95 def anything_changed? changed_for_autosave? end |
#apd? ⇒ Boolean
65 66 67 |
# File 'app/models/renalware/pd/regime.rb', line 65 def apd? pd_type == :apd end |
#capd? ⇒ Boolean
69 70 71 |
# File 'app/models/renalware/pd/regime.rb', line 69 def capd? pd_type == :capd end |
#current? ⇒ Boolean
53 54 55 |
# File 'app/models/renalware/pd/regime.rb', line 53 def current? Regime.current == self end |
#deep_dup ⇒ Object
81 82 83 84 85 |
# File 'app/models/renalware/pd/regime.rb', line 81 def deep_dup regime = dup regime.bags = bags.map(&:dup) regime end |
#deep_restore_attributes ⇒ Object
87 88 89 90 91 |
# File 'app/models/renalware/pd/regime.rb', line 87 def deep_restore_attributes restore_attributes bags.reload with_bag_destruction_marks_removed end |
#has_additional_manual_exchange_bag? ⇒ Boolean
77 78 79 |
# File 'app/models/renalware/pd/regime.rb', line 77 def has_additional_manual_exchange_bag? false end |
#pd_type ⇒ Object
73 74 75 |
# File 'app/models/renalware/pd/regime.rb', line 73 def pd_type raise NotImplementedError end |
#terminate(by:, terminated_on: Date.current) ⇒ Object
104 105 106 107 |
# File 'app/models/renalware/pd/regime.rb', line 104 def terminate(by:, terminated_on: Date.current) build_termination(by: by, terminated_on: terminated_on) self end |
#terminated? ⇒ Boolean
57 58 59 |
# File 'app/models/renalware/pd/regime.rb', line 57 def terminated? termination.present? end |
#with_bag_destruction_marks_removed ⇒ Object
99 100 101 102 |
# File 'app/models/renalware/pd/regime.rb', line 99 def with_bag_destruction_marks_removed bags.select(&:marked_for_destruction?).each(&:reload) self end |