lib/qme/tasks/bundle.rake in quality-measure-engine-2.1.0 vs lib/qme/tasks/bundle.rake in quality-measure-engine-2.2.0
- old
+ new
@@ -2,23 +2,23 @@
db_name = ENV['DB_NAME'] || 'test'
namespace :bundle do
desc 'Import a quality bundle into the database.'
- task :import, [:bundle_path, :delete_existing] => [:environment] do |task, args|
+ task :import, [:bundle_path, :delete_existing, :type] => [:environment] do |task, args|
raise "The path to the measures zip file must be specified" unless args.bundle_path
bundle = File.open(args.bundle_path)
importer = QME::Bundle::Importer.new(db_name)
- bundle_contents = importer.import(bundle, args.delete_existing == "true")
+ bundle_contents = importer.import(bundle, args.delete_existing == "true", args.type)
puts "Successfully imported bundle at: #{args.bundle_path}"
puts "\t Imported into environment: #{Rails.env.upcase}" if defined? Rails
+ puts "\t Loaded #{args.type || "all"} measures"
puts "\t Measures Loaded: #{bundle_contents[:measures].count}"
puts "\t Test Patients Loaded: #{bundle_contents[:patients].count}"
puts "\t Extensions Loaded: #{bundle_contents[:extensions].count}"
-
end
# this task is most likely temporary. Once Bonnie can handle both EP and EH measures together, this would no longer be required.
desc 'Merge two bundles into one.'
task :merge, [:bundle_one,:bundle_two] do |t, args|
@@ -66,14 +66,16 @@
end
['measures','patients','extensions'].each do |key|
json_out[key] = (json_one[key] + json_two[key]).uniq
end
+
+ version = json_out['version']
File.open(File.join(tmpdir,'output','bundle.json'), 'w') {|f| f.write(JSON.pretty_generate(json_out)) }
date_string = Time.now.strftime("%Y-%m-%d")
- out_zip = File.join('tmp','bundles',"bundle-merged-#{date_string}.zip")
+ out_zip = File.join('tmp','bundles',"bundle-merged-#{date_string}-#{version}.zip")
FileUtils.remove_entry_secure out_zip if File.exists?(out_zip)
Zip::ZipFile.open(out_zip, 'w') do |zipfile|
path = File.join(tmpdir,'output')
Dir[File.join(path,'**','**')].each do |file|
zipfile.add(file.sub(path+'/',''),file)