pokitdok-ruby 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b98345c45efe8a25ddc256e9d307c345b340c20
4
+ data.tar.gz: f69095d7412c999eed38f5a95cbf6c11a0f9ca51
5
+ SHA512:
6
+ metadata.gz: 8eb6c6ae134c48789095fd59585dbb8087faa8fd05db0715c6a11ffc7dd27ffbc8db94f90649f3ed77fc3992dfbbddc63b630b30abf73362fd1bbe379af5b0a9
7
+ data.tar.gz: be9f03e159860c775b92bb20314c0a2477d24dc0108cff00d8978a017712106e9311bcdb4216ef17b378bf78385532974a1bce38e8d91cb6d088d93cdcea0de1
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
4
+ - 2.0.0
5
+ - 1.9.3
6
+ - jruby-19mode # JRuby in 1.9 mode
7
+ - rbx-2.1.1
8
+
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source 'http://rubygems.org'
2
+ gem 'oauth2', '~> 0.9', require: 'oauth2'
3
+ gem 'multipart-post', '~> 2.0'
4
+
5
+ group :development do
6
+ gem 'bundler', '~> 1.0'
7
+ gem 'minitest', '~> 5.3'
8
+ gem 'mocha', '~> 1.0'
9
+ gem 'simplecov', '~> 0.8'
10
+ gem 'rubocop', '~> 0.20'
11
+ gem 'rdoc', '~> 4.1'
12
+ gem 'jeweler', '~> 2.0'
13
+ gem 'ansi', '~> 1.4'
14
+ gem 'minitest-reporters', '~> 1.0'
15
+ gem 'vcr', '~> 2.9'
16
+ gem 'webmock', '~> 1.17'
17
+ gem 'guard', '~> 2.6'
18
+ gem 'guard-minitest', '~> 2.2'
19
+ gem 'terminal-notifier-guard', '~> 1.5'
20
+ gem 'guard-rubocop', '~> 1.0'
21
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,140 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.6)
5
+ ansi (1.4.3)
6
+ ast (2.0.0)
7
+ builder (3.2.2)
8
+ celluloid (0.15.2)
9
+ timers (~> 1.1.0)
10
+ coderay (1.1.0)
11
+ crack (0.4.2)
12
+ safe_yaml (~> 1.0.0)
13
+ descendants_tracker (0.0.4)
14
+ thread_safe (~> 0.3, >= 0.3.1)
15
+ docile (1.1.3)
16
+ faraday (0.9.0)
17
+ multipart-post (>= 1.2, < 3)
18
+ ffi (1.9.3)
19
+ formatador (0.2.5)
20
+ git (1.2.6)
21
+ github_api (0.11.3)
22
+ addressable (~> 2.3)
23
+ descendants_tracker (~> 0.0.1)
24
+ faraday (~> 0.8, < 0.10)
25
+ hashie (>= 1.2)
26
+ multi_json (>= 1.7.5, < 2.0)
27
+ nokogiri (~> 1.6.0)
28
+ oauth2
29
+ guard (2.6.1)
30
+ formatador (>= 0.2.4)
31
+ listen (~> 2.7)
32
+ lumberjack (~> 1.0)
33
+ pry (>= 0.9.12)
34
+ thor (>= 0.18.1)
35
+ guard-minitest (2.3.0)
36
+ guard (~> 2.0)
37
+ minitest (>= 3.0)
38
+ guard-rubocop (1.1.0)
39
+ guard (~> 2.0)
40
+ rubocop (~> 0.20)
41
+ hashie (3.0.0)
42
+ highline (1.6.21)
43
+ jeweler (2.0.1)
44
+ builder
45
+ bundler (>= 1.0)
46
+ git (>= 1.2.5)
47
+ github_api
48
+ highline (>= 1.6.15)
49
+ nokogiri (>= 1.5.10)
50
+ rake
51
+ rdoc
52
+ json (1.8.1)
53
+ jwt (1.0.0)
54
+ listen (2.7.6)
55
+ celluloid (>= 0.15.2)
56
+ rb-fsevent (>= 0.9.3)
57
+ rb-inotify (>= 0.9)
58
+ lumberjack (1.0.6)
59
+ metaclass (0.0.4)
60
+ method_source (0.8.2)
61
+ mini_portile (0.6.0)
62
+ minitest (5.3.4)
63
+ minitest-reporters (1.0.4)
64
+ ansi
65
+ builder
66
+ minitest (>= 5.0)
67
+ ruby-progressbar
68
+ mocha (1.1.0)
69
+ metaclass (~> 0.0.1)
70
+ multi_json (1.10.1)
71
+ multi_xml (0.5.5)
72
+ multipart-post (2.0.0)
73
+ nokogiri (1.6.2.1)
74
+ mini_portile (= 0.6.0)
75
+ oauth2 (0.9.4)
76
+ faraday (>= 0.8, < 0.10)
77
+ jwt (~> 1.0)
78
+ multi_json (~> 1.3)
79
+ multi_xml (~> 0.5)
80
+ rack (~> 1.2)
81
+ parser (2.1.9)
82
+ ast (>= 1.1, < 3.0)
83
+ slop (~> 3.4, >= 3.4.5)
84
+ powerpack (0.0.9)
85
+ pry (0.9.12.6)
86
+ coderay (~> 1.0)
87
+ method_source (~> 0.8)
88
+ slop (~> 3.4)
89
+ rack (1.5.2)
90
+ rainbow (2.0.0)
91
+ rake (10.3.2)
92
+ rb-fsevent (0.9.4)
93
+ rb-inotify (0.9.4)
94
+ ffi (>= 0.5.0)
95
+ rdoc (4.1.1)
96
+ json (~> 1.4)
97
+ rubocop (0.23.0)
98
+ json (>= 1.7.7, < 2)
99
+ parser (~> 2.1.9)
100
+ powerpack (~> 0.0.6)
101
+ rainbow (>= 1.99.1, < 3.0)
102
+ ruby-progressbar (~> 1.4)
103
+ ruby-progressbar (1.5.1)
104
+ safe_yaml (1.0.3)
105
+ simplecov (0.8.2)
106
+ docile (~> 1.1.0)
107
+ multi_json
108
+ simplecov-html (~> 0.8.0)
109
+ simplecov-html (0.8.0)
110
+ slop (3.5.0)
111
+ terminal-notifier-guard (1.5.3)
112
+ thor (0.19.1)
113
+ thread_safe (0.3.4)
114
+ timers (1.1.0)
115
+ vcr (2.9.2)
116
+ webmock (1.18.0)
117
+ addressable (>= 2.3.6)
118
+ crack (>= 0.3.2)
119
+
120
+ PLATFORMS
121
+ ruby
122
+
123
+ DEPENDENCIES
124
+ ansi (~> 1.4)
125
+ bundler (~> 1.0)
126
+ guard (~> 2.6)
127
+ guard-minitest (~> 2.2)
128
+ guard-rubocop (~> 1.0)
129
+ jeweler (~> 2.0)
130
+ minitest (~> 5.3)
131
+ minitest-reporters (~> 1.0)
132
+ mocha (~> 1.0)
133
+ multipart-post (~> 2.0)
134
+ oauth2 (~> 0.9)
135
+ rdoc (~> 4.1)
136
+ rubocop (~> 0.20)
137
+ simplecov (~> 0.8)
138
+ terminal-notifier-guard (~> 1.5)
139
+ vcr (~> 2.9)
140
+ webmock (~> 1.17)
data/Guardfile ADDED
@@ -0,0 +1,18 @@
1
+ # Guardfile for pokitdok-ruby
2
+
3
+ guard :minitest do
4
+ # with Minitest::Unit
5
+ watch(%r{^test/(.*)\/?test_(.*)\.rb$})
6
+ watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
7
+ watch(%r{^test/test_helper\.rb$}) { 'test' }
8
+
9
+ # with Minitest::Spec
10
+ watch(%r{^spec/(.*)_spec\.rb$})
11
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
12
+ watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
13
+ end
14
+
15
+ guard :rubocop do
16
+ watch(%r{.+\.rb$})
17
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
18
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 PokitDok, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,80 @@
1
+ [![Build Status](https://travis-ci.org/pokitdok/pokitdok-ruby.svg?branch=master)](https://travis-ci.org/pokitdok/pokitdok-ruby)
2
+ [![Gem Version](https://badge.fury.io/rb/pokitdok-ruby.svg)](http://badge.fury.io/rb/pokitdok-ruby)
3
+
4
+ pokitdok-ruby
5
+ =============
6
+
7
+ PokitDok Platform API Client for Ruby
8
+
9
+ ## Resources
10
+ * [Read the PokitDok API docs][apidocs]
11
+ * [View Source on GitHub][code]
12
+ * [Report Issues on GitHub][issues]
13
+
14
+ [apidocs]: https://platform.pokitdok.com/dashboard#/documentation
15
+ [code]: https://github.com/PokitDok/pokitdok-ruby
16
+ [issues]: https://github.com/PokitDok/pokitdok-ruby/issues
17
+
18
+ ## Installation
19
+ gem install pokitdok-ruby
20
+
21
+ ## Quick Start
22
+ ```ruby
23
+ require 'pokitdok'
24
+ pd = PokitDok::PokitDok.new("your_client_id", "your_client_secret")
25
+
26
+ # Retrieve provider information by NPI
27
+ pd.providers(npi: '1467560003')
28
+
29
+ # Search providers by name (individuals)
30
+ pd.providers(first_name: 'JEROME', last_name: 'AYA-AY')
31
+
32
+ # Search providers by name (organizations)
33
+ pd.providers(name: 'Qliance')
34
+
35
+ # Search providers by location and/or specialty
36
+ pd.providers(zipcode: '29307', radius: '10mi')
37
+ pd.providers(zipcode: '29307', radius: '10mi', specialty: 'RHEUMATOLOGY')
38
+
39
+ # Eligibility
40
+ params = {
41
+ trading_partner_id: 'MOCKPAYER',
42
+ member_id: 'W34237875729',
43
+ provider_id: '1467560003',
44
+ provider_name: 'AYA-AY',
45
+ provider_first_name: 'JEROME',
46
+ provider_type: 'Person',
47
+ member_name: 'JOHN DOE',
48
+ member_birth_date: '05-21-1975',
49
+ service_types: ['Health Benefit Plan Coverage']
50
+ }
51
+
52
+ pd.eligibility(params)
53
+
54
+ # Retrieve an index of activities
55
+ pd.activities
56
+
57
+ # Check on a specific activity
58
+ pd.activities(activity_id: '5362b5a064da150ef6f2526c')
59
+
60
+ # Check on a batch of activities
61
+ pd.activities(parent_id: '537cd4b240b35755f5128d5c')
62
+
63
+ # Upload an EDI file
64
+ pd.files('trading_partner_id', 'path/to/a_file.edi')
65
+
66
+ ```
67
+
68
+ ## Supported Ruby Versions
69
+ This library aims to support and is tested against these Ruby versions:
70
+
71
+ * Ruby 1.9.3-p545
72
+ * Ruby 2.0.0-p451
73
+ * Ruby 2.1.1
74
+
75
+ You may have luck with other interpreters - let us know how it goes.
76
+
77
+ ## License
78
+ Copyright (c) 2014 PokitDok Inc. See [LICENSE][] for details.
79
+
80
+ [license]: LICENSE.txt
data/Rakefile ADDED
@@ -0,0 +1,59 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts 'Run `bundle install` to install missing gems'
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ gem.name = 'pokitdok-ruby'
17
+ gem.homepage = 'http://github.com/pokitdok/pokitdok-ruby'
18
+ gem.license = 'MIT'
19
+ gem.summary = %Q(Gem for easy access to the PokitDok Platform APIs)
20
+ gem.description = %Q(Gem for easy access to the PokitDok Platform APIs.)
21
+ gem.email = 'john.riney@pokitdok.com'
22
+ gem.authors = ['John Riney']
23
+ end
24
+
25
+ Jeweler::RubygemsDotOrgTasks.new
26
+
27
+ require 'rake/testtask'
28
+ Rake::TestTask.new(:spec) do |spec|
29
+ spec.libs << 'lib' << 'spec'
30
+ spec.pattern = 'spec/**/*_spec.rb'
31
+ spec.verbose = true
32
+ end
33
+
34
+ desc 'Code coverage detail'
35
+ task :simplecov do
36
+ ENV['COVERAGE'] = 'true'
37
+ Rake::Task['spec'].execute
38
+ end
39
+
40
+ task default: :spec
41
+
42
+ require 'rdoc/task'
43
+ Rake::RDocTask.new do |rdoc|
44
+ @version = File.exist?('VERSION') ? File.read('VERSION') : ''
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = 'pokitdok-ruby #{@version}'
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ rdoc.main = 'README.md'
51
+ end
52
+
53
+ require 'rubocop/rake_task'
54
+ desc 'Run RuboCop on the lib and test directory'
55
+ RuboCop::RakeTask.new(:rubocop) do |task|
56
+ task.patterns = %w( 'lib/**/*.rb' 'test/**/*.rb' )
57
+ task.formatters = %w( 'offenses' 'progress' )
58
+ task.fail_on_error = false
59
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.3
data/lib/pokitdok.rb ADDED
@@ -0,0 +1,167 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2014, All Rights Reserved, PokitDok, Inc.
4
+ # https://www.pokitdok.com
5
+ #
6
+ # Please see the LICENSE.txt file for more information.
7
+ # All other rights reserved.
8
+ #
9
+
10
+ require 'rubygems'
11
+ require 'bundler/setup'
12
+ require 'base64'
13
+ require 'json'
14
+ require 'oauth2'
15
+ require 'net/http/post/multipart'
16
+
17
+ module PokitDok
18
+ # PokitDok API client implementation for Ruby.
19
+ class PokitDok
20
+ POKITDOK_URL_BASE = 'https://platform.pokitdok.com' # :nodoc:
21
+
22
+ attr_reader :client # :nodoc:
23
+ attr_reader :token # :nodoc:
24
+
25
+ # Connect to the PokitDok API with the specified Client ID and Client
26
+ # Secret.
27
+ #
28
+ # +client_id+ your client ID, provided by PokitDok
29
+ #
30
+ # +client_secret+ your client secret, provided by PokitDok
31
+ #
32
+ def initialize(client_id, client_secret)
33
+ @client_id = client_id
34
+ @client_secret = client_secret
35
+
36
+ @client = OAuth2::Client.new(@client_id, @client_secret,
37
+ site: api_url, token_url: '/oauth2/token')
38
+ refresh_token
39
+ end
40
+
41
+ # Returns the URL used to communicate with the PokitDok API.
42
+ def api_url
43
+ POKITDOK_URL_BASE + '/api/v3'
44
+ end
45
+
46
+ def user_agent
47
+ "pokitdok-ruby 0.2.1 #{RUBY_DESCRIPTION}"
48
+ end
49
+
50
+ # returns a standard set of headers to be passed along with all requests
51
+ def headers
52
+ { 'User-Agent' => user_agent }
53
+ end
54
+
55
+ # Refreshes the client token associated with this PokitDok connection
56
+ #
57
+ # FIXME: automatic refresh on expiration
58
+ def refresh_token
59
+ @token = client.client_credentials.get_token(
60
+ headers: { 'Authorization' => 'Basic' })
61
+ end
62
+
63
+ # Invokes the activities endpoint, with an optional Hash of parameters.
64
+ def activities(params = {})
65
+ response = @token.get('activities',
66
+ headers: headers,
67
+ params: params)
68
+ JSON.parse(response.body)
69
+ end
70
+
71
+ # Invokes the cash prices endpoint, with an optional Hash of parameters.
72
+ def cash_prices(_params = {})
73
+ fail NotImplementedError, "The PokitDok API does not currently support
74
+ this endpoint."
75
+ end
76
+
77
+ # Invokes the claims endpoint, with an optional Hash of parameters.
78
+ def claims(params = {})
79
+ response = @token.post('claims/',
80
+ headers: headers,
81
+ body: params.to_json) do |request|
82
+ request.headers['Content-Type'] = 'application/json'
83
+ end
84
+ JSON.parse(response.body)
85
+ end
86
+
87
+ # Invokes the claims status endpoint, with an optional Hash of parameters.
88
+ def claim_status(_params = {})
89
+ fail NotImplementedError, 'The PokitDok API does not currently support
90
+ this endpoint.'
91
+ end
92
+
93
+ # Invokes the deductible endpoint, with an optional Hash of parameters.
94
+ def deductible(_params = {})
95
+ fail NotImplementedError, 'The PokitDok API does not currently support
96
+ this endpoint.'
97
+ end
98
+
99
+ # Invokes the eligibility endpoint, with an optional Hash of parameters.
100
+ def eligibility(params = {})
101
+ response = @token.post('eligibility/',
102
+ headers: headers,
103
+ body: params.to_json) do |request|
104
+ request.headers['Content-Type'] = 'application/json'
105
+ end
106
+ JSON.parse(response.body)
107
+ end
108
+
109
+ # Invokes the enrollment endpoint, with an optional Hash of parameters.
110
+ def enrollment(params = {})
111
+ response = @token.post('enrollment/',
112
+ headers: headers,
113
+ body: params.to_json) do |request|
114
+ request.headers['Content-Type'] = 'application/json'
115
+ end
116
+ JSON.parse(response.body)
117
+ end
118
+
119
+ # Uploads an EDI file to the files endpoint.
120
+ # Uses the multipart-post gem, since oauth2 doesn't support multipart.
121
+ #
122
+ # +trading_partner_id+ the trading partner to transmit to
123
+ #
124
+ # +filename+ the path to the file to transmit
125
+ #
126
+ def files(trading_partner_id, filename)
127
+ url = URI.parse(api_url + '/files/')
128
+
129
+ File.open(filename) do |f|
130
+ req = Net::HTTP::Post::Multipart.new url.path,
131
+ 'file' => UploadIO.new(f, 'application/EDI-X12', filename),
132
+ 'trading_partner_id' => trading_partner_id
133
+ req['Authorization'] = "Bearer #{@token.token}"
134
+ req['User-Agent'] = user_agent
135
+
136
+ @response = Net::HTTP.start(url.host, url.port) do |http|
137
+ http.request(req)
138
+ end
139
+ end
140
+
141
+ JSON.parse(@response.body)
142
+ end
143
+
144
+ # Invokes the insurance prices endpoint, with an optional Hash of
145
+ # parameters.
146
+ def insurance_prices(params = {})
147
+ response = @token.get('prices/insurance',
148
+ headers: headers,
149
+ params: params)
150
+ JSON.parse(response.body)
151
+ end
152
+
153
+ # Invokes the payers endpoint, with an optional Hash of parameters.
154
+ def payers(params = {})
155
+ response = @token.get('payers', headers: headers, params: params)
156
+ JSON.parse(response.body)
157
+ end
158
+
159
+ # Invokes the providers endpoint, with an optional Hash of parameters.
160
+ def providers(params = {})
161
+ response = @token.get('providers') do |request|
162
+ request.params = params
163
+ end
164
+ JSON.parse(response.body)
165
+ end
166
+ end
167
+ end