Class: Renalware::Pathology::ChartComponent

Inherits:
ApplicationComponent show all
Defined in:
app/components/renalware/pathology/chart_component.rb

Instance Method Summary collapse

Methods inherited from ApplicationComponent

#policy, #renalware

Instance Method Details

#cache_keyObject

TODO: cache key should expire when a new observation arrives of this type



19
20
21
# File 'app/components/renalware/pathology/chart_component.rb', line 19

def cache_key
  "#{patient.cache_key}/chart/#{observation_description.id}"
end

#chart_dataObject



8
9
10
11
12
13
14
15
16
# File 'app/components/renalware/pathology/chart_component.rb', line 8

def chart_data
  @chart_data ||= begin
    Pathology.cast_patient(patient)
      .observations
      .where(description_id: observation_description.id)
      .order(:observed_at)
      .pluck([:observed_at, :result])
  end
end

#dom_idObject



35
36
37
# File 'app/components/renalware/pathology/chart_component.rb', line 35

def dom_id
  @dom_id ||= ActionView::RecordIdentifier.dom_id(observation_description)
end

#optionsObject



31
32
33
# File 'app/components/renalware/pathology/chart_component.rb', line 31

def options
  {}
end

#render?Boolean

Because we cache the component html inside the view sidecar, we want to avoid implementing this method properly - ie checking if there anything to render - as that would involve querying the database, thus negating the befit of any caching.

Returns:

  • (Boolean)


27
28
29
# File 'app/components/renalware/pathology/chart_component.rb', line 27

def render?
  true
end