Sha256: dd99e2bf7823c95f4e430e3ad73cfec4b4f0667daa7abf6cccbfc331c6cc1e61

Contents?: true

Size: 712 Bytes

Versions: 17

Compression:

Stored size: 712 Bytes

Contents

require_dependency "renalware/letters"
require "attr_extras"

module Renalware
  module Letters
    module Delivery
      # A (non-pundit) policy driving logic around whether to email the letter to the practice
      class DeliveryPolicy
        pattr_initialize :letter
        delegate :patient, :recipients, to: :letter
        delegate :practice, to: :patient

        def email_letter_to_practice?
          email = PracticeEmail.new(letter).address
          email.present? && gp_recipient.present?
        end

        def gp_is_a_recipient?
          gp_recipient.present?
        end

        def gp_recipient
          recipients.find(&:primary_care_physician?)
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

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