Sha256: 8de9c68e942cd472be36e19c78a3eeb8f90951e19901fd1307dd51dd1e382132

Contents?: true

Size: 1.29 KB

Versions: 46

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

require_dependency "renalware"

module Renalware
  module HD
    class MDMPresenter < Renalware::MDMPresenter
      NullObject = Naught.build do |config|
        config.black_hole
        config.define_explicit_conversions
        config.singleton
        config.predicates_return false
      end

      def sessions
        @sessions ||= begin
          sessions = Sessions::LatestPatientSessionsQuery
                       .new(patient: patient)
                       .call(max_sessions: 6)
                       .includes(:patient, :hospital_unit, :signed_on_by, :signed_off_by)
          CollectionPresenter.new(sessions, SessionPresenter, view_context)
        end
      end

      def hd_profile
        @hd_profile ||= begin
          profile = HD::Profile.for_patient(patient).first
          if profile.present?
            HD::ProfilePresenter.new(profile)
          else
            NullObject.instance
          end
        end
      end

      def preference_set
        @preference_set ||= PreferenceSet.for_patient(patient).first || NullObject.instance
      end

      def audits
        @audits ||= PatientStatistics.for_patient(patient).limit(6).ordered
      end

      def rolling_audit
        @rolling_audit ||= audits.find_by(rolling: true)
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
renalware-core-2.0.126 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.125 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.124 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.123 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.121 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.120 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.119 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.118 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.117 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.116 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.115 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.113 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.112 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.111 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.110 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.109 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.108 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.106 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.105 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.104 app/presenters/renalware/hd/mdm_presenter.rb