Class: Renalware::Medications::TerminateAllPatientPrescriptions

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/medications/terminate_all_patient_prescriptions.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(patient, by) ⇒ TerminateAllPatientPrescriptions

Returns a new instance of TerminateAllPatientPrescriptions.



14
15
16
17
# File 'app/models/renalware/medications/terminate_all_patient_prescriptions.rb', line 14

def initialize(patient, by)
  @patient = patient
  @by = by
end

Instance Attribute Details

#byObject (readonly)

Returns the value of attribute by.



8
9
10
# File 'app/models/renalware/medications/terminate_all_patient_prescriptions.rb', line 8

def by
  @by
end

#patientObject (readonly)

Returns the value of attribute patient.



8
9
10
# File 'app/models/renalware/medications/terminate_all_patient_prescriptions.rb', line 8

def patient
  @patient
end

Class Method Details

.call(patient:, by:) ⇒ Object



10
11
12
# File 'app/models/renalware/medications/terminate_all_patient_prescriptions.rb', line 10

def self.call(patient:, by:)
  new(patient, by).call
end

Instance Method Details

#callObject



19
20
21
22
23
# File 'app/models/renalware/medications/terminate_all_patient_prescriptions.rb', line 19

def call
  patient.prescriptions.current.each do |prescription|
    prescription.terminate(by: by).save!
  end
end