Sha256: 0425463eb34e84323c71975dd8aa670aa8dcbadf807b0287adfb75d6ee346940

Contents?: true

Size: 932 Bytes

Versions: 6

Compression:

Stored size: 932 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/feeds"

module Renalware
  module Feeds
    #
    # Responsible for coordinating the processing sequences of a raw HL7 message.
    #
    class MessageProcessor
      include Wisper::Publisher

      def call(raw_message)
        ActiveRecord::Base.transaction do
          message_payload = parse_message(raw_message)
          persist_message(message_payload)
          broadcast(:message_processed, message_payload)
        end
      rescue StandardError => exception
        notify_exception(exception)
        raise exception
      end

      private

      def parse_message(raw_message)
        MessageParser.new.parse(raw_message)
      end

      def persist_message(message_payload)
        PersistMessage.new.call(message_payload)
      end

      def notify_exception(exception)
        Engine.exception_notifier.notify(exception)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
renalware-core-2.0.24 app/models/renalware/feeds/message_processor.rb
renalware-core-2.0.23 app/models/renalware/feeds/message_processor.rb
renalware-core-2.0.22 app/models/renalware/feeds/message_processor.rb
renalware-core-2.0.21 app/models/renalware/feeds/message_processor.rb
renalware-core-2.0.20 app/models/renalware/feeds/message_processor.rb
renalware-core-2.0.18 app/models/renalware/feeds/message_processor.rb