Sha256: a5f358785310569636b538dec214d5de8234ec3af3d00f0f0b9d2277ffbb4489

Contents?: true

Size: 1.29 KB

Versions: 121

Compression:

Stored size: 1.29 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,
               :schedule_definition,
               :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

121 entries across 121 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.1.0 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.167 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.166 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.165 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.164 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.163 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.162 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.161 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.160 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.159 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.158 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.157 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.156 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.155 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.153 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.152 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.151 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.149 app/presenters/renalware/hd/patient_presenter.rb
renalware-core-2.0.148 app/presenters/renalware/hd/patient_presenter.rb