Sha256: 523ff38c78d9638605949e5a9140d04cc11ea9866e5b885c953b9c218bcf2b00

Contents?: true

Size: 760 Bytes

Versions: 1

Compression:

Stored size: 760 Bytes

Contents

require_dependency "renalware/patients"

#
# This class subscribes to broadcasted `message_processed` messages and crates a patient
# from the HL7 data if one does not exist.
#
module Renalware
  module Patients
    class MessageListener
      def message_processed(message_payload)
        patient_params = parse_patient_params(message_payload)
        system_user = find_system_user
        create_patient(patient_params, system_user)
      end

      private

      def parse_patient_params(message_payload)
        MessageParamParser.new.parse(message_payload)
      end

      def create_patient(params, user)
        IdempotentCreatePatient.new(user).call(params)
      end

      def find_system_user
        SystemUser.find
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta12 app/models/renalware/patients/message_listener.rb