vistarpc4r 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/vistarpc4r/rpc_broker_connection.rb +109 -26
- data/vistarpc4r.gemspec +3 -3
- metadata +21 -21
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -36,13 +36,19 @@ module VistaRPC4r
|
|
36
36
|
@port=port
|
37
37
|
@access=access
|
38
38
|
@verify=verify
|
39
|
-
|
39
|
+
if debug
|
40
|
+
@loglevel=2
|
41
|
+
else
|
42
|
+
@loglevel=0
|
43
|
+
end
|
40
44
|
@token=nil
|
41
45
|
@socket = nil
|
42
46
|
@encryptedAV = nil
|
43
47
|
@writeBuffer = String.new
|
44
48
|
@duz = "0"
|
45
49
|
@currentContext = nil
|
50
|
+
@lastvistaerror = nil
|
51
|
+
|
46
52
|
end
|
47
53
|
|
48
54
|
def connect
|
@@ -70,7 +76,8 @@ module VistaRPC4r
|
|
70
76
|
retVal = logIn()
|
71
77
|
return retVal
|
72
78
|
end
|
73
|
-
|
79
|
+
|
80
|
+
# close tries to gracefully end the VistA session. If socket is already dead, will return nil
|
74
81
|
def close()
|
75
82
|
if isConnected()
|
76
83
|
if @sentConnect
|
@@ -81,36 +88,49 @@ module VistaRPC4r
|
|
81
88
|
@socket.close()
|
82
89
|
@socket = nil
|
83
90
|
@duz = "0"
|
91
|
+
@lastvistaerror = nil
|
84
92
|
@currentContext = nil
|
85
93
|
return retval
|
86
94
|
end
|
87
95
|
end
|
88
96
|
end
|
97
|
+
|
98
|
+
# force the broker into the pre connect state. Use if close returns nil
|
99
|
+
def forceclose
|
100
|
+
@sentConnect = false # set in connect()
|
101
|
+
@signedOn=false # set in signOn() inside connect()
|
102
|
+
@socket.close()
|
103
|
+
@socket = nil
|
104
|
+
@duz = "0"
|
105
|
+
@currentContext = nil
|
106
|
+
@lastvistaerror=nil
|
107
|
+
return true
|
108
|
+
end
|
89
109
|
|
90
110
|
def isConnected()
|
91
111
|
return @socket != nil
|
92
112
|
end
|
93
113
|
|
114
|
+
# execute differs from RPCBrokerConnection - We want the application to know about eof
|
115
|
+
# execute will return nil if ioerror most likely unexpected EOFError
|
94
116
|
def execute(rpc)
|
117
|
+
@lastvistaerror = nil
|
95
118
|
retVal = executeOnce(rpc)
|
96
119
|
if (retVal == nil && @signedOn)
|
97
|
-
#reconnect
|
120
|
+
#maybe some reconnect logic
|
98
121
|
if (rpc.name == "#BYE#")
|
99
122
|
# We're disconnecting anyway
|
100
123
|
return nil
|
101
124
|
end
|
102
125
|
# attempt to log back on
|
103
|
-
if (connect())
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
end
|
111
|
-
end
|
112
|
-
if (retVal == nil)
|
113
|
-
raise "Lost connection to server"
|
126
|
+
#if (connect())
|
127
|
+
# if (@currentContext != nil)
|
128
|
+
# tempcontext = @currentContext
|
129
|
+
# @currentContext = nil
|
130
|
+
# setContext(tempcontext)
|
131
|
+
# end
|
132
|
+
# retVal = executeOnce(rpc)
|
133
|
+
#end
|
114
134
|
end
|
115
135
|
return retVal
|
116
136
|
end
|
@@ -139,6 +159,12 @@ module VistaRPC4r
|
|
139
159
|
rpc.params = args
|
140
160
|
end
|
141
161
|
rpcresponse = execute(rpc)
|
162
|
+
if rpcresponse.nil?
|
163
|
+
return nil
|
164
|
+
end
|
165
|
+
if !rpcresponse.error_message.nil?
|
166
|
+
@lastvistaerror = rpcresponse.error_message
|
167
|
+
end
|
142
168
|
return rpcresponse.value
|
143
169
|
end
|
144
170
|
|
@@ -152,9 +178,19 @@ module VistaRPC4r
|
|
152
178
|
rpc.params = args
|
153
179
|
end
|
154
180
|
rpcresponse = execute(rpc)
|
181
|
+
if rpcresponse.nil?
|
182
|
+
return nil
|
183
|
+
end
|
184
|
+
if !rpcresponse.error_message.nil?
|
185
|
+
@lastvistaerror = rpcresponse.error_message
|
186
|
+
end
|
155
187
|
return rpcresponse.value
|
156
188
|
end
|
157
189
|
|
190
|
+
# if call_a or call_s return nil, you can check to see if there was a VistA error message
|
191
|
+
def lastvistaerror
|
192
|
+
return @lastvistaerror
|
193
|
+
end
|
158
194
|
|
159
195
|
def setContext(context)
|
160
196
|
if (context == @currentContext)
|
@@ -165,7 +201,7 @@ module VistaRPC4r
|
|
165
201
|
warn "changing context from " + @currentContext + " to " + context
|
166
202
|
end
|
167
203
|
|
168
|
-
puts "Setting context to: " + context
|
204
|
+
#puts "Setting context to: " + context
|
169
205
|
xwbCreateContext = VistaRPC.new("XWB CREATE CONTEXT", RPCResponse::SINGLE_VALUE)
|
170
206
|
encryptedContext = xwbCreateContext.encrypt(context)
|
171
207
|
xwbCreateContext.params[0] = encryptedContext
|
@@ -182,7 +218,14 @@ module VistaRPC4r
|
|
182
218
|
return @duz
|
183
219
|
end
|
184
220
|
|
185
|
-
|
221
|
+
# set log level 0= off, 1= informational, 2=debug
|
222
|
+
def loglevel(level)
|
223
|
+
if level < 0 or level > 2
|
224
|
+
return nil
|
225
|
+
end
|
226
|
+
@loglevel = level
|
227
|
+
return @loglevel
|
228
|
+
end
|
186
229
|
|
187
230
|
private
|
188
231
|
|
@@ -259,8 +302,12 @@ module VistaRPC4r
|
|
259
302
|
write(END_MARKER)
|
260
303
|
if (flush())
|
261
304
|
retVal = getResponse(rpc.type)
|
262
|
-
if @
|
263
|
-
|
305
|
+
if @loglevel ==2
|
306
|
+
if retVal.nil? # io error
|
307
|
+
puts "<Response> IO Error </Response>"
|
308
|
+
else
|
309
|
+
puts "<Response> " + retVal.to_s + "</Response>"
|
310
|
+
end
|
264
311
|
end
|
265
312
|
end
|
266
313
|
return retVal
|
@@ -350,7 +397,7 @@ module VistaRPC4r
|
|
350
397
|
def flush()
|
351
398
|
retVal = false
|
352
399
|
if (isConnected() || connect())
|
353
|
-
if @
|
400
|
+
if @loglevel ==2
|
354
401
|
puts "<Request>" + @writeBuffer + "</Request>"
|
355
402
|
end
|
356
403
|
@socket.write(@writeBuffer)
|
@@ -361,21 +408,24 @@ module VistaRPC4r
|
|
361
408
|
return retVal
|
362
409
|
end
|
363
410
|
|
411
|
+
# Get response will return a response object or nil
|
412
|
+
# Response object could contain a vista generated security/other error
|
413
|
+
# Nil means something went wrong with the connection, check the system error
|
364
414
|
def getResponse(rpcType)
|
365
415
|
hadError = Array.new # for passing around boolean by reference
|
366
416
|
hadError[0]=false
|
417
|
+
|
418
|
+
# Check for VistA erros
|
367
419
|
securityError = readSPack(hadError)
|
368
|
-
#puts "<SecurityError>" + securityError + "</SecurityError>"
|
369
420
|
if (hadError[0])
|
370
|
-
return nil
|
421
|
+
return nil # had a io error
|
371
422
|
end
|
372
423
|
if (securityError.empty?)
|
373
424
|
securityError = nil
|
374
425
|
end
|
375
|
-
|
376
426
|
otherError = readSPack(hadError)
|
377
427
|
if (hadError[0])
|
378
|
-
return nil
|
428
|
+
return nil # had a io error
|
379
429
|
end
|
380
430
|
if (otherError.empty?)
|
381
431
|
otherError = nil
|
@@ -445,7 +495,17 @@ module VistaRPC4r
|
|
445
495
|
buffer = String.new
|
446
496
|
gotCR = false
|
447
497
|
while true
|
448
|
-
|
498
|
+
begin
|
499
|
+
byte = @socket.readbyte # read one byte
|
500
|
+
rescue EOFError => emsg
|
501
|
+
if (hadError != nil)
|
502
|
+
hadError[0] = true
|
503
|
+
end
|
504
|
+
if @loglevel ==2
|
505
|
+
puts "EOFError"
|
506
|
+
end
|
507
|
+
return nil
|
508
|
+
end
|
449
509
|
if (byte == END_MARKER)
|
450
510
|
if (endMarker != nil)
|
451
511
|
endMarker[0] = true
|
@@ -474,9 +534,32 @@ module VistaRPC4r
|
|
474
534
|
if (hadError != nil)
|
475
535
|
hadError[0] = false
|
476
536
|
end
|
477
|
-
|
537
|
+
|
538
|
+
begin
|
539
|
+
len = @socket.readbyte # read one byte into a fixnum
|
540
|
+
rescue EOFError => emsg
|
541
|
+
if (hadError != nil)
|
542
|
+
hadError[0] = true
|
543
|
+
end
|
544
|
+
if @loglevel ==2
|
545
|
+
puts "EOFError"
|
546
|
+
end
|
547
|
+
return nil
|
548
|
+
end
|
549
|
+
|
478
550
|
data = String.new
|
479
|
-
|
551
|
+
begin
|
552
|
+
data = @socket.read(len)
|
553
|
+
rescue EOFError => emsg
|
554
|
+
if (hadError != nil)
|
555
|
+
hadError[0] = true
|
556
|
+
end
|
557
|
+
if @loglevel ==2
|
558
|
+
puts "EOFError"
|
559
|
+
end
|
560
|
+
return nil
|
561
|
+
end
|
562
|
+
|
480
563
|
return data
|
481
564
|
end
|
482
565
|
|
data/vistarpc4r.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{vistarpc4r}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Mike Cham"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-09-25}
|
13
13
|
s.description = %q{more}
|
14
14
|
s.email = %q{mike@blenderhouse.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -38,7 +38,7 @@ Gem::Specification.new do |s|
|
|
38
38
|
s.homepage = %q{http://github.com/michaelcham/vistarpc4r}
|
39
39
|
s.licenses = ["MIT"]
|
40
40
|
s.require_paths = ["lib"]
|
41
|
-
s.rubygems_version = %q{1.
|
41
|
+
s.rubygems_version = %q{1.4.2}
|
42
42
|
s.summary = %q{Provides capability to make rpc calls to VistA EHR systems that have rpcbroker running}
|
43
43
|
|
44
44
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vistarpc4r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 2
|
9
8
|
- 3
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mike Cham
|
@@ -15,12 +15,14 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-09-25 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
+
prerelease: false
|
23
|
+
name: shoulda
|
22
24
|
type: :development
|
23
|
-
|
25
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
26
|
none: false
|
25
27
|
requirements:
|
26
28
|
- - ">="
|
@@ -29,12 +31,12 @@ dependencies:
|
|
29
31
|
segments:
|
30
32
|
- 0
|
31
33
|
version: "0"
|
32
|
-
|
33
|
-
version_requirements: *id001
|
34
|
-
prerelease: false
|
34
|
+
requirement: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
+
prerelease: false
|
37
|
+
name: bundler
|
36
38
|
type: :development
|
37
|
-
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
40
|
none: false
|
39
41
|
requirements:
|
40
42
|
- - ~>
|
@@ -45,12 +47,12 @@ dependencies:
|
|
45
47
|
- 0
|
46
48
|
- 0
|
47
49
|
version: 1.0.0
|
48
|
-
|
49
|
-
version_requirements: *id002
|
50
|
-
prerelease: false
|
50
|
+
requirement: *id002
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
|
+
prerelease: false
|
53
|
+
name: jeweler
|
52
54
|
type: :development
|
53
|
-
|
55
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
54
56
|
none: false
|
55
57
|
requirements:
|
56
58
|
- - ~>
|
@@ -61,12 +63,12 @@ dependencies:
|
|
61
63
|
- 6
|
62
64
|
- 0
|
63
65
|
version: 1.6.0
|
64
|
-
|
65
|
-
version_requirements: *id003
|
66
|
-
prerelease: false
|
66
|
+
requirement: *id003
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
|
+
prerelease: false
|
69
|
+
name: rcov
|
68
70
|
type: :development
|
69
|
-
|
71
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
70
72
|
none: false
|
71
73
|
requirements:
|
72
74
|
- - ">="
|
@@ -75,9 +77,7 @@ dependencies:
|
|
75
77
|
segments:
|
76
78
|
- 0
|
77
79
|
version: "0"
|
78
|
-
|
79
|
-
version_requirements: *id004
|
80
|
-
prerelease: false
|
80
|
+
requirement: *id004
|
81
81
|
description: more
|
82
82
|
email: mike@blenderhouse.com
|
83
83
|
executables: []
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
requirements: []
|
136
136
|
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 1.
|
138
|
+
rubygems_version: 1.4.2
|
139
139
|
signing_key:
|
140
140
|
specification_version: 3
|
141
141
|
summary: Provides capability to make rpc calls to VistA EHR systems that have rpcbroker running
|