Sha256: 8733d732a8f474fd53fbeed3b6de5fe4b29dacbf9285e4eac8e49263690d1e6c
Contents?: true
Size: 1.32 KB
Versions: 28
Compression:
Stored size: 1.32 KB
Contents
require "benchmark" namespace :pathology do namespace :test do desc "In development only, import a test HL7 message. Useful for testing listeners." task import_one: :environment do raise NotImplementedError unless Rails.env.development? # Load the example HL7 file. path = Renalware::Engine.root.join("app", "jobs", "hl7_message_example.yml") raw_message = File.read(path) # It has a struct header at the top so it can also be dumped into # the delayed_job queue, but we want to skip queuing so strip out that header and simulate # the message being passed directly to the FeedJob which will persist and process the message. raw_message = raw_message.gsub("--- !ruby/struct:FeedJob\n", "") # Replace the MSH date with now() to guarantee a unique message. not doing so results in # an index violation becuase we calc am MD5 hash of the message and this has to be unique - # this prevents us importing the same message twice. raw_message = raw_message.gsub("20091112164645", Time.zone.now.strftime("%Y%m%d%H%M%S")) # Load the message into a hash as delayed_Job would do and splat the hash keys as keyword args # into the FeedJob ctor. hash = YAML.safe_load(*raw_message).symbolize_keys FeedJob.new(hash[:raw_message]).perform end end end
Version data entries
28 entries across 28 versions & 1 rubygems