Sha256: 83961902a2f46aa7cec52a6eeb9ac5c0e9719afa0ea73c37f0390a77fc87f2a9

Contents?: true

Size: 1.36 KB

Versions: 86

Compression:

Stored size: 1.36 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
      end

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

Version data entries

86 entries across 86 versions & 1 rubygems

Version Path
renalware-core-2.0.113 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.112 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.111 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.110 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.109 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.108 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.106 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.105 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.104 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.103 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.102 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.101 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.100 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.99 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.98 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.97 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.96 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.95 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.94 app/presenters/renalware/clinical/profile_presenter.rb
renalware-core-2.0.93 app/presenters/renalware/clinical/profile_presenter.rb