Class: Renalware::Pathology::RequestForPatientRequestDescriptionQuery

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/pathology/request_for_patient_request_description_query.rb

Instance Method Summary collapse

Constructor Details

#initialize(patient, request_description) ⇒ RequestForPatientRequestDescriptionQuery

Returns a new instance of RequestForPatientRequestDescriptionQuery.



8
9
10
11
# File 'app/models/renalware/pathology/request_for_patient_request_description_query.rb', line 8

def initialize(patient, request_description)
  @patient = patient
  @request_description = Renalware::Pathology::RequestDescription.find(request_description.id)
end

Instance Method Details

#callObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/renalware/pathology/request_for_patient_request_description_query.rb', line 13

def call
  @patient
    .requests
    .joins(:request_descriptions)
    .where(
      pathology_request_descriptions_requests_requests: {
        request_description_id: @request_description.id
      }
    )
    .order(created_at: :desc)
    .first
end