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 = request_description
end

Instance Method Details

#callObject



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

def call
  @patient
    .requests
    .includes(request_descriptions: :required_observation_description)
    .where(
      pathology_request_descriptions_requests_requests: {
        request_description_id: @request_description.id
      }
    )
    .order(created_at: :desc)
    .limit(1)
    .pluck(:created_at)
    .first
end