Sha256: 9d2f68d7f9b89753d7b86ea92f1279f141552a5127a362955ef89ab8becf0082

Contents?: true

Size: 1.05 KB

Versions: 42

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/pathology"

#
# When subscribed to HL7 `oru_message_arrived` messages, gets notified of incoming HL7 messages
# and creates the observations contained therein provided the patient exists.
#
module Renalware
  module Pathology
    class MessageListener
      # Note: We are already inside a transaction here
      def oru_message_arrived(hl7_message:, **)
        pathology_params = parse_pathology_params(hl7_message)
        create_observation_requests_and_their_child_observations_from(pathology_params)
        #
        # Note: The current_observation_set for the patient is updated by a trigger here!
        #
      end

      private

      def parse_pathology_params(hl7_message)
        ObservationRequestsAttributesBuilder.new(hl7_message).parse
      end

      def create_observation_requests_and_their_child_observations_from(pathology_params)
        return if pathology_params.nil? # e.g. patient does not exist

        CreateObservationRequests.new.call(pathology_params)
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
renalware-core-2.0.137 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.136 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.135 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.134 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.133 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.132 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.131 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.130 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.129 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.128 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.127 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.126 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.125 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.124 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.123 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.121 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.120 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.119 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.118 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.117 app/models/renalware/pathology/message_listener.rb