Sha256: 36e45256f58b3dfa8295638c6bea01ba04672cb4d32d6c66a46bf67f49b64c34

Contents?: true

Size: 793 Bytes

Versions: 103

Compression:

Stored size: 793 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/letters"

module Renalware
  module Letters
    class ReviseLetter
      include Wisper::Publisher
      include LetterPathology

      def self.build
        new
      end

      def call(patient, letter_id, params = {})
        letter = patient.letters.pending.find(letter_id)
        Letter.transaction do
          # See e.g. Letter::Draft.revise
          letter.revise(params)
          if letter.changes.key?(:pathology_timestamp)
            letter.pathology_snapshot = build_pathology_snapshot(patient)
          end
          letter.save!
        end
        broadcast(:revise_letter_successful, letter)
      rescue ActiveRecord::RecordInvalid
        broadcast(:revise_letter_failed, letter)
      end
    end
  end
end

Version data entries

103 entries across 103 versions & 1 rubygems

Version Path
renalware-core-2.0.84 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.83 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.82 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.81 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.80 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.79 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.78 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.77 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.76 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.75 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.74 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.73 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.72 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.71 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.70 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.69 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.68 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.67 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.64 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.63 app/models/renalware/letters/revise_letter.rb