Class: Renalware::HD::PrescriptionLastAdministrationQuery

Inherits:
Object
  • Object
show all
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.

Instance Method Summary collapse

Instance Method Details

#callObject

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
20
# File 'app/models/renalware/hd/prescription_last_administration_query.rb', line 11

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