Sha256: b0cc0548299e28fd4e3aa44b2efec3c65367f2fd9e9d288b457a17c98d4ccf2a

Contents?: true

Size: 1.47 KB

Versions: 11

Compression:

Stored size: 1.47 KB

Contents

require_dependency "renalware/letters"

module Renalware
  module Letters
    class LetterFormPresenter < DumbDelegator
      def person_roles
        [].tap do |collection|
          collection << primary_care_physician_role if patient.primary_care_physician.present?
          collection << patient_role
          collection << other_role
        end
      end

      def patient
        PatientPresenter.new(super)
      end

      def primary_care_physician
        PrimaryCarePhysicianPresenter.new(patient.primary_care_physician)
      end

      def patient_cc_hint
        scope = "renalware.letters.hints.cc_hint"
        if patient.cc_on_all_letters
          ::I18n.t("cc_on_all_letters", scope: scope).html_safe
        else
          ::I18n.t("not_cc_on_all_letters", scope: scope).html_safe
        end
      end

      def cc_recipient_for_contact(contact)
        find_cc_recipient_for_contact(contact)
      end

      private

      def primary_care_physician_role
        label = "Primary Care Physician <address>#{primary_care_physician.full_name}, " \
                "#{primary_care_physician.address}</address>".html_safe
        [label, "primary_care_physician", primary_care_physician.salutation]
      end

      def patient_role
        label = "Patient <address>#{patient.full_name}, #{patient.address}</address>".html_safe
        [label, "patient", patient.salutation]
      end

      def other_role
        ["Patient's Contact", "contact", ""]
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.rc3 app/presenters/renalware/letters/letter_form_presenter.rb
renalware-core-2.0.0.pre.rc1 app/presenters/renalware/letters/letter_form_presenter.rb
renalware-core-2.0.0.pre.beta12 app/presenters/renalware/letters/letter_form_presenter.rb
renalware-core-2.0.0.pre.beta11 app/presenters/renalware/letters/letter_form_presenter.rb
renalware-core-2.0.0.pre.beta10 app/presenters/renalware/letters/letter_form_presenter.rb
renalware-core-2.0.0.pre.beta9 app/presenters/renalware/letters/letter_form_presenter.rb
renalware-core-2.0.0.pre.beta8 app/presenters/renalware/letters/letter_form_presenter.rb
renalware-core-2.0.0.pre.beta7 app/presenters/renalware/letters/letter_form_presenter.rb
renalware-core-2.0.0.pre.beta6 app/presenters/renalware/letters/letter_form_presenter.rb
renalware-core-2.0.0.pre.beta5 app/presenters/renalware/letters/letter_form_presenter.rb
renalware-core-2.0.0.pre.beta4 app/presenters/renalware/letters/letter_form_presenter.rb