Sha256: 990ded8103a2f0e0b2e9095c93e5f4cf95be27931bb90453d7ed7b874daa94b5

Contents?: true

Size: 1.05 KB

Versions: 10

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

10 entries across 10 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/models/renalware/pathology/message_listener.rb
renalware-core-2.1.0 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.167 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.166 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.165 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.164 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.163 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.162 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.161 app/models/renalware/pathology/message_listener.rb
renalware-core-2.0.160 app/models/renalware/pathology/message_listener.rb