Sha256: d4a3956554c7a8c5e21a46170c21a91734ed4dc1d77f2c495134451070c13dc7

Contents?: true

Size: 1.33 KB

Versions: 24

Compression:

Stored size: 1.33 KB

Contents

module Renalware
  module MDMHelper
    def link_to_mdm(patient)
      MDMLink.new(patient).to_html
    end

    #
    # Create an html link to the MDM appropriate to the patient's current modality
    #
    class MDMLink
      include ActionView::Helpers
      include Renalware::Engine.routes.url_helpers

      def initialize(patient)
        @patient = patient
      end

      def path
        @path ||= begin
          return if modality_description.type.blank?
          case modality_description_symbol
          when :pd then patient_pd_mdm_path(patient)
          when :hd then patient_hd_mdm_path(patient)
          when :transplant then patient_transplants_mdm_path(patient)
          when :low_clearance then patient_low_clearance_mdm_path(patient)
          end
        end
      end

      def to_html
        link_to(mdm_name, path) if path
      end

      private

      attr_reader :patient
      delegate :name, to: :modality_description, prefix: true, allow_nil: true

      def modality_description
        current_modality = patient.current_modality || NullObject.instance
        current_modality.description
      end

      def mdm_name
        "#{modality_description_name} MDM"
      end

      def modality_description_symbol
        modality_description.becomes(modality_description.type.constantize).to_sym
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
renalware-core-2.0.16 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.15 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.14 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.13 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.12 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.11 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.9 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.8 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.7 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.5 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.4 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.3 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.2 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.1 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.0 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.0.pre.rc13 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.0.pre.rc11 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.0.pre.rc10 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.0.pre.rc9 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.0.pre.rc8 app/helpers/renalware/mdm_helper.rb