Class: Renalware::HD::PatientsDialysingByScheduleQuery
- Inherits:
-
Object
- Object
- Renalware::HD::PatientsDialysingByScheduleQuery
- Defined in:
- app/models/renalware/hd/patients_dialysing_by_schedule_query.rb
Instance Attribute Summary collapse
-
#hospital_unit_id ⇒ Object
readonly
Returns the value of attribute hospital_unit_id.
-
#schedule_definition_ids ⇒ Object
readonly
Returns the value of attribute schedule_definition_ids.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(hospital_unit_id, schedule_definition_ids) ⇒ PatientsDialysingByScheduleQuery
constructor
A new instance of PatientsDialysingByScheduleQuery.
Constructor Details
#initialize(hospital_unit_id, schedule_definition_ids) ⇒ PatientsDialysingByScheduleQuery
Returns a new instance of PatientsDialysingByScheduleQuery.
10 11 12 13 |
# File 'app/models/renalware/hd/patients_dialysing_by_schedule_query.rb', line 10 def initialize(hospital_unit_id, schedule_definition_ids) @hospital_unit_id = hospital_unit_id @schedule_definition_ids = Array(schedule_definition_ids) end |
Instance Attribute Details
#hospital_unit_id ⇒ Object (readonly)
Returns the value of attribute hospital_unit_id.
8 9 10 |
# File 'app/models/renalware/hd/patients_dialysing_by_schedule_query.rb', line 8 def hospital_unit_id @hospital_unit_id end |
#schedule_definition_ids ⇒ Object (readonly)
Returns the value of attribute schedule_definition_ids.
8 9 10 |
# File 'app/models/renalware/hd/patients_dialysing_by_schedule_query.rb', line 8 def schedule_definition_ids @schedule_definition_ids end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/renalware/hd/patients_dialysing_by_schedule_query.rb', line 15 def call return [] if schedule_definition_ids.empty? Patient .eager_load(hd_profile: [:hospital_unit, { schedule_definition: [:diurnal_period] }]) .where( hd_profiles: { schedule_definition_id: schedule_definition_ids, hospital_unit_id: hospital_unit_id }) .order(:family_name, :given_name) end |