Class: Renalware::Surveys::EQ5DComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Renalware::Surveys::EQ5DComponent
- Defined in:
- app/components/renalware/surveys/eq5d_component.rb
Instance Method Summary collapse
- #column_headings ⇒ Object
- #data_for_question_code(_code) ⇒ Object
- #question_labels ⇒ Object
- #rows ⇒ Object
- #survey ⇒ Object
Methods inherited from ApplicationComponent
Instance Method Details
#column_headings ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/components/renalware/surveys/eq5d_component.rb', line 29 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
22 23 24 25 26 27 |
# File 'app/components/renalware/surveys/eq5d_component.rb', line 22 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
14 15 16 17 18 19 20 |
# File 'app/components/renalware/surveys/eq5d_component.rb', line 14 def question_labels survey .questions .order(:position) .select(:code, :label) .each_with_object({}) { |q, hash| hash[q.code] = q.label } end |
#rows ⇒ Object
10 11 12 |
# File 'app/components/renalware/surveys/eq5d_component.rb', line 10 def rows @rows ||= EQ5DPivotedResponse.where(patient_id: patient.id) end |