allscripts_unity_client 4.0.1 → 5.0.0.pre.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +5 -5
  2. data/lib/allscripts_unity_client.rb +3 -0
  3. data/lib/allscripts_unity_client/client.rb +1 -1
  4. data/lib/allscripts_unity_client/client_options.rb +7 -3
  5. data/lib/allscripts_unity_client/json_client_driver.rb +33 -0
  6. data/lib/allscripts_unity_client/version.rb +1 -1
  7. metadata +22 -60
  8. data/.gitignore +0 -21
  9. data/.rspec +0 -2
  10. data/.rubocop.yml +0 -340
  11. data/.travis.yml +0 -11
  12. data/Gemfile +0 -2
  13. data/LICENSE +0 -22
  14. data/README.md +0 -347
  15. data/Rakefile +0 -7
  16. data/allscripts_unity_client.gemspec +0 -40
  17. data/spec/allscripts_unity_client_spec.rb +0 -66
  18. data/spec/client_driver_spec.rb +0 -23
  19. data/spec/client_options_spec.rb +0 -185
  20. data/spec/client_spec.rb +0 -471
  21. data/spec/factories/allscripts_unity_client_parameters_factory.rb +0 -18
  22. data/spec/factories/client_driver_factory.rb +0 -20
  23. data/spec/factories/client_factory.rb +0 -9
  24. data/spec/factories/client_options.rb +0 -18
  25. data/spec/factories/magic_request_factory.rb +0 -37
  26. data/spec/factories/unity_request_factory.rb +0 -13
  27. data/spec/factories/unity_response_factory.rb +0 -12
  28. data/spec/fixtures/attributes_hash.yml +0 -15
  29. data/spec/fixtures/date_hash.yml +0 -8
  30. data/spec/fixtures/date_string_hash.yml +0 -8
  31. data/spec/fixtures/error.json +0 -3
  32. data/spec/fixtures/get_providers.json +0 -69
  33. data/spec/fixtures/get_providers.xml +0 -119
  34. data/spec/fixtures/get_providers_json.yml +0 -65
  35. data/spec/fixtures/get_providers_xml.yml +0 -270
  36. data/spec/fixtures/get_security_token.json +0 -1
  37. data/spec/fixtures/get_security_token.xml +0 -7
  38. data/spec/fixtures/get_server_info.json +0 -10
  39. data/spec/fixtures/get_server_info.xml +0 -40
  40. data/spec/fixtures/get_server_info_json.yml +0 -8
  41. data/spec/fixtures/get_server_info_xml.yml +0 -55
  42. data/spec/fixtures/no_attributes_hash.yml +0 -7
  43. data/spec/fixtures/retire_security_token.json +0 -1
  44. data/spec/fixtures/retire_security_token.xml +0 -5
  45. data/spec/fixtures/soap_fault.xml +0 -13
  46. data/spec/fixtures/string_keyed_hash.yml +0 -8
  47. data/spec/fixtures/symbol_keyed_hash.yml +0 -8
  48. data/spec/json_client_driver_spec.rb +0 -152
  49. data/spec/json_unity_request_spec.rb +0 -37
  50. data/spec/json_unity_response_spec.rb +0 -44
  51. data/spec/spec_helper.rb +0 -85
  52. data/spec/support/factory_bot.rb +0 -10
  53. data/spec/support/fixture_loader.rb +0 -20
  54. data/spec/support/shared_examples_for_client_driver.rb +0 -118
  55. data/spec/support/shared_examples_for_unity_request.rb +0 -114
  56. data/spec/support/shared_examples_for_unity_response.rb +0 -26
  57. data/spec/unity_request_spec.rb +0 -37
  58. data/spec/unity_response_spec.rb +0 -36
  59. data/spec/utilities_spec.rb +0 -144
data/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.1.2
4
- - 2.2.2
5
- before_install:
6
- - gem update --system
7
- - gem update bundler
8
- - gem cleanup bundler
9
- install:
10
- - "gem install bundler"
11
- - "bundle install --jobs=3 --retry=3"
data/Gemfile DELETED
@@ -1,2 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
data/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2014 healthfinch, Inc
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md DELETED
@@ -1,347 +0,0 @@
1
- # Allscripts Unity Client [![Build Status](https://travis-ci.org/healthfinch/allscripts-unity-client.png?branch=master)](https://travis-ci.org/healthfinch/allscripts-unity-client) [![Coverage Status](https://coveralls.io/repos/healthfinch/allscripts-unity-client/badge.png?branch=master)](https://coveralls.io/r/healthfinch/allscripts-unity-client?branch=master)
2
-
3
- The `allscripts_unity_client` gem is a Ruby client for the Allscripts Unity API. See http://remotecentral.allscripts.com/UnityAPIReference for more documentation on the API.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem "allscripts_unity_client"
10
-
11
- And then execute:
12
-
13
- $ bundle install
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install allscripts_unity_client
18
-
19
- ## Usage
20
-
21
- ### Creating clients
22
-
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
-
26
- ```ruby
27
- unity_client = AllscriptsUnityClient.create({
28
- base_unity_url: "http://unity.base.url",
29
- appname: "appname",
30
- username: "username",
31
- password: "password"
32
- })
33
- ```
34
-
35
- A JSON client can also be created using the `:mode` option:
36
-
37
- ```ruby
38
- # Mode defaults to :soap
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
- })
46
- ```
47
-
48
- ### SSL Management
49
-
50
- [Faraday](https://github.com/lostisland/faraday) is used in combination with [EM-HTTP-Request](https://github.com/igrigorik/em-http-request) to send HTTP requests when using JSON clients. Faraday requires
51
- some configuration when making connections over SSL. AllscriptsUnityClient will try to auto-detect the location of the
52
- operating system's CA File or CA Path, but these values can be explicitly configured when creating a client:
53
-
54
- ```ruby
55
- # Mode defaults to :soap
56
- unity_client = AllscriptsUnityClient.create({
57
- mode: :json,
58
- base_unity_url: "http://unity.base.url",
59
- appname: "appname",
60
- username: "username",
61
- password: "password",
62
- ca_file: "/usr/lib/ssl/certs/ca-certificates.crt"
63
- })
64
- ```
65
-
66
- OR
67
-
68
- ```ruby
69
- # Mode defaults to :soap
70
- unity_client = AllscriptsUnityClient.create({
71
- mode: :json,
72
- base_unity_url: "http://unity.base.url",
73
- appname: "appname",
74
- username: "username",
75
- password: "password",
76
- ca_path: "/usr/lib/ssl/certs"
77
- })
78
- ```
79
-
80
- ### Request Timeout
81
-
82
- When using a JSON client, request timeouts can be configured:
83
-
84
- ```ruby
85
- # Mode defaults to :soap
86
- unity_client = AllscriptsUnityClient.create({
87
- mode: :json,
88
- base_unity_url: "http://unity.base.url",
89
- appname: "appname",
90
- username: "username",
91
- password: "password",
92
- timeout: 30
93
- })
94
- ```
95
-
96
- Timeout is given in seconds and defaults to 90.
97
-
98
- ### Security token management
99
-
100
- Security tokens can be manually requested using the `get_security_token!` method:
101
-
102
- ```ruby
103
- unity_client.get_security_token! # Fetches a new security token and stores it in security_token
104
- ```
105
-
106
- After calling `get_security_token!`, each call to `magic` will automatically send `security_token` with the request. If a security token is
107
- no longer valid, an exception will be raised by Unity.
108
-
109
- The token can be accessed using the `security_token` accessor:
110
-
111
- ```ruby
112
- unity_client.security_token
113
- ```
114
-
115
- Security tokens can be retired using the `retire_security_token!` method:
116
-
117
- ```ruby
118
- unity_client.retire_security_token! # Retires the security token with Unity and sets security_token to nil
119
- ```
120
-
121
- Existence of a security token can also be checked:
122
-
123
- ```ruby
124
- unity_client.security_token?
125
- ```
126
-
127
- ### Executing Magic calls
128
-
129
- The endpoint used to make API calls in Unity is called Magic. Magic can be accessed with the client:
130
-
131
- ```ruby
132
- unity_client.magic({
133
- action: "action",
134
- userid: "userid",
135
- appname: "appname", # Only use to override default. Default: unity_client.appname
136
- patientid: "patientid",
137
- token: "token", # Only use to override default. Default: unity_client.security_token
138
- parameter1: "parameter1",
139
- parameter2: "parameter2",
140
- parameter3: "parameter3",
141
- parameter4: "parameter4",
142
- parameter5: "parameter5",
143
- parameter6: "parameter6",
144
- data: "data"
145
- })
146
- ```
147
-
148
- All keys in the hash given to magic are optional. See the Allscripts Unity API documentation for more information
149
- about which API calls are supported
150
-
151
- ### Magic call helpers
152
-
153
- A number of helper methods exist that abstract away the details of the Magic operation:
154
-
155
- - `get_account`
156
- - `get_changed_patients(since = nil)`
157
- - `get_chart_item_details(userid, patientid, section)`
158
- - `get_clinical_summary(userid, patientid, extra_med_data = false)`
159
- - `get_dictionary(dictionary_name, userid = nil, site = nil)`
160
- - `get_encounter_list(userid, patientid, encounter_type, when_param = nil, nostradamus = nil, show_past_flag = nil, billing_provider_user_name = nil)`
161
- - `get_medication_by_trans_id(userid, patientid, transaction_id)`
162
- - `get_medication_info(userid, ddid, patientid = nil)`
163
- - `get_patient(userid, patientid, includepix = nil)`
164
- - `get_patient_activity(userid, patientid)`
165
- - `get_patient_problems(patientid, show_by_encounter_flag = nil, assessed = nil, encounter_id = nil, medcin_id = nil)`
166
- - `get_patient_by_mrn(userid, mrn)`
167
- - `get_patients_by_icd9(icd9, start = nil, end_param = nil)`
168
- - `get_provider(provider_id = nil, user_name = nil)`
169
- - `get_providers(security_filter = nil, name_filter = nil)`
170
- - `get_server_info`
171
- - `get_task(userid, transaction_id)`
172
- - `get_task_list(userid = nil, since = nil)`
173
- - `last_logs`
174
- - `save_rx(userid, patientid, rxxml)`
175
- - `save_task(userid, patientid, task_type = nil, target_user = nil, work_object_id = nil, comments = nil)`
176
- - `save_task_status(userid, transaction_id = nil, param = nil, delegate_id = nil, comment = nil)`
177
- - `search_meds(userid, patientid, search = nil)`
178
- - `search_patients(search)`
179
- - `search_pharmacies(search)`
180
-
181
- All magic helper methods not on this list currently raise `NotImplementedError`. More helper methods will be added in future releases. Pull requests welcome.
182
-
183
- ### Timezone
184
-
185
- All times and dates coming from Unity are in local timezones. When creating the client, the `:timezone` option can be used to configure
186
- automatic timezone conversion. If no `:timezone` is given, then it will default to `UTC`. Timezones must be given in `TZInfo` zone identifier
187
- format. See [TZInfo](http://tzinfo.github.io/) for more information:
188
-
189
- ```ruby
190
- unity_client = AllscriptsUnityClient.create({
191
- timezone: "America/New_York",
192
- base_unity_url: "http://unity.base.url",
193
- appname: "appname",
194
- username: "username",
195
- password: "password"
196
- })
197
- ```
198
-
199
- 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
200
- [ISO8601](http://en.wikipedia.org/wiki/ISO_8601) format that Unity requires.
201
-
202
- ### Logging
203
-
204
- 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:
205
-
206
- ```ruby
207
- unity_client = AllscriptsUnityClient.create({
208
- base_unity_url: "http://unity.base.url",
209
- appname: "appname",
210
- username: "username",
211
- password: "password",
212
- logger: Rails.logger
213
- })
214
- ```
215
-
216
- Logging can be disabled by setting the `:logger` option to nil (this is the default):
217
-
218
- ```ruby
219
- unity_client = AllscriptsUnityClient.create({
220
- base_unity_url: "http://unity.base.url",
221
- appname: "appname",
222
- username: "username",
223
- password: "password",
224
- logger: nil
225
- })
226
- ```
227
-
228
- Responses are not logged and Magic action is the only parameter logged with requests. This is done to prevent exposing PHI.
229
-
230
- ### Proxy
231
-
232
- An HTTP proxy can be configured using the `:proxy` option:
233
-
234
- ```ruby
235
- unity_client = AllscriptsUnityClient.create({
236
- base_unity_url: "http://unity.base.url",
237
- appname: "appname",
238
- username: "username",
239
- password: "password",
240
- proxy: "http://localhost:8888"
241
- })
242
- ```
243
-
244
- ### Locale
245
-
246
- This gem uses the [american_date](http://rubygems.org/gems/american_date) gem to force `Date.parse` to
247
- accept USA locale dates by default. There are currently no plans to support other locales. Pull requests welcome.
248
-
249
- ## Examples
250
-
251
- ### GetServerInfo SOAP
252
-
253
- ```ruby
254
- unity_client = AllscriptsUnityClient.create({
255
- base_unity_url: "http://unity.base.url",
256
- appname: "appname",
257
- username: "username",
258
- password: "password",
259
- timezone: "America/New_York"
260
- })
261
-
262
- unity_client.get_security_token!
263
-
264
- # API call made using a helper
265
- unity_client.get_server_info
266
- ```
267
-
268
- The above example would output the following `Hash`:
269
-
270
- ```
271
- {
272
- server_time_zone: "Eastern Standard Time",
273
- server_time: #<DateTime: 2013-11-01T15:49:23+00:00 ((2456598j,56963s,0n),+0s,2299161j)>,
274
- server_date_time_offset: #<DateTime: 2013-11-01T19:49:23+00:00 ((2456598j,71363s,0n),+0s,2299161j)>,
275
- system: "Enterprise EHR",
276
- product_version: "11.2.3.32.000",
277
- uaibornondate: #<Date: 2013-07-10 ((2456484j,0s,0n),+0s,2299161j)>
278
- }
279
- ```
280
-
281
- ### GetServerInfo JSON
282
-
283
- ```ruby
284
- unity_client = AllscriptsUnityClient.create({
285
- mode: :json
286
- base_unity_url: "http://unity.base.url",
287
- appname: "appname",
288
- username: "username",
289
- password: "password",
290
- timezone: "America/New_York"
291
- })
292
-
293
- unity_client.get_security_token!
294
-
295
- # API call made using a helper
296
- unity_client.get_server_info
297
- ```
298
-
299
- The above example would output the following `Hash`:
300
-
301
- ```
302
- {
303
- server_time_zone: "Eastern Standard Time",
304
- server_time: #<DateTime: 2013-11-01T15:49:23+00:00 ((2456598j,56963s,0n),+0s,2299161j)>,
305
- server_date_time_offset: #<DateTime: 2013-11-01T19:49:23+00:00 ((2456598j,71363s,0n),+0s,2299161j)>,
306
- system: "Enterprise EHR",
307
- product_version: "11.2.3.32.000",
308
- uaibornondate: #<Date: 2013-07-10 ((2456484j,0s,0n),+0s,2299161j)>
309
- }
310
- ```
311
-
312
- ## Contributing
313
-
314
- 1. Fork it
315
- 2. Create your feature branch (`git checkout -b my-new-feature`)
316
- 3. Commit your changes (`git commit -am 'Added some feature'`)
317
- 4. Push to the branch (`git push origin my-new-feature`)
318
- 5. Create new Pull Request
319
-
320
- ## Additional Information
321
-
322
- Maintainer(s): Neil Goodman (https://github.com/posco2k8)
323
-
324
- ## License
325
-
326
- Copyright (c) 2014 healthfinch, Inc
327
-
328
- MIT License
329
-
330
- Permission is hereby granted, free of charge, to any person obtaining
331
- a copy of this software and associated documentation files (the
332
- "Software"), to deal in the Software without restriction, including
333
- without limitation the rights to use, copy, modify, merge, publish,
334
- distribute, sublicense, and/or sell copies of the Software, and to
335
- permit persons to whom the Software is furnished to do so, subject to
336
- the following conditions:
337
-
338
- The above copyright notice and this permission notice shall be
339
- included in all copies or substantial portions of the Software.
340
-
341
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
342
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
343
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
344
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
345
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
346
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
347
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile DELETED
@@ -1,7 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new
5
-
6
- task default: :spec
7
- task test: :spec
@@ -1,40 +0,0 @@
1
- lib = File.expand_path('../lib/', __FILE__)
2
- $:.unshift lib unless $:.include?(lib)
3
-
4
- require 'allscripts_unity_client/version'
5
- require 'date'
6
-
7
- Gem::Specification.new do |gem|
8
- gem.name = 'allscripts_unity_client'
9
- gem.version = AllscriptsUnityClient::VERSION
10
- gem.date = Date.today
11
- gem.required_ruby_version = '> 2.0.0'
12
- gem.license = 'MIT'
13
- gem.homepage = 'https://github.com/healthfinch/allscripts-unity-client'
14
-
15
- gem.summary = 'Allscripts Unity API client'
16
- gem.description = 'Provides a simple interface to the Allscripts Unity API using JSON. Developed at healthfinch http://healthfinch.com'
17
-
18
- gem.authors = ['healthfinch']
19
- gem.email = %w(darkarts@healthfinch.com)
20
-
21
- gem.require_paths = ['lib']
22
-
23
- gem.files = `git ls-files`.split("\n").delete_if { |file| /^\.ruby-version$/.match(file) }
24
-
25
- gem.add_dependency 'httpclient', '~> 2.8'
26
- gem.add_dependency 'activesupport', '>= 4', '< 5.0'
27
- gem.add_dependency 'nokogiri', '>= 1.4.0'
28
- gem.add_dependency 'nori', '~> 2.6.0'
29
- gem.add_dependency 'american_date', '~> 1.1.0'
30
- gem.add_dependency 'multi_json', '~> 1.12'
31
- gem.add_dependency 'rubyntlm', '~> 0.6.2'
32
-
33
- gem.add_development_dependency 'factory_bot', '~> 4.8.0'
34
- gem.add_development_dependency 'rake', '~> 12.2.1'
35
- gem.add_development_dependency 'faker', '~> 1.8.4'
36
- gem.add_development_dependency 'rspec', '~> 3.7.0'
37
- gem.add_development_dependency 'webmock', '~> 3.1.0'
38
- gem.add_development_dependency 'simplecov', '~> 0.15.1'
39
- gem.add_development_dependency 'rubocop', '~> 0.51'
40
- end
@@ -1,66 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe AllscriptsUnityClient do
4
- subject { described_class }
5
-
6
- describe '#create' do
7
- context 'when given mode: :json' do
8
- it 'returns a client with client_type :json' do
9
- parameters = build(:allscripts_unity_client_parameters, mode: :json)
10
- expect(subject.create(parameters).client_type).to be(:json)
11
- end
12
- end
13
-
14
- context 'when not given :mode' do
15
- it 'returns a client with client_type :json' do
16
- parameters = build(:allscripts_unity_client_parameters)
17
- parameters[:mode] = nil
18
- expect(subject.create(parameters).client_type).to be(:json)
19
- end
20
- end
21
-
22
- context 'when given an invalid :mode' do
23
- it 'raises an argument error' do
24
- parameters = build(:allscripts_unity_client_parameters)
25
- parameters[:mode] = :cheese
26
- expect { subject.create(parameters) }.to raise_error(ArgumentError, ':mode must be :json')
27
- end
28
- end
29
- end
30
-
31
- describe '#save_task' do
32
- it 'raises when each of transaction_id, delegate_id, and comment are nil' do
33
- parameters = build(:allscripts_unity_client_parameters, mode: :json)
34
-
35
- client = subject.create(parameters)
36
-
37
- expect do
38
- client.save_task(:user_id, :patient_id)
39
- end.to raise_error(ArgumentError)
40
- end
41
- end
42
-
43
- describe '#save_task_status' do
44
- it 'raises when each of transaction_id, delegate_id, and comment are nil' do
45
- parameters = build(:allscripts_unity_client_parameters, mode: :json)
46
- client = subject.create(parameters)
47
-
48
- expect do
49
- client.save_task_status(:user_id, :patient_id)
50
- end.to raise_error(ArgumentError)
51
- end
52
-
53
- it 'maintains a nil parameter6 whenever taskchanges is nil' do
54
- parameters = build(:allscripts_unity_client_parameters, mode: :json)
55
- client = subject.create(parameters)
56
-
57
- def client.magic(params)
58
- params
59
- end
60
-
61
- result = client.save_task_status(1, 1, :status, 1, :comment, nil, 1)
62
-
63
- expect(result[:parameter6]).to eq("")
64
- end
65
- end
66
- end