Sha256: 55540db59054eac14fae3eff075b765fbd058e1fd31d2713eb28b4a038d8c0bd

Contents?: true

Size: 1.11 KB

Versions: 18

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Renalware
  module Pathology
    class ChartComponent < ApplicationComponent
      pattr_initialize [:current_user!, :patient!, :observation_description!]

      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

      # TODO: cache key should expire when a new observation arrives of this type
      def cache_key
        "#{patient.cache_key}/chart/#{observation_description.id}"
      end

      # 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.
      def render?
        true
      end

      def options
        {}
      end

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/components/renalware/pathology/chart_component.rb
renalware-core-2.1.0 app/components/renalware/pathology/chart_component.rb
renalware-core-2.0.167 app/components/renalware/pathology/chart_component.rb
renalware-core-2.0.166 app/components/renalware/pathology/chart_component.rb
renalware-core-2.0.165 app/components/renalware/pathology/chart_component.rb
renalware-core-2.0.164 app/components/renalware/pathology/chart_component.rb
renalware-core-2.0.163 app/components/renalware/pathology/chart_component.rb
renalware-core-2.0.162 app/components/renalware/pathology/chart_component.rb
renalware-core-2.0.161 app/components/renalware/pathology/chart_component.rb
renalware-core-2.0.160 app/components/renalware/pathology/chart_component.rb
renalware-core-2.0.159 app/components/renalware/pathology/chart_component.rb
renalware-core-2.0.158 app/components/renalware/pathology/chart_component.rb
renalware-core-2.0.157 app/components/renalware/pathology/chart_component.rb
renalware-core-2.0.156 app/components/renalware/pathology/chart_component.rb
renalware-core-2.0.155 app/components/renalware/pathology/chart_component.rb
renalware-core-2.0.153 app/components/renalware/pathology/chart_component.rb
renalware-core-2.0.152 app/components/renalware/pathology/chart_component.rb
renalware-core-2.0.151 app/components/renalware/pathology/chart_component.rb