Sha256: fab477902fdc01cad0582e961d31b1ac169ee5d2d24ef316c7b59dc98a88860d

Contents?: true

Size: 1.25 KB

Versions: 37

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require "renalware/hd"

module Renalware
  module HD
    class PatientPresenter < SimpleDelegator
      # delegate_missing_to :patient # TODO: when rails 5.1, try instead of SimpleDelegator
      delegate :document, to: :hd_profile
      delegate :hospital_unit,
               :transport_summary,
               to: :hd_profile, allow_nil: true
      delegate :unit_code, to: :hospital_unit, allow_nil: true, prefix: true
      delegate :transport, to: :document
      delegate :type, to: :transport, prefix: true
      alias_method :dialysing_at_unit, :hospital_unit_unit_code

      def initialize(patient)
        super(HD.cast_patient(patient.__getobj__))
      end

      def finished_hd_sessions
        # TODO: standardise on a way to get closed sessions - a scope on patient maybe?
        hd_sessions.eager_load(:hospital_unit).where(type: "Renalware::HD::Session::Closed")
      end

      def current_observation_set
        @current_observation_set ||= begin
          Renalware::Pathology::ObservationSetPresenter.new(__getobj__.current_observation_set)
        end
      end

      private

      def hd_profile
        @hd_profile ||= HD::ProfilePresenter.new(__getobj__.hd_profile) || NullObject.instance
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

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