Sha256: ec66fa511350757f748a33b2a5cebaffb65f12fb3aab9656ea08e5e5eaf322ba

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require_dependency "renalware"

module Renalware
  module Clinical
    class ProfilePresenter
      attr_reader :patient, :params
      delegate :allergies, to: :patient
      delegate :diagnosis, :diagnosed_on, to: :diabetes, prefix: true

      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
        patient.document.history || NullObject.instance
      end

      def diabetes
        patient.document.diabetes || NullObject.instance
      end

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

      def body_compositions
        @body_compositions ||= BodyComposition.for_patient(patient).ordered
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta4 app/presenters/renalware/clinical/profile_presenter.rb