Class: PrescriptionDetails
- Inherits:
-
Prescription
- Object
- Common::Base
- Prescription
- PrescriptionDetails
- Defined in:
- app/models/prescription_details.rb
Instance Attribute Summary
Attributes inherited from Prescription
#dispensed_date, #expiration_date, #facility_name, #is_refillable, #is_trackable, #ordered_date, #prescription_id, #prescription_name, #prescription_number, #quantity, #refill_date, #refill_remaining, #refill_status, #refill_submit_date, #station_number
Attributes inherited from Common::Base
Instance Method Summary collapse
Methods inherited from Prescription
Methods inherited from Common::Base
#changed, #changed?, #changes, default_sort, filterable_attributes, #initialize, max_per_page, per_page, sortable_attributes
Constructor Details
This class inherits a constructor from Common::Base
Instance Method Details
#sorted_dispensed_date ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/models/prescription_details.rb', line 31 def sorted_dispensed_date has_refills = try(:rx_rf_records).present? last_refill_date = Date.new(0) if has_refills refills = rx_rf_records[0][1] refills.each do |r| last_dispensed = r.try(:[], :dispensed_date) next if last_dispensed.nil? refill_date = Date.parse(r.try(:[], :dispensed_date)) last_refill_date = refill_date if refill_date.present? && refill_date > last_refill_date end end if has_refills && last_refill_date.present? last_refill_date.to_date elsif dispensed_date.present? dispensed_date.to_date else Date.new(0) end end |