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.1.1 app/models/renalware/letters/revise_letter.rb
renalware-core-2.1.0 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.167 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.166 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.165 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.164 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.163 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.162 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.161 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.160 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.159 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.158 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.157 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.156 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.155 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.153 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.152 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.151 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.149 app/models/renalware/letters/revise_letter.rb
renalware-core-2.0.148 app/models/renalware/letters/revise_letter.rb