Class: Renalware::PD::PETResultsComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Renalware::PD::PETResultsComponent
- Includes:
- Pagy::Backend, Pagy::Frontend, DropdownButtonHelper, ToggleHelper
- Defined in:
- app/components/renalware/pd/pet_results_component.rb
Constant Summary collapse
- TITLE =
"PET Results"
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#pagination ⇒ Object
readonly
Returns the value of attribute pagination.
-
#patient ⇒ Object
readonly
Returns the value of attribute patient.
Instance Method Summary collapse
- #graph_data ⇒ Object
-
#graph_options ⇒ Object
TODO: Finish adding plot bands and fix xaxis.
-
#initialize(patient:, current_user:) ⇒ PETResultsComponent
constructor
A new instance of PETResultsComponent.
- #results ⇒ Object
- #title ⇒ Object
Methods included from DropdownButtonHelper
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
Constructor Details
#initialize(patient:, current_user:) ⇒ PETResultsComponent
Returns a new instance of PETResultsComponent.
16 17 18 19 |
# File 'app/components/renalware/pd/pet_results_component.rb', line 16 def initialize(patient:, current_user:) @patient = PD.cast_patient(patient) @current_user = current_user end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
12 13 14 |
# File 'app/components/renalware/pd/pet_results_component.rb', line 12 def current_user @current_user end |
#pagination ⇒ Object (readonly)
Returns the value of attribute pagination.
12 13 14 |
# File 'app/components/renalware/pd/pet_results_component.rb', line 12 def pagination @pagination end |
#patient ⇒ Object (readonly)
Returns the value of attribute patient.
12 13 14 |
# File 'app/components/renalware/pd/pet_results_component.rb', line 12 def patient @patient end |
Instance Method Details
#graph_data ⇒ Object
36 37 38 39 40 41 42 |
# File 'app/components/renalware/pd/pet_results_component.rb', line 36 def graph_data patient .pet_results .where("d_pcr is not null and net_uf is not null") .order(performed_on: :asc) .pluck(:d_pcr, :net_uf) end |
#graph_options ⇒ Object
TODO: Finish adding plot bands and fix xaxis. Need to build this graph in codepen outside of the app so we can experiment - at the moment the x axis is built from the data series (pcr), which is not linear. So we need to specify the x axis and the series data separately. Best to use highcharts natively perhaps and skip the chartkick wrapper. rubocop:disable Metrics/MethodLength
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/components/renalware/pd/pet_results_component.rb', line 50 def { xtitle: "D/Pcr", ytitle: "net UF", curve: false, discrete: true, # required to allow points to double back on themselves library: { xAxis: { plotBands: [ { from: 0.0, to: 0.5, color: "rgba(68, 170, 213, 0.1)", label: { text: "Low", style: { color: "#606060" } } } ] } } } end |
#results ⇒ Object
21 22 23 24 25 26 |
# File 'app/components/renalware/pd/pet_results_component.rb', line 21 def results @results ||= begin @pagination, @results = pagy(scope, items: 6) @results end end |
#title ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/components/renalware/pd/pet_results_component.rb', line 28 def title if pagination.items < pagination.count "#{TITLE} (#{pagination.items} of #{pagination.count})" else "#{TITLE} (#{pagination.items})" end end |