Sha256: db4e584576e3ea026521859924867311090e410c7db8c0bba5b3ff3ba4aa910d

Contents?: true

Size: 1.39 KB

Versions: 34

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

require_dependency "renalware"

module Renalware
  module Clinical
    class ProfilePresenter
      attr_reader :patient, :params
      delegate :allergies, :document, to: :patient

      def initialize(patient:, params:)
        @params = params
        @patient = Clinical.cast_patient(patient)
      end

      def swabs
        @swabs ||= Renalware::Events::Swab.for_patient(patient)
                                          .ordered
                                          .page(params[:page])
                                          .per(params.fetch(:per_page, 10))
      end

      def smoking_history
        history.smoking || NullObject.instance
      end

      def alcohol_history
        history.alcohol || NullObject.instance
      end

      def history
        document.history || NullObject.instance
      end

      %i(diabetes).each do |document_attribute|
        define_method(document_attribute) do
          document.send(document_attribute) || NullObject.instance
        end
      end

      def dry_weights
        @dry_weights ||= DryWeight.for_patient(patient).ordered.limit(5)
      end

      def body_compositions
        @body_compositions ||= begin
          BodyComposition
            .for_patient(patient)
            .includes([:modality_description, :assessor])
            .ordered
            .limit(5)
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
renalware-core-2.0.149 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.148 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.147 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.146 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.145 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.144 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.143 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.142 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.141 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.140 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.139 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.138 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.137 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.136 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.135 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.134 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.133 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.132 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.131 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.130 app/presenters/renalware/clinical/profile_presenter.rb