Sha256: 05e82f397819dc51a1eca48f5a98e8c8ff3ab0ddf907702a2aa6dbe4f0a7e141

Contents?: true

Size: 974 Bytes

Versions: 24

Compression:

Stored size: 974 Bytes

Contents

require_dependency "renalware/letters"

module Renalware
  module Letters
    class ApprovedLettersController < Letters::BaseController
      before_action :load_patient

      def create
        letter = @patient.letters.pending_review.find(params[:letter_id])

        # See config.broadcast_subscription_map for ApproveLetter event subscribers
        # We use an event subscription pattern to drive the delivery of letters at this point
        # rather than hard-wiring in a call to DeliverLetter.call etc. This is because letter
        # delivery is hospital-specific, and each might want to plumb in different or many classes
        # to handle different aspects of letter processing - not just delivery but also EPR etc.
        ApproveLetter
          .build(letter)
          .broadcasting_to_configured_subscribers
          .call(by: current_user)

        redirect_to patient_clinical_summary_path(@patient), notice: t(".success")
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.rc7 app/controllers/renalware/letters/approved_letters_controller.rb
renalware-core-2.0.0.pre.rc6 app/controllers/renalware/letters/approved_letters_controller.rb
renalware-core-2.0.0.pre.rc5 app/controllers/renalware/letters/approved_letters_controller.rb
renalware-core-2.0.0.pre.rc4 app/controllers/renalware/letters/approved_letters_controller.rb