Sha256: 36fd370dd7c3f7edca3198329150b3f37f2d02353dd15b4390dcd1658bbf318e

Contents?: true

Size: 1.31 KB

Versions: 102

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/pathology"

module Renalware
  module Pathology
    module Requests
      class RequestPresenter < SimpleDelegator
        def self.present(requests)
          requests.map { |request| new request }
        end

        def patient_name
          patient.full_name.upcase
        end

        def date
          I18n.l Date.current
        end

        def date_of_birth
          I18n.l patient.born_on
        end

        def consultant
          request_form.consultant.full_name
        end

        def clinical_detail
          clinic.name
        end
        alias_method :contact, :clinical_detail

        def requested_by
          return "" if created_by.nil?

          created_by.full_name
        end

        def patient_rules
          ::Renalware::Pathology::Requests::PatientRulePresenter.present(super)
        end

        def global_requests_by_lab_and_bottle_type
          request_descriptions.group_by do |request_description|
            [request_description.lab.name, request_description.bottle_type]
          end
        end

        def patient_requests_by_lab
          patient_rules.group_by { |patient_rule| patient_rule.lab.name }
        end

        private

        def request_form
          __getobj__
        end
      end
    end
  end
end

Version data entries

102 entries across 102 versions & 1 rubygems

Version Path
renalware-core-2.0.109 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.108 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.106 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.105 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.104 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.103 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.102 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.101 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.100 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.99 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.98 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.97 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.96 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.95 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.94 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.93 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.92 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.91 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.90 app/presenters/renalware/pathology/requests/request_presenter.rb
renalware-core-2.0.89 app/presenters/renalware/pathology/requests/request_presenter.rb