Sha256: 7ca872908a29679d0e0eaf9118cdc888a178d0108fdb3e96a7ff96a15b8d419d

Contents?: true

Size: 1.14 KB

Versions: 36

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/surveys"

module Renalware
  module Surveys
    class EQ5DSummaryPart < Renalware::SummaryPart
      def rows
        @rows ||= EQ5DPivotedResponse.where(patient_id: patient.id)
      end

      def question_labels
        survey
          .questions
          .order(:position)
          .select(:code, :label)
          .each_with_object({}) { |q, hash| hash[q.code] = q.label }
      end

      def data_for_question_code(_code)
        Renalware::Surveys::Response
          .where(patient_id: patient.id, question_id: 1)
          .pluck(:answered_on, :value)
          .to_h
      end

      def column_headings
        @column_headings ||= begin
          headings = ["Date"]

          headings.concat(
            Renalware::Survey
            .find_by!(code: "eq5d")
            .questions
            .order(:position)
            .pluck(:label)
          )
          headings
        end
      end

      def to_partial_path
        "renalware/surveys/eq5d_summary_part"
      end

      def survey
        @survey ||= Renalware::Surveys::Survey.find_by!(code: "eq5d")
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
renalware-core-2.0.149 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.148 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.147 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.146 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.145 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.144 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.143 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.142 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.141 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.140 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.139 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.138 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.137 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.136 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.135 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.134 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.133 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.132 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.131 app/models/renalware/surveys/eq5d_summary_part.rb
renalware-core-2.0.130 app/models/renalware/surveys/eq5d_summary_part.rb