Sha256: 810daa36ee85ba27b471c7c665d9751fb7f4ce6e392e666a86b2f680beafec55

Contents?: true

Size: 1.06 KB

Versions: 15

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/pathology"

#
# When subscribed to HL7 `message_processed` 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 message_processed(message_payload)
        pathology_params = parse_pathology_params(message_payload)
        create_observation_requests_and_their_child_observations_from(pathology_params)
        #
        # Note: The the current_observation_set for the patient is updated by a trigger here
        #
      end

      private

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

      def create_observation_requests_and_their_child_observations_from(pathology_params)
        return if pathology_params.nil? # eg patient does not exist
        CreateObservationRequests.new.call(pathology_params)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
renalware-core-2.0.41 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.40 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.39 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.38 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.37 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.36 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.35 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.34 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.33 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.32 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.31 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.30 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.28 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.27 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.26 app/models/renalware/pathology/message_listener.rb