Sha256: 41ad89a4ae07603f37e591fe40d7a8097ddb6a96ed845cd704fd04801b762fb3

Contents?: true

Size: 898 Bytes

Versions: 20

Compression:

Stored size: 898 Bytes

Contents

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") if cc_patient?
        counterpart_css << build_recipient("primary_care_physician") if cc_primary_care_physican?
        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)
        Recipient.new(person_role: person_role, letter: __getobj__)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
renalware-core-2.0.8 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.7 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.5 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.4 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.3 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.2 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.1 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.0 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.0.pre.rc13 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.0.pre.rc11 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.0.pre.rc10 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.0.pre.rc9 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.0.pre.rc8 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.0.pre.rc7 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.0.pre.rc6 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.0.pre.rc5 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.0.pre.rc4 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.0.pre.rc3 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.0.pre.rc1 app/models/renalware/letters/determine_counterpart_ccs.rb
renalware-core-2.0.0.pre.beta12 app/models/renalware/letters/determine_counterpart_ccs.rb