Class: Renalware::HD::PrescriptionLastAdministrationQuery
- Inherits:
-
Object
- Object
- Renalware::HD::PrescriptionLastAdministrationQuery
- Defined in:
- app/models/renalware/hd/prescription_last_administration_query.rb
Overview
Find the lastest PrescriptionAdministration for a particular prescription - ie the last time it was given.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.call(prescription:) ⇒ Object
11 12 13 |
# File 'app/models/renalware/hd/prescription_last_administration_query.rb', line 11 def self.call(prescription:) new(prescription: prescription).call end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/renalware/hd/prescription_last_administration_query.rb', line 15 def call raise ArgumentError if prescription.blank? raise ArgumentError if patient.blank? hd_patient .prescription_administrations .where(prescription: prescription, administered: true) .order(recorded_on: :desc, created_at: :desc) .first end |