Sha256: 6755335869c06e3b029693981fe698451334b4f890f871370dc5dfb6c713b2e3

Contents?: true

Size: 1.45 KB

Versions: 35

Compression:

Stored size: 1.45 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)
          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 access
        @access ||= begin
          access_profile = Renalware::Accesses.cast_patient(patient).current_profile
          if access_profile.present?
            Accesses::ProfilePresenter.new(access_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
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
renalware-core-2.0.37 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.36 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.35 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.34 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.33 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.32 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.31 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.30 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.28 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.27 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.26 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.25 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.24 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.23 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.22 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.21 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.20 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.18 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.17 app/presenters/renalware/hd/mdm_presenter.rb
renalware-core-2.0.16 app/presenters/renalware/hd/mdm_presenter.rb