Class: Renalware::Medications::RevisePrescription
- Inherits:
-
Object
- Object
- Renalware::Medications::RevisePrescription
- Defined in:
- app/models/renalware/medications/revise_prescription.rb
Constant Summary collapse
- NEW_PRESCRIPTION_ATTRS =
%w(dose_amount dose_unit frequency).freeze
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#prescription ⇒ Object
readonly
Returns the value of attribute prescription.
Instance Method Summary collapse
- #call(params) ⇒ Object
-
#initialize(prescription) ⇒ RevisePrescription
constructor
A new instance of RevisePrescription.
Constructor Details
#initialize(prescription) ⇒ RevisePrescription
Returns a new instance of RevisePrescription.
12 13 14 |
# File 'app/models/renalware/medications/revise_prescription.rb', line 12 def initialize(prescription) @prescription = prescription end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'app/models/renalware/medications/revise_prescription.rb', line 8 def params @params end |
#prescription ⇒ Object (readonly)
Returns the value of attribute prescription.
8 9 10 |
# File 'app/models/renalware/medications/revise_prescription.rb', line 8 def prescription @prescription end |
Instance Method Details
#call(params) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/renalware/medications/revise_prescription.rb', line 16 def call(params) @prescription.assign_attributes(params) return false unless @prescription.valid? if new_prescription_required? @prescription.reload TerminateExistingAndCreateNewPescription.new(@prescription, params).call else @prescription.save end end |