ruby_astm 1.1.2 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/publisher/google_lab_interface.rb +31 -2
- data/lib/ruby_astm/lab_interface.rb +69 -41
- data/lib/ruby_astm/result.rb +5 -3
- 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: 749dcf0c64ea38ebdded6d8da1861145cda0da3217e1580caced8d17ab49488a
|
4
|
+
data.tar.gz: 79765a8914e651457350650b07e8382fbfb8cf7e35dcc27d9d67b16a4c06d1b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e51861e24962d0498871a115cb88ec521ec433247c203539d706fd66fb6e4837b9922e812c41f45f8c08931187f4079d09caeed29fb31d9cd80cdf60cd772fd
|
7
|
+
data.tar.gz: fa5d0a0e2806fc2957848c2cfb29e46e5f85aabe8544e196a6f81351794fe13b28191402ad33fa8c46aad7f3642352f668b41e338e7b0bc6c3a8c78f96de4b31
|
@@ -14,7 +14,7 @@ class Google_Lab_Interface < Poller
|
|
14
14
|
#TOKEN_PATH = 'token.yaml'.freeze
|
15
15
|
SCOPE = 'https://www.googleapis.com/auth/script.projects'.freeze
|
16
16
|
|
17
|
-
SCOPES = ["https://www.googleapis.com/auth/documents","https://www.googleapis.com/auth/drive","https://www.googleapis.com/auth/script.projects","https://www.googleapis.com/auth/spreadsheets"]
|
17
|
+
SCOPES = ["https://www.googleapis.com/auth/documents","https://www.googleapis.com/auth/drive","https://www.googleapis.com/auth/script.projects","https://www.googleapis.com/auth/spreadsheets","https://www.googleapis.com/auth/script.external_request"]
|
18
18
|
|
19
19
|
$service = nil
|
20
20
|
|
@@ -135,8 +135,37 @@ class Google_Lab_Interface < Poller
|
|
135
135
|
|
136
136
|
end
|
137
137
|
|
138
|
+
## sends emails of report pdfs to patients
|
139
|
+
def notify_patients
|
140
|
+
request = Google::Apis::ScriptV1::ExecutionRequest.new(
|
141
|
+
function: 'process_email_log'
|
142
|
+
)
|
143
|
+
|
144
|
+
begin
|
145
|
+
AstmServer.log("Processing Email Log")
|
146
|
+
AstmServer.log(request.parameters.to_s)
|
147
|
+
resp = $service.run_script(self.script_id, request)
|
148
|
+
if resp.error
|
149
|
+
AstmServer.log("Error Processing Email Log, message follows")
|
150
|
+
AstmServer.log("error: #{resp.error.message} : code: #{resp.error.code}")
|
151
|
+
false
|
152
|
+
else
|
153
|
+
AstmServer.log("Email log processing successfull")
|
154
|
+
true
|
155
|
+
end
|
156
|
+
rescue => e
|
157
|
+
AstmServer.log("Error processing email log, backtrace follows")
|
158
|
+
AstmServer.log(e.backtrace.to_s)
|
159
|
+
false
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
138
163
|
def poll
|
139
|
-
|
164
|
+
pre_poll_LIS
|
165
|
+
poll_LIS_for_requisition
|
166
|
+
update_LIS
|
167
|
+
notify_patients
|
168
|
+
post_poll_LIS
|
140
169
|
end
|
141
170
|
|
142
171
|
end
|
@@ -59,15 +59,37 @@ module LabInterface
|
|
59
59
|
strCksm.upcase
|
60
60
|
end
|
61
61
|
|
62
|
+
def generate_response
|
63
|
+
header_responses = self.headers[-1].build_one_response
|
64
|
+
header_responses.each_with_index {|response,key|
|
65
|
+
message_checksum = checksum(response + terminator + ETX)
|
66
|
+
final_resp = STX + response + terminator + ETX + message_checksum + "\r"
|
67
|
+
final_resp_arr = final_resp.bytes.to_a
|
68
|
+
final_resp_arr << 10
|
69
|
+
if (self.headers[-1].response_sent == false)
|
70
|
+
puts "sending the data as follows----------------------------------------------"
|
71
|
+
puts "response sent is:"
|
72
|
+
puts self.headers[-1].response_sent
|
73
|
+
puts final_resp_arr.to_s
|
74
|
+
puts final_resp_arr.pack('c*').gsub(/\r/,'\n')
|
75
|
+
send_data(final_resp_arr.pack('c*'))
|
76
|
+
self.headers[-1].response_sent = true if (key == (header_responses.size - 1))
|
77
|
+
else
|
78
|
+
puts "sending EOT"
|
79
|
+
send_data(EOT)
|
80
|
+
end
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
62
84
|
def receive_data(data)
|
63
85
|
|
64
86
|
self.data_buffer ||= ''
|
65
87
|
|
66
|
-
|
88
|
+
puts "incoming data bytes."
|
67
89
|
|
68
90
|
concat = ""
|
69
91
|
|
70
|
-
|
92
|
+
puts data.bytes.to_a.to_s
|
71
93
|
|
72
94
|
data.bytes.to_a.each do |byte|
|
73
95
|
x = [byte].pack('c*').force_encoding('UTF-8')
|
@@ -95,54 +117,60 @@ module LabInterface
|
|
95
117
|
|
96
118
|
|
97
119
|
if data.bytes.to_a[-1] == 4
|
98
|
-
#puts self.data_buffer
|
99
120
|
puts "GOT EOT --- PROCESSING BUFFER, AND CLEARING."
|
100
121
|
process_text(self.data_buffer)
|
101
|
-
puts "queries are:"
|
102
|
-
if !self.headers.blank?
|
103
|
-
puts self.headers[-1].queries
|
104
|
-
end
|
105
122
|
self.data_buffer = ''
|
106
|
-
|
123
|
+
if self.headers[-1].queries.blank?
|
124
|
+
puts "no queries in header so sending ack after getting EOT and processing the buffer"
|
125
|
+
send_data(ACK)
|
126
|
+
else
|
127
|
+
puts "sending ENQ"
|
128
|
+
send_data(ENQ)
|
129
|
+
end
|
107
130
|
elsif data.bytes.to_a[0] == 6
|
108
|
-
puts "
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
final_resp_arr << 10
|
116
|
-
if (self.headers[-1].response_sent == false)
|
117
|
-
puts "sending the data as follows----------------------------------------------"
|
118
|
-
puts "response sent is:"
|
119
|
-
puts self.headers[-1].response_sent
|
120
|
-
puts final_resp_arr.pack('c*').gsub(/\r/,'\n')
|
121
|
-
send_data(final_resp_arr.pack('c*'))
|
122
|
-
self.headers[-1].response_sent = true if (key == (header_responses.size - 1))
|
123
|
-
else
|
124
|
-
send_data(EOT)
|
131
|
+
puts "GOT ACK --- GENERATING RESPONSE"
|
132
|
+
unless self.headers.blank?
|
133
|
+
header_responses = self.headers[-1].build_one_response
|
134
|
+
## if no queries then, we have to send ack.
|
135
|
+
if header_responses.blank?
|
136
|
+
puts "sending ACK since there are queries in the header"
|
137
|
+
send_data(ACK)
|
125
138
|
end
|
126
|
-
|
139
|
+
header_responses.each_with_index {|response,key|
|
140
|
+
message_checksum = checksum(response + terminator + ETX)
|
141
|
+
final_resp = STX + response + terminator + ETX + message_checksum + "\r"
|
142
|
+
final_resp_arr = final_resp.bytes.to_a
|
143
|
+
final_resp_arr << 10
|
144
|
+
if (self.headers[-1].response_sent == false)
|
145
|
+
puts "sending the data as follows----------------------------------------------"
|
146
|
+
puts "response sent is:"
|
147
|
+
puts self.headers[-1].response_sent
|
148
|
+
puts final_resp_arr.pack('c*').gsub(/\r/,'\n')
|
149
|
+
send_data(final_resp_arr.pack('c*'))
|
150
|
+
self.headers[-1].response_sent = true if (key == (header_responses.size - 1))
|
151
|
+
else
|
152
|
+
puts "sending EOT"
|
153
|
+
send_data(EOT)
|
154
|
+
end
|
155
|
+
}
|
156
|
+
else
|
157
|
+
puts "NO HEADERS PRESENT --- "
|
158
|
+
end
|
127
159
|
else
|
160
|
+
puts self.data_buffer.gsub(/\r/,'\n').to_s
|
128
161
|
## send the header
|
129
162
|
#puts "--------- SENT ACK -----------"
|
130
|
-
if self.
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
process_text(self.data_buffer)
|
138
|
-
self.data_buffer = ''
|
139
|
-
if self.headers.size > 0
|
140
|
-
## commit should return the jsonified thing, if possible.
|
141
|
-
|
142
|
-
self.headers[-1].commit
|
143
|
-
send_data(self.headers[-1].generate_ack_success_response)
|
144
|
-
end
|
163
|
+
if self.data_buffer[1..3] == "MSH"
|
164
|
+
puts " -------------- HEADERS ARE BLANK WITH HL7, sending ack. ------------ "
|
165
|
+
process_text(self.data_buffer)
|
166
|
+
self.data_buffer = ''
|
167
|
+
if self.headers.size > 0
|
168
|
+
self.headers[-1].commit
|
169
|
+
send_data(self.headers[-1].generate_ack_success_response)
|
145
170
|
end
|
171
|
+
else
|
172
|
+
puts " -------------- HEADERS ARE BLANK NOT HL7, sending ack. ------------ "
|
173
|
+
send_data(ACK)
|
146
174
|
end
|
147
175
|
end
|
148
176
|
end
|
data/lib/ruby_astm/result.rb
CHANGED
@@ -38,9 +38,11 @@ class Result
|
|
38
38
|
|
39
39
|
def set_timestamp(args)
|
40
40
|
if line = args[:line]
|
41
|
-
line.fields[12].
|
42
|
-
|
43
|
-
|
41
|
+
unless line.fields[12].blank?
|
42
|
+
line.fields[12].strip.scan(/(?<year>\d{4})(?<month>\d{2})(?<day>\d{2})(?<hours>\d{2})(?<minutes>\d{2})(?<seconds>\d{2})/) {|year,month,day,hours,minutes,seconds|
|
43
|
+
self.timestamp = Time.new(year,month,day,hours,minutes,seconds)
|
44
|
+
}
|
45
|
+
end
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|