ruby_astm 1.0.9 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby_astm/lab_interface.rb +22 -7
- data/lib/ruby_astm/order.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5aad9b688056b23b5252d954ec6f6e53d11decab2e5adbd33251613642f5ee0
|
4
|
+
data.tar.gz: 1b9b7cac6d3122b4cd62a36611a05226254453a124788078ba51ab0ea03f22fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ca884192d09d41a0982012a22fd79a832f7737697f1b182ba125e28cfc4a194c4908a62d7e5eae127e4acfa6bdf248a3012d26a5d557fcacdb083625bd1fad2
|
7
|
+
data.tar.gz: 6e1896e259496d069a9aa86e255a38b70c119b4460b3e875958360bbcfc013a86dd88aed79a2a78192c729fad14de321794573bdf4008fe5b0e58a4eaee89fdf
|
@@ -10,13 +10,18 @@ module LabInterface
|
|
10
10
|
ETX = "\x03"
|
11
11
|
EOT = "\x04"
|
12
12
|
|
13
|
+
|
14
|
+
|
13
15
|
mattr_accessor :headers
|
14
16
|
mattr_accessor :ethernet_server
|
15
17
|
mattr_accessor :server_ip
|
16
18
|
mattr_accessor :server_port
|
17
19
|
mattr_accessor :mapping
|
18
20
|
mattr_accessor :respond_to_queries
|
19
|
-
|
21
|
+
|
22
|
+
## buffer of incoming data.
|
23
|
+
mattr_accessor :data_buffer
|
24
|
+
|
20
25
|
|
21
26
|
## returns the root directory of the gem.
|
22
27
|
def root
|
@@ -56,7 +61,9 @@ module LabInterface
|
|
56
61
|
|
57
62
|
def receive_data(data)
|
58
63
|
|
59
|
-
|
64
|
+
self.data_buffer ||= ''
|
65
|
+
|
66
|
+
#puts "incoming data bytes."
|
60
67
|
|
61
68
|
concat = ""
|
62
69
|
|
@@ -77,10 +84,20 @@ module LabInterface
|
|
77
84
|
end
|
78
85
|
|
79
86
|
#puts "concat is:"
|
87
|
+
|
80
88
|
#puts concat.to_s
|
81
|
-
process_text(concat)
|
82
89
|
|
83
|
-
|
90
|
+
self.data_buffer << concat
|
91
|
+
|
92
|
+
## if the last byte is EOT, then call process text.
|
93
|
+
## inside that split by line and process one at a time.
|
94
|
+
##process_text(concat)
|
95
|
+
|
96
|
+
|
97
|
+
if data.bytes.to_a[-1] == 4
|
98
|
+
puts self.data_buffer
|
99
|
+
process_text(self.data_buffer)
|
100
|
+
self.data_buffer = ''
|
84
101
|
send_data(ENQ)
|
85
102
|
elsif data.bytes.to_a[0] == 6
|
86
103
|
self.headers[-1].build_responses.each do |response|
|
@@ -99,7 +116,7 @@ module LabInterface
|
|
99
116
|
end
|
100
117
|
else
|
101
118
|
## send the header
|
102
|
-
puts "--------- SENT ACK -----------"
|
119
|
+
#puts "--------- SENT ACK -----------"
|
103
120
|
if self.headers.blank?
|
104
121
|
send_data(ACK)
|
105
122
|
else
|
@@ -123,8 +140,6 @@ module LabInterface
|
|
123
140
|
end
|
124
141
|
|
125
142
|
def process_text(text)
|
126
|
-
## should replace carriage returns with new lines, before processing any file.
|
127
|
-
## or text.
|
128
143
|
text.split("\n").each do |l|
|
129
144
|
line = Line.new({:text => l})
|
130
145
|
process_type(line)
|
data/lib/ruby_astm/order.rb
CHANGED
@@ -36,13 +36,13 @@ class Order
|
|
36
36
|
|
37
37
|
def set_id(args)
|
38
38
|
if line = args[:line]
|
39
|
-
if !line.fields[2].
|
39
|
+
if !line.fields[2].blank?
|
40
40
|
line.fields[2].strip.scan(/(?<specimen_id>[^\^]+)/) { |specimen_id|
|
41
|
-
self.id ||= specimen_id
|
41
|
+
self.id ||= specimen_id[0]
|
42
42
|
}
|
43
|
-
elsif !line.fields[3].
|
43
|
+
elsif !line.fields[3].blank?
|
44
44
|
## for the sysmex xn-550 this is the regex.
|
45
|
-
line.fields[3].strip.scan(/(?<tube_rack>\d+\^)+(?<patient_id>.+)\^/) { |tube_rack,patient_id| self.id = patient_id.strip}
|
45
|
+
line.fields[3].strip.scan(/(?<tube_rack>\d+\^)+(?<patient_id>.+)\^/) { |tube_rack,patient_id| self.id = patient_id.strip}
|
46
46
|
end
|
47
47
|
else
|
48
48
|
self.id = args[:specimen_id]
|