Sha256: 047dbee4523a7bce86723e6f60397e13d511ce0216da10560924435f79e14422

Contents?: true

Size: 816 Bytes

Versions: 5

Compression:

Stored size: 816 Bytes

Contents

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, to: :hd_profile, allow_nil: true
      delegate :unit_code, to: :hospital_unit, allow_nil: true, prefix: true
      delegate :transport, to: :document
      delegate :has_transport, to: :transport, prefix: false
      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

      private

      def hd_profile
        @hd_profile ||= __getobj__.hd_profile || NullObject.instance
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta8 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.0.pre.beta7 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.0.pre.beta6 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.0.pre.beta5 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.0.pre.beta4 app/presenters/renalware/hd/patient_presenter.rb