Class: Renalware::Surveys::EQ5DComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Renalware::Surveys::EQ5DComponent
- Defined in:
- app/components/renalware/surveys/eq5d_component.rb
Instance Attribute Summary collapse
-
#patient ⇒ Object
readonly
Returns the value of attribute patient.
Instance Method Summary collapse
- #column_headings ⇒ Object
- #data_for_question_code(_code) ⇒ Object
-
#initialize(patient:) ⇒ EQ5DComponent
constructor
A new instance of EQ5DComponent.
- #question_labels ⇒ Object
- #rows ⇒ Object
- #survey ⇒ Object
Methods inherited from ApplicationComponent
Constructor Details
#initialize(patient:) ⇒ EQ5DComponent
Returns a new instance of EQ5DComponent.
10 11 12 |
# File 'app/components/renalware/surveys/eq5d_component.rb', line 10 def initialize(patient:) @patient = patient end |
Instance Attribute Details
#patient ⇒ Object (readonly)
Returns the value of attribute patient.
8 9 10 |
# File 'app/components/renalware/surveys/eq5d_component.rb', line 8 def patient @patient end |
Instance Method Details
#column_headings ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/components/renalware/surveys/eq5d_component.rb', line 33 def column_headings @column_headings ||= begin headings = ["Date"] headings.concat( Renalware::Survey .find_by!(code: "eq5d") .questions .order(:position) .pluck(:label) ) headings end end |
#data_for_question_code(_code) ⇒ Object
26 27 28 29 30 31 |
# File 'app/components/renalware/surveys/eq5d_component.rb', line 26 def data_for_question_code(_code) Renalware::Surveys::Response .where(patient_id: patient.id, question_id: 1) .pluck(:answered_on, :value) .to_h end |
#question_labels ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/components/renalware/surveys/eq5d_component.rb', line 18 def question_labels survey .questions .order(:position) .select(:code, :label) .each_with_object({}) { |q, hash| hash[q.code] = q.label } end |
#rows ⇒ Object
14 15 16 |
# File 'app/components/renalware/surveys/eq5d_component.rb', line 14 def rows @rows ||= EQ5DPivotedResponse.where(patient_id: patient.id) end |