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
88
89
90
|
# File 'app/models/renalware/medications/prescription.rb', line 88
def self.default_search_order
["drug_name asc", "prescribed_on desc"]
end
|
Instance Method Details
#current?(date = Date.current) ⇒ Boolean
103
104
105
|
# File 'app/models/renalware/medications/prescription.rb', line 103
def current?(date = Date.current)
terminated_on.nil? || terminated_on >= date
end
|
#terminate(by:, terminated_on: Date.current) ⇒ Object
114
115
116
|
# File 'app/models/renalware/medications/prescription.rb', line 114
def terminate(by:, terminated_on: Date.current)
build_termination(by: by, terminated_on: terminated_on)
end
|
#terminated_by ⇒ Object
94
95
96
97
98
|
# File 'app/models/renalware/medications/prescription.rb', line 94
def terminated_by
return unless terminated_or_marked_for_termination?
termination.created_by
end
|
#terminated_or_marked_for_termination? ⇒ Boolean
107
108
109
|
# File 'app/models/renalware/medications/prescription.rb', line 107
def terminated_or_marked_for_termination?
terminated_on.present?
end
|