eligible 2.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.
@@ -0,0 +1,344 @@
1
+ require File.expand_path('../test_helper', __FILE__)
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'mocha'
5
+ require 'rest-client'
6
+
7
+ class TestEligible < Test::Unit::TestCase
8
+ include Mocha
9
+
10
+ context "Version" do
11
+ should "have a version number" do
12
+ assert_not_nil Eligible::VERSION
13
+ end
14
+ end
15
+
16
+ context "General API" do
17
+ setup do
18
+ Eligible.api_key = "TEST"
19
+ @mock = mock
20
+ Eligible.mock_rest_client = @mock
21
+ end
22
+
23
+ teardown do
24
+ Eligible.mock_rest_client = nil
25
+ Eligible.api_key = nil
26
+ end
27
+
28
+ should "not specifying api credentials should raise an exception" do
29
+ Eligible.api_key = nil
30
+ assert_raises Eligible::AuthenticationError do
31
+ Eligible::Plan.get({})
32
+ end
33
+ end
34
+
35
+ should "specifying invalid api credentials should raise an exception" do
36
+ Eligible.api_key = "invalid"
37
+ response = test_response(test_invalid_api_key_error, 401)
38
+ assert_raises Eligible::AuthenticationError do
39
+ @mock.expects(:get).once.raises(RestClient::ExceptionWithResponse.new(response, 401))
40
+ Eligible::Plan.get({})
41
+ end
42
+ end
43
+ end
44
+
45
+ context "Plan" do
46
+ setup do
47
+ Eligible.api_key = "TEST"
48
+ @mock = mock
49
+ Eligible.mock_rest_client = @mock
50
+ end
51
+
52
+ teardown do
53
+ Eligible.mock_rest_client = nil
54
+ Eligible.api_key = nil
55
+ end
56
+
57
+ should "return an error if no params are supplied" do
58
+ params = {}
59
+ response = test_response(test_plan_missing_params)
60
+ @mock.expects(:get).returns(response)
61
+ plan = Eligible::Plan.get(params)
62
+ assert_not_nil plan.error
63
+ end
64
+
65
+ should "return plan information if valid params are supplied" do
66
+ params = {
67
+ :payer_name => "Aetna",
68
+ :payer_id => "000001",
69
+ :provider_last_name => "Last",
70
+ :provider_first_name => "First",
71
+ :provider_npi => "1028384219",
72
+ :member_id => "W120923801",
73
+ :member_last_name => "Austen",
74
+ :member_first_name => "Jane",
75
+ :member_dob => "1955-12-14"
76
+ }
77
+ response = test_response(test_plan)
78
+ @mock.expects(:get).returns(response)
79
+ plan = Eligible::Plan.get(params)
80
+ assert_nil plan.error
81
+ assert_not_nil plan.all
82
+ end
83
+
84
+ should "return the right subsets of the data when requested" do
85
+ params = {
86
+ :payer_name => "Aetna",
87
+ :payer_id => "000001",
88
+ :provider_last_name => "Last",
89
+ :provider_first_name => "First",
90
+ :provider_npi => "1028384219",
91
+ :member_id => "W120923801",
92
+ :member_last_name => "Austen",
93
+ :member_first_name => "Jane",
94
+ :member_dob => "1955-12-14"
95
+ }
96
+ response = test_response(test_plan)
97
+ @mock.expects(:get).returns(response)
98
+ plan = Eligible::Plan.get(params)
99
+
100
+ assert_not_nil plan.all[:primary_insurance]
101
+ assert_not_nil plan.status[:coverage_status]
102
+ assert_nil plan.status[:deductible_in_network]
103
+ assert_not_nil plan.deductible[:deductible_in_network]
104
+ assert_nil plan.deductible[:balance]
105
+ assert_not_nil plan.dates[:primary_insurance][:plan_begins]
106
+ assert_nil plan.dates[:deductible_in_network]
107
+ assert_not_nil plan.balance[:balance]
108
+ assert_nil plan.balance[:deductible_in_network]
109
+ assert_not_nil plan.stop_loss[:stop_loss_in_network]
110
+ assert_nil plan.stop_loss[:deductible_in_network]
111
+ end
112
+ end
113
+
114
+ context "Service" do
115
+ setup do
116
+ Eligible.api_key = "TEST"
117
+ @mock = mock
118
+ Eligible.mock_rest_client = @mock
119
+ end
120
+
121
+ teardown do
122
+ Eligible.mock_rest_client = nil
123
+ Eligible.api_key = nil
124
+ end
125
+
126
+ should "return an error if no params are supplied" do
127
+ params = {}
128
+ response = test_response(test_service_missing_params)
129
+ @mock.expects(:get).returns(response)
130
+ service = Eligible::Service.get(params)
131
+ assert_not_nil service.error
132
+ end
133
+
134
+ should "return eligibility information if valid params are supplied" do
135
+ params = {
136
+ :payer_name => "Aetna",
137
+ :payer_id => "000001",
138
+ :provider_last_name => "Last",
139
+ :provider_first_name => "First",
140
+ :provider_npi => "1028384219",
141
+ :member_id => "W120923801",
142
+ :member_last_name => "Austen",
143
+ :member_first_name => "Jane",
144
+ :member_dob => "1955-12-14"
145
+ }
146
+ response = test_response(test_service)
147
+ @mock.expects(:get).returns(response)
148
+ service = Eligible::Service.get(params)
149
+ assert_nil service.error
150
+ assert_not_nil service.all
151
+ end
152
+
153
+ should "return the right subsets of the data when requested" do
154
+ params = {
155
+ :payer_name => "Aetna",
156
+ :payer_id => "000001",
157
+ :provider_last_name => "Last",
158
+ :provider_first_name => "First",
159
+ :provider_npi => "1028384219",
160
+ :member_id => "W120923801",
161
+ :member_last_name => "Austen",
162
+ :member_first_name => "Jane",
163
+ :member_dob => "1955-12-14"
164
+ }
165
+ response = test_response(test_service)
166
+ @mock.expects(:get).returns(response)
167
+ service = Eligible::Service.get(params)
168
+
169
+ assert_not_nil service.all[:service_begins]
170
+ assert_not_nil service.visits[:visits_in_network]
171
+ assert_nil service.visits[:copayment_in_network]
172
+ assert_not_nil service.copayment[:copayment_in_network]
173
+ assert_nil service.copayment[:visits_in_network]
174
+ assert_not_nil service.coinsurance[:coinsurance_in_network]
175
+ assert_nil service.coinsurance[:visits_in_network]
176
+ assert_not_nil service.deductible[:deductible_in_network]
177
+ assert_nil service.deductible[:visits_in_network]
178
+ end
179
+ end
180
+
181
+ context "Demographic" do
182
+ setup do
183
+ Eligible.api_key = "TEST"
184
+ @mock = mock
185
+ Eligible.mock_rest_client = @mock
186
+ end
187
+
188
+ teardown do
189
+ Eligible.mock_rest_client = nil
190
+ Eligible.api_key = nil
191
+ end
192
+
193
+ should "return an error if no params are supplied" do
194
+ params = {}
195
+ response = test_response(test_demographic_missing_params)
196
+ @mock.expects(:get).returns(response)
197
+ demographic = Eligible::Demographic.get(params)
198
+ assert_not_nil demographic.error
199
+ end
200
+
201
+ should "return demographic information if valid params are supplied" do
202
+ params = {
203
+ :payer_name => "Aetna",
204
+ :payer_id => "000001",
205
+ :provider_last_name => "Last",
206
+ :provider_first_name => "First",
207
+ :provider_npi => "1028384219",
208
+ :member_id => "W120923801",
209
+ :member_last_name => "Austen",
210
+ :member_first_name => "Jane",
211
+ :member_dob => "1955-12-14"
212
+ }
213
+ response = test_response(test_demographic)
214
+ @mock.expects(:get).returns(response)
215
+ demographic = Eligible::Demographic.get(params)
216
+ assert_nil demographic.error
217
+ assert_not_nil demographic.all
218
+ end
219
+
220
+ should "return the right subsets of the data when requested" do
221
+ params = {
222
+ :payer_name => "Aetna",
223
+ :payer_id => "000001",
224
+ :provider_last_name => "Last",
225
+ :provider_first_name => "First",
226
+ :provider_npi => "1028384219",
227
+ :member_id => "W120923801",
228
+ :member_last_name => "Austen",
229
+ :member_first_name => "Jane",
230
+ :member_dob => "1955-12-14"
231
+ }
232
+ response = test_response(test_demographic)
233
+ @mock.expects(:get).returns(response)
234
+ demographic = Eligible::Demographic.get(params)
235
+
236
+ assert_not_nil demographic.all[:timestamp]
237
+ assert_not_nil demographic.zip[:zip]
238
+ assert_nil demographic.zip[:group_id]
239
+ assert_not_nil demographic.employer[:group_id]
240
+ assert_nil demographic.employer[:zip]
241
+ assert_not_nil demographic.address[:address]
242
+ assert_nil demographic.address[:group_id]
243
+ assert_not_nil demographic.dob[:dob]
244
+ assert_nil demographic.dob[:address]
245
+ end
246
+ end
247
+
248
+ context "Claim" do
249
+ setup do
250
+ Eligible.api_key = "TEST"
251
+ @mock = mock
252
+ Eligible.mock_rest_client = @mock
253
+ end
254
+
255
+ teardown do
256
+ Eligible.mock_rest_client = nil
257
+ Eligible.api_key = nil
258
+ end
259
+
260
+ should "return an error if no params are supplied" do
261
+ params = {}
262
+ response = test_response(test_claim_missing_params)
263
+ @mock.expects(:get).returns(response)
264
+ claim = Eligible::Claim.get(params)
265
+ assert claim["success"] == "false"
266
+ end
267
+
268
+ should "post a claim" do
269
+ params = {"api_key"=>"asdfsdfsd21132ddsfsdfd", "billing_provider"=>{"taxonomy_code"=>"332B00000X", "practice_name"=>"Jane Austen Practice", "npi"=>"1922222222", "address"=>{"street_line_1"=>"419 Fulton", "street_line_2"=>"", "city"=>"San Francisco", "state"=>"CA", "zip"=>"94102"}, "tin"=>"43291023", "insurance_provider_id"=>"129873210"}, "pay_to_provider"=>{"address"=>{"street_line_1"=>"", "street_line_2"=>"", "city"=>"", "state"=>"", "zip"=>""}}, "subscriber"=>{"last_name"=>"Franklin", "first_name"=>"Benjamin", "member_id"=>"W2832032427", "group_id"=>"455716", "group_name"=>"none", "dob"=>"1734-05-04", "gender"=>"M", "address"=>{"street_line_1"=>"435 Sugar Lane", "street_line_2"=>"", "city"=>"Sweet", "state"=>"OH", "zip"=>"436233127"}}, "payer"=>{"name"=>"AETNA", "id"=>"60054", "address"=>{"street_line_1"=>"Po Box 981106", "street_line_2"=>"", "city"=>"El Paso", "state"=>"TX", "zip"=>"799981222"}}, "dependent"=>{"relationship"=>"", "last_name"=>"", "first_name"=>"", "dob"=>"", "gender"=>"", "address"=>{"street_line_1"=>"", "street_line_2"=>"", "city"=>"", "state"=>"", "zip"=>""}}, "claim"=>{"total_charge_amount"=>"275", "claim_frequency"=>"1", "patient_signature_on_file"=>"Y", "provider_plan_participation"=>"A", "direct_payment_authorized"=>"Y", "release_of_information"=>"I", "service_lines"=>[{"line_number"=>"1", "service_start"=>"2013-03-07", "service_end"=>"2013-03-07", "authorization_code"=>"", "place_of_service"=>"11", "charge_amount"=>"275", "product_service"=>"99213", "qualifier"=>"HC", "description"=>"", "modifier_1"=>"", "diagnosis_1"=>"32723"}]}}
270
+ response = test_response(test_post_claim)
271
+ end
272
+ end
273
+
274
+ context "Coverage" do
275
+ setup do
276
+ Eligible.api_key = "TEST"
277
+ @mock = mock
278
+ Eligible.mock_rest_client = @mock
279
+ end
280
+
281
+ teardown do
282
+ Eligible.mock_rest_client = nil
283
+ Eligible.api_key = nil
284
+ end
285
+
286
+ should "return an error if no params are supplied" do
287
+ params = {}
288
+ response = test_response(test_coverage_missing_params)
289
+ @mock.expects(:get).returns(response)
290
+ coverage = Eligible::Coverage.get(params)
291
+ assert_not_nil coverage.error
292
+ end
293
+
294
+ should "return coverage information if valid params are supplied" do
295
+ params = {
296
+ :payer_name => "Aetna",
297
+ :payer_id => "000001",
298
+ :provider_last_name => "Last",
299
+ :provider_first_name => "First",
300
+ :provider_npi => "1028384219",
301
+ :member_id => "W120923801",
302
+ :member_last_name => "Austen",
303
+ :member_first_name => "Jane",
304
+ :member_dob => "1955-12-14"
305
+ }
306
+ response = test_response(test_coverage)
307
+ @mock.expects(:get).returns(response)
308
+ coverage = Eligible::Coverage.get(params)
309
+
310
+ assert_not_nil coverage.all[:eligible_id]
311
+ end
312
+ end
313
+
314
+ context "Enrollment" do
315
+ setup do
316
+ Eligible.api_key = "TEST"
317
+ @mock = mock
318
+ Eligible.mock_rest_client = @mock
319
+ end
320
+
321
+ teardown do
322
+ Eligible.mock_rest_client = nil
323
+ Eligible.api_key = nil
324
+ end
325
+
326
+ should "post an enrollment request" do
327
+ params = {"service_provider_list"=>[{"facility_name"=>"Quality", "provider_name"=>"Jane Austen", "tax_id"=>"12345678", "address"=>"125 Snow Shoe Road", "city"=>"Sacramento", "state"=>"CA", "zip"=>"94107", "ptan"=>"54321", "npi"=>"987654321"}, {"facility_name"=>"Aetna", "provider_name"=>"Jack Austen", "tax_id"=>"12345678", "address"=>"985 Snow Shoe Road", "city"=>"Menlo Park", "state"=>"CA", "zip"=>"94107", "ptan"=>"54321", "npi"=>"987654321"}], "payer_ids"=>["00431", "00282"]}
328
+ response = test_response(test_post_enrollment)
329
+
330
+ @mock.expects(:post).returns(response)
331
+ enrollment = Eligible::Enrollment.post(params)
332
+
333
+ assert_not_nil enrollment.all[:enrollment_request]
334
+ end
335
+
336
+ should "get the status of an enrollment request" do
337
+ params = { "NPI" => "1028384219" }
338
+ response = test_response(test_get_enrollment)
339
+ @mock.expects(:get).returns(response)
340
+ enrollment = Eligible::Enrollment.get(params)
341
+ assert_not_nil enrollment.all[:enrollments]
342
+ end
343
+ end
344
+ end
@@ -0,0 +1,87 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'eligible'
3
+
4
+ module Eligible
5
+ @mock_rest_client = nil
6
+
7
+ def self.mock_rest_client=(mock_client)
8
+ @mock_rest_client = mock_client
9
+ end
10
+
11
+ def self.execute_request(opts)
12
+ get_params = (opts[:headers] || {})[:params]
13
+ post_params = opts[:payload]
14
+ case opts[:method]
15
+ when :get then @mock_rest_client.get opts[:url], get_params, post_params
16
+ when :post then @mock_rest_client.post opts[:url], get_params, post_params
17
+ when :delete then @mock_rest_client.delete opts[:url], get_params, post_params
18
+ end
19
+ end
20
+ end
21
+
22
+ def test_response(body, code=200)
23
+ # When an exception is raised, restclient clobbers method_missing. Hence we
24
+ # can't just use the stubs interface.
25
+ body = MultiJson.dump(body) if !(body.kind_of? String)
26
+ m = mock
27
+ m.instance_variable_set('@eligible_values', { :body => body, :code => code })
28
+ def m.body; @eligible_values[:body]; end
29
+ def m.code; @eligible_values[:code]; end
30
+ m
31
+ end
32
+
33
+ def test_invalid_api_key_error
34
+ { "error" => [ { "message" => "Could not authenticate you. Please re-try with a valid API key.", "code" => 1 }] }
35
+ end
36
+
37
+ def test_plan_missing_params
38
+ {"timestamp"=>"2013-02-01T13:25:58", "eligible_id"=>"A4F4E1D6-7DC3-4B20-87CE-B59F48811290", "mapping_version"=>"plan/all$Revision:6$$Date:13-01-110:18$", "error"=>{"response_code"=>"Y", "response_description"=>"Yes", "agency_qualifier_code"=>"", "agency_qualifier_description"=>"", "reject_reason_code"=>"41", "reject_reason_description"=>"Authorization/AccessRestrictions", "follow-up_action_code"=>"C", "follow-up_action_description"=>"PleaseCorrectandResubmit"}}
39
+ end
40
+
41
+ def test_plan
42
+ {"timestamp"=>"2013-01-14T20:39:57", "eligible_id"=>"B97BC91A-3E84-40A9-AA5C-D416CAE5CDB1", "mapping_version"=>"plan/all$Revision:6$$Date:13-01-110:18$", "primary_insurance"=>{"name"=>"Aetna", "id"=>"00002", "group_name"=>"TOWERGROUPCOMPANIES", "plan_begins"=>"2010-01-01", "plan_ends"=>"", "comments"=>["AetnaChoicePOSII"]}, "type"=>"30", "coverage_status"=>"1", "precertification_needed"=>"", "exclusions"=>"", "deductible_in_network"=>{"individual"=>{"base_period"=>"500", "remaining"=>"500", "comments"=>["MedDent", "MedDent"]}, "family"=>{"base_period"=>"1000", "remaining"=>"1000", "comments"=>["MedDent", "MedDent"]}}, "deductible_out_network"=>{"individual"=>{"base_period"=>"1250", "remaining"=>"1250", "comments"=>["MedDent", "MedDent"]}, "family"=>{"base_period"=>"3750", "remaining"=>"3750", "comments"=>["MedDent", "MedDent"]}}, "stop_loss_in_network"=>{"individual"=>{"base_period"=>"", "remaining"=>"2000", "comments"=>[]}, "family"=>{"base_period"=>"", "remaining"=>"4000", "comments"=>[]}}, "stop_loss_out_network"=>{"individual"=>{"base_period"=>"", "remaining"=>"3000", "comments"=>[]}, "family"=>{"base_period"=>"", "remaining"=>"6000", "comments"=>[]}}, "balance"=>"", "comments"=>[], "additional_insurance"=>{"comments"=>[]}}
43
+ end
44
+
45
+ def test_service_missing_params
46
+ {"timestamp"=>"2013-02-04T17:23:12", "eligible_id"=>"7EEA40A7-58C5-4EBC-A450-10C37CA2D252", "mapping_version"=>"service/all$Revision:4$$Date:12-12-280:13$", "error"=>{"response_code"=>"Y", "response_description"=>"Yes", "agency_qualifier_code"=>"", "agency_qualifier_description"=>"", "reject_reason_code"=>"41", "reject_reason_description"=>"Authorization/AccessRestrictions", "follow-up_action_code"=>"C", "follow-up_action_description"=>"PleaseCorrectandResubmit"}}
47
+ end
48
+
49
+ def test_service
50
+ {"timestamp"=>"2013-02-01T15:28:16", "eligible_id"=>"FD8994B1-F977-459A-81AC-D182EA8FE66D", "mapping_version"=>"service/all$Revision:4$$Date:12-12-280:13$", "type"=>"33", "coverage_status"=>"1", "service_begins"=>"", "service_ends"=>"", "not_covered"=>[], "comments"=>["AetnaChoicePOSII"], "precertification_needed"=>"", "visits_in_network"=>{"individual"=>{"total"=>"", "remaining"=>"", "comments"=>[]}, "family"=>{"total"=>"", "remaining"=>"", "comments"=>[]}}, "visits_out_network"=>{"individual"=>{"total"=>"", "remaining"=>"", "comments"=>[]}, "family"=>{"total"=>"", "remaining"=>"", "comments"=>[]}}, "copayment_in_network"=>{"individual"=>{"amount"=>"", "comments"=>[]}, "family"=>{"amount"=>"35", "comments"=>["OFFCHIROVISI", "COPAYNOTINCLUDEDINOOP", "MANPULATNCHRO"]}}, "copayment_out_network"=>{"individual"=>{"amount"=>"", "comments"=>[]}, "family"=>{"amount"=>"0", "comments"=>["MANPULATNCHRO"]}}, "coinsurance_in_network"=>{"individual"=>{"percent"=>"", "comments"=>[]}, "family"=>{"percent"=>"0", "comments"=>["OFFCHIROVISI", "MANPULATNCHRO"]}}, "coinsurance_out_network"=>{"individual"=>{"percent"=>"", "comments"=>[]}, "family"=>{"percent"=>"30", "comments"=>["CHIROVSTEVAL", "COINSAPPLIESTOOUTOFPOCKET", "MANPULATNCHRO"]}}, "deductible_in_network"=>{"individual"=>{"base_period"=>"", "remaining"=>"", "comments"=>[]}, "family"=>{"base_period"=>"", "remaining"=>"", "comments"=>[]}}, "deductible_out_network"=>{"individual"=>{"base_period"=>"", "remaining"=>"", "comments"=>[]}, "family"=>{"base_period"=>"", "remaining"=>"", "comments"=>[]}}, "additional_insurance"=>{"comments"=>[]}}
51
+ end
52
+
53
+ def test_demographic_missing_params
54
+ {"timestamp"=>"2013-02-05T13:21:38", "eligible_id"=>"AE9F5EB3-B4BF-4B2E-92C5-6307CE91DB81", "mapping_version"=>"demographic/dob$Revision:1$$Date:12-12-2619:01$", "error"=>{"response_code"=>"Y", "response_description"=>"Yes", "agency_qualifier_code"=>"", "agency_qualifier_description"=>"", "reject_reason_code"=>"41", "reject_reason_description"=>"Authorization/AccessRestrictions", "follow-up_action_code"=>"C", "follow-up_action_description"=>"PleaseCorrectandResubmit"}}
55
+ end
56
+
57
+ def test_demographic
58
+ {"timestamp"=>"2013-02-05T13:14:36", "eligible_id"=>"DCE2FFB3-179A-4825-ADA6-B8108FB5FB90", "mapping_version"=>"demographic/all$Revision:4$$Date:12-12-2622:25$", "last_name"=>"AUSTEN", "first_name"=>"JANE", "member_id"=>"R112114321", "group_id"=>"060801203300001", "group_name"=>"TOWERGROUPCOMPANIES", "dob"=>"1955-12-14", "gender"=>"M", "address"=>{"street_line_1"=>"123SOUTH7THSTREET", "street_line_2"=>"", "city"=>"CHICAGO", "state"=>"CA", "zip"=>"89701"}}
59
+ end
60
+
61
+ def test_claim_missing_params
62
+ {"success"=>"false", "created_at"=>"2013-06-03T23:53:39Z", "error"=>{"type"=>"scrub", "message"=>"you forgot to include gender"}}
63
+ end
64
+
65
+ def test_post_claim
66
+ {"timestamp"=>"2012-12-30T22:41:10", "eligible_id"=>"DCE2FFB3-179A-4825-ADA6-B8108FB5FB90", "mapping_version"=>"claim/status$Revision:1$$Date:12-12-3022:10$", "referenced_transaction_trace_number"=>"970779644", "claim_status_category_code"=>"F0", "claim_status_category_description"=>"Finalized-Theclaim/encounterhascompletedtheadjudicationcycleandnomoreactionwillbetaken.", "claim_status_code"=>"1", "claim_status_description"=>"Formoredetailedinformation,seeremittanceadvice.", "status_information_effective_date"=>"2007-03-13", "total_claim_charge_amount"=>"172", "claim_payment_amount"=>"126.9", "adjudication_finalized_date"=>"2007-03-18", "remittance_date"=>"2007-03-19", "remittance_trace_number"=>"458787", "payer_claim_control_number"=>"4121476181852", "claim_service_begin_date"=>"2007-02-23", "claim_service_end_date"=>"2007-02-28"}
67
+ end
68
+
69
+ def test_coverage_missing_params
70
+ {"created_at"=>"2013-06-11T12:21:47Z", "eligible_id"=>"57c320d8-2e14-68ed-73d0-41c3b23c0f43", "error"=>{"response_code"=>"Y", "response_description"=>"Yes", "agency_qualifier_code"=>"", "agency_qualifier_description"=>"", "reject_reason_code"=>"41", "reject_reason_description"=>"Authorization/Access Restrictions", "follow-up_action_code"=>"C", "follow-up_action_description"=>"Please Correct and Resubmit", "details"=>""}}
71
+ end
72
+
73
+ def test_coverage
74
+ {"created_at"=>"2013-05-09T22:42:40Z", "eligible_id"=>"3233a9a1-a286-2896-ba3d-9f171303428b", "demographics"=>{"subscriber"=>{"last_name"=>"FRANKLIN", "first_name"=>"BENJAMIN", "member_id"=>"TYA445554301", "group_id"=>"3207524", "group_name"=>"FOUNDING FATHERS", "dob"=>"1701-10-17", "gender"=>"M", "address"=>{"street_line_1"=>"2 FRANKLIN STREET", "street_line_2"=>"", "city"=>"SAN FRANCISCO", "state"=>"CA", "zip"=>"94102"}}, "dependent"=>{"last_name"=>"FRANKLIN", "first_name"=>"IDA", "member_id"=>"ZZZ445554301", "group_id"=>"3207524", "group_name"=>"FOUNDING FATHERS", "dob"=>"1701-12-12", "gender"=>"F", "address"=>{"street_line_1"=>"2 FRANKLIN STREET", "street_line_2"=>"", "city"=>"SAN FRANCISCO", "state"=>"CA", "zip"=>"94102"}}}, "primary_insurance"=>{"name"=>"CIGNA", "id"=>"00001", "contacts"=>[{"contact_type"=>"url", "contact_value"=>"cignaforhcp.cigna.com"}], "service_providers"=>{"physicians"=>[{"insurance_type"=>"HN", "insurance_type_label"=>"Health Maintenance Organization (HMO)", "primary_care"=>"true", "restricted"=>"TRUE", "contact_details"=>[{"last_name"=>"JEFFERSON", "first_name"=>"THOMAS", "indentification_type"=>"Centers for Medicare and Medicaid Services National Provider Identifier", "identification_code"=>"2222222222", "contacts"=>[], "address"=>{"street_line_1"=>"PO BOX 2222222", "street_line_2"=>"", "city"=>"SAN FRANCISCO", "state"=>"CA", "zip"=>"94105"}}], "dates"=>[{"date_type"=>"eligibility", "date_value"=>"2010-01-01"}], "comments"=>["HRA BALANCE"]}]}}, "plan"=>{"type"=>"30", "coverage_status"=>"1", "coverage_status_label"=>"ACTIVE COVERAGE", "coverage_basis"=>[], "plan_number"=>"43", "plan_name"=>"TRADITIONAL BLUE PPO 813 $15/ $15 COPAY", "group_name"=>"FOUNDING FATHERS", "dates"=>[{"date_type"=>"plan_begin", "date_value"=>"2010-01-01"}, {"date_type"=>"service", "date_value"=>"2013-05-24"}, {"date_type"=>"eligibility_begin", "date_value"=>"2007-02-01"}], "exclusions"=>{"noncovered"=>[{"type"=>"BZ", "type_label"=>"Physician Visit - Well", "time_period"=>"32", "time_period_label"=>"lifetime", "level"=>"INDIVIDUAL", "network"=>"OUT", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "dates"=>[], "contact_details"=>[], "comments"=>[]}], "pre_exisiting_condition"=>{"waiting_period"=>[]}}, "financials"=>{"deductible"=>{"remainings"=>{"in_network"=>[{"amount"=>"0", "level"=>"FAMILY", "insurance_type"=>"", "insurance_type_label"=>"", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "contact_details"=>[], "dates"=>[], "comments"=>[]}, {"amount"=>"0", "level"=>"INDIVIDUAL", "insurance_type"=>"", "insurance_type_label"=>"", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "contact_details"=>[], "dates"=>[], "comments"=>[]}], "out_network"=>[]}, "totals"=>{"in_network"=>[{"amount"=>"0", "time_period"=>"24", "time_period_label"=>"year_to_date", "level"=>"INDIVIDUAL", "insurance_type"=>"", "insurance_type_label"=>"", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "contact_details"=>[], "dates"=>[], "comments"=>[]}, {"amount"=>"0", "time_period"=>"23", "time_period_label"=>"calendar_year", "level"=>"INDIVIDUAL", "insurance_type"=>"", "insurance_type_label"=>"", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "contact_details"=>[], "dates"=>[], "comments"=>[]}, {"amount"=>"0", "time_period"=>"24", "time_period_label"=>"year_to_date", "level"=>"FAMILY", "insurance_type"=>"", "insurance_type_label"=>"", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "contact_details"=>[], "dates"=>[], "comments"=>[]}, {"amount"=>"0", "time_period"=>"23", "time_period_label"=>"calendar_year", "level"=>"FAMILY", "insurance_type"=>"", "insurance_type_label"=>"", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "contact_details"=>[], "dates"=>[], "comments"=>[]}], "out_network"=>[]}}, "stop_loss"=>{"remainings"=>{"in_network"=>[{"amount"=>"6490", "level"=>"INDIVIDUAL", "insurance_type"=>"HN", "insurance_type_label"=>"Health Maintenance Organization (HMO) - Medicare Risk", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "contact_details"=>[], "dates"=>[], "comments"=>[]}, {"amount"=>"0", "level"=>"FAMILY", "insurance_type"=>"HN", "insurance_type_label"=>"Health Maintenance Organization (HMO) - Medicare Risk", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "contact_details"=>[], "dates"=>[], "comments"=>[]}], "out_network"=>[]}, "totals"=>{"in_network"=>[{"amount"=>"210", "time_period"=>"24", "time_period_label"=>"year_to_date", "level"=>"INDIVIDUAL", "insurance_type"=>"HN", "insurance_type_label"=>"Health Maintenance Organization (HMO) - Medicare Risk", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "contact_details"=>[], "dates"=>[], "comments"=>[]}, {"amount"=>"210", "time_period"=>"24", "time_period_label"=>"year_to_date", "level"=>"FAMILY", "insurance_type"=>"HN", "insurance_type_label"=>"Health Maintenance Organization (HMO) - Medicare Risk", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "contact_details"=>[], "dates"=>[], "comments"=>[]}, {"amount"=>"0", "time_period"=>"23", "time_period_label"=>"calendar_year", "level"=>"FAMILY", "insurance_type"=>"HN", "insurance_type_label"=>"Health Maintenance Organization (HMO) - Medicare Risk", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "contact_details"=>[], "dates"=>[], "comments"=>[]}, {"amount"=>"6700", "time_period"=>"23", "time_period_label"=>"calendar_year", "level"=>"INDIVIDUAL", "insurance_type"=>"HN", "insurance_type_label"=>"Health Maintenance Organization (HMO) - Medicare Risk", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "contact_details"=>[], "dates"=>[], "comments"=>[]}], "out_network"=>[]}}, "spending_account"=>{"remaining"=>[]}, "coinsurance"=>{"percents"=>{"in_network"=>[], "out_network"=>[]}}, "copayment"=>{"amounts"=>{"in_network"=>[{"amount"=>"20", "time_period"=>"", "time_period_label"=>"", "level"=>"INDIVIDUAL", "insurance_type"=>"", "insurance_type_label"=>"", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "dates"=>[], "contact_details"=>[], "comments"=>[]}], "out_network"=>[{"amount"=>"40", "time_period"=>"", "time_period_label"=>"", "level"=>"INDIVIDUAL", "insurance_type"=>"", "insurance_type_label"=>"", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "dates"=>[], "contact_details"=>[], "comments"=>[]}]}}, "cost_containment"=>{"remainings"=>{"in_network"=>[], "out_network"=>[]}, "totals"=>{"in_network"=>[], "out_network"=>[]}}, "spend_down"=>{"remainings"=>{"in_network"=>[], "out_network"=>[]}, "totals"=>{"in_network"=>[], "out_network"=>[]}}, "limitations"=>{"amounts"=>[]}, "disclaimer"=>[], "other_sources"=>{"amounts"=>[]}}, "benefit_details"=>{"benefit_type_label"=>{"amounts"=>[]}, "managed_care"=>{"amounts"=>[]}, "unlimited"=>{"amounts"=>[]}}, "additional_insurance_policies"=>[{"insurance_type"=>"47", "insurance_type_label"=>"Medicare Secondary, Other Liability Insurance is Primary", "coverage_description"=>"", "reference"=>[{"reference_code"=>"IG", "reference_label"=>"Insurance Policy Number", "reference_number"=>"1232004008"}], "contact_details"=>[{"last_name"=>"CLAIMS MANAGEMENT INC", "first_name"=>"", "indentification_type"=>"", "identification_code"=>"", "contacts"=>[], "address"=>{"street_line_1"=>"PO BOX 2210", "street_line_2"=>"ATTN JANE AUSTEN", "city"=>"SAN FRANCISCO", "state"=>"CA", "zip"=>"941052312"}}], "dates"=>[{"date_type"=>"coordination_of_benefits", "date_value"=>"2005-02-12"}], "comments"=>[]}]}, "services"=>[{"type"=>"96", "type_label"=>"Physician Professional", "coverage_status"=>"11", "coverage_status_label"=>"generic inquiry provided no information for this service type. Retry by including service_type_code=96 for an explicit inquiry for this service type."}, {"type"=>"98", "type_label"=>"Professional Physician Visit - Office", "coverage_status"=>"1", "coverage_status_label"=>"active coverage", "authorization_required"=>"", "noncovered"=>[], "facility"=>{"amounts"=>[{"amount"=>"", "time_period"=>"26", "time_period_label"=>"EPISODE", "level"=>"INDIVIDUAL", "network"=>"Y", "insurance_type"=>"MA", "insurance_type_label"=>"MEDICARE PART A", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "contact_details"=>[], "dates"=>[{"date_type"=>"benefit_begin", "date_value"=>"2013-05-20"}], "comments"=>["Revocation Code - 0"]}]}, "benefit_details"=>{"benefit_type_label"=>{"amounts"=>[]}, "managed_care"=>{"amounts"=>[]}, "unlimited"=>{"amounts"=>[]}}, "financials"=>{"deductible"=>{}, "stop_loss"=>{}, "spending_account"=>{}, "coinsurance"=>{}, "copayment"=>{}, "cost_containment"=>{}, "spend_down"=>{}, "limitations"=>{}, "other_sources"=>{}}, "visits"=>{"amounts"=>{"in_network"=>[{"amount"=>"20", "time_period"=>"", "time_period_label"=>"", "level"=>"INDIVIDUAL", "insurance_type"=>"", "insurance_type_label"=>"", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "dates"=>[], "contact_details"=>[], "comments"=>[]}], "out_network"=>[{"amount"=>"40", "time_period"=>"", "time_period_label"=>"", "level"=>"INDIVIDUAL", "insurance_type"=>"", "insurance_type_label"=>"", "pos"=>"", "pos_label"=>"", "authorization_required"=>"", "dates"=>[], "contact_details"=>[], "comments"=>[]}]}}, "additional_insurance_policies"=>[{"insurance_type"=>"47", "insurance_type_label"=>"Medicare Secondary, Other Liability Insurance is Primary", "coverage_description"=>"", "reference"=>[{"reference_code"=>"IG", "reference_label"=>"Insurance Policy Number", "reference_number"=>"1232004008"}], "contact_details"=>[{"last_name"=>"CLAIMS MANAGEMENT INC", "first_name"=>"", "indentification_type"=>"", "identification_code"=>"", "contacts"=>[], "address"=>{"street_line_1"=>"PO BOX 2210", "street_line_2"=>"ATTN JANE AUSTEN", "city"=>"SAN FRANCISCO", "state"=>"CA", "zip"=>"941052312"}}], "dates"=>[{"date_type"=>"coordination_of_benefits", "date_value"=>"2005-02-12"}], "comments"=>[]}]}]}
75
+ end
76
+
77
+ def test_enrollment_missing_params
78
+ {"error" =>"Expeting enrollment_request_id or npis"}
79
+ end
80
+
81
+ def test_get_enrollment
82
+ [{"enrollment_npi"=>{"address"=>"985 Snow Shoe Road", "city"=>"Sacramento", "created_at"=>"2013-04-24T21:47:31+00:00", "facility_name"=>"Quality", "npi"=>"987654321", "provider_name"=>"Jack Austen", "ptan"=>"54321", "state"=>"CA", "status"=>"rejected", "tax_id"=>"12345678", "updated_at"=>"2013-04-28T17:10:00+00:00", "zip"=>"94107", "enrollment_insurance_company"=>{"name"=>"Medicare", "payer_id"=>"00431"}}}, {"enrollment_npi"=>{"address"=>"985 Snow Shoe Road", "city"=>"Sacramento", "created_at"=>"2013-04-24T21:47:31+00:00", "facility_name"=>"Quality", "npi"=>"987654321", "provider_name"=>"Jack Austen", "ptan"=>"54321", "state"=>"CA", "status"=>"accepted", "tax_id"=>"12345678", "updated_at"=>"2013-04-28T22:51:43+00:00", "zip"=>"94107", "enrollment_insurance_company"=>{"name"=>"Kaiser North", "payer_id"=>"00282"}}}]
83
+ end
84
+
85
+ def test_post_enrollment
86
+ {"enrollment_request"=>{"created_at"=>"2013-04-14T07:29:09-07:00", "id"=>5, "status"=>"pending", "updated_at"=>"2013-04-14T07:29:09-07:00", "enrollment_npis"=>[{"address"=>"125 Snow Shoe Road", "city"=>"Sacramento", "created_at"=>"2013-04-14T07:29:09-07:00", "facility_name"=>"Quality", "npi"=>"987654321", "provider_name"=>"Jane Austen", "ptan"=>"54321", "state"=>"CA", "status"=>"submitted", "tax_id"=>"12345678", "updated_at"=>"2013-04-14T07:29:09-07:00", "zip"=>"94107", "enrollment_insurance_company"=>{"name"=>"Medicare", "payer_id"=>"00431"}}, {"address"=>"125 Snow Shoe Road", "city"=>"Sacramento", "created_at"=>"2013-04-14T07:29:09-07:00", "facility_name"=>"Quality", "npi"=>"987654321", "provider_name"=>"Jane Austen", "ptan"=>"54321", "state"=>"CA", "status"=>"submitted", "tax_id"=>"12345678", "updated_at"=>"2013-04-14T07:29:09-07:00", "zip"=>"94107", "enrollment_insurance_company"=>{"name"=>"Medicare", "payer_id"=>"00431"}}, {"address"=>"125 Snow Shoe Road", "city"=>"Sacramento", "created_at"=>"2013-04-14T07:29:09-07:00", "facility_name"=>"Quality", "npi"=>"987654321", "provider_name"=>"Jane Austen", "ptan"=>"54321", "state"=>"CA", "status"=>"submitted", "tax_id"=>"12345678", "updated_at"=>"2013-04-14T07:29:09-07:00", "zip"=>"94107", "enrollment_insurance_company"=>{"name"=>"Kaiser Nort", "payer_id"=>"00282"}}, {"address"=>"125 Snow Shoe Road", "city"=>"Sacramento", "created_at"=>"2013-04-14T07:29:09-07:00", "facility_name"=>"Quality", "npi"=>"987654321", "provider_name"=>"Jane Austen", "ptan"=>"54321", "state"=>"CA", "status"=>"submitted", "tax_id"=>"12345678", "updated_at"=>"2013-04-14T07:29:09-07:00", "zip"=>"94107", "enrollment_insurance_company"=>{"name"=>"Kaiser Nort", "payer_id"=>"00282"}}]}}
87
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eligible
3
+ version: !ruby/object:Gem::Version
4
+ version: '2.0'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andy Brett
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mocha
16
+ requirement: &70203756283980 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70203756283980
25
+ - !ruby/object:Gem::Dependency
26
+ name: shoulda
27
+ requirement: &70203756283560 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70203756283560
36
+ - !ruby/object:Gem::Dependency
37
+ name: test-unit
38
+ requirement: &70203756283140 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70203756283140
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: &70203756282720 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70203756282720
58
+ - !ruby/object:Gem::Dependency
59
+ name: rest-client
60
+ requirement: &70203756282220 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '1.4'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *70203756282220
69
+ - !ruby/object:Gem::Dependency
70
+ name: multi_json
71
+ requirement: &70203756281700 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: 1.0.4
77
+ - - <
78
+ - !ruby/object:Gem::Version
79
+ version: '2'
80
+ type: :runtime
81
+ prerelease: false
82
+ version_requirements: *70203756281700
83
+ description: Eligible is a developer-friendly way to process health care eligibility
84
+ checks. Learn more at https://eligibleapi.com
85
+ email:
86
+ - andy@andybrett.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - CONTRIBUTORS
93
+ - Gemfile
94
+ - LICENSE
95
+ - README.md
96
+ - Rakefile
97
+ - eligible.gemspec
98
+ - lib/eligible.rb
99
+ - lib/eligible/api_resource.rb
100
+ - lib/eligible/claim.rb
101
+ - lib/eligible/coverage.rb
102
+ - lib/eligible/demographic.rb
103
+ - lib/eligible/eligible_object.rb
104
+ - lib/eligible/enrollment.rb
105
+ - lib/eligible/errors/api_connection_error.rb
106
+ - lib/eligible/errors/api_error.rb
107
+ - lib/eligible/errors/authentication_error.rb
108
+ - lib/eligible/errors/eligible_error.rb
109
+ - lib/eligible/json.rb
110
+ - lib/eligible/plan.rb
111
+ - lib/eligible/service.rb
112
+ - lib/eligible/util.rb
113
+ - lib/eligible/version.rb
114
+ - lib/eligible/webhook.rb
115
+ - test/test_eligible.rb
116
+ - test/test_helper.rb
117
+ homepage: https://eligibleapi.com/
118
+ licenses:
119
+ - MIT
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ! '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 1.8.13
139
+ signing_key:
140
+ specification_version: 3
141
+ summary: Ruby wrapper for the Eligible API
142
+ test_files:
143
+ - test/test_eligible.rb
144
+ - test/test_helper.rb