allscripts_unity_client 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -20,38 +20,46 @@ Or install it yourself as:
20
20
 
21
21
  ### Creating clients
22
22
 
23
- The Allscripts Unity API has three endpoints: GetSecurityToken, Magic, and RetireSecurityToken and supports both SOAP and JSON.
24
- A Unity API client can be created using the `AllscriptsUnityClient#create` factory:
23
+ The Allscripts Unity API supports both JSON and SOAP. Both versions are supported by this gem.
24
+ A Unity API client can be created using the `AllscriptsUnityClient.create` factory:
25
25
 
26
26
  ```ruby
27
- unity_client = AllscriptsUnityClient.create(:base_unity_url => "http://unity.base.url", :appname => "appname", :username => "username", :password => "password")
27
+ unity_client = AllscriptsUnityClient.create({
28
+ :base_unity_url => "http://unity.base.url",
29
+ :appname => "appname",
30
+ :username => "username",
31
+ :password => "password"
32
+ })
28
33
  ```
29
34
 
30
35
  A JSON client can also be created using the `:mode` option:
31
36
 
32
37
  ```ruby
33
38
  # Mode defaults to :soap
34
- unity_client = AllscriptsUnityClient.create(:mode => :json, :base_unity_url => "http://unity.base.url", :appname => "appname", :username => "username", :password => "password")
39
+ unity_client = AllscriptsUnityClient.create({
40
+ :mode => :json,
41
+ :base_unity_url => "http://unity.base.url",
42
+ :appname => "appname",
43
+ :username => "username",
44
+ :password => "password"
45
+ })
35
46
  ```
36
47
 
37
48
  ### Security token management
38
49
 
39
- The `create` factory will request a security token from Unity when created. The token can be accessed using the `security_token` accessor:
50
+ Security tokens can be manually requested using the `get_security_token!` method:
40
51
 
41
52
  ```ruby
42
- unity_client.security_token
53
+ unity_client.get_security_token! # Fetches a new security token and stores it in security_token
43
54
  ```
44
55
 
45
- Existence of a security token can also be checked:
46
-
47
- ```ruby
48
- unity_client.security_token?
49
- ```
56
+ After calling `get_security_token!`, each call to `magic` will automatically send `security_token` with the request. If a security token is
57
+ no longer valid, an exception will be raised by Unity.
50
58
 
51
- Security tokens can be manually requested using the `get_security_token!` method:
59
+ The token can be accessed using the `security_token` accessor:
52
60
 
53
61
  ```ruby
54
- unity_client.get_security_token! # Fetches a new security token and stores it in security_token
62
+ unity_client.security_token
55
63
  ```
56
64
 
57
65
  Security tokens can be retired using the `retire_security_token!` method:
@@ -60,8 +68,11 @@ Security tokens can be retired using the `retire_security_token!` method:
60
68
  unity_client.retire_security_token! # Retires the security token with Unity and sets security_token to nil
61
69
  ```
62
70
 
63
- After calling `get_security_token!`, each call to `magic` will automatically send `security_token` with the request. If a security token is
64
- no longer valid, an exception will be raised by Unity.
71
+ Existence of a security token can also be checked:
72
+
73
+ ```ruby
74
+ unity_client.security_token?
75
+ ```
65
76
 
66
77
  ### Executing Magic calls
67
78
 
@@ -113,34 +124,129 @@ A number of helper methods exist that abstract away the details of the Magic ope
113
124
 
114
125
  All magic helper methods not on this list currently raise `NotImplementedError`. More helper methods will be added in future releases. Pull requests welcome.
115
126
 
116
- ## Timezone
127
+ ### Timezone
117
128
 
118
129
  All times and dates coming from Unity are in local timezones. When creating the client, the `:timezone` option can be used to configure
119
130
  automatic timezone conversion. If no `:timezone` is given, then it will default to `UTC`. Timezones must be given in `TZInfo` zone identifier
120
131
  format. See [TZInfo](http://tzinfo.github.io/) for more information:
121
132
 
122
133
  ```ruby
123
- unity_client = AllscriptsUnityClient.create(:timezone => "America/New_York", :base_unity_url => "http://unity.base.url", :appname => "appname", :username => "username", :password => "password")
134
+ unity_client = AllscriptsUnityClient.create({
135
+ :timezone => "America/New_York",
136
+ :base_unity_url => "http://unity.base.url",
137
+ :appname => "appname",
138
+ :username => "username",
139
+ :password => "password"
140
+ })
124
141
  ```
125
142
 
126
143
  Any `magic` action that takes in a date needs to be given in UTC. Dates can be `Date`, `DateTime`, `Time`, or a string. Dates will be processed and formatted in the correct
127
144
  [ISO8601](http://en.wikipedia.org/wiki/ISO_8601) format that Unity requires.
128
145
 
129
- ## Logging
146
+ ### Logging
147
+
148
+ By default Ruby's `Logger` is used and logs to `STDOUT` with a level of `Logger::INFO`. Custom loggers can be configured with the `:logger` option:
149
+
150
+ ```ruby
151
+ unity_client = AllscriptsUnityClient.create({
152
+ :base_unity_url => "http://unity.base.url",
153
+ :appname => "appname",
154
+ :username => "username",
155
+ :password => "password",
156
+ :logger => Rails.logger
157
+ })
158
+ ```
159
+
160
+ Logging can also be disabled with the `:log` option:
161
+
162
+ ```ruby
163
+ unity_client = AllscriptsUnityClient.create({
164
+ :base_unity_url => "http://unity.base.url",
165
+ :appname => "appname",
166
+ :username => "username",
167
+ :password => "password",
168
+ :log => false
169
+ })
170
+ ```
171
+
172
+ Responses are not logged and Magic action is the only parameter logged with requests. This is done to prevent exposing PHI.
130
173
 
131
- By default Ruby's Logger is used and logs to STDOUT with level Logger::INFO. Custom loggers can be configured:
174
+ ### Proxy
175
+
176
+ An HTTP proxy can be configured using the `:proxy` option:
132
177
 
133
178
  ```ruby
134
- unity_client = AllscriptsUnityClient.create(:base_unity_url => "http://unity.base.url", :appname => "appname", :username => "username", :password => "password", :logger => Rails.logger)
179
+ unity_client = AllscriptsUnityClient.create({
180
+ :base_unity_url => "http://unity.base.url",
181
+ :appname => "appname",
182
+ :username => "username",
183
+ :password => "password",
184
+ :proxy => "http://localhost:8888"
185
+ })
135
186
  ```
136
187
 
137
- Logging can also be disabled:
188
+ ## Examples
189
+
190
+ ### GetServerInfo SOAP
138
191
 
139
192
  ```ruby
140
- unity_client = AllscriptsUnityClient.create(:base_unity_url => "http://unity.base.url", :appname => "appname", :username => "username", :password => "password", :log => false)
193
+ unity_client = AllscriptsUnityClient.create({
194
+ :base_unity_url => "http://unity.base.url",
195
+ :appname => "appname",
196
+ :username => "username",
197
+ :password => "password",
198
+ :timezone => "America/New_York"
199
+ })
200
+
201
+ unity_client.get_security_token!
202
+
203
+ # API call made using a helper
204
+ unity_client.get_server_info
141
205
  ```
142
206
 
143
- Magic action is the only parameter logged with requests and responses are not logged. This is done to prevent logging PHI.
207
+ The above example would output the following `Hash`:
208
+
209
+ ```
210
+ {
211
+ :server_time_zone => "Eastern Standard Time",
212
+ :server_time => #<DateTime: 2013-11-01T15:49:23+00:00 ((2456598j,56963s,0n),+0s,2299161j)>,
213
+ :server_date_time_offset => #<DateTime: 2013-11-01T19:49:23+00:00 ((2456598j,71363s,0n),+0s,2299161j)>,
214
+ :system => "Enterprise EHR",
215
+ :product_version => "11.2.3.32.000",
216
+ :uaibornondate => #<Date: 2013-07-10 ((2456484j,0s,0n),+0s,2299161j)>
217
+ }
218
+ ```
219
+
220
+ ### GetServerInfo JSON
221
+
222
+ ```ruby
223
+ unity_client = AllscriptsUnityClient.create({
224
+ :mode => :json
225
+ :base_unity_url => "http://unity.base.url",
226
+ :appname => "appname",
227
+ :username => "username",
228
+ :password => "password",
229
+ :timezone => "America/New_York"
230
+ })
231
+
232
+ unity_client.get_security_token!
233
+
234
+ # API call made using a helper
235
+ unity_client.get_server_info
236
+ ```
237
+
238
+ The above example would output the following `Hash`:
239
+
240
+ ```
241
+ {
242
+ :server_time_zone => "Eastern Standard Time",
243
+ :server_time => #<DateTime: 2013-11-01T15:49:23+00:00 ((2456598j,56963s,0n),+0s,2299161j)>,
244
+ :server_date_time_offset => #<DateTime: 2013-11-01T19:49:23+00:00 ((2456598j,71363s,0n),+0s,2299161j)>,
245
+ :system => "Enterprise EHR",
246
+ :product_version => "11.2.3.32.000",
247
+ :uaibornondate => #<Date: 2013-07-10 ((2456484j,0s,0n),+0s,2299161j)>
248
+ }
249
+ ```
144
250
 
145
251
  ## Contributing
146
252
 
@@ -154,7 +260,7 @@ Magic action is the only parameter logged with requests and responses are not lo
154
260
 
155
261
  Maintainer(s): Ash Gupta (https://github.com/incomethax), Neil Goodman (https://github.com/posco2k8)
156
262
 
157
- ## License:
263
+ ## License
158
264
 
159
265
  Copyright (c) 2013 healthfinch, Inc
160
266
 
@@ -27,7 +27,8 @@ Gem::Specification.new do |gem|
27
27
  gem.add_runtime_dependency "net-http-persistent", "~> 2.9.0"
28
28
  gem.add_runtime_dependency "tzinfo", "~> 0.3.29"
29
29
  gem.add_runtime_dependency "tzinfo-data", "~> 1.2013.7"
30
- gem.add_runtime_dependency "nokogiri", "~> 1.5.0"
30
+ gem.add_runtime_dependency "nokogiri", "< 1.6", ">= 1.4.0"
31
+ gem.add_runtime_dependency "nori", "~> 2.3.0"
31
32
 
32
33
  gem.add_development_dependency "factory_girl", "~> 4.2.0"
33
34
  gem.add_development_dependency "rake", "~> 10.1.0"
@@ -26,7 +26,6 @@ module AllscriptsUnityClient
26
26
  end
27
27
 
28
28
  client = Client.new(client_driver)
29
- client.get_security_token!
30
29
  client
31
30
  end
32
31
 
@@ -1,3 +1,4 @@
1
+ require "nori"
1
2
  require "date"
2
3
 
3
4
  module AllscriptsUnityClient
@@ -1,3 +1,3 @@
1
1
  module AllscriptsUnityClient
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
@@ -5,15 +5,9 @@ describe 'AllscriptsUnityClient' do
5
5
 
6
6
  subject { AllscriptsUnityClient }
7
7
 
8
- let(:get_security_token) { FixtureLoader.load_file("get_security_token.xml") }
9
-
10
- before(:all) { savon.mock! }
11
- after(:all) { savon.unmock! }
12
-
13
8
  describe '.create' do
14
9
  context 'when given :mode => :soap' do
15
10
  it 'returns a SOAPClient' do
16
- savon.expects("GetSecurityToken").with(:message => :any).returns(get_security_token)
17
11
  parameters = FactoryGirl.build(:allscripts_unity_client_parameters, :mode => :soap)
18
12
  expect(subject.create(parameters).client_type).to be(:soap)
19
13
  end
@@ -21,7 +15,6 @@ describe 'AllscriptsUnityClient' do
21
15
 
22
16
  context 'when given :mode => :json' do
23
17
  it 'returns a client with client_type :json' do
24
- stub_request(:post, "http://www.example.com/Unity/UnityService.svc/json/GetToken")
25
18
  parameters = FactoryGirl.build(:allscripts_unity_client_parameters, :mode => :json)
26
19
  expect(subject.create(parameters).client_type).to be(:json)
27
20
  end
@@ -29,7 +22,6 @@ describe 'AllscriptsUnityClient' do
29
22
 
30
23
  context 'when not given :mode' do
31
24
  it 'returns a client with client_type :soap' do
32
- savon.expects("GetSecurityToken").with(:message => :any).returns(get_security_token)
33
25
  parameters = FactoryGirl.build(:allscripts_unity_client_parameters)
34
26
  parameters[:mode] = nil
35
27
  expect(subject.create(parameters).client_type).to be(:soap)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allscripts_unity_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-10-31 00:00:00.000000000 Z
13
+ date: 2013-11-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: savon
@@ -94,12 +94,34 @@ dependencies:
94
94
  version: 1.2013.7
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: nokogiri
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - <
101
+ - !ruby/object:Gem::Version
102
+ version: '1.6'
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: 1.4.0
106
+ type: :runtime
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - <
112
+ - !ruby/object:Gem::Version
113
+ version: '1.6'
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: 1.4.0
117
+ - !ruby/object:Gem::Dependency
118
+ name: nori
97
119
  requirement: !ruby/object:Gem::Requirement
98
120
  none: false
99
121
  requirements:
100
122
  - - ~>
101
123
  - !ruby/object:Gem::Version
102
- version: 1.5.0
124
+ version: 2.3.0
103
125
  type: :runtime
104
126
  prerelease: false
105
127
  version_requirements: !ruby/object:Gem::Requirement
@@ -107,7 +129,7 @@ dependencies:
107
129
  requirements:
108
130
  - - ~>
109
131
  - !ruby/object:Gem::Version
110
- version: 1.5.0
132
+ version: 2.3.0
111
133
  - !ruby/object:Gem::Dependency
112
134
  name: factory_girl
113
135
  requirement: !ruby/object:Gem::Requirement