allscripts_unity_client 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -0
- data/.travis.yml +3 -0
- data/Gemfile +2 -0
- data/LICENSE +22 -0
- data/README.md +180 -0
- data/Rakefile +7 -0
- data/allscripts_unity_client.gemspec +39 -0
- data/lib/allscripts_unity_client.rb +43 -0
- data/lib/allscripts_unity_client/client.rb +594 -0
- data/lib/allscripts_unity_client/client_driver.rb +95 -0
- data/lib/allscripts_unity_client/json_client_driver.rb +110 -0
- data/lib/allscripts_unity_client/json_unity_request.rb +33 -0
- data/lib/allscripts_unity_client/json_unity_response.rb +27 -0
- data/lib/allscripts_unity_client/soap_client_driver.rb +128 -0
- data/lib/allscripts_unity_client/timezone.rb +99 -0
- data/lib/allscripts_unity_client/unity_request.rb +63 -0
- data/lib/allscripts_unity_client/unity_response.rb +110 -0
- data/lib/allscripts_unity_client/utilities.rb +66 -0
- data/lib/allscripts_unity_client/version.rb +3 -0
- data/spec/allscripts_unity_client_spec.rb +57 -0
- data/spec/client_driver_spec.rb +71 -0
- data/spec/client_spec.rb +406 -0
- data/spec/factories/allscripts_unity_client_parameters_factory.rb +13 -0
- data/spec/factories/client_driver_factory.rb +14 -0
- data/spec/factories/client_factory.rb +7 -0
- data/spec/factories/json_client_driver_factory.rb +3 -0
- data/spec/factories/json_unity_request_factory.rb +3 -0
- data/spec/factories/json_unity_response_factory.rb +3 -0
- data/spec/factories/magic_request_factory.rb +33 -0
- data/spec/factories/soap_client_driver_factory.rb +3 -0
- data/spec/factories/timezone_factory.rb +7 -0
- data/spec/factories/unity_request_factory.rb +10 -0
- data/spec/factories/unity_response_factory.rb +8 -0
- data/spec/fixtures/attributes_hash.yml +15 -0
- data/spec/fixtures/date_hash.yml +8 -0
- data/spec/fixtures/date_string_hash.yml +8 -0
- data/spec/fixtures/error.json +3 -0
- data/spec/fixtures/get_providers.json +69 -0
- data/spec/fixtures/get_providers.xml +119 -0
- data/spec/fixtures/get_providers_json.yml +65 -0
- data/spec/fixtures/get_providers_xml.yml +270 -0
- data/spec/fixtures/get_security_token.json +1 -0
- data/spec/fixtures/get_security_token.xml +7 -0
- data/spec/fixtures/get_server_info.json +10 -0
- data/spec/fixtures/get_server_info.xml +40 -0
- data/spec/fixtures/get_server_info_json.yml +8 -0
- data/spec/fixtures/get_server_info_xml.yml +55 -0
- data/spec/fixtures/no_attributes_hash.yml +7 -0
- data/spec/fixtures/retire_security_token.json +1 -0
- data/spec/fixtures/retire_security_token.xml +5 -0
- data/spec/fixtures/soap_fault.xml +13 -0
- data/spec/fixtures/string_keyed_hash.yml +8 -0
- data/spec/fixtures/symbol_keyed_hash.yml +8 -0
- data/spec/json_client_driver_spec.rb +209 -0
- data/spec/json_unity_request_spec.rb +37 -0
- data/spec/json_unity_response_spec.rb +44 -0
- data/spec/soap_client_driver_spec.rb +201 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/support/fixture_loader.rb +22 -0
- data/spec/support/shared_examples_for_client_driver.rb +139 -0
- data/spec/support/shared_examples_for_unity_request.rb +94 -0
- data/spec/support/shared_examples_for_unity_response.rb +26 -0
- data/spec/timezone_spec.rb +161 -0
- data/spec/unity_request_spec.rb +37 -0
- data/spec/unity_response_spec.rb +36 -0
- data/spec/utilities_spec.rb +69 -0
- metadata +323 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 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
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
# Allscripts Unity Client [![Build Status](https://travis-ci.org/healthfinch/allscripts-unity-client.png?branch=version1)](https://travis-ci.org/healthfinch/allscripts-unity-client) [![Coverage Status](https://coveralls.io/repos/healthfinch/allscripts-unity-client/badge.png?branch=version1)](https://coveralls.io/r/healthfinch/allscripts-unity-client?branch=version1)
|
2
|
+
|
3
|
+
The `allscripts_unity_client` gem is a Ruby client for the Allscripts Unity API. See http://asdn.unitysandbox.com/UnitySDK/SDK/ 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 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:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
unity_client = AllscriptsUnityClient.create(:base_unity_url => "http://unity.base.url", :appname => "appname", :username => "username", :password => "password")
|
28
|
+
```
|
29
|
+
|
30
|
+
A JSON client can also be created using the `:mode` option:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
# Mode defaults to :soap
|
34
|
+
unity_client = AllscriptsUnityClient.create(:mode => :json, :base_unity_url => "http://unity.base.url", :appname => "appname", :username => "username", :password => "password")
|
35
|
+
```
|
36
|
+
|
37
|
+
### Security token management
|
38
|
+
|
39
|
+
The `create` factory will request a security token from Unity when created. The token can be accessed using the `security_token` accessor:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
unity_client.security_token
|
43
|
+
```
|
44
|
+
|
45
|
+
Existence of a security token can also be checked:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
unity_client.security_token?
|
49
|
+
```
|
50
|
+
|
51
|
+
Security tokens can be manually requested using the `get_security_token!` method:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
unity_client.get_security_token! # Fetches a new security token and stores it in security_token
|
55
|
+
```
|
56
|
+
|
57
|
+
Security tokens can be retired using the `retire_security_token!` method:
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
unity_client.retire_security_token! # Retires the security token with Unity and sets security_token to nil
|
61
|
+
```
|
62
|
+
|
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.
|
65
|
+
|
66
|
+
### Executing Magic calls
|
67
|
+
|
68
|
+
The endpoint used to make API calls in Unity is called Magic. Magic can be accessed with the client:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
unity_client.magic({
|
72
|
+
:action => "action",
|
73
|
+
:userid => "userid",
|
74
|
+
:appname => "appname", # Only use to override default. Default: unity_client.appname
|
75
|
+
:patientid => "patientid",
|
76
|
+
:token => "token", # Only use to override default. Default: unity_client.security_token
|
77
|
+
:parameter1 => "parameter1",
|
78
|
+
:parameter2 => "parameter2",
|
79
|
+
:parameter3 => "parameter3",
|
80
|
+
:parameter4 => "parameter4",
|
81
|
+
:parameter5 => "parameter5",
|
82
|
+
:parameter6 => "parameter6",
|
83
|
+
:data => "data"
|
84
|
+
})
|
85
|
+
```
|
86
|
+
|
87
|
+
All keys in the hash given to magic are optional. See the Allscripts Unity API documentation for more information
|
88
|
+
about which API calls are supported
|
89
|
+
|
90
|
+
### Magic call helpers
|
91
|
+
|
92
|
+
A number of helper methods exist that abstract away the details of the Magic operation:
|
93
|
+
|
94
|
+
- `get_changed_patients(since = nil)`
|
95
|
+
- `get_chart_item_details(userid, patientid, section)`
|
96
|
+
- `get_clinical_summary(userid, patientid)`
|
97
|
+
- `get_dictionary(dictionary_name, userid = nil, site = nil)`
|
98
|
+
- `get_encounter_list(userid, patientid, encounter_type, when_param = nil, nostradamus = nil, show_past_flag = nil, billing_provider_user_name = nil)`
|
99
|
+
- `get_medication_by_trans_id(userid, patientid, transaction_id)`
|
100
|
+
- `get_patient(userid, patientid, includepix = nil)`
|
101
|
+
- `get_patient_activity(userid, patientid)`
|
102
|
+
- `get_patient_problems(patientid, show_by_encounter_flag = nil, assessed = nil, encounter_id = nil, medcin_id = nil)`
|
103
|
+
- `get_patients_by_icd9(icd9, start = nil, end_param = nil)`
|
104
|
+
- `get_provider(provider_id = nil, user_name = nil)`
|
105
|
+
- `get_providers(security_filter = nil, name_filter = nil)`
|
106
|
+
- `get_server_info`
|
107
|
+
- `get_task(userid, transaction_id)`
|
108
|
+
- `get_task_list(userid = nil, since = nil)`
|
109
|
+
- `save_rx(userid, patientid, rxxml)`
|
110
|
+
- `save_task(userid, patientid, task_type = nil, target_user = nil, work_object_id = nil, comments = nil)`
|
111
|
+
- `save_task_status(userid, transaction_id = nil, param = nil, delegate_id = nil, comment = nil)`
|
112
|
+
- `search_meds(userid, patientid, search = nil)`
|
113
|
+
|
114
|
+
All magic helper methods not on this list currently raise `NotImplementedError`. More helper methods will be added in future releases. Pull requests welcome.
|
115
|
+
|
116
|
+
## Timezone
|
117
|
+
|
118
|
+
All times and dates coming from Unity are in local timezones. When creating the client, the `:timezone` option can be used to configure
|
119
|
+
automatic timezone conversion. If no `:timezone` is given, then it will default to `UTC`. Timezones must be given in `TZInfo` zone identifier
|
120
|
+
format. See [TZInfo](http://tzinfo.github.io/) for more information:
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
unity_client = AllscriptsUnityClient.create(:timezone => "America/New_York", :base_unity_url => "http://unity.base.url", :appname => "appname", :username => "username", :password => "password")
|
124
|
+
```
|
125
|
+
|
126
|
+
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
|
+
[ISO8601](http://en.wikipedia.org/wiki/ISO_8601) format that Unity requires.
|
128
|
+
|
129
|
+
## Logging
|
130
|
+
|
131
|
+
By default Ruby's Logger is used and logs to STDOUT with level Logger::INFO. Custom loggers can be configured:
|
132
|
+
|
133
|
+
```ruby
|
134
|
+
unity_client = AllscriptsUnityClient.create(:base_unity_url => "http://unity.base.url", :appname => "appname", :username => "username", :password => "password", :logger => Rails.logger)
|
135
|
+
```
|
136
|
+
|
137
|
+
Logging can also be disabled:
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
unity_client = AllscriptsUnityClient.create(:base_unity_url => "http://unity.base.url", :appname => "appname", :username => "username", :password => "password", :log => false)
|
141
|
+
```
|
142
|
+
|
143
|
+
Magic action is the only parameter logged with requests and responses are not logged. This is done to prevent logging PHI.
|
144
|
+
|
145
|
+
## Contributing
|
146
|
+
|
147
|
+
1. Fork it
|
148
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
149
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
150
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
151
|
+
5. Create new Pull Request
|
152
|
+
|
153
|
+
## Additional Information
|
154
|
+
|
155
|
+
Maintainer(s): Ash Gupta (https://github.com/incomethax), Neil Goodman (https://github.com/posco2k8)
|
156
|
+
|
157
|
+
## License:
|
158
|
+
|
159
|
+
Copyright (c) 2013 healthfinch, Inc
|
160
|
+
|
161
|
+
MIT License
|
162
|
+
|
163
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
164
|
+
a copy of this software and associated documentation files (the
|
165
|
+
"Software"), to deal in the Software without restriction, including
|
166
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
167
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
168
|
+
permit persons to whom the Software is furnished to do so, subject to
|
169
|
+
the following conditions:
|
170
|
+
|
171
|
+
The above copyright notice and this permission notice shall be
|
172
|
+
included in all copies or substantial portions of the Software.
|
173
|
+
|
174
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
175
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
176
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
177
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
178
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
179
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
180
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
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 = "~> 1.9"
|
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 or SOAP. Developed at healthfinch, Inc. http://healthfinch.com"
|
17
|
+
|
18
|
+
gem.authors = ["Ash Gupta", "Neil Goodman"]
|
19
|
+
gem.email = ["ash.gupta@healthfinch.com", "neil@healthfinch.com"]
|
20
|
+
|
21
|
+
gem.require_paths = ["lib"]
|
22
|
+
|
23
|
+
gem.files = `git ls-files`.split("\n")
|
24
|
+
|
25
|
+
gem.add_runtime_dependency "savon", "~> 2.3.0"
|
26
|
+
gem.add_runtime_dependency "httpi", "~> 2.1.0"
|
27
|
+
gem.add_runtime_dependency "net-http-persistent", "~> 2.9.0"
|
28
|
+
gem.add_runtime_dependency "tzinfo", "~> 0.3.29"
|
29
|
+
gem.add_runtime_dependency "tzinfo-data", "~> 1.2013.7"
|
30
|
+
gem.add_runtime_dependency "nokogiri", "~> 1.5.0"
|
31
|
+
|
32
|
+
gem.add_development_dependency "factory_girl", "~> 4.2.0"
|
33
|
+
gem.add_development_dependency "rake", "~> 10.1.0"
|
34
|
+
gem.add_development_dependency "faker", "~> 1.2.0"
|
35
|
+
gem.add_development_dependency "rspec", "~> 2.14.1"
|
36
|
+
gem.add_development_dependency "simplecov", "~> 0.7.1"
|
37
|
+
gem.add_development_dependency "webmock", "~> 1.15.0"
|
38
|
+
gem.add_development_dependency "coveralls", "~> 0.7.0"
|
39
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "allscripts_unity_client/utilities"
|
2
|
+
require "allscripts_unity_client/timezone"
|
3
|
+
require "allscripts_unity_client/unity_request"
|
4
|
+
require "allscripts_unity_client/json_unity_request"
|
5
|
+
require "allscripts_unity_client/unity_response"
|
6
|
+
require "allscripts_unity_client/json_unity_response"
|
7
|
+
require "allscripts_unity_client/client"
|
8
|
+
require "allscripts_unity_client/client_driver"
|
9
|
+
require "allscripts_unity_client/soap_client_driver"
|
10
|
+
require "allscripts_unity_client/json_client_driver"
|
11
|
+
|
12
|
+
module AllscriptsUnityClient
|
13
|
+
class APIError < RuntimeError
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.create(parameters = {})
|
17
|
+
parameters[:mode] ||= :soap
|
18
|
+
parameters[:log] = true unless parameters[:log] === false
|
19
|
+
raise_if_parameters_invalid parameters
|
20
|
+
|
21
|
+
case parameters[:mode]
|
22
|
+
when :json
|
23
|
+
client_driver = JSONClientDriver.new(parameters[:base_unity_url], parameters[:username], parameters[:password], parameters[:appname], parameters[:proxy], parameters[:timezone], parameters[:logger], parameters[:log])
|
24
|
+
when :soap
|
25
|
+
client_driver = SOAPClientDriver.new(parameters[:base_unity_url], parameters[:username], parameters[:password], parameters[:appname], parameters[:proxy], parameters[:timezone], parameters[:logger], parameters[:log])
|
26
|
+
end
|
27
|
+
|
28
|
+
client = Client.new(client_driver)
|
29
|
+
client.get_security_token!
|
30
|
+
client
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def self.raise_if_parameters_invalid(parameters)
|
36
|
+
raise ArgumentError, ":mode must be :json or :soap" if ![:json, :soap].include?(parameters[:mode])
|
37
|
+
raise ArgumentError, ":base_unity_url required" if parameters[:base_unity_url].nil?
|
38
|
+
raise ArgumentError, ":username required" if parameters[:username].nil?
|
39
|
+
raise ArgumentError, ":password required" if parameters[:password].nil?
|
40
|
+
raise ArgumentError, ":appname required" if parameters[:appname].nil?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,594 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
|
3
|
+
module AllscriptsUnityClient
|
4
|
+
class Client
|
5
|
+
attr_accessor :client_driver
|
6
|
+
|
7
|
+
def initialize(client_driver)
|
8
|
+
raise ArgumentError, "client_driver can not be nil" if client_driver.nil?
|
9
|
+
|
10
|
+
@client_driver = client_driver
|
11
|
+
end
|
12
|
+
|
13
|
+
def magic(parameters = {})
|
14
|
+
@client_driver.magic(parameters)
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_security_token!(parameters = {})
|
18
|
+
@client_driver.get_security_token!(parameters)
|
19
|
+
end
|
20
|
+
|
21
|
+
def retire_security_token!(parameters = {})
|
22
|
+
@client_driver.retire_security_token!(parameters)
|
23
|
+
end
|
24
|
+
|
25
|
+
def security_token?
|
26
|
+
@client_driver.security_token?
|
27
|
+
end
|
28
|
+
|
29
|
+
def client_type
|
30
|
+
return @client_driver.client_type
|
31
|
+
end
|
32
|
+
|
33
|
+
def commit_charges
|
34
|
+
raise NotImplementedError, "CommitCharges magic action not implemented"
|
35
|
+
end
|
36
|
+
|
37
|
+
def echo(echo_text)
|
38
|
+
magic_parameters = {
|
39
|
+
:action => "Echo",
|
40
|
+
:userid => echo_text,
|
41
|
+
:appname => echo_text,
|
42
|
+
:patientid => echo_text,
|
43
|
+
:parameter1 => echo_text,
|
44
|
+
:parameter2 => echo_text,
|
45
|
+
:parameter3 => echo_text,
|
46
|
+
:parameter4 => echo_text,
|
47
|
+
:parameter5 => echo_text,
|
48
|
+
:parameter6 => echo_text
|
49
|
+
}
|
50
|
+
response = magic(magic_parameters)
|
51
|
+
response[:userid]
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_account
|
55
|
+
raise NotImplementedError, "GetAccount magic action not implemented"
|
56
|
+
end
|
57
|
+
|
58
|
+
def get_changed_patients(since = nil)
|
59
|
+
magic_parameters = {
|
60
|
+
:action => "GetChangedPatients",
|
61
|
+
:parameter1 => since
|
62
|
+
}
|
63
|
+
magic(magic_parameters)
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_charge_info_by_username
|
67
|
+
raise NotImplementedError, "GetChargeInfoByUsername magic action not implemented"
|
68
|
+
end
|
69
|
+
|
70
|
+
def get_charges
|
71
|
+
raise NotImplementedError, "GetCharges magic action not implemented"
|
72
|
+
end
|
73
|
+
|
74
|
+
def get_chart_item_details(userid, patientid, section)
|
75
|
+
magic_parameters = {
|
76
|
+
:action => "GetChartItemDetails",
|
77
|
+
:userid => userid,
|
78
|
+
:patientid => patientid,
|
79
|
+
:parameter1 => section
|
80
|
+
}
|
81
|
+
magic(magic_parameters)
|
82
|
+
end
|
83
|
+
|
84
|
+
def get_clinical_summary(userid, patientid)
|
85
|
+
magic_parameters = {
|
86
|
+
:action => "GetClinicalSummary",
|
87
|
+
:userid => userid,
|
88
|
+
:patientid => patientid
|
89
|
+
}
|
90
|
+
magic(magic_parameters)
|
91
|
+
end
|
92
|
+
|
93
|
+
def get_delegates
|
94
|
+
raise NotImplementedError, "GetDelegates magic action not implemented"
|
95
|
+
end
|
96
|
+
|
97
|
+
def get_dictionary(dictionary_name, userid = nil, site = nil)
|
98
|
+
magic_parameters = {
|
99
|
+
:action => "GetDictionary",
|
100
|
+
:userid => userid,
|
101
|
+
:parameter1 => dictionary_name,
|
102
|
+
:parameter2 => site
|
103
|
+
}
|
104
|
+
magic(magic_parameters)
|
105
|
+
end
|
106
|
+
|
107
|
+
def get_dictionary_sets
|
108
|
+
raise NotImplementedError, "GetDictionarySets magic action not implemented"
|
109
|
+
end
|
110
|
+
|
111
|
+
def get_doc_template
|
112
|
+
raise NotImplementedError, "GetDocTemplate magic action not implemented"
|
113
|
+
end
|
114
|
+
|
115
|
+
def get_document_by_accession
|
116
|
+
raise NotImplementedError, "GetDocumentByAccession magic action not implemented"
|
117
|
+
end
|
118
|
+
|
119
|
+
def get_document_image
|
120
|
+
raise NotImplementedError, "GetDocumentImage magic action not implemented"
|
121
|
+
end
|
122
|
+
|
123
|
+
def get_documents
|
124
|
+
raise NotImplementedError, "GetDocuments magic action not implemented"
|
125
|
+
end
|
126
|
+
|
127
|
+
def get_document_type
|
128
|
+
raise NotImplementedError, "GetDocumentType magic action not implemented"
|
129
|
+
end
|
130
|
+
|
131
|
+
def get_dur
|
132
|
+
raise NotImplementedError, "GetDUR magic action not implemented"
|
133
|
+
end
|
134
|
+
|
135
|
+
def get_encounter
|
136
|
+
raise NotImplementedError, "GetEncounter magic action not implemented"
|
137
|
+
end
|
138
|
+
|
139
|
+
def get_encounter_date
|
140
|
+
raise NotImplementedError, "GetEncounterDate magic action not implemented"
|
141
|
+
end
|
142
|
+
|
143
|
+
def get_encounter_list(userid, patientid, encounter_type, when_param = nil, nostradamus = nil, show_past_flag = nil, billing_provider_user_name = nil)
|
144
|
+
magic_parameters = {
|
145
|
+
:action => "GetEncounterList",
|
146
|
+
:userid => userid,
|
147
|
+
:patientid => patientid,
|
148
|
+
:parameter1 => encounter_type,
|
149
|
+
:parameter2 => when_param,
|
150
|
+
:parameter3 => nostradamus,
|
151
|
+
:parameter4 => show_past_flag,
|
152
|
+
:parameter5 => billing_provider_user_name
|
153
|
+
}
|
154
|
+
response = magic(magic_parameters)
|
155
|
+
|
156
|
+
# Remove nil encounters
|
157
|
+
response.delete_if do |value|
|
158
|
+
value[:id] == "0" && value[:patientid] == "0"
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def get_hie_document
|
163
|
+
raise NotImplementedError, "GetHIEDocument magic action not implemented"
|
164
|
+
end
|
165
|
+
|
166
|
+
def get_last_patient
|
167
|
+
raise NotImplementedError, "GetLastPatient magic action not implemented"
|
168
|
+
end
|
169
|
+
|
170
|
+
def get_list_of_dictionaries
|
171
|
+
raise NotImplementedError, "GetListOfDictionaries magic action not implemented"
|
172
|
+
end
|
173
|
+
|
174
|
+
def get_medication_by_trans_id(userid, patientid, transaction_id)
|
175
|
+
magic_parameters = {
|
176
|
+
:action => "GetMedicationByTransID",
|
177
|
+
:userid => userid,
|
178
|
+
:patientid => patientid,
|
179
|
+
:parameter1 => transaction_id
|
180
|
+
}
|
181
|
+
magic(magic_parameters)
|
182
|
+
end
|
183
|
+
|
184
|
+
def get_order_history
|
185
|
+
raise NotImplementedError, "GetOrderHistory magic action not implemented"
|
186
|
+
end
|
187
|
+
|
188
|
+
def get_organization_id
|
189
|
+
raise NotImplementedError, "GetOrganizationID magic action not implemented"
|
190
|
+
end
|
191
|
+
|
192
|
+
def get_packages
|
193
|
+
raise NotImplementedError, "GetPackages magic action not implemented"
|
194
|
+
end
|
195
|
+
|
196
|
+
def get_patient(userid, patientid, includepix = nil)
|
197
|
+
magic_parameters = {
|
198
|
+
:action => "GetPatient",
|
199
|
+
:userid => userid,
|
200
|
+
:patientid => patientid,
|
201
|
+
:parameter1 => includepix
|
202
|
+
}
|
203
|
+
magic(magic_parameters)
|
204
|
+
end
|
205
|
+
|
206
|
+
def get_patient_activity(userid, patientid)
|
207
|
+
magic_parameters = {
|
208
|
+
:action => "GetPatientActivity",
|
209
|
+
:userid => userid,
|
210
|
+
:patientid => patientid
|
211
|
+
}
|
212
|
+
magic(magic_parameters)
|
213
|
+
end
|
214
|
+
|
215
|
+
def get_patient_by_mrn
|
216
|
+
raise NotImplementedError, "GetPatientByMRN magic action not implemented"
|
217
|
+
end
|
218
|
+
|
219
|
+
def get_patient_cda
|
220
|
+
raise NotImplementedError, "GetPatientCDA magic action not implemented"
|
221
|
+
end
|
222
|
+
|
223
|
+
def get_patient_diagnosis
|
224
|
+
raise NotImplementedError, "GetPatientDiagnosis magic action not implemented"
|
225
|
+
end
|
226
|
+
|
227
|
+
def get_patient_full
|
228
|
+
raise NotImplementedError, "GetPatientFull magic action not implemented"
|
229
|
+
end
|
230
|
+
|
231
|
+
def get_patient_ids
|
232
|
+
raise NotImplementedError, "GetPatientIDs magic action not implemented"
|
233
|
+
end
|
234
|
+
|
235
|
+
def get_patient_list
|
236
|
+
raise NotImplementedError, "GetPatientList magic action not implemented"
|
237
|
+
end
|
238
|
+
|
239
|
+
def get_patient_locations
|
240
|
+
raise NotImplementedError, "GetPatientLocations magic action not implemented"
|
241
|
+
end
|
242
|
+
|
243
|
+
def get_patient_pharmacies
|
244
|
+
raise NotImplementedError, "GetPatientPharmacies magic action not implemented"
|
245
|
+
end
|
246
|
+
|
247
|
+
def get_patient_problems(patientid, show_by_encounter_flag = nil, assessed = nil, encounter_id = nil, medcin_id = nil)
|
248
|
+
magic_parameters = {
|
249
|
+
:action => "GetPatientProblems",
|
250
|
+
:patientid => patientid,
|
251
|
+
:parameter1 => show_by_encounter_flag,
|
252
|
+
:parameter2 => assessed,
|
253
|
+
:parameter3 => encounter_id,
|
254
|
+
:parameter4 => medcin_id
|
255
|
+
}
|
256
|
+
magic(magic_parameters)
|
257
|
+
end
|
258
|
+
|
259
|
+
def get_patients_by_icd9(icd9, start = nil, end_param = nil)
|
260
|
+
magic_parameters = {
|
261
|
+
:action => "GetPatientsByICD9",
|
262
|
+
:parameter1 => icd9,
|
263
|
+
:parameter2 => start,
|
264
|
+
:parameter3 => end_param
|
265
|
+
}
|
266
|
+
magic(magic_parameters)
|
267
|
+
end
|
268
|
+
|
269
|
+
def get_patient_sections
|
270
|
+
raise NotImplementedError, "GetPatientSections magic action not implemented"
|
271
|
+
end
|
272
|
+
|
273
|
+
def get_procedures
|
274
|
+
raise NotImplementedError, "GetProcedures magic action not implemented"
|
275
|
+
end
|
276
|
+
|
277
|
+
def get_provider(provider_id = nil, user_name = nil)
|
278
|
+
if provider_id.nil? && user_name.nil?
|
279
|
+
raise ArgumentError, "provider_id or user_name must be given"
|
280
|
+
end
|
281
|
+
|
282
|
+
magic_parameters = {
|
283
|
+
:action => "GetProvider",
|
284
|
+
:parameter1 => provider_id,
|
285
|
+
:parameter2 => user_name
|
286
|
+
}
|
287
|
+
magic(magic_parameters)
|
288
|
+
end
|
289
|
+
|
290
|
+
def get_providers(security_filter = nil, name_filter = nil)
|
291
|
+
magic_parameters = {
|
292
|
+
:action => "GetProviders",
|
293
|
+
:parameter1 => security_filter,
|
294
|
+
:parameter2 => name_filter
|
295
|
+
}
|
296
|
+
magic(magic_parameters)
|
297
|
+
end
|
298
|
+
|
299
|
+
def get_ref_providers_by_specialty
|
300
|
+
raise NotImplementedError, "GetRefProvidersBySpecialty magic action not implemented"
|
301
|
+
end
|
302
|
+
|
303
|
+
def get_rounding_list_entries
|
304
|
+
raise NotImplementedError, "GetRoundingListEntries magic action not implemented"
|
305
|
+
end
|
306
|
+
|
307
|
+
def get_rounding_lists
|
308
|
+
raise NotImplementedError, "GetRoundingLists magic action not implemented"
|
309
|
+
end
|
310
|
+
|
311
|
+
def get_rx_favs
|
312
|
+
raise NotImplementedError, "GetRXFavs magic action not implemented"
|
313
|
+
end
|
314
|
+
|
315
|
+
def get_schedule
|
316
|
+
raise NotImplementedError, "GetSchedule magic action not implemented"
|
317
|
+
end
|
318
|
+
|
319
|
+
def get_server_info
|
320
|
+
magic_parameters = {
|
321
|
+
:action => "GetServerInfo"
|
322
|
+
}
|
323
|
+
magic(magic_parameters)
|
324
|
+
end
|
325
|
+
|
326
|
+
def get_sigs
|
327
|
+
raise NotImplementedError, "GetSigs magic action not implemented"
|
328
|
+
end
|
329
|
+
|
330
|
+
def get_task(userid, transaction_id)
|
331
|
+
magic_parameters = {
|
332
|
+
:action => "GetTask",
|
333
|
+
:userid => userid,
|
334
|
+
:parameter1 => transaction_id
|
335
|
+
}
|
336
|
+
magic(magic_parameters)
|
337
|
+
end
|
338
|
+
|
339
|
+
def get_task_list(userid = nil, since = nil)
|
340
|
+
magic_parameters = {
|
341
|
+
:action => "GetTaskList",
|
342
|
+
:userid => userid,
|
343
|
+
:parameter1 => since
|
344
|
+
}
|
345
|
+
magic(magic_parameters)
|
346
|
+
end
|
347
|
+
|
348
|
+
def get_user_authentication
|
349
|
+
raise NotImplementedError, "GetUserAuthentication magic action not implemented"
|
350
|
+
end
|
351
|
+
|
352
|
+
def get_user_id
|
353
|
+
raise NotImplementedError, "GetUserID magic action not implemented"
|
354
|
+
end
|
355
|
+
|
356
|
+
def get_user_security
|
357
|
+
raise NotImplementedError, "GetUserSecurity magic action not implemented"
|
358
|
+
end
|
359
|
+
|
360
|
+
def get_vaccine_manufacturers
|
361
|
+
raise NotImplementedError, "GetVaccineManufacturers magic action not implemented"
|
362
|
+
end
|
363
|
+
|
364
|
+
def get_vitals
|
365
|
+
raise NotImplementedError, "GetVitals magic action not implemented"
|
366
|
+
end
|
367
|
+
|
368
|
+
def make_task
|
369
|
+
raise NotImplementedError, "MakeTask magic action not implemented"
|
370
|
+
end
|
371
|
+
|
372
|
+
def save_admin_task
|
373
|
+
raise NotImplementedError, "SaveAdminTask magic action not implemented"
|
374
|
+
end
|
375
|
+
|
376
|
+
def save_allergy
|
377
|
+
raise NotImplementedError, "SaveAllergy magic action not implemented"
|
378
|
+
end
|
379
|
+
|
380
|
+
def save_ced
|
381
|
+
raise NotImplementedError, "SaveCED magic action not implemented"
|
382
|
+
end
|
383
|
+
|
384
|
+
def save_charge
|
385
|
+
raise NotImplementedError, "SaveCharge magic action not implemented"
|
386
|
+
end
|
387
|
+
|
388
|
+
def save_chart_view_audit
|
389
|
+
raise NotImplementedError, "SaveChartViewAudit magic action not implemented"
|
390
|
+
end
|
391
|
+
|
392
|
+
def save_diagnosis
|
393
|
+
raise NotImplementedError, "SaveDiagnosis magic action not implemented"
|
394
|
+
end
|
395
|
+
|
396
|
+
def save_document_image
|
397
|
+
raise NotImplementedError, "SaveDocumentImage magic action not implemented"
|
398
|
+
end
|
399
|
+
|
400
|
+
def save_er_note
|
401
|
+
raise NotImplementedError, "SaveERNote magic action not implemented"
|
402
|
+
end
|
403
|
+
|
404
|
+
def save_hie_document
|
405
|
+
raise NotImplementedError, "SaveHIEDocument magic action not implemented"
|
406
|
+
end
|
407
|
+
|
408
|
+
def save_history
|
409
|
+
raise NotImplementedError, "SaveHistory magic action not implemented"
|
410
|
+
end
|
411
|
+
|
412
|
+
def save_immunization
|
413
|
+
raise NotImplementedError, "SaveImmunization magic action not implemented"
|
414
|
+
end
|
415
|
+
|
416
|
+
def save_note
|
417
|
+
raise NotImplementedError, "SaveNote magic action not implemented"
|
418
|
+
end
|
419
|
+
|
420
|
+
def save_patient
|
421
|
+
raise NotImplementedError, "SavePatient magic action not implemented"
|
422
|
+
end
|
423
|
+
|
424
|
+
def save_patient_location
|
425
|
+
raise NotImplementedError, "SavePatientLocation magic action not implemented"
|
426
|
+
end
|
427
|
+
|
428
|
+
def save_problem
|
429
|
+
raise NotImplementedError, "SaveProblem magic action not implemented"
|
430
|
+
end
|
431
|
+
|
432
|
+
def save_problems_data
|
433
|
+
raise NotImplementedError, "SaveProblemsData magic action not implemented"
|
434
|
+
end
|
435
|
+
|
436
|
+
def save_ref_provider
|
437
|
+
raise NotImplementedError, "SaveRefProvider magic action not implemented"
|
438
|
+
end
|
439
|
+
|
440
|
+
def save_result
|
441
|
+
raise NotImplementedError, "SaveResult magic action not implemented"
|
442
|
+
end
|
443
|
+
|
444
|
+
def save_rx(userid, patientid, rxxml)
|
445
|
+
# Generate XML structure for rxxml
|
446
|
+
builder = Nokogiri::XML::Builder.new do |xml|
|
447
|
+
xml.saverx {
|
448
|
+
xml.field("name" => "transid", "value" => rxxml[:transid]) unless rxxml[:transid].nil?
|
449
|
+
xml.field("name" => "PharmID", "value" => rxxml[:pharmid]) unless rxxml[:pharmid].nil?
|
450
|
+
xml.field("name" => "DDI", "value" => rxxml[:ddi]) unless rxxml[:ddi].nil?
|
451
|
+
xml.field("name" => "GPPCCode", "value" => rxxml[:gppccode]) unless rxxml[:gppccode].nil?
|
452
|
+
xml.field("name" => "GPPCText", "value" => rxxml[:gppctext]) unless rxxml[:gppctext].nil?
|
453
|
+
xml.field("name" => "GPPCCustom", "value" => rxxml[:gppccustom]) unless rxxml[:gppccustom].nil?
|
454
|
+
xml.field("name" => "Sig", "value" => rxxml[:sig]) unless rxxml[:sig].nil?
|
455
|
+
xml.field("name" => "QuanPresc", "value" => rxxml[:quanpresc]) unless rxxml[:quanpresc].nil?
|
456
|
+
xml.field("name" => "Refills", "value" => rxxml[:refills]) unless rxxml[:refills].nil?
|
457
|
+
xml.field("name" => "DAW", "value" => rxxml[:daw]) unless rxxml[:daw].nil?
|
458
|
+
xml.field("name" => "DaysSupply", "value" => rxxml[:dayssupply]) unless rxxml[:dayssupply].nil?
|
459
|
+
xml.field("name" => "startdate", "value" => utc_to_local(Date.parse(rxxml[:startdate].to_s))) unless rxxml[:startdate].nil?
|
460
|
+
xml.field("name" => "historicalflag", "value" => rxxml[:historicalflag]) unless rxxml[:historicalflag].nil?
|
461
|
+
}
|
462
|
+
end
|
463
|
+
|
464
|
+
magic_parameters = {
|
465
|
+
:action => "SaveRX",
|
466
|
+
:userid => userid,
|
467
|
+
:patientid => patientid,
|
468
|
+
:parameter1 => nokogiri_to_string(builder)
|
469
|
+
}
|
470
|
+
magic(magic_parameters)
|
471
|
+
end
|
472
|
+
|
473
|
+
def save_simple_encounter
|
474
|
+
raise NotImplementedError, "SaveSimpleEncounter magic action not implemented"
|
475
|
+
end
|
476
|
+
|
477
|
+
def save_simple_rx
|
478
|
+
raise NotImplementedError, "SaveSimpleRX magic action not implemented"
|
479
|
+
end
|
480
|
+
|
481
|
+
def save_specialist
|
482
|
+
raise NotImplementedError, "SaveSpecialist magic action not implemented"
|
483
|
+
end
|
484
|
+
|
485
|
+
def save_task(userid, patientid, task_type = nil, target_user = nil, work_object_id = nil, comments = nil)
|
486
|
+
if task_type.nil? && target_user.nil? && work_object_id.nil? && comments.nil?
|
487
|
+
raise ArugmentError, "task_type, target_user, work_object_id, and comments can not all be nil"
|
488
|
+
end
|
489
|
+
|
490
|
+
magic_parameters = {
|
491
|
+
:action => "SaveTask",
|
492
|
+
:userid => userid,
|
493
|
+
:patientid => patientid,
|
494
|
+
:parameter1 => task_type,
|
495
|
+
:parameter2 => target_user,
|
496
|
+
:parameter3 => work_object_id,
|
497
|
+
:parameter4 => comments
|
498
|
+
}
|
499
|
+
magic(magic_parameters)
|
500
|
+
end
|
501
|
+
|
502
|
+
def save_task_status(userid, transaction_id = nil, status = nil, delegate_id = nil, comment = nil)
|
503
|
+
if transaction_id.nil? && param.nil? && delegate_id.nil? && comment.nil?
|
504
|
+
raise ArugmentError, "task_type, target_user, work_object_id, and comments can not all be nil"
|
505
|
+
end
|
506
|
+
|
507
|
+
magic_parameters = {
|
508
|
+
:action => "SaveTaskStatus",
|
509
|
+
:userid => userid,
|
510
|
+
:parameter1 => transaction_id,
|
511
|
+
:parameter2 => status,
|
512
|
+
:parameter3 => delegate_id,
|
513
|
+
:parameter4 => comment
|
514
|
+
}
|
515
|
+
magic(magic_parameters)
|
516
|
+
end
|
517
|
+
|
518
|
+
def save_tiff
|
519
|
+
raise NotImplementedError, "SaveTiff magic action not implemented"
|
520
|
+
end
|
521
|
+
|
522
|
+
def save_unstructured_document
|
523
|
+
raise NotImplementedError, "SaveUnstructuredDocument magic action not implemented"
|
524
|
+
end
|
525
|
+
|
526
|
+
def save_v10_doc_signature
|
527
|
+
raise NotImplementedError, "SaveV10DocSignature magic action not implemented"
|
528
|
+
end
|
529
|
+
|
530
|
+
def save_v11_note
|
531
|
+
raise NotImplementedError, "SaveV11Note magic action not implemented"
|
532
|
+
end
|
533
|
+
|
534
|
+
def save_vitals
|
535
|
+
raise NotImplementedError, "SaveVitals magic action not implemented"
|
536
|
+
end
|
537
|
+
|
538
|
+
def save_vitals_data
|
539
|
+
raise NotImplementedError, "SaveVitalsData magic action not implemented"
|
540
|
+
end
|
541
|
+
|
542
|
+
def search_charge_codes
|
543
|
+
raise NotImplementedError, "SearchChargeCodes magic action not implemented"
|
544
|
+
end
|
545
|
+
|
546
|
+
def search_diagnosis_codes
|
547
|
+
raise NotImplementedError, "SearchDiagnosisCodes magic action not implemented"
|
548
|
+
end
|
549
|
+
|
550
|
+
def search_meds(userid, patientid, search = nil)
|
551
|
+
magic_parameters = {
|
552
|
+
:action => "SearchMeds",
|
553
|
+
:userid => userid,
|
554
|
+
:patientid => patientid,
|
555
|
+
:parameter1 => search
|
556
|
+
}
|
557
|
+
magic(magic_parameters)
|
558
|
+
end
|
559
|
+
|
560
|
+
def search_patients
|
561
|
+
raise NotImplementedError, "SearchPatients magic action not implemented"
|
562
|
+
end
|
563
|
+
|
564
|
+
def search_patients_rxhub5
|
565
|
+
raise NotImplementedError, "SearchPatientsRXHub5 magic action not implemented"
|
566
|
+
end
|
567
|
+
|
568
|
+
def search_pharmacies
|
569
|
+
raise NotImplementedError, "SearchPharmacies magic action not implemented"
|
570
|
+
end
|
571
|
+
|
572
|
+
def search_problem_codes
|
573
|
+
raise NotImplementedError, "SearchProblemCodes magic action not implemented"
|
574
|
+
end
|
575
|
+
|
576
|
+
def update_encounter
|
577
|
+
raise NotImplementedError, "UpdateEncounter magic action not implemented"
|
578
|
+
end
|
579
|
+
|
580
|
+
def update_order
|
581
|
+
raise NotImplementedError, "UpdateOrder magic action not implemented"
|
582
|
+
end
|
583
|
+
|
584
|
+
def update_referral_order_status
|
585
|
+
raise NotImplementedError, "UpdateReferralOrderStatus magic action not implemented"
|
586
|
+
end
|
587
|
+
|
588
|
+
private
|
589
|
+
|
590
|
+
def nokogiri_to_string(builder)
|
591
|
+
builder.to_xml(:save_with => Nokogiri::XML::Node::SaveOptions::AS_XML | Nokogiri::XML::Node::SaveOptions::NO_DECLARATION).strip
|
592
|
+
end
|
593
|
+
end
|
594
|
+
end
|