Class: Pipeline::BSI::Importer::SpecimenImporter
- Inherits:
-
Importer::Base
- Object
- Importer::Base
- Pipeline::BSI::Importer::SpecimenImporter
- Defined in:
- lib/bsi-pipeline/importer.rb
Instance Attribute Summary collapse
-
#batch_delimiter ⇒ Object
Returns the value of attribute batch_delimiter.
-
#batches ⇒ Object
Returns the value of attribute batches.
-
#specimens ⇒ Object
Returns the value of attribute specimens.
Instance Method Summary collapse
- #import(all_specimens, options = {}) ⇒ Object
-
#initialize(key, options = {}) ⇒ SpecimenImporter
constructor
A new instance of SpecimenImporter.
Constructor Details
#initialize(key, options = {}) ⇒ SpecimenImporter
Returns a new instance of SpecimenImporter.
84 85 86 87 88 |
# File 'lib/bsi-pipeline/importer.rb', line 84 def initialize(key, ={}) @bsi = RBC.new(key, ) @specimens = specimens @batches = Array.new end |
Instance Attribute Details
#batch_delimiter ⇒ Object
Returns the value of attribute batch_delimiter.
82 83 84 |
# File 'lib/bsi-pipeline/importer.rb', line 82 def batch_delimiter @batch_delimiter end |
#batches ⇒ Object
Returns the value of attribute batches.
82 83 84 |
# File 'lib/bsi-pipeline/importer.rb', line 82 def batches @batches end |
#specimens ⇒ Object
Returns the value of attribute specimens.
82 83 84 |
# File 'lib/bsi-pipeline/importer.rb', line 82 def specimens @specimens end |
Instance Method Details
#import(all_specimens, options = {}) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/bsi-pipeline/importer.rb', line 90 def import(all_specimens, ={}) @specimens = all_specimens study_ids = @specimens.map{|e| e.study_id}.uniq subject_ids = @specimens.map{|e| e.subject_id}.uniq study_ids.each do |study| subject_ids.each_with_index do |sid, i| # Filter by subject_id and study_id subset = @specimens.select{|e| e.study_id == study && e.subject_id == sid} batch_properties = { 'batch.description' => "Subject: #{sid}", 'batch.study_id' => study.to_s } @batch = AddBatch.new(@bsi, batch_properties) @batch.add_specimens(subset) @batch.commit if ['commit'] @batches << @batch end end @bsi.common.logoff end |