Sha256: 36d176a387f6345ce15cae5ef402e2250f3255f46282e6b1b7148eadf8869320

Contents?: true

Size: 1.05 KB

Versions: 103

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/letters"

# A method object initialized with an instance of Letter responsible
# for determining the "counterpart CC's". A counterpart CC can be a patient,
# primary care physician or both.
#
module Renalware
  module Letters
    class DetermineCounterpartCCs < SimpleDelegator
      def call
        counterpart_css = []
        counterpart_css << build_recipient("patient", patient) if cc_patient?
        if cc_primary_care_physican?
          counterpart_css << build_recipient("primary_care_physician", primary_care_physician)
        end
        counterpart_css
      end

      private

      def cc_primary_care_physican?
        pcp = patient.primary_care_physician
        pcp&.cc_on_letter?(self)
      end

      def cc_patient?
        patient.cc_on_letter?(self)
      end

      def build_recipient(person_role, addressee)
        Recipient.new(
          person_role: person_role,
          role: :cc,
          addressee: addressee,
          letter: __getobj__
        )
      end
    end
  end
end

Version data entries

103 entries across 103 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.1.0 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.167 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.166 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.165 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.164 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.163 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.162 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.161 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.160 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.159 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.158 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.157 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.156 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.155 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.153 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.152 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.151 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.149 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.148 app/models/renalware/letters/determine_counterpart_ccs.rb