ruby_astm 1.1.6 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97473c3503fe13333b10d72191a32d48e7893885a953059f6e30b13a749e0b18
4
- data.tar.gz: db9984ca11f5302743aab7406469925ce2cc223e7c7a0c35131576c94eb5e84e
3
+ metadata.gz: cc95c55e3f2b580c554e371e52a5280a694a82dc3473ec1e637c82512db728ea
4
+ data.tar.gz: 97e680a545852f2f4694a8ee3b7574cfe6310f7ec7e419139ed6247d068fe808
5
5
  SHA512:
6
- metadata.gz: 44e68e846d2d9acdc9580c0b5a5881091f104a68fb894540768bd43b6465fc6c717425775bddee642d8102ee1fdcd5a156042aff22c8a86bd7ae5aef90d14b25
7
- data.tar.gz: 54499a0a1880df3c0933878f5bc1af9ba714767cad0ed2038a4cd2704df4ac43cf711e2cb2d4ba265f2a5d65513c8cf18f5f2a0d61048e1c8dad91d56513944a
6
+ metadata.gz: dd6b39268e00df41b84eb2ef466d4a499436dd9839a0ddbd277678bafb0288226810e76c39cfc2801f0a35cbe3aedace08b0328d111c1d0a38f22a0adcf3ee82
7
+ data.tar.gz: 1c2635c9fcfb327a58d6e77e1cf96f701ec90b1d3e40eca95d2a8479249aff90a1262f854d76b216e8ad4cf4eff91f8fff5f4fc73a93264a805d3858b4270ebb
@@ -191,8 +191,8 @@
191
191
  "TUBE" : "SERUM",
192
192
  "REPORT_NAME" : "SGPT"
193
193
  },
194
- "HOMOCY" : {
195
- "LIS_CODE" : "HOMOCY",
194
+ "HOMCY" : {
195
+ "LIS_CODE" : "HOMCY",
196
196
  "TUBE" : "SERUM",
197
197
  "REPORT_NAME" : "Homocysteine"
198
198
  },
@@ -39,6 +39,8 @@ class AstmServer
39
39
 
40
40
  def start_server
41
41
  EventMachine.run {
42
+ serial = EventMachine.open_serial('/dev/ttyS0', 9600, 8,LabInterface)
43
+ puts "RUNNING SERIAL ON dev/ttyS0 ------------ #{serial.to_s}"
42
44
  self.ethernet_server = EventMachine::start_server self.server_ip, self.server_port, LabInterface
43
45
  AstmServer.log("Running ETHERNET SERVER on #{server_port}")
44
46
  #serial = EventMachine.open_serial('/dev/ttyUSB0', 9600, 8)
@@ -45,7 +45,17 @@ class Header
45
45
  puts JSON.pretty_generate(JSON.parse(self.to_json))
46
46
  end
47
47
 
48
- def build_one_response
48
+ def get_header_response(options)
49
+ if (options[:machine_name] && (options[:machine_name] == "cobas-e411"))
50
+ "1H|\\^&|||host^1|||||cobas-e411|TSDWN^REPLY|P|1\r"
51
+ else
52
+ "1H|\`^&||||||||||P|E 1394-97|#{Time.now.strftime("%Y%m%d%H%M%S")}\r"
53
+ end
54
+ end
55
+
56
+ ## depends on the machine code.
57
+ ## if we have that or not.
58
+ def build_one_response(options)
49
59
  puts "building one response=========="
50
60
  puts "queries are:"
51
61
  puts self.queries.size.to_s
@@ -53,12 +63,11 @@ class Header
53
63
  self.queries.each do |query|
54
64
  puts "doing query"
55
65
  puts query.sample_ids
56
- header_response = "1H|\`^&||||||||||P|E 1394-97|#{Time.now.strftime("%Y%m%d%H%M%S")}\r"
57
- query.build_response.each do |qresponse|
66
+ header_response = get_header_response(options)
67
+ query.build_response(options).each do |qresponse|
58
68
  puts "qresponse is:"
59
69
  puts qresponse
60
70
  header_response += qresponse
61
- #responses << (header_response + qresponse)
62
71
  end
63
72
  responses << header_response
64
73
  end
@@ -130,10 +130,10 @@ module LabInterface
130
130
  elsif data.bytes.to_a[0] == 6
131
131
  puts "GOT ACK --- GENERATING RESPONSE"
132
132
  unless self.headers.blank?
133
- header_responses = self.headers[-1].build_one_response
133
+ header_responses = self.headers[-1].build_one_response({machine_name: self.headers[-1].machine_name})
134
134
  ## if no queries then, we have to send ack.
135
135
  if header_responses.blank?
136
- puts "sending ACK since there are queries in the header"
136
+ puts "sending ACK since there are no queries in the header"
137
137
  send_data(ACK)
138
138
  end
139
139
  header_responses.each_with_index {|response,key|
@@ -204,13 +204,16 @@ module LabInterface
204
204
  hl7_order = Hl7Order.new({:line => line, :patient_id => self.headers[-1].patients[-1].patient_id})
205
205
  self.headers[-1].patients[-1].orders << hl7_order
206
206
  when "Header"
207
+ puts "got header"
207
208
  header = Header.new({:line => line})
208
209
  self.headers ||= []
209
210
  self.headers << header
210
211
  when "Query"
212
+ puts "got query"
211
213
  query = Query.new({:line => line})
212
214
  self.headers[-1].queries << query
213
215
  when "Patient"
216
+ puts "got patient."
214
217
  patient = Patient.new({:line => line})
215
218
  self.headers[-1].patients << patient
216
219
  when "Order"
@@ -221,6 +224,7 @@ module LabInterface
221
224
  self.headers[-1].patients[-1].orders[-1].results[result.name] = result
222
225
  when "Terminator"
223
226
  ## it didn't terminate so there was no commit being called.
227
+ puts "got terminator."
224
228
  self.headers[-1].commit
225
229
  end
226
230
  end
@@ -106,7 +106,7 @@ class Order
106
106
  self.results = {}
107
107
  end
108
108
 
109
- def build_response
109
+ def build_response(options)
110
110
 
111
111
  raise "provide a sequence number" if self.sequence_number.blank?
112
112
  raise "provide a specimen id" if self.id.blank?
@@ -117,7 +117,19 @@ class Order
117
117
  #puts "no specimen type has been provided, sending SERUM"
118
118
  end
119
119
 
120
- "O|#{self.sequence_number}|#{self.id}|#{Time.now.to_i.to_s}|^^^#{self.tests.join('`^^^')}|#{self.priority}||#{Time.now.strftime("%Y%m%d%H%M%S")}||||N||||#{self.specimen_type || 'SERUM'}\r"
120
+ if (options[:machine_name] && (options[:machine_name] == "cobas-e411"))
121
+ self.tests = self.tests.map{|c| c = "^^^" + c + "^1"}
122
+ # ^^0000000387^587^0^2^^S1^SC
123
+ id_string = options[:sequence_number] + "^" + options[:carrier_number] + "^" + options[:position_number] + "^^" + options[:sample_type] + "^" + options[:container_type]
124
+
125
+ "O|1|#{self.id.to_s}|#{id_string}|#{self.tests.join('\\')}|#{self.priority}||#{Time.now.strftime("%Y%m%d%H%M%S")}||||A||||1||||||||||O\r"
126
+
127
+ else
128
+
129
+ "O|#{self.sequence_number}|#{self.id}|#{Time.now.to_i.to_s}|^^^#{self.tests.join('`^^^')}|#{self.priority}||#{Time.now.strftime("%Y%m%d%H%M%S")}||||N||||#{self.specimen_type || 'SERUM'}\r"
130
+
131
+ end
132
+
121
133
  end
122
134
 
123
135
  end
@@ -24,8 +24,12 @@ class Patient
24
24
  end
25
25
 
26
26
  ## patient id.
27
- def build_response
28
- "P|#{self.sequence_number}|#{self.patient_id}|||||||||||||||\r"
27
+ def build_response(options)
28
+ if (options[:machine_name] && (options[:machine_name] == "cobas-e411"))
29
+ "P|1\r"
30
+ else
31
+ "P|#{self.sequence_number}|#{self.patient_id}|||||||||||||||\r"
32
+ end
29
33
  end
30
34
 
31
35
  def to_json
@@ -6,12 +6,66 @@ class Query
6
6
 
7
7
  attr_accessor :sample_ids
8
8
 
9
+
10
+ ###################################################################################################
11
+ ##
12
+ ##
13
+ ## FIELDS SPECIFIC TO ROCHE E411
14
+ ##
15
+ ##
16
+ ###################################################################################################
17
+
18
+ attr_accessor :sequence_number
19
+
20
+ attr_accessor :carrier_number
21
+
22
+ attr_accessor :position_number
23
+
24
+ attr_accessor :sample_type
25
+
26
+ attr_accessor :container_type
27
+
28
+ ###################################################################################################
29
+ ##
30
+ ##
31
+ ## ROCHE SPECIFIC FIELDS END.
32
+ ##
33
+ ##
34
+ ###################################################################################################
35
+
36
+ def parse_field_for_sample_id(fields,index)
37
+ return false if fields[index].blank?
38
+ return false if fields[index].strip.blank?
39
+
40
+ self.sample_ids = fields[index].strip.split(/\'/)
41
+
42
+ return true
43
+ end
44
+
9
45
  def initialize(args)
10
46
  line = args[:line]
11
47
  unless line.fields[2].empty?
48
+ ## do the gsub for roche type.
49
+ ## if not successfuul, then parse for one.
50
+ puts "line fields is:"
51
+ puts line.fields[2].to_s
52
+ line.fields[2].scan(/\^{2}(?<sample_id>[A-Za-z0-9]+)\^(?<sequence_number>[0-9]+)\^(?<carrier_number>[a-zA-Z0-9]+)\^(?<position_number>[0-9]+)\^{2}(?<sample_type>[a-zA-Z0-9]+)\^(?<container_type>[a-zA-Z0-9]+)/) { |sample_id,sequence_number,carrier_number,position_number,sample_type,container_type|
53
+
54
+ self.sequence_number = sequence_number
55
+ self.sample_ids = [sample_id]
56
+ self.carrier_number = carrier_number
57
+ self.position_number = position_number
58
+ self.sample_type = sample_type
59
+ self.container_type = container_type
60
+ }
61
+
62
+ puts "sequence_number: #{self.sequence_number}, sample id: #{self.sample_id}, carrier number: #{self.carrier_number}, position_number: #{self.position_number}, sample_type: #{self.sample_type}, container_type: #{self.container_type}"
63
+
12
64
  fields = line.fields[2].split(/\^/)
13
- sample_id = fields[1].strip
14
- self.sample_ids = sample_id.split(/\`/)
65
+
66
+ parse_field_for_sample_id(fields,1) if self.container_type.blank?
67
+
68
+
15
69
  end
16
70
  end
17
71
 
@@ -26,7 +80,7 @@ class Query
26
80
 
27
81
  ## each query will build one patient and one order inside it.
28
82
  ## the order can have many tests.
29
- def build_response(variables=nil)
83
+ def build_response(options={})
30
84
 
31
85
  responses = []
32
86
 
@@ -50,7 +104,7 @@ class Query
50
104
 
51
105
  order = Order.new({:sequence_number => patient.sequence_number, :specimen_id => sid, :tests => tests, :priority => "R"})
52
106
 
53
- responses << (patient.build_response + order.build_response)
107
+ responses << (patient.build_response(options) + order.build_response(options.merge({sequence_number: self.sequence_number, carrier_number: self.carrier_number, position_number: self.position_number, sample_type: self.sample_type, container_type: self.container_type})))
54
108
 
55
109
  }
56
110
 
@@ -10,16 +10,33 @@ class Result
10
10
 
11
11
  def set_name(args)
12
12
  if line = args[:line]
13
+
13
14
  line.fields[2].scan(/\^+(?<name>[A-Za-z0-9\%\#\-\_\?\/]+)\^?(?<dilution>\d+)?/) { |name,dilution|
14
15
  self.name = lookup_mapping(name)
16
+
15
17
  self.report_name = lookup_report_name(name)
18
+
16
19
  }
20
+
21
+ self.name.scan(/(?<test_name>\d+)\/(?<dilution>\d+)\/(?<pre_dilution>[a-zA-Z0-9]+)/) { |test_name,dilution,pre_dilution|
22
+
23
+ self.name = lookup_mapping(test_name)
24
+
25
+ self.report_name = lookup_report_name(test_name)
26
+
27
+ self.dilution = dilution
28
+
29
+ }
30
+
17
31
  end
18
32
  end
19
33
 
20
34
  def set_value(args)
21
35
  if line = args[:line]
22
36
  self.value = line.fields[3].strip
37
+ self.value.scan(/(?<flag>\d+)\^(?<value>\d?\.?\d+)/) {|flag,value|
38
+ self.value = value
39
+ }
23
40
  line.fields[2].scan(/\^+(?<name>[A-Za-z0-9\%\#\-\_\?\/]+)\^?(?<dilution>\d+)?/) { |name,dilution|
24
41
  if transform_expression = lookup_transform(name)
25
42
  self.value = eval(transform_expression)
@@ -57,7 +74,7 @@ class Result
57
74
  def set_dilution(args)
58
75
  if line = args[:line]
59
76
  line.fields[2].scan(/\^+(?<name>[A-Za-z0-9\%\#\-\_\?\/]+)\^?(?<dilution>\d+)?/) { |name,dilution|
60
- self.dilution = dilution
77
+ self.dilution = dilution unless self.dilution
61
78
  }
62
79
  end
63
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_astm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bhargav Raut