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.
96 97 98 |
# File 'app/models/renalware/pd/regime.rb', line 96 def total_potential_fluid_available_for_overnight_exchanges @total_potential_fluid_available_for_overnight_exchanges end |
Class Method Details
.current ⇒ Object
36 37 38 |
# File 'app/models/renalware/pd/regime.rb', line 36 def self.current Regime.order("pd_regimes.created_at DESC").limit(1).with_bags.first end |
.policy_class ⇒ Object
48 49 50 |
# File 'app/models/renalware/pd/regime.rb', line 48 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.
82 83 84 |
# File 'app/models/renalware/pd/regime.rb', line 82 def anything_changed? changed_for_autosave? end |
#apd? ⇒ Boolean
52 53 54 |
# File 'app/models/renalware/pd/regime.rb', line 52 def apd? pd_type == :apd end |
#capd? ⇒ Boolean
56 57 58 |
# File 'app/models/renalware/pd/regime.rb', line 56 def capd? pd_type == :capd end |
#current? ⇒ Boolean
40 41 42 |
# File 'app/models/renalware/pd/regime.rb', line 40 def current? Regime.current == self end |
#deep_dup ⇒ Object
68 69 70 71 72 |
# File 'app/models/renalware/pd/regime.rb', line 68 def deep_dup regime = dup regime.bags = bags.map(&:dup) regime end |
#deep_restore_attributes ⇒ Object
74 75 76 77 78 |
# File 'app/models/renalware/pd/regime.rb', line 74 def deep_restore_attributes restore_attributes bags.reload with_bag_destruction_marks_removed end |
#has_additional_manual_exchange_bag? ⇒ Boolean
64 65 66 |
# File 'app/models/renalware/pd/regime.rb', line 64 def has_additional_manual_exchange_bag? false end |
#pd_type ⇒ Object
60 61 62 |
# File 'app/models/renalware/pd/regime.rb', line 60 def pd_type raise NotImplementedError end |
#terminate(by:, terminated_on: Date.current) ⇒ Object
91 92 93 94 |
# File 'app/models/renalware/pd/regime.rb', line 91 def terminate(by:, terminated_on: Date.current) build_termination(by: by, terminated_on: terminated_on) self end |
#terminated? ⇒ Boolean
44 45 46 |
# File 'app/models/renalware/pd/regime.rb', line 44 def terminated? termination.present? end |
#with_bag_destruction_marks_removed ⇒ Object
86 87 88 89 |
# File 'app/models/renalware/pd/regime.rb', line 86 def with_bag_destruction_marks_removed bags.select(&:marked_for_destruction?).each(&:reload) self end |