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.
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: pokitdok-ruby 0.8.1 ruby lib
5
+ # stub: pokitdok-ruby 0.9.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "pokitdok-ruby"
9
- s.version = "0.8.1"
9
+ s.version = "0.9.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["PokitDok, Inc."]
14
- s.date = "2017-01-10"
14
+ s.date = "2017-02-24"
15
15
  s.description = "Gem for easy access to the PokitDok Platform APIs."
16
16
  s.email = "platform@pokitdok.com"
17
17
  s.extra_rdoc_files = [
@@ -20,7 +20,12 @@ Gem::Specification.new do |s|
20
20
  ]
21
21
  s.files = [
22
22
  ".document",
23
- ".travis.yml",
23
+ "Dockerfile-1.9",
24
+ "Dockerfile-2.0",
25
+ "Dockerfile-2.1",
26
+ "Dockerfile-2.2",
27
+ "Dockerfile-2.3",
28
+ "Dockerfile-J9.1",
24
29
  "Gemfile",
25
30
  "Gemfile.lock",
26
31
  "Guardfile",
@@ -28,9 +33,11 @@ Gem::Specification.new do |s|
28
33
  "README.md",
29
34
  "Rakefile",
30
35
  "VERSION",
36
+ "examples/quick_start.rb",
31
37
  "lib/OAuthApplicationClient.rb",
32
38
  "lib/pokitdok.rb",
33
39
  "pokitdok-ruby.gemspec",
40
+ "run_tests_in_docker.sh",
34
41
  "spec/fixtures/acme_inc_supplemental_identifiers.834",
35
42
  "spec/fixtures/authorizations.json",
36
43
  "spec/fixtures/chiropractic_example.837",
@@ -40,6 +47,7 @@ Gem::Specification.new do |s|
40
47
  "spec/fixtures/identity_match.json",
41
48
  "spec/fixtures/referrals.json",
42
49
  "spec/fixtures/sample.270",
50
+ "spec/fixtures/test_claim.837",
43
51
  "spec/pokitdok_spec.rb",
44
52
  "spec/spec_helper.rb"
45
53
  ]
@@ -54,6 +62,7 @@ Gem::Specification.new do |s|
54
62
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
63
  s.add_runtime_dependency(%q<oauth2>, ["~> 1.0"])
56
64
  s.add_runtime_dependency(%q<multipart-post>, ["~> 2.0"])
65
+ s.add_development_dependency(%q<dotenv-rails>, [">= 0"])
57
66
  s.add_development_dependency(%q<bundler>, ["~> 1.0"])
58
67
  s.add_development_dependency(%q<minitest>, ["~> 5.3"])
59
68
  s.add_development_dependency(%q<mocha>, ["~> 1.0"])
@@ -63,7 +72,6 @@ Gem::Specification.new do |s|
63
72
  s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
64
73
  s.add_development_dependency(%q<ansi>, ["~> 1.4"])
65
74
  s.add_development_dependency(%q<minitest-reporters>, ["~> 1.0"])
66
- s.add_development_dependency(%q<webmock>, ["~> 1.17"])
67
75
  s.add_development_dependency(%q<guard>, ["~> 2.6"])
68
76
  s.add_development_dependency(%q<guard-minitest>, ["~> 2.2"])
69
77
  s.add_development_dependency(%q<terminal-notifier>, [">= 0"])
@@ -73,6 +81,7 @@ Gem::Specification.new do |s|
73
81
  else
74
82
  s.add_dependency(%q<oauth2>, ["~> 1.0"])
75
83
  s.add_dependency(%q<multipart-post>, ["~> 2.0"])
84
+ s.add_dependency(%q<dotenv-rails>, [">= 0"])
76
85
  s.add_dependency(%q<bundler>, ["~> 1.0"])
77
86
  s.add_dependency(%q<minitest>, ["~> 5.3"])
78
87
  s.add_dependency(%q<mocha>, ["~> 1.0"])
@@ -82,7 +91,6 @@ Gem::Specification.new do |s|
82
91
  s.add_dependency(%q<jeweler>, ["~> 2.0"])
83
92
  s.add_dependency(%q<ansi>, ["~> 1.4"])
84
93
  s.add_dependency(%q<minitest-reporters>, ["~> 1.0"])
85
- s.add_dependency(%q<webmock>, ["~> 1.17"])
86
94
  s.add_dependency(%q<guard>, ["~> 2.6"])
87
95
  s.add_dependency(%q<guard-minitest>, ["~> 2.2"])
88
96
  s.add_dependency(%q<terminal-notifier>, [">= 0"])
@@ -93,6 +101,7 @@ Gem::Specification.new do |s|
93
101
  else
94
102
  s.add_dependency(%q<oauth2>, ["~> 1.0"])
95
103
  s.add_dependency(%q<multipart-post>, ["~> 2.0"])
104
+ s.add_dependency(%q<dotenv-rails>, [">= 0"])
96
105
  s.add_dependency(%q<bundler>, ["~> 1.0"])
97
106
  s.add_dependency(%q<minitest>, ["~> 5.3"])
98
107
  s.add_dependency(%q<mocha>, ["~> 1.0"])
@@ -102,7 +111,6 @@ Gem::Specification.new do |s|
102
111
  s.add_dependency(%q<jeweler>, ["~> 2.0"])
103
112
  s.add_dependency(%q<ansi>, ["~> 1.4"])
104
113
  s.add_dependency(%q<minitest-reporters>, ["~> 1.0"])
105
- s.add_dependency(%q<webmock>, ["~> 1.17"])
106
114
  s.add_dependency(%q<guard>, ["~> 2.6"])
107
115
  s.add_dependency(%q<guard-minitest>, ["~> 2.2"])
108
116
  s.add_dependency(%q<terminal-notifier>, [">= 0"])
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+
3
+ for VERSION in J9.1 1.9 2.0 2.1 2.2 2.3
4
+ do
5
+ docker build -f Dockerfile-$VERSION .
6
+ done
@@ -0,0 +1 @@
1
+ ISA*00* *00* *01*9012345720000 *01*9088877320000 *151004*2235*U*00501*000000007*0*T*:~GS*HC*901234572000*908887732000*20151004*2235*7*X*005010X222~ST*837*0001~BHT*0019*00*2KYXDRE61GU20TFMBPA*20151004*2231*CH~NM1*41*2*Pokitdok, Inc.*****46*12345~PER*IC**EM*x12info@pokitdok.com~NM1*40*2*MOCKPAYER*****46*12345~HL*1**20*1~PRV*BI*PXC*207Q00000X~NM1*85*1*Aya-Ay*Jerome****XX*1467560003~N3*8311 WARREN H ABERNATHY HWY~N4*SPARTANBURG*SC*293010000~REF*EI*123456789~HL*2*1*22*0~SBR*P*18*******ZZ~NM1*IL*1*Doe*Jane****MI*W000000000~N3*123 N MAIN ST~N4*SPARTANBURG*SC*29301~DMG*D8*19700101*F~NM1*PR*2*MOCKPAYER*****PI*12345~CLM*0f17b46dd39a4bb0add152e99633adbc*60***11:B:1*Y*A*Y*I~HI*BK:4871~LX*1~SV1*HC:99213*60*UN*1.0***1~DTP*472*D8*20140601~SE*24*0001~GE*1*905~IEA*1*000000905~
@@ -1,689 +1,625 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require 'spec_helper'
4
+ require 'dotenv'
5
+ Dotenv.load
4
6
 
5
- CLIENT_ID = 'F7q38MzlwOxUwTHb7jvk'
6
- CLIENT_SECRET = 'O8DRamKmKMLtSTPjK99eUlbfOQEc44VVmp8ARmcY'
7
- SCHEDULE_AUTH_CODE = 'KmCCkuYkSmPEf7AxaCIUApX1pUFedJx9CrDWPMD8'
8
- BASE_URL = 'https://platform.pokitdok.com/v4/api'
9
- MATCH_NETWORK_LOCATION = /(.*\.)?pokitdok\.com/
10
- MATCH_OAUTH2_PATH = /[\/]oauth2[\/]token/
11
- TEST_REQUEST_PATH = '/endpoint'
7
+ CLIENT_ID = ENV["POKITDOK_CLIENT_ID"]
8
+ CLIENT_SECRET = ENV["POKITDOK_CLIENT_SECRET"]
12
9
 
13
10
  class PokitDokTest < MiniTest::Test
14
11
  @@pokitdok = nil
15
12
  @@current_request = nil
13
+ @identity_request = {
14
+ prefix: "Mr.",
15
+ first_name: "Oscar",
16
+ middle_name: "Harold",
17
+ last_name: "Whitmire",
18
+ suffix: "IV",
19
+ birth_date: "2000-05-01",
20
+ gender: "male",
21
+ email: "oscar@pokitdok.com",
22
+ phone: "555-555-5555",
23
+ secondary_phone: "333-333-4444",
24
+ address: {
25
+ address_lines: ["1400 Anyhoo Avenue"],
26
+ city: "Springfield",
27
+ state: "IL",
28
+ zipcode: "90210"
29
+ },
30
+ identifiers: [
31
+ {
32
+ provider_uuid: "1917f12b-fb6a-4016-93bc-adeb83204c83",
33
+ system_uuid: "967d207f-b024-41cc-8cac-89575a1f6fef",
34
+ value: "W90100-IG-88",
35
+ location: [-121.93831, 37.53901]
36
+ }
37
+ ]
38
+ }
16
39
 
17
40
  describe PokitDok do
18
41
 
19
- describe 'Authenticated functions' do
20
-
21
- let(:base_headers) {
22
- {
23
- :'User-Agent' => "#{@@pokitdok.user_agent}"
24
- }
25
- }
26
- let(:json_headers) {
27
- {
28
- :'User-Agent' => "#{@@pokitdok.user_agent}",
29
- :'Content-Type'=> 'application/json'
30
- }
31
- }
32
-
33
- let(:snub_auth) {
34
- stub_request(:post, /#{MATCH_NETWORK_LOCATION}#{MATCH_OAUTH2_PATH}/).
35
- to_return(
36
- :status => 200,
37
- :body => '{
38
- "access_token": "s8KYRJGTO0rWMy0zz1CCSCwsSesDyDlbNdZoRqVR",
39
- "token_type": "bearer",
40
- "expires": 1393350569,
41
- "expires_in": 3600
42
- }',
43
- :headers => {
44
- 'Server'=> 'nginx',
45
- 'Date' => Time.now(),
46
- 'Content-type' => 'application/json;charset=UTF-8',
47
- 'Connection' => 'keep-alive',
48
- 'Pragma' => 'no-cache',
49
- 'Cache-Control' => 'no-store'
50
- }).times(2)
51
- }
52
-
53
- before do
54
- if @@pokitdok.nil?
55
- snub_auth
56
-
57
- @@pokitdok = PokitDok::PokitDok.new(CLIENT_ID, CLIENT_SECRET)
58
- end
42
+ before do
43
+ if @@pokitdok.nil?
44
+ @@pokitdok = PokitDok::PokitDok.new(CLIENT_ID, CLIENT_SECRET)
59
45
  end
60
-
61
- describe 'Test token reuse' do
62
- it 'should work with existing token' do
63
- snub_auth
64
- pokitdok_for_token = PokitDok::PokitDok.new(CLIENT_ID, CLIENT_SECRET)
65
- first_token = pokitdok_for_token.token
66
-
67
- snub_auth
68
- pokitdok_with_old_token = PokitDok::PokitDok.new(CLIENT_ID, CLIENT_SECRET, nil, nil, nil, nil, nil, token=first_token)
69
- second_token = pokitdok_with_old_token.token
70
-
71
- stub_request(:get, MATCH_NETWORK_LOCATION).
72
- to_return(status: 200, body: '{ "string" : "" }')
73
- assert first_token == second_token
74
- results = pokitdok_with_old_token.activities
75
- refute_nil(results)
76
-
77
- snub_auth
78
- pokitdok_for_new_token = PokitDok::PokitDok.new(CLIENT_ID, CLIENT_SECRET)
79
- third_token = pokitdok_for_new_token.token
80
- assert (first_token != third_token) && (second_token != third_token)
81
- end
46
+ end
47
+ #
48
+ # ******************************
49
+ # client set up tests
50
+ # ******************************
51
+ #
52
+ describe 'Test token reuse' do
53
+ it 'should work with existing token' do
54
+ pokitdok_for_token = PokitDok::PokitDok.new(CLIENT_ID, CLIENT_SECRET)
55
+ first_token = pokitdok_for_token.token
56
+
57
+ pokitdok_with_old_token = PokitDok::PokitDok.new(CLIENT_ID, CLIENT_SECRET, nil, nil, nil, nil, nil, token=first_token)
58
+ second_token = pokitdok_with_old_token.token
59
+
60
+ assert first_token == second_token
61
+ results = pokitdok_with_old_token.activities
62
+ refute_nil(results)
63
+
64
+ pokitdok_for_new_token = PokitDok::PokitDok.new(CLIENT_ID, CLIENT_SECRET)
65
+ third_token = pokitdok_for_new_token.token
66
+ assert (first_token != third_token) && (second_token != third_token)
82
67
  end
68
+ end
83
69
 
84
- describe 'Test Connection' do
85
- it 'should instantiate the api_client' do
86
- refute_nil(@@pokitdok.api_client)
87
- end
70
+ describe 'Test Connection' do
71
+ it 'should instantiate the api_client' do
72
+ refute_nil(@@pokitdok)
73
+ assert @@pokitdok.user_agent.include? "pokitdok-ruby#"
88
74
  end
75
+ end
89
76
 
90
- describe 'General Request method' do
91
- it 'should test request post' do
92
- stub_request(:post, MATCH_NETWORK_LOCATION).
93
- to_return(lambda { |request|
94
- @@current_request = request
95
- {
96
- status: 200,
97
- body: '{ "string" : "" }'
98
- }
99
- })
100
-
101
- @@pokitdok.request(TEST_REQUEST_PATH, 'POST', nil, {param: 'value'})
102
- json_headers.each do |key, value|
103
- assert_equal(value, @@current_request.headers["#{key}"])
104
- end
105
-
106
- # NOTE: Currently this shows as an error in an IDE. I believe this is because it's
107
- # a reserved property in Ruby
108
- assert_equal('post', "#{@@current_request.method}")
109
- end
110
- it 'should test request put' do
111
- stub_request(:put, MATCH_NETWORK_LOCATION).
112
- to_return(lambda { |request|
113
- @@current_request = request
114
- {
115
- status: 200,
116
- body: '{ "string" : "" }'
117
- }
118
- })
119
-
120
- @@pokitdok.request(TEST_REQUEST_PATH, 'PUT', nil, {param: 'value'})
121
- json_headers.each do |key, value|
122
- assert_equal(value, @@current_request.headers["#{key}"])
123
- end
124
-
125
- # NOTE: Currently this shows as an error in an IDE. I believe this is because it's
126
- # a reserved property in Ruby
127
- assert_equal('put', "#{@@current_request.method}")
128
- end
129
- it 'should test request get' do
130
- stub_request(:get, MATCH_NETWORK_LOCATION).
131
- to_return(lambda { |request|
132
- @@current_request = request
133
- {
134
- status: 200,
135
- body: '{ "string" : "" }'
136
- }
137
- })
138
-
139
- @@pokitdok.request(TEST_REQUEST_PATH, 'GET', nil, {param: 'value'})
140
- base_headers.each do |key, value|
141
- assert_equal(value, @@current_request.headers["#{key}"])
142
- end
143
-
144
- # NOTE: Currently this shows as an error in an IDE. I believe this is because it's
145
- # a reserved property in Ruby
146
- assert_equal('get', "#{@@current_request.method}")
147
- end
148
- it 'should test request delete' do
149
- stub_request(:delete, MATCH_NETWORK_LOCATION).
150
- to_return(lambda { |request|
151
- @@current_request = request
152
- {
153
- status: 200,
154
- body: '{ "string" : "" }'
155
- }
156
- })
157
-
158
- @@pokitdok.request(TEST_REQUEST_PATH, 'DELETE', nil, {param: 'value'})
159
- base_headers.each do |key, value|
160
- assert_equal(value, @@current_request.headers["#{key}"])
161
- end
162
-
163
- # NOTE: Currently this shows as an error in an IDE. I believe this is because it's
164
- # a reserved property in Ruby
165
- assert_equal('delete', "#{@@current_request.method}")
166
- end
77
+ #
78
+ # ******************************
79
+ # error tests
80
+ # ******************************
81
+ #
82
+ describe 'Error Test: Missing Trading Partner ID' do
83
+ it 'make a call to eligibility without a Trading partner' do
84
+ @eligibility_query_2 = {
85
+ member: {
86
+ birth_date: '1970-01-01',
87
+ first_name: 'Jane',
88
+ last_name: 'Doe',
89
+ id: 'W000000000'
90
+ },
91
+ provider: {
92
+ first_name: 'JEROME',
93
+ last_name: 'AYA-AY',
94
+ npi: '1467560003'
95
+ },
96
+ service_types: ['health_benefit_plan_coverage'],
97
+ }
98
+ response = @@pokitdok.eligibility @eligibility_query_2
99
+ refute_nil(response["meta"].keys, msg="the response[meta] section is empty")
100
+ refute_nil(response["data"].keys, msg="the response[data] section is empty")
101
+ assert response["data"]["errors"]["query"].to_s.include? "Unable to find configuration for trading_partner_id: None, transaction_set_name: eligibility"
102
+ assert @@pokitdok.status_code == 400, "Status Code assertion failure. Tested for 400, Observed status code: #{@@pokitdok.status_code}"
167
103
  end
168
-
169
- describe 'Activities endpoint' do
170
- it 'should expose the activities endpoint' do
171
- stub_request(:get, MATCH_NETWORK_LOCATION).
172
- to_return(status: 200, body: '{ "string" : "" }')
173
-
174
- @activities = @@pokitdok.activities
175
- refute_nil(@activities)
176
- end
177
-
178
- it 'should expose the activities endpoint with an id parameter' do
179
- stub_request(:get, MATCH_NETWORK_LOCATION).
180
- to_return(status: 200, body: '{ "string" : "" }')
181
-
182
- @activities = @@pokitdok.activities(activity_id: 'activity_id')
183
- refute_nil(@activities)
184
- end
104
+ end
105
+ describe 'Validation Error Test: Malformed Request' do
106
+ it 'make a call to eligibility with bad data' do
107
+ @bad_request = "bad request"
108
+ response = @@pokitdok.eligibility @bad_request
109
+ refute_nil(response["meta"].keys, msg="the response[meta] section is empty")
110
+ refute_nil(response["data"].keys, msg="the response[data] section is empty")
111
+ assert response["data"]["errors"]["validation"].to_s.include? "This endpoint only accepts JSON requests of <type 'dict'>. Request provided was of <type 'unicode'>."
112
+ assert @@pokitdok.status_code == 422, "Status Code assertion failure. Tested for 422, Observed status code: #{@@pokitdok.status_code}"
185
113
  end
186
-
187
- describe 'Cash Prices endpoint' do
188
- it 'should expose the cash prices endpoint' do
189
- stub_request(:get, MATCH_NETWORK_LOCATION).
190
- to_return(status: 200, body: '{ "string" : "" }')
191
-
192
- query = { cpt_code: '90658', zip_code: '94403' }
193
- @prices = @@pokitdok.cash_prices query
194
-
195
- refute_nil(@prices)
196
- end
114
+ end
115
+ describe 'Validation Error Test: Malformed Request' do
116
+ it 'make a call to eligibility with bad data' do
117
+ @bad_request = {
118
+ member: {
119
+ birth_date: '1970-01-01',
120
+ first_name: 'Jane',
121
+ last_name: 'Doe',
122
+ id: '1'
123
+ },
124
+ trading_partner_id: 'MOCKPAYER'
125
+ }
126
+ response = @@pokitdok.eligibility @bad_request
127
+ refute_nil(response["meta"].keys, msg="the response[meta] section is empty")
128
+ refute_nil(response["data"].keys, msg="the response[data] section is empty")
129
+ assert response["data"]["errors"]["validation"]["member"]["id"].to_s.include? "String value is too short."
130
+ assert @@pokitdok.status_code == 422, "Status Code assertion failure. Tested for 422, Observed status code: #{@@pokitdok.status_code}"
197
131
  end
198
-
199
- describe 'Claims endpoint' do
200
- it 'should expose the claims endpoint' do
201
- stub_request(:post, MATCH_NETWORK_LOCATION).
202
- to_return(status: 200, body: '{ "string" : "" }')
203
-
204
- query = JSON.parse(IO.read('spec/fixtures/claim.json'))
205
- @claim = @@pokitdok.claims(query)
206
-
207
- refute_nil(@claim)
208
- end
132
+ end
133
+ describe 'Validation Error Test: Malformed Request' do
134
+ it 'make a call to eligibility with bad data' do
135
+ @bad_request = {
136
+ member: {
137
+ birth_date: '1970-01-01',
138
+ first_name: 'Jane',
139
+ last_name: 'Doe',
140
+ id: '100000000000'
141
+ },
142
+ provider: {
143
+ first_name: 'JEROME',
144
+ last_name: 'AYA-AY',
145
+ npi: '2'
146
+ },
147
+ trading_partner_id: 'MOCKPAYER'
148
+ }
149
+ response = @@pokitdok.eligibility @bad_request
150
+ refute_nil(response["meta"].keys, msg="the response[meta] section is empty")
151
+ refute_nil(response["data"].keys, msg="the response[data] section is empty")
152
+ assert response["data"]["errors"]["validation"]["provider"]["npi"].to_s.include? "String value is too short."
153
+ assert @@pokitdok.status_code == 422, "Status Code assertion failure. Tested for 422, Observed status code: #{@@pokitdok.status_code}"
209
154
  end
210
-
211
- describe 'Claims status endpoint' do
212
- it 'should expose the claims status endpoint' do
213
- stub_request(:post, MATCH_NETWORK_LOCATION).
214
- to_return(status: 200, body: '{ "string" : "" }')
215
-
216
- query = JSON.parse(IO.read('spec/fixtures/claims_status.json'))
217
- @claims_status = @@pokitdok.claims_status(query)
218
-
219
- refute_nil(@claims_status)
220
- end
155
+ end
156
+ #
157
+ # ******************************
158
+ # get/post/put tests
159
+ # ******************************
160
+ #
161
+ describe 'test the POST method' do
162
+ it 'should make a real eligibility via the POST method' do
163
+ @eligibility_query = {
164
+ member: {
165
+ birth_date: '1970-01-01',
166
+ first_name: 'Jane',
167
+ last_name: 'Doe',
168
+ id: 'W000000000'
169
+ },
170
+ provider: {
171
+ first_name: 'JEROME',
172
+ last_name: 'AYA-AY',
173
+ npi: '1467560003'
174
+ },
175
+ service_types: ['health_benefit_plan_coverage'],
176
+ trading_partner_id: 'MOCKPAYER'
177
+ }
178
+ response = @@pokitdok.post('eligibility/', @eligibility_query)
179
+ refute_nil(response["meta"].keys, msg="the response[meta] section is empty")
180
+ refute_nil(response["data"].keys, msg="the response[data] section is empty")
181
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
221
182
  end
222
-
223
- describe 'Medical Procedure Endpoint endpoint' do
224
- it 'should expose the mpc endpoint when a code is specified' do
225
- stub_request(:get, MATCH_NETWORK_LOCATION).
226
- to_return(status: 200, body: '{ "string" : "" }')
227
-
228
- query = { code: '99213' }
229
- @mpc = @@pokitdok.mpc(query)
230
-
231
- refute_nil(@mpc)
232
- end
233
- it 'should expose the mpc endpoint when name is specified' do
234
- stub_request(:get, MATCH_NETWORK_LOCATION).
235
- to_return(status: 200, body: '{ "string" : "" }')
236
-
237
- query = { name: 'office' }
238
- @mpc = @@pokitdok.mpc(query)
239
-
240
- refute_nil(@mpc)
241
- end
183
+ end
184
+ describe 'Live test of PUT, DELETE, CLAIMS, ACTIVITIES' do
185
+ it 'Exercise the workflow of submitting a and deleting a claim' do
186
+ # this claim body represents the minimal amount of data needed to submit a claim via the claims endpoint
187
+ @test_claim = {
188
+ transaction_code: "chargeable",
189
+ trading_partner_id: "MOCKPAYER",
190
+ billing_provider: {
191
+ taxonomy_code: "207Q00000X",
192
+ first_name: "Jerome",
193
+ last_name: "Aya-Ay",
194
+ npi: "1467560003",
195
+ address: {
196
+ address_lines: [
197
+ "8311 WARREN H ABERNATHY HWY"
198
+ ],
199
+ city: "SPARTANBURG",
200
+ state: "SC",
201
+ zipcode: "29301"
202
+ },
203
+ tax_id: "123456789"
204
+ },
205
+ subscriber: {
206
+ first_name: "Jane",
207
+ last_name: "Doe",
208
+ member_id: "W000000000",
209
+ address: {
210
+ address_lines: ["123 N MAIN ST"],
211
+ city: "SPARTANBURG",
212
+ state: "SC",
213
+ zipcode: "29301"
214
+ },
215
+ birth_date: "1970-01-25",
216
+ gender: "female"
217
+ },
218
+ claim: {
219
+ total_charge_amount: 60.0,
220
+ service_lines: [
221
+ {
222
+ procedure_code: "99213",
223
+ charge_amount: 60.0,
224
+ unit_count: 1.0,
225
+ diagnosis_codes: [
226
+ "J10.1"
227
+ ],
228
+ service_date: "2016-01-25"
229
+ }
230
+ ]
231
+ }
232
+ }
233
+ # assert success of the claim post
234
+ claim_response = @@pokitdok.claims(@test_claim)
235
+ refute_nil(claim_response["meta"].keys, msg="the response[meta] section is empty")
236
+ refute_nil(claim_response["data"].keys, msg="the response[data] section is empty")
237
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200 on use of claims endpoint, Observed status code: #{@@pokitdok.status_code}"
238
+
239
+ # use the activities endpoint via a GET to analyze the current status of this claim
240
+ activity_id = claim_response["meta"]["activity_id"]
241
+ activity_url = "/activities/#{activity_id}"
242
+ get_response = @@pokitdok.get(activity_url, data={})
243
+ refute_nil(get_response["data"]["history"], msg="the response[data][history] section is empty")
244
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200 on the first get to activities, Observed status code: #{@@pokitdok.status_code}"
245
+
246
+ # look in the history to see if it has transitioned from state "init" to "canceled"
247
+ history = get_response["data"]["history"]
248
+ if history.length != 1
249
+ # this means that the claim is been picked up and is processing within the internal pokitdok system
250
+ # we aim to test out the put functionality by deleting the claim,
251
+ # so we need to resubmit a claim to get one that is going to stay in the INIT stage
252
+ claim_response = @@pokitdok.claims(@test_claim)
253
+ refute_nil(claim_response["meta"].keys, msg="the response[meta] section is empty")
254
+ refute_nil(claim_response["data"].keys, msg="the response[data] section is empty")
255
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200 on the second use of claims endpoint, Observed status code: #{@@pokitdok.status_code}"
256
+ activity_id = claim_response["meta"]["activity_id"]
257
+ activity_url = "/activities/#{activity_id}"
258
+ end
259
+
260
+ # exercise the PUT functionality to delete the claim from its INIT status
261
+ put_data = @@pokitdok.put(activity_url, data={transition: "cancel"})
262
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200 on put to cancel the activity, Observed status code: #{@@pokitdok.status_code}"
263
+ refute_nil(put_data, msg="the respones body is empty")
264
+ refute_nil(put_data["data"], msg="the responesbody[data] is empty")
265
+ assert put_data["data"].kind_of?(Hash), "Error grabbing the activity data; try running the test suite again. Full response: #{put_data}"
266
+
267
+ # look in the history to see if it has transitioned from state "init" to "canceled"
268
+ assert put_data["data"]["history"].kind_of?(Array), "Error grabbing the activity data; try running the test suite again. Full response: #{assert put_data["data"]["history"]}"
269
+ history = put_data["data"]["history"]
270
+ assert history.length == 3, "Tested for cancelled claim, but recived the following claim history: #{history.to_s}"
271
+
272
+ # exercise the PUT functionality to delete an already deleted claim
273
+ put_data = @@pokitdok.put(activity_url, data={transition: "cancel"})
274
+ refute_nil(put_data["data"]["errors"], msg="The response[data][errors] is empty")
275
+ assert @@pokitdok.status_code == 422, "Status Code assertion failure. Tested for 422 on put to cancel the activity, Observed status code: #{@@pokitdok.status_code}"
276
+
277
+ # exercise the activities endpoint to get the status of this claims transaction
278
+ updated_get_response = @@pokitdok.activities(claim_response["meta"]["activity_id"])
279
+ refute_nil(updated_get_response["meta"], msg="the response[meta] section is empty. The full response: #{updated_get_response.to_s}")
280
+ refute_nil(updated_get_response["data"], msg="the response[data] section is empty")
281
+ assert @@pokitdok.status_code == 404, "Status Code assertion failure. Tested for 200 on the last use of the activities endpoint, Observed status code: #{@@pokitdok.status_code} #{updated_get_response}"
282
+ assert updated_get_response["data"]["errors"]["query"].include?("is not a valid Activity Id"), "Failed test for error message. Observed payload: #{updated_get_response}"
242
283
  end
284
+ end
285
+ #
286
+ # ******************************
287
+ # X12 API tests
288
+ # ******************************
289
+ #
290
+ describe 'X12 API Convenience function test: authorizations' do
291
+ it 'make a call to the live endpoint for: authorizations' do
292
+ @params = {
293
+ event: {
294
+ category: "health_services_review",
295
+ certification_type: "initial",
296
+ delivery: {
297
+ quantity: 1,
298
+ quantity_qualifier: "visits"
299
+ },
300
+ diagnoses: [
301
+ {
302
+ code: "R10.9",
303
+ date: "2016-01-25"
304
+ }
305
+ ],
306
+ place_of_service: "office",
307
+ provider: {
308
+ organization_name: "KELLY ULTRASOUND CENTER, LLC",
309
+ npi: "1760779011",
310
+ phone: "8642341234"
311
+ },
312
+ services: [
313
+ {
314
+ cpt_code: "76700",
315
+ measurement: "unit",
316
+ quantity: 1
317
+ }
318
+ ],
319
+ type: "diagnostic_medical"
320
+ },
321
+ patient: {
322
+ birth_date: "1970-01-25",
323
+ first_name: "JANE",
324
+ last_name: "DOE",
325
+ id: "1234567890"
326
+ },
327
+ provider: {
328
+ first_name: "JEROME",
329
+ npi: "1467560003",
330
+ last_name: "AYA-AY"
331
+ },
332
+ trading_partner_id: "MOCKPAYER"
333
+ }
334
+ response = @@pokitdok.authorizations @params
335
+ refute_nil(response["meta"], msg="the response[meta] section is empty")
336
+ refute_nil(response["data"], msg="the response[data] section is empty")
337
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
243
338
 
244
- describe 'ICD Convert endpoint' do
245
- it 'should expose the icd convert endpoint' do
246
- stub_request(:get, MATCH_NETWORK_LOCATION).
247
- to_return(status: 200, body: '{ "string" : "" }')
248
-
249
- @icd = @@pokitdok.icd_convert({code: '250.12'})
250
- refute_nil(@icd)
251
- end
252
339
  end
340
+ end
341
+ describe 'X12 API Convenience function test: claims_status' do
342
+ it 'make a call to the live endpoint for: claims_status' do
343
+ @params = {
344
+ patient: {
345
+ birth_date: "1970-01-25",
346
+ first_name: "JANE",
347
+ last_name: "DOE",
348
+ id: "1234567890"
349
+ },
350
+ provider: {
351
+ first_name: "Jerome",
352
+ last_name: "Aya-Ay",
353
+ npi: "1467560003"
354
+ },
355
+ service_date: "2014-01-25",
356
+ trading_partner_id: "MOCKPAYER"
357
+ }
358
+ response = @@pokitdok.claims_status @params
359
+ refute_nil(response["meta"].keys, msg="the response[meta] section is empty")
360
+ refute_nil(response["data"].keys, msg="the response[data] section is empty")
361
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
253
362
 
254
- describe 'Claims convert endpoint' do
255
- it 'should expose the claims convert endpoint' do
256
- stub_request(:post, MATCH_NETWORK_LOCATION).
257
- to_return(status: 200, body: '{ "string" : "" }')
258
-
259
- @converted_claim = @@pokitdok.claims_convert('spec/fixtures/chiropractic_example.837')
260
-
261
- refute_nil(@converted_claim)
262
- end
263
363
  end
364
+ end
365
+ describe 'X12 API Convenience function test: claims_convert' do
366
+ it 'make a call to the live endpoint for: claims_convert' do
367
+ response = @@pokitdok.claims_convert('spec/fixtures/test_claim.837')
368
+ refute_nil(response["meta"].keys, msg="the response[meta] section is empty")
369
+ refute_nil(response["data"].keys, msg="the response[data] section is empty")
370
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
264
371
 
265
- describe 'Eligibility endpoint' do
266
- it 'should expose the eligibility endpoint' do
267
- stub_request(:post, MATCH_NETWORK_LOCATION).
268
- to_return(status: 200, body: '{ "string" : "" }')
269
-
270
- @eligibility_query = {
271
- member: {
272
- birth_date: '1970-01-01',
273
- first_name: 'Jane',
274
- last_name: 'Doe',
275
- id: 'W000000000'
276
- },
277
- provider: {
278
- first_name: 'JEROME',
279
- last_name: 'AYA-AY',
280
- npi: '1467560003'
281
- },
282
- service_types: ['health_benefit_plan_coverage'],
283
- trading_partner_id: 'MOCKPAYER'
284
- }
285
- @eligibility = @@pokitdok.eligibility(@eligibility_query)
286
-
287
- refute_nil(@eligibility)
288
- end
289
372
  end
290
-
291
- describe 'Enrollment endpoint' do
292
- it 'should expose the enrollment endpoint' do
293
- stub_request(:post, MATCH_NETWORK_LOCATION).
294
- to_return(status: 200, body: '{ "string" : "" }')
295
-
296
- query = JSON.parse(IO.read('spec/fixtures/enrollment.json'))
297
- @enrollment = @@pokitdok.enrollment(query)
298
-
299
- refute_nil(@enrollment)
300
- end
373
+ end
374
+ describe 'X12 API Convenience function test: eligibility' do
375
+ it 'make a call to the live endpoint for: eligibility' do
376
+ params = {
377
+ member: {
378
+ birth_date: '1970-01-01',
379
+ first_name: 'Jane',
380
+ last_name: 'Doe',
381
+ id: 'W000000000'
382
+ },
383
+ provider: {
384
+ first_name: 'JEROME',
385
+ last_name: 'AYA-AY',
386
+ npi: '1467560003'
387
+ },
388
+ service_types: ['health_benefit_plan_coverage'],
389
+ trading_partner_id: 'MOCKPAYER'
390
+ }
391
+ response = @@pokitdok.eligibility params
392
+ refute_nil(response["meta"].keys, msg="the response[meta] section is empty")
393
+ refute_nil(response["data"].keys, msg="the response[data] section is empty")
394
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
301
395
  end
396
+ end
397
+ describe 'X12 API Convenience function test: referrals' do
398
+ it 'make a call to the live endpoint for: referrals' do
399
+ @params = {
400
+ event: {
401
+ category: "specialty_care_review",
402
+ certification_type: "initial",
403
+ delivery: {
404
+ quantity: 1,
405
+ quantity_qualifier: "visits"
406
+ },
407
+ diagnoses: [
408
+ {
409
+ code: "H72.90",
410
+ date: "2014-09-25"
411
+ }
412
+ ],
413
+ place_of_service: "office",
414
+ provider: {
415
+ first_name: "JOHN",
416
+ npi: "1154387751",
417
+ last_name: "FOSTER",
418
+ phone: "8645822900"
419
+ },
420
+ type: "consultation"
421
+ },
422
+ patient: {
423
+ birth_date: "1970-01-25",
424
+ first_name: "JANE",
425
+ last_name: "DOE",
426
+ id: "1234567890"
427
+ },
428
+ provider: {
429
+ first_name: "CHRISTINA",
430
+ last_name: "BERTOLAMI",
431
+ npi: "1619131232"
432
+ },
433
+ trading_partner_id: "MOCKPAYER"
434
+ }
435
+ response = @@pokitdok.referrals @params
436
+ refute_nil(response["meta"], msg="the response[meta] section is empty")
437
+ refute_nil(response["data"], msg="the response[data] section is empty")
438
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
302
439
 
303
- describe 'Enrollment Snapshot endpoint' do
304
- it 'should expose the enrollment snapshot endpoint' do
305
- stub_request(:post, MATCH_NETWORK_LOCATION).
306
- to_return(status: 200, body: '{ "string" : "" }')
307
-
308
- @enrollment_snapshot_activity = @@pokitdok.enrollment_snapshot('MOCKPAYER', 'spec/fixtures/acme_inc_supplemental_identifiers.834')
309
-
310
- refute_nil(@enrollment_snapshot_activity)
311
- end
312
- it 'should expose the enrollment snapshots endpoint' do
313
- stub_request(:get, MATCH_NETWORK_LOCATION).
314
- to_return(status: 200, body: '{ "string" : "" }')
315
-
316
- @enrollment_snapshot = @@pokitdok.enrollment_snapshots({snapshot_id: '577294e00640fd5ce02d493f'})
317
-
318
- refute_nil(@enrollment_snapshot)
319
- end
320
- it 'should expose the enrollment snapshot data endpoint' do
321
- stub_request(:get, MATCH_NETWORK_LOCATION).
322
- to_return(status: 200, body: '{ "string" : "" }')
323
-
324
- @enrollment_snapshot_data = @@pokitdok.enrollment_snapshot_data({snapshot_id: '577294e00640fd5ce02d493f'})
325
-
326
- refute_nil(@enrollment_snapshot_data)
327
- end
328
440
  end
441
+ end
442
+ #
443
+ # ******************************
444
+ # Data API tests
445
+ # ******************************
446
+ #
447
+ describe 'Data API Convenience function test: cash_prices' do
448
+ it 'make a call to the live endpoint for: cash_prices' do
449
+ response = @@pokitdok.cash_prices({ zip_code: '29412', cpt_code: '99385'})
450
+ refute_nil(response["meta"], msg="the response[meta] section is empty")
451
+ refute_nil(response["data"], msg="the response[data] section is empty")
452
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
329
453
 
330
- describe 'Insurance Prices endpoint' do
331
- it 'should expose the insurance prices endpoint' do
332
- stub_request(:get, MATCH_NETWORK_LOCATION).
333
- to_return(status: 200, body: '{ "string" : "" }')
334
-
335
- query = { cpt_code: '87799', zip_code: '32218' }
336
- @prices = @@pokitdok.insurance_prices query
337
-
338
- refute_nil(@prices)
339
- end
340
454
  end
455
+ end
456
+ describe 'Data API Convenience function test: icd_convert' do
457
+ it 'make a call to the live endpoint for: icd_convert' do
458
+ @params = {code: '250.12'}
459
+ response = @@pokitdok.icd_convert @params
460
+ refute_nil(response["meta"].keys, msg="the response[meta] section is empty")
461
+ refute_nil(response["data"].keys, msg="the response[data] section is empty")
462
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
341
463
 
342
- describe 'Payers endpoint' do
343
- it 'should expose the payers endpoint' do
344
- stub_request(:get, MATCH_NETWORK_LOCATION).
345
- to_return(status: 200, body: '{ "string" : "" }')
346
-
347
- @payers = @@pokitdok.payers(state: 'CA')
348
-
349
- refute_nil(@payers)
350
- end
351
464
  end
465
+ end
466
+ describe 'Data API Convenience function test: mpc' do
467
+ it 'make a call to the live endpoint for: mpc' do
468
+ @params = {code: '99213'}
469
+ response = @@pokitdok.mpc @params
470
+ refute_nil(response["meta"], msg="the response[meta] section is empty")
471
+ refute_nil(response["data"], msg="the response[data] section is empty")
472
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
352
473
 
353
- describe 'Plans endpoint' do
354
- it 'should expose the plans endpoint' do
355
- stub_request(:get, MATCH_NETWORK_LOCATION).
356
- to_return(status: 200, body: '{ "string" : "" }')
357
-
358
- @plans = @@pokitdok.plans
359
-
360
- refute_nil(@plans)
361
- end
362
-
363
- it 'should expose the plans endpoint withe state and plan type' do
364
- stub_request(:get, MATCH_NETWORK_LOCATION).
365
- to_return(status: 200, body: '{ "string" : "" }')
366
-
367
- query = {state: 'TX', plan_type: 'PPO'}
368
- @plans = @@pokitdok.plans(query)
369
-
370
- refute_nil(@plans)
371
- end
372
474
  end
475
+ end
476
+ describe 'Data API Convenience function test: insurance_prices' do
477
+ it 'make a call to the live endpoint for: insurance_prices' do
478
+ @params = {zip_code: '94401', cpt_code: '90658'}
479
+ response = @@pokitdok.insurance_prices @params
480
+ refute_nil(response["meta"].keys, msg="the response[meta] section is empty")
481
+ refute_nil(response["data"].keys, msg="the response[data] section is empty")
482
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
373
483
 
374
- describe 'Providers endpoint' do
375
- it 'should expose the providers endpoint' do
376
- stub_request(:get, MATCH_NETWORK_LOCATION).
377
- to_return(status: 200, body: '{ "string" : "" }')
378
-
379
- query = { npi: '1467560003' }
380
- @providers = @@pokitdok.providers(query)
381
-
382
- refute_nil(@providers)
383
- end
384
-
385
- it 'should expose the providers endpoint with args' do
386
- stub_request(:get, MATCH_NETWORK_LOCATION).
387
- to_return(status: 200, body: '{ "string" : "" }')
388
-
389
- query = {
390
- zipcode: '29307',
391
- specialty: 'rheumatology',
392
- radius: '20mi'
393
- }
394
- @providers = @@pokitdok.providers(query)
395
-
396
- refute_nil(@providers)
397
- end
398
484
  end
485
+ end
486
+ describe 'Data API Convenience function test: oop_insurance_estimate' do
487
+ it 'make a call to the live endpoint for: oop_insurance_estimate' do
488
+ @params = {
489
+ trading_partner_id: "MOCKPAYER",
490
+ cpt_bundle: ["99385"],
491
+ zip_code: "29412",
492
+ eligibility: {
493
+ provider: {
494
+ first_name: "JEROME",
495
+ last_name: "AYA-AY",
496
+ npi: "1467560003"
497
+ },
498
+ member: {
499
+ birth_date: "1970-01-25",
500
+ first_name: "Jane",
501
+ last_name: "Doe",
502
+ id: "W000000000"
503
+ }
504
+ }
505
+ }
506
+ response = @@pokitdok.oop_insurance_estimate @params
507
+ refute_nil(response["meta"].keys, msg="the response[meta] section is empty")
508
+ refute_nil(response["data"].keys, msg="the response[data] section is empty")
509
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
399
510
 
400
- describe 'Trading Partners endpoints' do
401
- it 'should expose the trading partners endpoint (index call)' do
402
- stub_request(:get, MATCH_NETWORK_LOCATION).
403
- to_return(status: 200, body: '{ "string" : "" }')
404
-
405
- @trading_partners = @@pokitdok.trading_partners
406
-
407
- refute_nil(@trading_partners)
408
- end
409
-
410
- it 'should expose the trading partners endpoint (get call)' do
411
- stub_request(:get, MATCH_NETWORK_LOCATION).
412
- to_return(status: 200, body: '{ "string" : "" }')
413
-
414
- @trading_partners = @@pokitdok.trading_partners({ trading_partner_id: 'aetna' })
415
-
416
- refute_nil(@trading_partners)
417
- end
418
511
  end
512
+ end
513
+ describe 'Data API Convenience function test: oop_insurance_prices' do
514
+ it 'make a call to the live endpoint for: oop_insurance_prices' do
515
+ @params = {
516
+ trading_partner_id: "MOCKPAYER",
517
+ cpt_bundle:["99385"],
518
+ price: {
519
+ amount: "750"
520
+ }
521
+ }
522
+ response = @@pokitdok.oop_insurance_prices @params
523
+ refute_nil(response["meta"].keys, msg="the response[meta] section is empty")
524
+ refute_nil(response["data"].keys, msg="the response[data] section is empty")
525
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
419
526
 
420
- describe 'Referrals endpoint' do
421
- it 'should expose the referrals endpoint' do
422
- stub_request(:post, MATCH_NETWORK_LOCATION).
423
- to_return(status: 200, body: '{ "string" : "" }')
424
-
425
- query = JSON.parse(IO.read('spec/fixtures/referrals.json'))
426
- @referrals = @@pokitdok.referrals(query)
427
-
428
- refute_nil(@referrals)
429
- end
430
527
  end
528
+ end
529
+ describe 'Data API Convenience function test: plans' do
530
+ it 'make a call to the live endpoint for: plans' do
531
+ @params = {state: 'SC', plan_type: 'PPO'}
532
+ response = @@pokitdok.plans @params
533
+ refute_nil(response["meta"], msg="the response[meta] section is empty")
534
+ refute_nil(response["data"], msg="the response[data] section is empty")
535
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
431
536
 
432
- describe 'Authorizations endpoint' do
433
- it 'should expose the authorizations endpoint' do
434
- stub_request(:post, MATCH_NETWORK_LOCATION).
435
- to_return(status: 200, body: '{ "string" : "" }')
436
-
437
- query = JSON.parse(IO.read('spec/fixtures/authorizations.json'))
438
- @authorizations = @@pokitdok.authorizations query
439
-
440
- refute_nil(@authorizations)
441
- end
442
537
  end
538
+ end
539
+ describe 'Data API Convenience function test: providers' do
540
+ it 'make a call to the live endpoint for: providers' do
541
+ @params = {npi: '1467560003'}
542
+ response = @@pokitdok.providers @params
543
+ refute_nil(response["meta"], msg="the response[meta] section is empty")
544
+ refute_nil(response["data"], msg="the response[data] section is empty")
545
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
443
546
 
444
- describe 'Scheduling endpoints' do
445
- it 'should list the schedulers' do
446
- stub_request(:get, MATCH_NETWORK_LOCATION).
447
- to_return(status: 200, body: '{ "string" : "" }')
448
-
449
- @schedulers = @@pokitdok.schedulers
450
-
451
- refute_nil(@schedulers)
452
- end
453
-
454
- it 'should give details on a specific scheduler' do
455
- stub_request(:get, MATCH_NETWORK_LOCATION).
456
- to_return(status: 200, body: '{ "string" : "" }')
457
-
458
- @scheduler = @@pokitdok.scheduler({ uuid: '967d207f-b024-41cc-8cac-89575a1f6fef' })
459
-
460
- refute_nil(@scheduler)
461
- end
462
-
463
- it 'should list appointment types' do
464
- stub_request(:get, MATCH_NETWORK_LOCATION).
465
- to_return(status: 200, body: '{ "string" : "" }')
466
-
467
- @appointment_types = @@pokitdok.appointment_types
468
-
469
- refute_nil(@appointment_types)
470
- end
471
-
472
- it 'should give details on a specific appointment type' do
473
- stub_request(:get, MATCH_NETWORK_LOCATION).
474
- to_return(status: 200, body: '{ "string" : "" }')
475
-
476
- @appointment_type = @@pokitdok.appointment_type({ uuid: 'ef987695-0a19-447f-814d-f8f3abbf4860' })
477
-
478
- refute_nil(@appointment_type)
479
- end
480
-
481
- it 'should create an open schedule slot' do
482
- # Special Case: The scheduling endpoint reauthenticates for the scope (user_schedule),
483
- # which would be caught by the below 'stub_request'. This would cause the OAuth module
484
- # to fail because of an empty return body (to see what is required on an OAuth) POST
485
- # refer to the 'before' code block above. This 'stub_request' will only catch the /schedule/slots/ request.
486
- stub_request(:post, MATCH_NETWORK_LOCATION).
487
- to_return(status: 200, body: '{ "string" : "" }')
488
-
489
- query = {
490
- pd_provider_uuid: "b691b7f9-bfa8-486d-a689-214ae47ea6f8",
491
- location: [32.788110, -79.932364],
492
- appointment_type: "AT1",
493
- start_date: "2014-12-25T15:09:34.197709",
494
- end_date: "2014-12-25T16:09:34.197717"
495
- }
496
- @slot = @@pokitdok.schedule_slots(query)
497
-
498
- refute_nil(@slot)
499
- end
500
-
501
- it 'should give details on a specific appointment' do
502
- stub_request(:get, MATCH_NETWORK_LOCATION).
503
- to_return(status: 200, body: '{ "string" : "" }')
504
-
505
- @appointment = @@pokitdok.appointments({ uuid: 'ef987691-0a19-447f-814d-f8f3abbf4859' })
506
-
507
- refute_nil(@appointment)
508
- end
509
-
510
- it 'should give details on a searched appointments' do
511
- stub_request(:get, MATCH_NETWORK_LOCATION).
512
- to_return(status: 200, body: '{ "string" : "" }')
513
-
514
- query = {
515
- 'appointment_type' => 'AT1',
516
- 'start_date' => Time.now.strftime("%Y/%m/%d"),
517
- 'end_date' => Time.now.strftime("%Y/%m/%d"),
518
- }
519
- @appointments = @@pokitdok.appointments(query)
520
-
521
- refute_nil(@appointments)
522
- end
523
-
524
- it 'should book appointment for an open slot' do
525
- stub_request(:put, MATCH_NETWORK_LOCATION).
526
- to_return(status: 200, body: '{ "string" : "" }')
527
-
528
- appt_uuid = "ef987691-0a19-447f-814d-f8f3abbf4859"
529
- booking_query = {
530
- patient: {
531
- uuid: "500ef469-2767-4901-b705-425e9b6f7f83",
532
- email: "john@johndoe.com",
533
- phone: "800-555-1212",
534
- birth_date: "1970-01-01",
535
- first_name: "John",
536
- last_name: "Doe"
537
- },
538
- description: "Welcome to M0d3rN Healthcare"
539
- }
540
- @slot = @@pokitdok.book_appointment(appt_uuid, booking_query)
541
-
542
- refute_nil(@slot)
543
- end
544
-
545
- it 'should cancel a specified appointment' do
546
- stub_request(:delete, MATCH_NETWORK_LOCATION).
547
- to_return(status: 200, body: '{ "string" : "" }')
548
-
549
- @cancel_response = @@pokitdok.cancel_appointment "ef987691-0a19-447f-814d-f8f3abbf4859"
550
-
551
- refute_nil(@cancel_response)
552
- end
553
547
  end
554
-
555
- describe 'Identity Endpoint' do
556
- it 'should expose the identity endpoint for creation' do
557
- stub_request(:post, MATCH_NETWORK_LOCATION).
558
- to_return(status: 200, body: '{ "string" : "" }')
559
-
560
- query = {
561
- prefix: "Mr.",
562
- first_name: "Gerald",
563
- middle_name: "Harold",
564
- last_name: "Whitmire",
565
- suffix: "IV",
566
- birth_date: "2000-05-25",
567
- gender: "male",
568
- email: "oscar@@pokitdok.com",
569
- phone: "555-555-5555",
570
- secondary_phone: "333-333-4444",
571
- address: {
572
- address_lines: ["1400 Anyhoo Avenue"],
573
- city: "Springfield",
574
- state: "IL",
575
- zipcode: "90210"
576
- }
577
- }
578
- @identity = @@pokitdok.create_identity(query)
579
-
580
- refute_nil(@identity)
581
- end
582
-
583
- it 'should expose the identity endpoint for querying via id' do
584
- stub_request(:get, MATCH_NETWORK_LOCATION).
585
- to_return(status: 200, body: '{ "string" : "" }')
586
-
587
- @identity = @@pokitdok.identity(identity_uuid: '1a0a60b2-3e07-11e6-94c0-08002778b074')
588
-
589
- refute_nil(@identity)
590
- end
591
-
592
- it 'should expose the identity endpoint for querying via params' do
593
- stub_request(:get, MATCH_NETWORK_LOCATION).
594
- to_return(status: 200, body: '{ "string" : "" }')
595
-
596
- query = {first_name: 'Gerald', last_name: 'Whitmire'}
597
- @identities = @@pokitdok.identity(query)
598
-
599
- refute_nil(@identities)
600
- end
601
-
602
- it 'should expose the identity endpoint for updating' do
603
- stub_request(:put, MATCH_NETWORK_LOCATION).
604
- to_return(status: 200, body: '{ "string" : "" }')
605
-
606
- @identity = @@pokitdok.update_identity('1a0a60b2-3e07-11e6-94c0-08002778b074', { first_name: 'John' })
607
-
608
- refute_nil(@identity)
609
- end
610
-
611
- it 'should expose the identity history endpoint' do
612
- stub_request(:get, MATCH_NETWORK_LOCATION).
613
- to_return(status: 200, body: '{ "string" : "" }')
614
-
615
- @identity = @@pokitdok.identity_history('1a0a60b2-3e07-11e6-94c0-08002778b074')
616
-
617
- refute_nil(@identity)
618
- end
619
-
620
- it 'should expose the identity history endpoint with version number' do
621
- stub_request(:get, MATCH_NETWORK_LOCATION).
622
- to_return(status: 200, body: '{ "string" : "" }')
623
-
624
- @identity = @@pokitdok.identity_history('1a0a60b2-3e07-11e6-94c0-08002778b074', 1)
625
-
626
- refute_nil(@identity)
627
- end
628
-
629
- it 'should expose the identity match endpoint' do
630
- stub_request(:post, MATCH_NETWORK_LOCATION).
631
- to_return(status: 200, body: '{ "string" : "" }')
632
-
633
- query = JSON.parse(IO.read('spec/fixtures/identity_match.json'))
634
- @identity = @@pokitdok.identity_match(query)
635
-
636
- refute_nil(@identity)
637
- end
548
+ end
549
+ describe 'Data API Convenience function test: trading_partners' do
550
+ it 'make a call to the live endpoint for: trading_partners' do
551
+ response = @@pokitdok.trading_partners("aetna")
552
+ refute_nil(response["meta"], msg="the response[meta] section is empty")
553
+ refute_nil(response["data"], msg="the response[data] section is empty")
554
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
638
555
  end
556
+ end
639
557
 
640
- describe 'Pharmacy Plans Endpoint' do
641
- it 'should expose the pharmacy plans endpoint' do
642
- stub_request(:get, MATCH_NETWORK_LOCATION).
643
- to_return(status: 200, body: '{ "string" : "" }')
644
-
645
- query = {trading_partner_id: 'MOCKPAYER', plan_number: 'S5820003'}
646
- @pharmacy_plans = @@pokitdok.pharmacy_plans(query)
558
+ #
559
+ # ******************************
560
+ # Pharmacy API tests
561
+ # ******************************
562
+ #
563
+ describe 'Pharmacy API Convenience function test: pharmacy_plans' do
564
+ it 'make a call to the live endpoint for: pharmacy_plans' do
565
+ response = @@pokitdok.pharmacy_plans(trading_partner_id:'medicare_national', plan_number:'S5820003')
566
+ refute_nil(response["meta"], msg="the response[meta] section is empty")
567
+ refute_nil(response["data"], msg="the response[data] section is empty")
568
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
647
569
 
648
- refute_nil(@pharmacy_plans)
649
- end
650
570
  end
571
+ end
572
+ describe 'Pharmacy API Convenience function test: pharmacy_formulary' do
573
+ it 'make a call to the live endpoint for: pharmacy_formulary' do
574
+ response = @@pokitdok.pharmacy_formulary(trading_partner_id: 'medicare_national', plan_number: 'S5820003', ndc: '00006073554')
575
+ refute_nil(response["meta"], msg="the response[meta] section is empty")
576
+ refute_nil(response["data"], msg="the response[data] section is empty")
577
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
651
578
 
652
- describe 'Pharmacy Formulary Endpoint' do
653
- it 'should expose the pharmacy formulary endpoint' do
654
- stub_request(:get, MATCH_NETWORK_LOCATION).
655
- to_return(status: 200, body: '{ "string" : "" }')
656
-
657
- query = {trading_partner_id: 'MOCKPAYER', plan_number: 'S5820003',
658
- ndc: '59310-579-22'}
659
- @pharmacy_formulary = @@pokitdok.pharmacy_formulary(query)
660
-
661
- refute_nil(@pharmacy_formulary)
662
- end
663
579
  end
580
+ end
581
+ describe 'Pharmacy API Convenience function test: pharmacy_network' do
582
+ it 'make a call to the live endpoint for: pharmacy_network' do
583
+ response = @@pokitdok.pharmacy_network(trading_partner_id: 'medicare_national', plan_number: 'S5820003' , zipcode: '07030', radius: '1mi')
584
+ refute_nil(response["meta"], msg="the response[meta] section is empty")
585
+ refute_nil(response["data"], msg="the response[data] section is empty")
586
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
587
+ end
588
+ end
664
589
 
665
- describe 'Pharmacy Network Endpoint' do
666
- it 'should expose the pharmacy formulary endpoint by NPI' do
667
- stub_request(:get, MATCH_NETWORK_LOCATION).
668
- to_return(status: 200, body: '{ "string" : "" }')
669
-
670
- query = {trading_partner_id: 'MOCKPAYER', plan_number: 'S5596033',
671
- npi: '1912301953'}
672
- @pharmacy_network = @@pokitdok.pharmacy_network(query)
673
-
674
- refute_nil(@pharmacy_network)
675
- end
676
- it 'should expose the pharmacy formulary endpoint by searching' do
677
- stub_request(:get, MATCH_NETWORK_LOCATION).
678
- to_return(status: 200, body: '{ "string" : "" }')
679
-
680
- query = {trading_partner_id: 'MOCKPAYER', plan_number: 'S5596033',
681
- zipcode: '94401', radius: '10mi'}
682
- @pharmacy_network = @@pokitdok.pharmacy_network(query)
683
-
684
- refute_nil(@pharmacy_network)
685
- end
590
+ #
591
+ # ******************************
592
+ # identity tests
593
+ # ******************************
594
+ #
595
+
596
+ describe 'Identity API Convenience function test: validate_identity ' do
597
+ it 'make a call to the live endpoint for: validate_identity' do
598
+ # make a fake identity
599
+ @DUARD = {
600
+ first_name: 'Duard',
601
+ last_name: 'Osinski',
602
+ birth_date: {
603
+ day: 12,
604
+ month: 3,
605
+ year: 1952
606
+ },
607
+ ssn: '491450000',
608
+ address: {city: 'North Perley',
609
+ country_code: 'US',
610
+ postal_code: '24330',
611
+ state_or_province: 'GA',
612
+ street1: '41072 Douglas Terrace ',
613
+ street2: 'Apt. 992'
614
+ }
615
+ }
616
+ # test that DUARD is a valid identity
617
+ response = @@pokitdok.validate_identity @DUARD
618
+ refute_nil(response["meta"], msg="the response[meta] section is empty: #{response}")
619
+ refute_nil(response["data"], msg="the response[data] section is empty: #{response}")
620
+ assert @@pokitdok.status_code == 200, "Status Code assertion failure. Tested for 200, Observed status code: #{@@pokitdok.status_code}"
686
621
  end
687
622
  end
688
623
  end
689
624
  end
625
+