Sha256: 28f559466420ad7e328ff5072c30471561d927ba56145ebd55d205c0ec54ae83

Contents?: true

Size: 1.61 KB

Versions: 9

Compression:

Stored size: 1.61 KB

Contents

require_dependency "renalware/renal"
require "collection_presenter"

module Renalware
  module Renal
    class ClinicalSummaryPresenter
      def initialize(patient)
        @patient = patient
      end

      def current_prescriptions
        @current_prescriptions ||= begin
          prescriptions = @patient.prescriptions
                                  .includes(drug: [:drug_types])
                                  .includes(:medication_route)
                                  .current
                                  .ordered
          CollectionPresenter.new(prescriptions, Medications::PrescriptionPresenter)
        end
      end

      def current_problems
        @current_problems ||= @patient.problems
                                      .current
                                      .with_patient
                                      .ordered
      end

      def current_events
        @current_events ||= Events::Event.includes([:created_by, :event_type])
                                         .for_patient(@patient)
                                         .ordered
      end

      def letters
        present_letters(find_letters)
      end

      private

      def find_letters
        patient = Renalware::Letters.cast_patient(@patient)
        patient.letters
               .with_main_recipient
               .with_letterhead
               .with_author
               .with_patient
               .limit(10)
               .order(issued_on: :desc)
      end

      def present_letters(letters)
        CollectionPresenter.new(letters, Renalware::Letters::LetterPresenterFactory)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta12 app/presenters/renalware/renal/clinical_summary_presenter.rb
renalware-core-2.0.0.pre.beta11 app/presenters/renalware/renal/clinical_summary_presenter.rb
renalware-core-2.0.0.pre.beta10 app/presenters/renalware/renal/clinical_summary_presenter.rb
renalware-core-2.0.0.pre.beta9 app/presenters/renalware/renal/clinical_summary_presenter.rb
renalware-core-2.0.0.pre.beta8 app/presenters/renalware/renal/clinical_summary_presenter.rb
renalware-core-2.0.0.pre.beta7 app/presenters/renalware/renal/clinical_summary_presenter.rb
renalware-core-2.0.0.pre.beta6 app/presenters/renalware/renal/clinical_summary_presenter.rb
renalware-core-2.0.0.pre.beta5 app/presenters/renalware/renal/clinical_summary_presenter.rb
renalware-core-2.0.0.pre.beta4 app/presenters/renalware/renal/clinical_summary_presenter.rb