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.159 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.158 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.157 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.156 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.155 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.153 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.152 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.151 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.149 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.148 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.147 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.146 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.145 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.144 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.143 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.142 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.141 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.140 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.139 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.138 app/models/renalware/pathology/message_listener.rb