Class: Renalware::Pathology::ObservationForPatientRequestDescriptionQuery

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

Instance Method Summary collapse

Constructor Details

#initialize(patient, request_description) ⇒ ObservationForPatientRequestDescriptionQuery

Returns a new instance of ObservationForPatientRequestDescriptionQuery.



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

def initialize(patient, request_description)
  @patient = patient
  @observation_description = request_description.required_observation_description
end

Instance Method Details

#callObject

I tried to switch over here to pulling the results from current_observation_set but] the dates seemed to be one year ahead in the test suite



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/renalware/pathology/observation_for_patient_request_description_query.rb', line 15

def call
  return if @observation_description.nil?

  return if @patient.current_observation_set.nil?

  result = @patient.current_observation_set.values[@observation_description.code]
  if result
    OpenStruct.new(
      observed_on: Time.zone.parse(result["observed_at"]).to_date,
      result: result["result"].to_f
    )
  end

  # @patient
  #   .observations
  #   .where(description: @observation_description)
  #   .order(observed_at: :desc)
  #   .first
end