Class: Renalware::Surveys::POSSComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Renalware::Surveys::POSSComponent
- Includes:
- ToggleHelper
- Defined in:
- app/components/renalware/surveys/pos_s_component.rb
Instance Method Summary collapse
- #column_headings ⇒ Object
-
#data_for_question_code(_code) ⇒ Object
Return data for charting.
- #question_labels ⇒ Object
-
#rows ⇒ Object
Backed by a SQL view.
- #survey ⇒ Object
Methods included from ToggleHelper
#css_toggle_link_to, #row_toggler, #rows_toggler, #table_toggler, #td_toggle_row, #th_toggle_all_rows, #toggler
Methods inherited from ApplicationComponent
Instance Method Details
#column_headings ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/components/renalware/surveys/pos_s_component.rb', line 35 def column_headings @column_headings ||= begin headings = ["Date"] headings.concat( Renalware::Survey .find_by!(code: "prom") .questions .order(:position) .pluck(:label) ) headings end end |
#data_for_question_code(_code) ⇒ Object
Return data for charting
28 29 30 31 32 33 |
# File 'app/components/renalware/surveys/pos_s_component.rb', line 28 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
17 18 19 20 21 22 23 24 25 |
# File 'app/components/renalware/surveys/pos_s_component.rb', line 17 def question_labels @question_labels ||= begin survey .questions .order(:position) .select(:code, :label, :label_abbrv) .each_with_object({}) { |q, hash| hash[q.code] = q.admin_label } end end |
#rows ⇒ Object
Backed by a SQL view
13 14 15 |
# File 'app/components/renalware/surveys/pos_s_component.rb', line 13 def rows @rows ||= POSSPivotedResponse.where(patient_id: patient.id) end |
#survey ⇒ Object
50 51 52 |
# File 'app/components/renalware/surveys/pos_s_component.rb', line 50 def survey @survey ||= Renalware::Surveys::Survey.find_by!(code: "prom") end |