Class: Order
- Inherits:
-
Object
- Object
- Order
- Defined in:
- lib/ruby_astm/order.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#action_code ⇒ Object
action code index (11).
-
#date_time ⇒ Object
the date and time of collection index (7).
-
#id ⇒ Object
> patient id.
-
#priority ⇒ Object
the order type, like stat, routine etc.
-
#results ⇒ Object
> key : result name.
-
#sequence_number ⇒ Object
this should be same as the one for patient.
-
#specimen_type ⇒ Object
index (15).
-
#tests ⇒ Object
the list of tests that need to be performed.
Instance Method Summary collapse
- #build_response(options) ⇒ Object
-
#initialize(args = {}) ⇒ Order
constructor
A new instance of Order.
- #results_values_hash ⇒ Object
- #set_action_Code(args) ⇒ Object
- #set_date_time(args) ⇒ Object
- #set_id(args) ⇒ Object
- #set_priority(args) ⇒ Object
- #set_sequence_number(args) ⇒ Object
- #set_specimen_type(args) ⇒ Object
- #set_tests(args) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Order
Returns a new instance of Order.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/ruby_astm/order.rb', line 76 def initialize(args={}) puts "------------ INITIALIZING ORDER -------------- " set_id(args) set_priority(args) set_sequence_number(args) set_tests(args) set_specimen_type(args) set_date_time(args) set_priority(args) set_action_Code(args) =begin if args[:line] line = args[:line] if !line.fields[2].strip.blank? line.fields[2].strip.scan(/(?<specimen_id>[^\^]+)/) { |specimen_id| self.id ||= specimen_id } elsif !line.fields[3].strip.blank? ## for the sysmex xn-550 this is the regex. line.fields[3].strip.scan(/(?<tube_rack>\d+\^)+(?<patient_id>.+)\^/) { |tube_rack,patient_id| self.id = patient_id.strip} end else self.sequence_number = args[:sequence_number] self.tests = args[:tests] self.id = args[:specimen_id] self.specimen_type = args[:specimen_type] self.date_time = args[:date_time] self.priority = args[:priority] self.action_code = args[:action_code] end =end self.results = {} end |
Instance Attribute Details
#action_code ⇒ Object
action code index (11)
35 36 37 |
# File 'lib/ruby_astm/order.rb', line 35 def action_code @action_code end |
#date_time ⇒ Object
the date and time of collection index (7)
31 32 33 |
# File 'lib/ruby_astm/order.rb', line 31 def date_time @date_time end |
#id ⇒ Object
> patient id.
> should match the specimen id that comes into the query.
index (2)
5 6 7 |
# File 'lib/ruby_astm/order.rb', line 5 def id @id end |
#priority ⇒ Object
the order type, like stat, routine etc. index (5)
27 28 29 |
# File 'lib/ruby_astm/order.rb', line 27 def priority @priority end |
#results ⇒ Object
> key : result name.
> value : result object
13 14 15 |
# File 'lib/ruby_astm/order.rb', line 13 def results @results end |
#sequence_number ⇒ Object
this should be same as the one for patient. index (1)
9 10 11 |
# File 'lib/ruby_astm/order.rb', line 9 def sequence_number @sequence_number end |
#specimen_type ⇒ Object
index (15)
22 23 24 |
# File 'lib/ruby_astm/order.rb', line 22 def specimen_type @specimen_type end |
#tests ⇒ Object
the list of tests that need to be performed. each should be prefixed by three carets index (4)
18 19 20 |
# File 'lib/ruby_astm/order.rb', line 18 def tests @tests end |
Instance Method Details
#build_response(options) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/ruby_astm/order.rb', line 110 def build_response() raise "provide a sequence number" if self.sequence_number.blank? raise "provide a specimen id" if self.id.blank? #raise "provide a list of tests" if self.tests.blank? raise "provide a test priority" if self.priority.blank? if self.specimen_type.blank? #puts "no specimen type has been provided, sending SERUM" end if ([:machine_name] && ([:machine_name] == "cobas-e411")) ## remove all the non number tests, as these are not to be run on the roche system, and cause the roche machine to clam up totally if non recognized/alphabetic tests are sent to it in the response. self.tests = self.tests.select{|c| c =~ /[0-9]+/} self.tests = self.tests.map{|c| c = "^^^" + c + "^1"} # ^^0000000387^587^0^2^^S1^SC id_string = [:sequence_number] + "^" + [:carrier_number] + "^" + [:position_number] + "^^" + [:sample_type] + "^" + [:container_type] "O|1|#{self.id.to_s}|#{id_string}|#{tests.join('\\')}|#{self.priority}||#{Time.now.strftime("%Y%m%d%H%M%S")}||||A||||1||||||||||O\r" else tests = self.tests.select{|c| c =~ /[A-Z]+/} "O|#{self.sequence_number}|#{self.id}|#{Time.now.to_i.to_s}|^^^#{tests.join('`^^^')}|#{self.priority}||#{Time.now.strftime("%Y%m%d%H%M%S")}||||N||||#{self.specimen_type || 'SERUM'}\r" end ## for urine it does not get the report name. ## so let me do one entry for urine and hemogram. end |
#results_values_hash ⇒ Object
149 150 151 152 153 154 155 |
# File 'lib/ruby_astm/order.rb', line 149 def results_values_hash values_hash = {} self.results.keys.each do |k| values_hash[k] = self.results[k].value end values_hash end |
#set_action_Code(args) ⇒ Object
72 73 74 |
# File 'lib/ruby_astm/order.rb', line 72 def set_action_Code(args) self.action_code = args[:args] end |
#set_date_time(args) ⇒ Object
64 65 66 |
# File 'lib/ruby_astm/order.rb', line 64 def set_date_time(args) self.date_time = args[:date_time] end |
#set_id(args) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ruby_astm/order.rb', line 37 def set_id(args) if line = args[:line] if !line.fields[2].blank? line.fields[2].strip.scan(/(?<specimen_id>[^\^]+)/) { |specimen_id| self.id ||= specimen_id[0] } elsif !line.fields[3].blank? ## for the sysmex xn-550 this is the regex. line.fields[3].strip.scan(/(?<tube_rack>\d+\^)+(?<patient_id>.+)\^/) { |tube_rack,patient_id| self.id = patient_id.strip} end else self.id = args[:specimen_id] end end |
#set_priority(args) ⇒ Object
68 69 70 |
# File 'lib/ruby_astm/order.rb', line 68 def set_priority(args) self.priority = args[:priority] end |
#set_sequence_number(args) ⇒ Object
52 53 54 |
# File 'lib/ruby_astm/order.rb', line 52 def set_sequence_number(args) self.sequence_number = args[:sequence_number] end |
#set_specimen_type(args) ⇒ Object
60 61 62 |
# File 'lib/ruby_astm/order.rb', line 60 def set_specimen_type(args) self.specimen_type = args[:specimen_type] end |
#set_tests(args) ⇒ Object
56 57 58 |
# File 'lib/ruby_astm/order.rb', line 56 def set_tests(args) self.tests = args[:tests] end |