pokitdok-ruby 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Dockerfile-1.9 +2 -0
- data/Dockerfile-2.0 +2 -0
- data/Dockerfile-2.1 +2 -0
- data/Dockerfile-2.2 +2 -0
- data/Dockerfile-2.3 +2 -0
- data/Dockerfile-J9.1 +2 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +46 -8
- data/README.md +49 -10
- data/VERSION +1 -1
- data/examples/quick_start.rb +45 -0
- data/lib/OAuthApplicationClient.rb +2 -3
- data/lib/pokitdok.rb +259 -126
- data/pokitdok-ruby.gemspec +15 -7
- data/run_tests_in_docker.sh +6 -0
- data/spec/fixtures/test_claim.837 +1 -0
- data/spec/pokitdok_spec.rb +567 -631
- data/spec/spec_helper.rb +0 -1
- metadata +25 -17
- data/.travis.yml +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b39ac044a97e9ac83136372927fe6c5bfa6870b9
|
4
|
+
data.tar.gz: 21f88737cc7b018516557e852a0e4442592907cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 729e896046445e051c1f85592df8d7a53d084f2639cf7cb800ba3350140b242d5814f133a6b8209b4265e8ebad4ac818aeab0a2c3e658ca8d685b12a8625ce1b
|
7
|
+
data.tar.gz: 9ba4038b4f3c01de58be59952063e80b292feb62228c366689dd66e0b1f3c82c84f3935b01b4f16888073865c5c6878d0961c503c9744e160883918dbcc80ffe
|
data/Dockerfile-1.9
ADDED
data/Dockerfile-2.0
ADDED
data/Dockerfile-2.1
ADDED
data/Dockerfile-2.2
ADDED
data/Dockerfile-2.3
ADDED
data/Dockerfile-J9.1
ADDED
data/Gemfile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
gem 'oauth2', '~> 1.0', require: 'oauth2'
|
3
3
|
gem 'multipart-post', '~> 2.0'
|
4
|
+
gem 'dotenv-rails', groups: [:development, :test]
|
4
5
|
|
5
6
|
group :development do
|
6
7
|
gem 'bundler', '~> 1.0'
|
@@ -12,7 +13,6 @@ group :development do
|
|
12
13
|
gem 'jeweler', '~> 2.0'
|
13
14
|
gem 'ansi', '~> 1.4'
|
14
15
|
gem 'minitest-reporters', '~> 1.0'
|
15
|
-
gem 'webmock', '~> 1.17'
|
16
16
|
gem 'guard', '~> 2.6'
|
17
17
|
gem 'guard-minitest', '~> 2.2'
|
18
18
|
gem 'terminal-notifier'
|
data/Gemfile.lock
CHANGED
@@ -1,6 +1,25 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
+
actionpack (4.2.7.1)
|
5
|
+
actionview (= 4.2.7.1)
|
6
|
+
activesupport (= 4.2.7.1)
|
7
|
+
rack (~> 1.6)
|
8
|
+
rack-test (~> 0.6.2)
|
9
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
10
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
11
|
+
actionview (4.2.7.1)
|
12
|
+
activesupport (= 4.2.7.1)
|
13
|
+
builder (~> 3.1)
|
14
|
+
erubis (~> 2.7.0)
|
15
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
16
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
17
|
+
activesupport (4.2.7.1)
|
18
|
+
i18n (~> 0.7)
|
19
|
+
json (~> 1.7, >= 1.7.7)
|
20
|
+
minitest (~> 5.1)
|
21
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
22
|
+
tzinfo (~> 1.1)
|
4
23
|
addressable (2.4.0)
|
5
24
|
ansi (1.5.0)
|
6
25
|
ast (2.0.0)
|
@@ -16,13 +35,16 @@ GEM
|
|
16
35
|
simplecov (~> 0.10.0)
|
17
36
|
term-ansicolor (~> 1.3)
|
18
37
|
thor (~> 0.19.1)
|
19
|
-
crack (0.4.2)
|
20
|
-
safe_yaml (~> 1.0.0)
|
21
38
|
descendants_tracker (0.0.4)
|
22
39
|
thread_safe (~> 0.3, >= 0.3.1)
|
23
40
|
docile (1.1.5)
|
24
41
|
domain_name (0.5.24)
|
25
42
|
unf (>= 0.0.5, < 1.0.0)
|
43
|
+
dotenv (2.2.0)
|
44
|
+
dotenv-rails (2.2.0)
|
45
|
+
dotenv (= 2.2.0)
|
46
|
+
railties (>= 3.2, < 5.1)
|
47
|
+
erubis (2.7.0)
|
26
48
|
faraday (0.9.2)
|
27
49
|
multipart-post (>= 1.2, < 3)
|
28
50
|
ffi (1.9.8)
|
@@ -57,6 +79,7 @@ GEM
|
|
57
79
|
hitimes (1.2.2-java)
|
58
80
|
http-cookie (1.0.2)
|
59
81
|
domain_name (~> 0.5)
|
82
|
+
i18n (0.8.0)
|
60
83
|
jeweler (2.1.1)
|
61
84
|
builder
|
62
85
|
bundler (>= 1.0)
|
@@ -74,6 +97,8 @@ GEM
|
|
74
97
|
celluloid (~> 0.16.0)
|
75
98
|
rb-fsevent (>= 0.9.3)
|
76
99
|
rb-inotify (>= 0.9)
|
100
|
+
loofah (2.0.3)
|
101
|
+
nokogiri (>= 1.5.9)
|
77
102
|
lumberjack (1.0.9)
|
78
103
|
metaclass (0.0.4)
|
79
104
|
method_source (0.8.2)
|
@@ -119,6 +144,21 @@ GEM
|
|
119
144
|
slop (~> 3.4)
|
120
145
|
spoon (~> 0.0)
|
121
146
|
rack (1.6.4)
|
147
|
+
rack-test (0.6.3)
|
148
|
+
rack (>= 1.0)
|
149
|
+
rails-deprecated_sanitizer (1.0.3)
|
150
|
+
activesupport (>= 4.2.0.alpha)
|
151
|
+
rails-dom-testing (1.0.8)
|
152
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
153
|
+
nokogiri (~> 1.6)
|
154
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
155
|
+
rails-html-sanitizer (1.0.3)
|
156
|
+
loofah (~> 2.0)
|
157
|
+
railties (4.2.7.1)
|
158
|
+
actionpack (= 4.2.7.1)
|
159
|
+
activesupport (= 4.2.7.1)
|
160
|
+
rake (>= 0.8.7)
|
161
|
+
thor (>= 0.18.1, < 2.0)
|
122
162
|
rainbow (2.0.0)
|
123
163
|
rake (11.2.2)
|
124
164
|
rb-fsevent (0.9.5)
|
@@ -137,7 +177,6 @@ GEM
|
|
137
177
|
rainbow (>= 1.99.1, < 3.0)
|
138
178
|
ruby-progressbar (~> 1.4)
|
139
179
|
ruby-progressbar (1.7.5)
|
140
|
-
safe_yaml (1.0.4)
|
141
180
|
semver (1.0.1)
|
142
181
|
shellany (0.0.1)
|
143
182
|
simplecov (0.10.0)
|
@@ -158,13 +197,12 @@ GEM
|
|
158
197
|
timers (4.0.1)
|
159
198
|
hitimes
|
160
199
|
tins (1.5.1)
|
200
|
+
tzinfo (1.2.2)
|
201
|
+
thread_safe (~> 0.1)
|
161
202
|
unf (0.1.4)
|
162
203
|
unf_ext
|
163
204
|
unf (0.1.4-java)
|
164
205
|
unf_ext (0.0.7.1)
|
165
|
-
webmock (1.21.0)
|
166
|
-
addressable (>= 2.3.6)
|
167
|
-
crack (>= 0.3.2)
|
168
206
|
|
169
207
|
PLATFORMS
|
170
208
|
java
|
@@ -174,6 +212,7 @@ DEPENDENCIES
|
|
174
212
|
ansi (~> 1.4)
|
175
213
|
bundler (~> 1.0)
|
176
214
|
coveralls
|
215
|
+
dotenv-rails
|
177
216
|
guard (~> 2.6)
|
178
217
|
guard-minitest (~> 2.2)
|
179
218
|
guard-rubocop (~> 1.0)
|
@@ -188,7 +227,6 @@ DEPENDENCIES
|
|
188
227
|
simplecov (~> 0.8)
|
189
228
|
terminal-notifier
|
190
229
|
terminal-notifier-guard (~> 1.5)
|
191
|
-
webmock (~> 1.17)
|
192
230
|
|
193
231
|
BUNDLED WITH
|
194
|
-
1.
|
232
|
+
1.14.3
|
data/README.md
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
[](https://travis-ci.org/pokitdok/pokitdok-ruby)
|
2
1
|
[](http://badge.fury.io/rb/pokitdok-ruby)
|
3
2
|
[](https://www.versioneye.com/user/projects/538e498b46c4739edd0000ee)
|
4
3
|
|
@@ -19,11 +18,44 @@ PokitDok Platform API Client for Ruby
|
|
19
18
|
|
20
19
|
## Installation
|
21
20
|
gem install pokitdok-ruby
|
21
|
+
|
22
|
+
## Client ID and Secret Keys
|
23
|
+
Always use environment variables to store your PokitDok client and secret keys. To do so,
|
24
|
+
we recommmend either using `dotenv` or setting plain old Linux OS environment variables. The dotenv gem is very
|
25
|
+
similar to Figaro, except it loads environment variables from .env, and it doesn't use YAML.
|
26
|
+
|
27
|
+
To use `dotenv`, just install the gem by adding to your Gemfile:
|
28
|
+
```
|
29
|
+
gem 'dotenv-rails', groups: [:development, :test]
|
30
|
+
```
|
31
|
+
|
32
|
+
And add your configuration values to a `.env` file. Make sure you git ignore the file so that you don't
|
33
|
+
accidentally publish it to github:
|
34
|
+
```
|
35
|
+
POKITDOK_CLIENT_ID=your_client_id
|
36
|
+
POKITDOK_CLIENT_SECRET=your_secret_id
|
37
|
+
```
|
38
|
+
You can then access the values in your Ruby ENV hash
|
39
|
+
```
|
40
|
+
require 'dotenv'
|
41
|
+
Dotenv.load
|
42
|
+
client_id = ENV["POKITDOK_CLIENT_ID"]
|
43
|
+
client_secret = ENV["POKITDOK_CLIENT_SECRET"]
|
44
|
+
```
|
45
|
+
|
46
|
+
It's also possible to maintain unique sets of environment variables per app using basic linux commands.
|
47
|
+
One approach is to have each app running on your server be owned by a different user. You can then use the user's `.bashrc`
|
48
|
+
to store application-specific values.
|
22
49
|
|
23
50
|
## Quick Start
|
24
51
|
```ruby
|
25
52
|
require 'pokitdok'
|
26
|
-
|
53
|
+
require 'dotenv'
|
54
|
+
Dotenv.load
|
55
|
+
|
56
|
+
client_id = ENV["POKITDOK_CLIENT_ID"]
|
57
|
+
client_secret = ENV["POKITDOK_CLIENT_SECRET"]
|
58
|
+
pd = PokitDok::PokitDok.new(client_id, client_secret)
|
27
59
|
|
28
60
|
# Retrieve provider information by NPI
|
29
61
|
pd.providers(npi: '1467560003')
|
@@ -126,14 +158,21 @@ pd.request('/ssl/')
|
|
126
158
|
```
|
127
159
|
|
128
160
|
## Supported Ruby Versions
|
129
|
-
This library aims to support and is tested against these Ruby versions
|
130
|
-
|
131
|
-
|
132
|
-
* 2.
|
133
|
-
* 2.
|
134
|
-
* 2.
|
135
|
-
*
|
136
|
-
*
|
161
|
+
This library aims to support and is tested against these Ruby versions using the official [Docker Image packing for Ruby](https://github.com/docker-library/ruby).
|
162
|
+
To use the Dockerfile within this project to run the tests, please head over to the [Docker Install Guide](https://docs.docker.com/engine/installation/)
|
163
|
+
|
164
|
+
* 2.3
|
165
|
+
* 2.2
|
166
|
+
* 2.1
|
167
|
+
* 2.0
|
168
|
+
* 1.9
|
169
|
+
* JRuby 9.1 (which is running Ruby 2.3.1)
|
170
|
+
|
171
|
+
To execute the tests against those versions within a Docker Container, build the image and the tests will execute on build:
|
172
|
+
```shell
|
173
|
+
|
174
|
+
docker build .
|
175
|
+
```
|
137
176
|
|
138
177
|
You may have luck with other interpreters - let us know how it goes.
|
139
178
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.9.0
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'pokitdok'
|
2
|
+
require 'dotenv'
|
3
|
+
Dotenv.load
|
4
|
+
|
5
|
+
########################
|
6
|
+
# make a .env file at the top of your project with
|
7
|
+
# POKITDOK_CLIENT_ID=your_client_id
|
8
|
+
# POKITDOK_CLIENT_SECRET=your_secret_id
|
9
|
+
########################
|
10
|
+
|
11
|
+
client_id = ENV["POKITDOK_CLIENT_ID"]
|
12
|
+
client_secret = ENV["POKITDOK_CLIENT_SECRET"]
|
13
|
+
pd = PokitDok::PokitDok.new(client_id, client_secret)
|
14
|
+
|
15
|
+
# Retrieve provider information by NPI
|
16
|
+
pd.providers(npi: '1467560003')
|
17
|
+
|
18
|
+
# Search providers by name (individuals)
|
19
|
+
pd.providers(first_name: 'JEROME', last_name: 'AYA-AY')
|
20
|
+
|
21
|
+
# Search providers by name (organizations)
|
22
|
+
pd.providers(name: 'Qliance')
|
23
|
+
|
24
|
+
# Search providers by location and/or specialty
|
25
|
+
pd.providers(zipcode: '29307', radius: '10mi')
|
26
|
+
pd.providers(zipcode: '29307', radius: '10mi', specialty: 'RHEUMATOLOGY')
|
27
|
+
|
28
|
+
# Eligibility
|
29
|
+
@eligibility_query = {
|
30
|
+
member: {
|
31
|
+
birth_date: '1970-01-01',
|
32
|
+
first_name: 'Jane',
|
33
|
+
last_name: 'Doe',
|
34
|
+
id: 'W000000000'
|
35
|
+
},
|
36
|
+
provider: {
|
37
|
+
first_name: 'JEROME',
|
38
|
+
last_name: 'AYA-AY',
|
39
|
+
npi: '1467560003'
|
40
|
+
},
|
41
|
+
service_types: ['health_benefit_plan_coverage'],
|
42
|
+
trading_partner_id: 'MOCKPAYER'
|
43
|
+
}
|
44
|
+
|
45
|
+
pd.eligibility @eligibility_query
|
@@ -77,17 +77,16 @@ class OAuthApplicationClient
|
|
77
77
|
fetch_access_token()
|
78
78
|
end
|
79
79
|
url = URI.parse(@api_url + endpoint)
|
80
|
-
|
81
80
|
File.open(file) do |f|
|
82
81
|
additional_params = params.merge({'file' => UploadIO.new(f, 'application/EDI-X12', file)})
|
83
82
|
req = Net::HTTP::Post::Multipart.new(url.path, additional_params)
|
84
|
-
|
85
83
|
req['Authorization'] = "Bearer #{self.token.token}"
|
86
84
|
req['User-Agent'] = @user_agent
|
87
85
|
|
88
|
-
@response = Net::HTTP.start(url.host, url.port) do |http|
|
86
|
+
@response = Net::HTTP.start(url.host, url.port, :use_ssl => true) do |http|
|
89
87
|
http.request(req)
|
90
88
|
end
|
89
|
+
@status_code = @response.code.to_i
|
91
90
|
JSON.parse(@response.body)
|
92
91
|
end
|
93
92
|
end
|
data/lib/pokitdok.rb
CHANGED
@@ -20,6 +20,7 @@ module PokitDok
|
|
20
20
|
attr_reader :api_client # :nodoc:
|
21
21
|
attr_reader :api_url
|
22
22
|
attr_reader :version
|
23
|
+
attr_reader :status_code
|
23
24
|
|
24
25
|
# Connect to the PokitDok API with the specified Client ID and Client
|
25
26
|
# Secret.
|
@@ -35,35 +36,109 @@ module PokitDok
|
|
35
36
|
redirect_uri=nil, scope= nil, code=nil, token= nil)
|
36
37
|
@version = version
|
37
38
|
@api_url = "#{base}/api/#{version}"
|
38
|
-
@user_agent = "pokitdok-ruby
|
39
|
-
|
39
|
+
@user_agent = "pokitdok-ruby#0.9.0##{Gem::Platform.local.os}##{Gem::Platform.local.version}"
|
40
40
|
super(client_id, client_secret, '/oauth2/token', redirect_uri, scope, code, token, user_agent)
|
41
41
|
end
|
42
42
|
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
43
|
+
#
|
44
|
+
# ******************************
|
45
|
+
# General Use APIs
|
46
|
+
# ******************************
|
47
|
+
#
|
48
|
+
|
49
|
+
# Invokes the the general request method for submitting API request.
|
50
|
+
#
|
51
|
+
# +endpoint+ the API request path
|
52
|
+
# +method+ the http request method that should be used
|
53
|
+
# +file+ file when the API accepts file uploads as input
|
54
|
+
# +params+ an optional Hash of parameters
|
55
|
+
#
|
56
|
+
# NOTE: There might be a better way of achieving the seperation of get/get_request
|
57
|
+
# but currently using the "send" method will go down the ancestor chain until the correct
|
58
|
+
# method is found. In this case the 'httpMethod'_request
|
59
|
+
def request(endpoint, method='get', file=nil, params={})
|
60
|
+
method = method.downcase
|
61
|
+
if file
|
62
|
+
self.send("post_file", endpoint, file)
|
63
|
+
else
|
64
|
+
if endpoint[0] == '/'
|
65
|
+
endpoint[0] = ''
|
66
|
+
end
|
67
|
+
# Work around to delete the leading slash on the request endpoint
|
68
|
+
# Currently the module we're using appends a slash to the base url
|
69
|
+
# so an additional url will break the request.
|
70
|
+
# Refer to ...faraday/connection.rb L#404
|
71
|
+
self.send("#{method}_request", endpoint, params)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
public
|
76
|
+
def get(endpoint, params = {})
|
77
|
+
response = request(endpoint, 'GET', nil, params)
|
78
|
+
@status_code = response.status
|
79
|
+
JSON.parse(response.body)
|
80
|
+
end
|
81
|
+
|
82
|
+
def post(endpoint, params = {})
|
83
|
+
response = request(endpoint, 'POST', nil, params)
|
84
|
+
@status_code = response.status
|
85
|
+
JSON.parse(response.body)
|
86
|
+
end
|
87
|
+
|
88
|
+
def put(endpoint, params = {})
|
89
|
+
response = request(endpoint, 'PUT', nil, params)
|
90
|
+
@status_code = response.status
|
91
|
+
JSON.parse(response.body)
|
92
|
+
end
|
93
|
+
|
94
|
+
def delete(endpoint, params = {})
|
95
|
+
response = request(endpoint, 'DELETE', nil, params)
|
96
|
+
@status_code = response.status
|
97
|
+
if response.body.empty?
|
98
|
+
response.status == 204
|
99
|
+
else
|
100
|
+
JSON.parse(response.body)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Invokes the activities endpoint.
|
105
|
+
#
|
106
|
+
# This endpoint uses the user_schedule OAuth2 scope. You'll need to
|
107
|
+
# get the user's authorization via our OAuth2 provider
|
46
108
|
#
|
47
109
|
# +params+ an optional Hash of parameters
|
48
110
|
#
|
49
|
-
def activities(params = {})
|
50
|
-
|
111
|
+
def activities(activity_id = nil, params = {})
|
112
|
+
activities_endpoint = 'activities/'
|
113
|
+
if activity_id
|
114
|
+
activities_endpoint = "activities/#{activity_id}" + activity_id.to_s
|
115
|
+
end
|
116
|
+
get(activities_endpoint, params)
|
51
117
|
end
|
52
118
|
|
53
|
-
# Invokes the
|
119
|
+
# Invokes the trading partners endpoint.
|
54
120
|
#
|
55
|
-
# +params+ an optional
|
121
|
+
# +params+ an optional Hash of parameters
|
56
122
|
#
|
57
|
-
def
|
58
|
-
|
123
|
+
def trading_partners(trading_partner_id = nil, params = {})
|
124
|
+
if params
|
125
|
+
trading_partner_id = params.delete :trading_partner_id
|
126
|
+
end
|
127
|
+
get("tradingpartners/#{trading_partner_id}")
|
59
128
|
end
|
60
129
|
|
61
|
-
#
|
130
|
+
#
|
131
|
+
# ******************************
|
132
|
+
# X12 API Convenience Functions
|
133
|
+
# ******************************
|
134
|
+
#
|
135
|
+
|
136
|
+
# Invokes the authorizations endpoint: Submit an authorization request
|
62
137
|
#
|
63
138
|
# +params+ an optional hash of parameters that will be sent in the POST body
|
64
139
|
#
|
65
|
-
def
|
66
|
-
|
140
|
+
def authorizations(params = {})
|
141
|
+
post('authorizations/', params)
|
67
142
|
end
|
68
143
|
|
69
144
|
# Invokes the claims endpoint.
|
@@ -82,24 +157,8 @@ module PokitDok
|
|
82
157
|
post('claims/status', params)
|
83
158
|
end
|
84
159
|
|
85
|
-
# Invokes the ICD convert endpoint.
|
86
|
-
#
|
87
|
-
# +params+ an optional hash of parameters
|
88
|
-
#
|
89
|
-
def icd_convert(params = {})
|
90
|
-
get("icd/convert/#{params[:code]}")
|
91
|
-
end
|
92
|
-
|
93
|
-
# Invokes the mpc endpoint.
|
94
|
-
#
|
95
|
-
# +params+ an optional hash of parameters
|
96
|
-
#
|
97
|
-
def mpc(params = {})
|
98
|
-
get('mpc/', params)
|
99
|
-
end
|
100
|
-
|
101
160
|
# Uploads an .837 file to the claims convert endpoint.
|
102
|
-
# Uses the multipart-post gem, since oauth2
|
161
|
+
# Uses the multipart-post gem, since oauth2 adoesn't support multipart.
|
103
162
|
#
|
104
163
|
# +x12_claims_file+ the path to the file to transmit
|
105
164
|
#
|
@@ -120,6 +179,7 @@ module PokitDok
|
|
120
179
|
# +params+ an optional hash of parameters that will be sent in the POST body
|
121
180
|
#
|
122
181
|
def enrollment(params = {})
|
182
|
+
warn "[DEPRECATION] ` enrollment will be removed in the next release"
|
123
183
|
post('enrollment/', params)
|
124
184
|
end
|
125
185
|
|
@@ -130,6 +190,7 @@ module PokitDok
|
|
130
190
|
# +x12_file+ the path to the file to transmit
|
131
191
|
#
|
132
192
|
def enrollment_snapshot(trading_partner_id, x12_file)
|
193
|
+
warn "[DEPRECATION] ` enrollment_snapshot will be removed in the next release"
|
133
194
|
request("/enrollment/snapshot/#{trading_partner_id}", "POST", x12_file)
|
134
195
|
end
|
135
196
|
|
@@ -138,6 +199,7 @@ module PokitDok
|
|
138
199
|
# +params+ an optional Hash of parameters
|
139
200
|
#
|
140
201
|
def enrollment_snapshots(params = {})
|
202
|
+
warn "[DEPRECATION] ` enrollment_snapshots will be removed in the next release"
|
141
203
|
snapshot_id = params.delete :snapshot_id
|
142
204
|
get("enrollment/snapshot" + (snapshot_id ? "/#{snapshot_id}" : ''), params)
|
143
205
|
end
|
@@ -147,9 +209,48 @@ module PokitDok
|
|
147
209
|
# +params+ an optional Hash of parameters
|
148
210
|
#
|
149
211
|
def enrollment_snapshot_data(params = {})
|
212
|
+
warn "[DEPRECATION] ` enrollment_snapshot_data will be removed in the next release"
|
150
213
|
get("enrollment/snapshot/#{params[:snapshot_id]}/data")
|
151
214
|
end
|
152
215
|
|
216
|
+
# Invokes the referrals endpoint.
|
217
|
+
#
|
218
|
+
# +params+ an optional Hash of parameters
|
219
|
+
#
|
220
|
+
def referrals(params = {})
|
221
|
+
post('referrals/', params)
|
222
|
+
end
|
223
|
+
|
224
|
+
|
225
|
+
#
|
226
|
+
# ******************************
|
227
|
+
# DATA API Convenience Functions
|
228
|
+
# ******************************
|
229
|
+
#
|
230
|
+
|
231
|
+
# Invokes the cash prices endpoint.
|
232
|
+
#
|
233
|
+
# +params+ an optional hash of parameters that will be sent in the POST body
|
234
|
+
#
|
235
|
+
def cash_prices(params = {})
|
236
|
+
get('prices/cash', params)
|
237
|
+
end
|
238
|
+
|
239
|
+
# Invokes the ICD convert endpoint.
|
240
|
+
#
|
241
|
+
# +params+ an optional hash of parameters
|
242
|
+
#
|
243
|
+
def icd_convert(params = {})
|
244
|
+
get("icd/convert/#{params[:code]}")
|
245
|
+
end
|
246
|
+
|
247
|
+
# Invokes the mpc endpoint.
|
248
|
+
#
|
249
|
+
# +params+ an optional hash of parameters
|
250
|
+
#
|
251
|
+
def mpc(params = {})
|
252
|
+
get('mpc/', params)
|
253
|
+
end
|
153
254
|
# Invokes the insurance prices endpoint.
|
154
255
|
#
|
155
256
|
# +params+ an optional hash of parameters
|
@@ -158,11 +259,30 @@ module PokitDok
|
|
158
259
|
get('prices/insurance', params)
|
159
260
|
end
|
160
261
|
|
262
|
+
# Invokes the insurance price estimate endpoint
|
263
|
+
# Returns estimated out of pocket cost and eligibility information for a given procedure
|
264
|
+
#
|
265
|
+
# +params+ an optional hash of parameters
|
266
|
+
#
|
267
|
+
def oop_insurance_estimate(params = {})
|
268
|
+
post("/oop/insurance-estimate", params)
|
269
|
+
end
|
270
|
+
|
271
|
+
# Invokes the insurance load price endpoint
|
272
|
+
# Loads procedure prices for a specific trading partner
|
273
|
+
#
|
274
|
+
# +params+ an optional hash of parameters
|
275
|
+
#
|
276
|
+
def oop_insurance_prices(params = {})
|
277
|
+
post("/oop/insurance-load-price", params)
|
278
|
+
end
|
279
|
+
|
161
280
|
# Invokes the payers endpoint.
|
162
281
|
#
|
163
282
|
# +params+ an optional hash of parameters
|
164
283
|
#
|
165
284
|
def payers(params = {})
|
285
|
+
warn "[DEPRECATION] `payers` will be deprecated in the next release. Please use `trading_partners` instead."
|
166
286
|
get('payers/', params)
|
167
287
|
end
|
168
288
|
|
@@ -182,25 +302,43 @@ module PokitDok
|
|
182
302
|
get('providers/', params)
|
183
303
|
end
|
184
304
|
|
185
|
-
#
|
305
|
+
#
|
306
|
+
# ******************************
|
307
|
+
# Pharmacy API Convenience Functions
|
308
|
+
# ******************************
|
309
|
+
#
|
310
|
+
|
311
|
+
# Invokes the pharmacy plans endpoint.
|
186
312
|
#
|
187
313
|
# +params+ an optional Hash of parameters
|
188
314
|
#
|
189
|
-
def
|
190
|
-
|
315
|
+
def pharmacy_plans(params = {})
|
316
|
+
get('pharmacy/plans', params)
|
191
317
|
end
|
192
318
|
|
193
|
-
# Invokes the
|
319
|
+
# Invokes the pharmacy formulary endpoint.
|
194
320
|
#
|
195
321
|
# +params+ an optional Hash of parameters
|
196
322
|
#
|
197
|
-
def
|
198
|
-
|
199
|
-
get("tradingpartners/#{trading_partner_id}")
|
323
|
+
def pharmacy_formulary(params = {})
|
324
|
+
get('pharmacy/formulary', params)
|
200
325
|
end
|
201
326
|
|
202
|
-
#
|
327
|
+
# Invokes the pharmacy network cost endpoint.
|
328
|
+
#
|
329
|
+
# +params+ an optional Hash of parameters
|
330
|
+
#
|
331
|
+
def pharmacy_network(params = {})
|
332
|
+
npi = params.delete :npi
|
333
|
+
endpoint = npi ? "pharmacy/network/#{npi}" : "pharmacy/network"
|
334
|
+
get(endpoint, params)
|
335
|
+
end
|
203
336
|
|
337
|
+
#
|
338
|
+
# ******************************
|
339
|
+
# Scheduling API Convenience Functions
|
340
|
+
# ******************************
|
341
|
+
#
|
204
342
|
# Invokes the appointments endpoint to query for an open appointment
|
205
343
|
# slot or a booked appointment given a specific pd_appointment_uuid,
|
206
344
|
# the PokitDok unique appointment identifier.
|
@@ -208,19 +346,34 @@ module PokitDok
|
|
208
346
|
# +params+ an optional Hash of parameters
|
209
347
|
#
|
210
348
|
def appointment(params = {})
|
349
|
+
warn "[DEPRECATION] `appointment` will be deprecated in the next release. Please use `appointment_types` instead."
|
211
350
|
appointment_id = params.delete :appointment_id
|
212
351
|
get("schedule/appointmenttypes/#{appointment_id}", params)
|
213
352
|
end
|
214
353
|
|
215
|
-
# Invokes the
|
354
|
+
# Invokes the appointments endpoint, to query for open appointment slots
|
355
|
+
# (using pd_provider_uuid and location) or booked appointments (using
|
356
|
+
# patient_uuid).
|
216
357
|
#
|
217
|
-
#
|
218
|
-
#
|
358
|
+
# +params+ an optional Hash of parameters
|
359
|
+
#
|
360
|
+
def get_appointments(appointment_uuid=nil, params = {})
|
361
|
+
endpoint = "schedule/appointments/"
|
362
|
+
if appointment_uuid
|
363
|
+
endpoint = "schedule/appointments/#{appointment_uuid}"
|
364
|
+
end
|
365
|
+
get(endpoint, params)
|
366
|
+
end
|
367
|
+
|
368
|
+
# Invokes the appointments endpoint, to query for open appointment slots
|
369
|
+
# (using pd_provider_uuid and location) or booked appointments (using
|
370
|
+
# patient_uuid).
|
219
371
|
#
|
220
372
|
# +params+ an optional Hash of parameters
|
221
373
|
#
|
222
|
-
def appointments(params = {})
|
223
|
-
|
374
|
+
def appointments(appointment_uuid=nil, params = {})
|
375
|
+
warn "[DEPRECATION] `appointments` will be deprecated in the next release. Please use `get_appointments` instead."
|
376
|
+
get_appointments(params, appointment_uuid)
|
224
377
|
end
|
225
378
|
|
226
379
|
# Invokes the appointment_types endpoint, to get information on a specific
|
@@ -229,16 +382,22 @@ module PokitDok
|
|
229
382
|
# +params+ an optional Hash of parameters
|
230
383
|
#
|
231
384
|
def appointment_type(params = {})
|
385
|
+
warn "[DEPRECATION] `appointment_type` will be deprecated in the next release. Please use `appointment_types` instead."
|
232
386
|
appointment_type = params.delete :uuid
|
233
387
|
get("schedule/appointmenttypes/#{appointment_type}")
|
234
388
|
end
|
235
389
|
|
236
390
|
# Invokes the appointment_types endpoint.
|
391
|
+
# Get information about appointment types or fetch data about a specific appointment type
|
237
392
|
#
|
238
393
|
# +params+ an optional hash of parameters
|
239
394
|
#
|
240
|
-
def appointment_types(params = {})
|
241
|
-
|
395
|
+
def appointment_types(appointment_type_uuid=nil, params = {})
|
396
|
+
endpoint = "schedule/appointmenttypes/"
|
397
|
+
if appointment_type_uuid
|
398
|
+
endpoint = "schedule/appointmenttypes/#{appointment_type_uuid}"
|
399
|
+
end
|
400
|
+
get(endpoint, params)
|
242
401
|
end
|
243
402
|
|
244
403
|
# Books an appointment.
|
@@ -256,7 +415,7 @@ module PokitDok
|
|
256
415
|
#
|
257
416
|
# This endpoint uses the user_schedule OAuth2 scope. You'll need to
|
258
417
|
# get the user's authorization via our OAuth2 provider
|
259
|
-
#
|
418
|
+
#
|
260
419
|
# +params+ an optional Hash of parameters
|
261
420
|
#
|
262
421
|
def cancel_appointment(appointment_uuid, params={})
|
@@ -264,13 +423,15 @@ module PokitDok
|
|
264
423
|
end
|
265
424
|
|
266
425
|
# Invokes the schedule/appointments endpoint.
|
426
|
+
# Query for open appointment slots or retrieve information for a specific appointment
|
267
427
|
#
|
268
428
|
# This endpoint uses the user_schedule OAuth2 scope. You'll need to
|
269
429
|
# get the user's authorization via our OAuth2 provider
|
270
|
-
#
|
430
|
+
#
|
271
431
|
# +params+ an optional hash of parameters
|
272
432
|
#
|
273
433
|
def open_appointment_slots(params = {})
|
434
|
+
warn "[DEPRECATION] `open_appointment_slots` will be deprecated in the next release. Please use `get_appointments` instead."
|
274
435
|
get('schedule/appointments', params)
|
275
436
|
end
|
276
437
|
|
@@ -278,8 +439,12 @@ module PokitDok
|
|
278
439
|
#
|
279
440
|
# +params an optional Hash of parameters
|
280
441
|
#
|
281
|
-
def schedulers(params = {})
|
282
|
-
|
442
|
+
def schedulers(scheduler_uuid = nil, params = {})
|
443
|
+
endpoint = "schedule/schedulers/"
|
444
|
+
if scheduler_uuid
|
445
|
+
endpoint = "schedule/schedulers/#{scheduler_uuid}"
|
446
|
+
end
|
447
|
+
get(endpoint, params)
|
283
448
|
end
|
284
449
|
|
285
450
|
# Invokes the schedulers endpoint, to get information about a specific
|
@@ -288,6 +453,7 @@ module PokitDok
|
|
288
453
|
# +params+ an optional Hash of parameters
|
289
454
|
#
|
290
455
|
def scheduler(params = {})
|
456
|
+
warn "[DEPRECATION] `scheduler` will be deprecated in the next release. Please use `schedulers` instead."
|
291
457
|
scheduler_id = params.delete :uuid
|
292
458
|
get("schedule/schedulers/#{scheduler_id}")
|
293
459
|
end
|
@@ -296,48 +462,48 @@ module PokitDok
|
|
296
462
|
#
|
297
463
|
# This endpoint uses the user_schedule OAuth2 scope. You'll need to
|
298
464
|
# get the user's authorization via our OAuth2 provider
|
299
|
-
#
|
465
|
+
#
|
300
466
|
# +params+ an optional Hash of parameters
|
301
467
|
#
|
302
468
|
def schedule_slots(params = {})
|
303
469
|
post('/schedule/slots/', params)
|
304
470
|
end
|
305
471
|
|
306
|
-
#
|
472
|
+
# Updates the specified appointment.
|
473
|
+
#
|
474
|
+
# This endpoint uses the user_schedule OAuth2 scope. You'll need to
|
475
|
+
# get the user's authorization via our OAuth2 provider
|
307
476
|
#
|
308
477
|
# +params+ an optional Hash of parameters
|
309
478
|
#
|
310
|
-
def
|
311
|
-
|
479
|
+
def update_appointment(appointment_uuid, params={})
|
480
|
+
put("schedule/appointments/#{appointment_uuid}", params)
|
312
481
|
end
|
313
482
|
|
314
|
-
# Invokes the pharmacy formulary endpoint.
|
315
483
|
#
|
316
|
-
#
|
484
|
+
# ******************************
|
485
|
+
# Identity API Convenience Functions
|
486
|
+
# ******************************
|
317
487
|
#
|
318
|
-
def pharmacy_formulary(params = {})
|
319
|
-
get('pharmacy/formulary', params)
|
320
|
-
end
|
321
488
|
|
322
|
-
# Invokes the
|
489
|
+
# Invokes the identity proof question endpoint
|
490
|
+
# Submit a user’s response to a knowledge based authentication question
|
323
491
|
#
|
324
|
-
# +params+
|
492
|
+
# +params+ a hash of parameters that will be sent in the POST body
|
325
493
|
#
|
326
|
-
def
|
327
|
-
|
328
|
-
endpoint = npi ? "pharmacy/network/#{npi}" : "pharmacy/network"
|
329
|
-
get(endpoint, params)
|
494
|
+
def answer_proof_question(params = {})
|
495
|
+
post("/identity/proof/questions/score/", params)
|
330
496
|
end
|
331
497
|
|
332
|
-
|
498
|
+
|
499
|
+
# Invokes the identity proof questionnaire endpoint
|
500
|
+
# Validates an identity proof request and generates a
|
501
|
+
# Knowledge Based Authentication questionnaire if possible
|
333
502
|
#
|
334
|
-
#
|
335
|
-
# get the user's authorization via our OAuth2 provider
|
336
|
-
#
|
337
|
-
# +params+ an optional Hash of parameters
|
503
|
+
# +params+ a hash of parameters that will be sent in the POST body
|
338
504
|
#
|
339
|
-
def
|
340
|
-
|
505
|
+
def create_proof_questionnaire(params = {})
|
506
|
+
post("/identity/proof/questions/generate/", params)
|
341
507
|
end
|
342
508
|
|
343
509
|
# Invokes the identity endpoint for creation
|
@@ -345,7 +511,7 @@ module PokitDok
|
|
345
511
|
# +params+ a hash of parameters that will be sent in the POST body
|
346
512
|
#
|
347
513
|
def create_identity(params = {})
|
348
|
-
post(
|
514
|
+
post("identity/", params)
|
349
515
|
end
|
350
516
|
|
351
517
|
# Invokes the identity endpoint for updating
|
@@ -361,9 +527,21 @@ module PokitDok
|
|
361
527
|
#
|
362
528
|
# +params+ an optional hash of parameters that will be sent in the GET body
|
363
529
|
#
|
364
|
-
def
|
365
|
-
|
366
|
-
|
530
|
+
def get_identity(identity_uuid=nil, params = {})
|
531
|
+
endpoint = "/identity"
|
532
|
+
if identity_uuid
|
533
|
+
endpoint = "/identity#{identity_uuid}"
|
534
|
+
end
|
535
|
+
get(endpoint, params)
|
536
|
+
end
|
537
|
+
|
538
|
+
# Invokes the identity endpoint for querying
|
539
|
+
#
|
540
|
+
# +params+ an optional hash of parameters that will be sent in the GET body
|
541
|
+
#
|
542
|
+
def identity(identity_uuid=nil, params = {})
|
543
|
+
warn "[DEPRECATION] `identity` will be deprecated in the next release. Please use `get_identity` instead."
|
544
|
+
get_identity(params, identity_uuid)
|
367
545
|
end
|
368
546
|
|
369
547
|
# Invokes the identity history endpoint
|
@@ -383,59 +561,14 @@ module PokitDok
|
|
383
561
|
post("identity/match", params)
|
384
562
|
end
|
385
563
|
|
386
|
-
# Invokes the
|
564
|
+
# Invokes the validate identity endpoint
|
565
|
+
# Tests the validity of an identity through the Identity Proof api
|
566
|
+
# (our knowledge based authentication solution)
|
387
567
|
#
|
388
|
-
# +endpoint+ the API request path
|
389
|
-
# +method+ the http request method that should be used
|
390
|
-
# +file+ file when the API accepts file uploads as input
|
391
|
-
# +params+ an optional Hash of parameters
|
392
568
|
#
|
393
|
-
|
394
|
-
|
395
|
-
# method is found. In this case the 'httpMethod'_request
|
396
|
-
def request(endpoint, method='get', file=nil, params={})
|
397
|
-
method = method.downcase
|
398
|
-
if file
|
399
|
-
self.send('post_file', endpoint, file, params)
|
400
|
-
else
|
401
|
-
# Work around to delete the leading slash on the request endpoint
|
402
|
-
# Currently the module we're using appends a slash to the base url
|
403
|
-
# so an additional url will break the request.
|
404
|
-
# Refer to ...faraday/connection.rb L#404
|
405
|
-
if endpoint[0] == '/'
|
406
|
-
endpoint[0] = ''
|
407
|
-
end
|
408
|
-
self.send("#{method}_request", endpoint, params)
|
409
|
-
end
|
569
|
+
def validate_identity(params = {})
|
570
|
+
post("/identity/proof/valid/", params)
|
410
571
|
end
|
411
572
|
|
412
|
-
private
|
413
|
-
def get(endpoint, params = {})
|
414
|
-
response = request(endpoint, 'GET', nil, params)
|
415
|
-
|
416
|
-
JSON.parse(response.body)
|
417
|
-
end
|
418
|
-
|
419
|
-
def post(endpoint, params = {})
|
420
|
-
response = request(endpoint, 'POST', nil, params)
|
421
|
-
|
422
|
-
JSON.parse(response.body)
|
423
|
-
end
|
424
|
-
|
425
|
-
def put(endpoint, params = {})
|
426
|
-
response = request(endpoint, 'PUT', nil, params)
|
427
|
-
|
428
|
-
JSON.parse(response.body)
|
429
|
-
end
|
430
|
-
|
431
|
-
def delete(endpoint, params = {})
|
432
|
-
response = request(endpoint, 'DELETE', nil, params)
|
433
|
-
|
434
|
-
if response.body.empty?
|
435
|
-
response.status == 204
|
436
|
-
else
|
437
|
-
JSON.parse(response.body)
|
438
|
-
end
|
439
|
-
end
|
440
573
|
end
|
441
574
|
end
|