Class: Renalware::Medications::Prescription
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#first_or_create_by!, #save_by, #save_by!, #update_by
Instance Attribute Details
#drug_select ⇒ Object
Returns the value of attribute drug_select.
11
12
13
|
# File 'app/models/renalware/medications/prescription.rb', line 11
def drug_select
@drug_select
end
|
Class Method Details
.default_search_order ⇒ Object
This is a Ransack-compatible search predicate
86
87
88
|
# File 'app/models/renalware/medications/prescription.rb', line 86
def self.default_search_order
["drug_name asc", "prescribed_on desc"]
end
|
.policy_class ⇒ Object
90
91
92
|
# File 'app/models/renalware/medications/prescription.rb', line 90
def self.policy_class
BasePolicy
end
|
Instance Method Details
#current?(date = Date.current) ⇒ Boolean
105
106
107
|
# File 'app/models/renalware/medications/prescription.rb', line 105
def current?(date = Date.current)
terminated_on.nil? || terminated_on >= date
end
|
#terminate(by:, terminated_on: Date.current) ⇒ Object
116
117
118
|
# File 'app/models/renalware/medications/prescription.rb', line 116
def terminate(by:, terminated_on: Date.current)
build_termination(by: by, terminated_on: terminated_on)
end
|
#terminated_by ⇒ Object
96
97
98
99
100
|
# File 'app/models/renalware/medications/prescription.rb', line 96
def terminated_by
return unless terminated_or_marked_for_termination?
termination.created_by
end
|
#terminated_or_marked_for_termination? ⇒ Boolean
109
110
111
|
# File 'app/models/renalware/medications/prescription.rb', line 109
def terminated_or_marked_for_termination?
terminated_on.present?
end
|