Class: Renalware::Pathology::ObservationsController

Inherits:
BaseController show all
Includes:
Concerns::Pageable
Defined in:
app/controllers/renalware/pathology/observations_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Instance Method Details

#indexObject

Observation history for a particular OBX.

  • HTML version is rendered from patient pathology under Investigations when you

select a Request and see its Observations and click on the Code.

  • JSON version used in graphs

rubocop:disable Metrics/MethodLength



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/renalware/pathology/observations_controller.rb', line 16

def index
  description = find_description
  observations = find_observations_for_description(description)

  respond_to do |format|
    format.html do
      render locals: {
        patient: @patient,
        observations: observations,
        description: description
      }
    end
    format.json do
      render json: {
        code: description.code,
        name: description.name,
        results: observations.pluck(:observed_at, :result).map { |arr|
          [arr.first.to_date, arr.last&.to_f]
        }
      }
    end
  end
end