Sha256: 62e8c649de43a396c4876a86b2a73c68d87747aeb39c4d05ad679594c2d9bb85

Contents?: true

Size: 1.38 KB

Versions: 26

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

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"
        "MDM"
      end

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

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
renalware-core-2.0.149 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.148 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.147 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.146 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.145 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.144 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.143 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.142 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.141 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.140 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.139 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.138 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.137 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.136 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.135 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.134 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.133 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.132 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.131 app/helpers/renalware/mdm_helper.rb
renalware-core-2.0.130 app/helpers/renalware/mdm_helper.rb