Sha256: d1ee2d8cc9e52073570ef15ddbf1066577fe43aae420e323200c5bed4c790022

Contents?: true

Size: 975 Bytes

Versions: 30

Compression:

Stored size: 975 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/letters/letter"

module Renalware
  module Letters
    class Letter::PendingReview < Letter
      def self.policy_class
        PendingReviewLetterPolicy
      end

      def revise(params)
        params = LetterParamsProcessor.new(patient).call(params)
        self.attributes = params
      end

      def reject(by:)
        becomes!(Draft).tap { |letter| letter.by = by }
      end

      def sign(by:)
        build_signature(user: by, signed_at: Time.current)
        self.approved_by = by
        self.approved_at = Time.current
        self.by = by
        self
      end

      def generate_archive(by:, presenter: default_presenter)
        becomes!(Approved).tap do |letter|
          letter.by = by
          letter.build_archive(by: by, content: presenter.content)
        end
      end

      private

      def default_presenter
        LetterPresenterFactory.new(self)
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
renalware-core-2.0.41 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.40 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.39 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.38 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.37 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.36 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.35 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.34 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.33 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.32 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.31 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.30 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.28 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.27 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.26 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.25 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.24 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.23 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.22 app/models/renalware/letters/letter/pending_review.rb
renalware-core-2.0.21 app/models/renalware/letters/letter/pending_review.rb