eligible 1.0 → 3.0.0.beta17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +76 -0
  3. data/.codeclimate.yml +23 -0
  4. data/.gitignore +3 -0
  5. data/.rspec +3 -0
  6. data/.rubocop.yml +1158 -0
  7. data/.ruby-version +1 -0
  8. data/CHANGELOG.md +170 -0
  9. data/Gemfile +4 -0
  10. data/Gemfile.lock +66 -0
  11. data/LICENSE +1 -1
  12. data/README.md +700 -93
  13. data/Rakefile +12 -2
  14. data/eligible.gemspec +14 -16
  15. data/lib/eligible/api_resource.rb +49 -5
  16. data/lib/eligible/calculator_deploy_url.rb +7 -0
  17. data/lib/eligible/claim.rb +22 -6
  18. data/lib/eligible/coverage.rb +19 -0
  19. data/lib/eligible/coverage_resource.rb +23 -0
  20. data/lib/eligible/customer.rb +19 -0
  21. data/lib/eligible/demographic.rb +6 -35
  22. data/lib/eligible/eligible_object.rb +12 -15
  23. data/lib/eligible/encryptor.rb +121 -0
  24. data/lib/eligible/enrollment.rb +23 -0
  25. data/lib/eligible/errors/eligible_error.rb +6 -3
  26. data/lib/eligible/errors/invalid_request_error.rb +4 -0
  27. data/lib/eligible/icd.rb +16 -0
  28. data/lib/eligible/json.rb +5 -15
  29. data/lib/eligible/lockbox.rb +39 -0
  30. data/lib/eligible/medicare.rb +11 -0
  31. data/lib/eligible/oauth_token.rb +9 -0
  32. data/lib/eligible/ocr.rb +15 -0
  33. data/lib/eligible/original_signature_pdf.rb +45 -0
  34. data/lib/eligible/payer.rb +17 -0
  35. data/lib/eligible/payer_mapping.rb +37 -0
  36. data/lib/eligible/payment.rb +11 -0
  37. data/lib/eligible/preauth_resource.rb +11 -0
  38. data/lib/eligible/precert.rb +15 -0
  39. data/lib/eligible/provider_model.rb +7 -0
  40. data/lib/eligible/public_key.rb +27 -0
  41. data/lib/eligible/received_pdf.rb +26 -0
  42. data/lib/eligible/referral.rb +11 -0
  43. data/lib/eligible/risk_assessment.rb +15 -0
  44. data/lib/eligible/session_token.rb +11 -0
  45. data/lib/eligible/ticket.rb +40 -0
  46. data/lib/eligible/util.rb +29 -38
  47. data/lib/eligible/v1_0/action.rb +9 -0
  48. data/lib/eligible/v1_0/attribute.rb +9 -0
  49. data/lib/eligible/v1_0/charge.rb +13 -0
  50. data/lib/eligible/v1_0/claim.rb +25 -0
  51. data/lib/eligible/v1_0/claim_service_line.rb +9 -0
  52. data/lib/eligible/v1_0/contract.rb +9 -0
  53. data/lib/eligible/v1_0/device.rb +9 -0
  54. data/lib/eligible/v1_0/discount.rb +9 -0
  55. data/lib/eligible/v1_0/enrollment.rb +17 -0
  56. data/lib/eligible/v1_0/estimate.rb +29 -0
  57. data/lib/eligible/v1_0/estimate_service_line.rb +17 -0
  58. data/lib/eligible/v1_0/fee.rb +21 -0
  59. data/lib/eligible/v1_0/fee_refund.rb +29 -0
  60. data/lib/eligible/v1_0/file.rb +17 -0
  61. data/lib/eligible/v1_0/file_link.rb +13 -0
  62. data/lib/eligible/v1_0/insurance_company.rb +21 -0
  63. data/lib/eligible/v1_0/insurance_company_alias.rb +9 -0
  64. data/lib/eligible/v1_0/insurance_policy.rb +9 -0
  65. data/lib/eligible/v1_0/patient_question.rb +9 -0
  66. data/lib/eligible/v1_0/patient_questionnaire.rb +9 -0
  67. data/lib/eligible/v1_0/patient_record.rb +9 -0
  68. data/lib/eligible/v1_0/patient_statement.rb +54 -0
  69. data/lib/eligible/v1_0/patient_statement_service_line.rb +13 -0
  70. data/lib/eligible/v1_0/payment_report.rb +21 -0
  71. data/lib/eligible/v1_0/product.rb +9 -0
  72. data/lib/eligible/v1_0/provider.rb +9 -0
  73. data/lib/eligible/v1_0/remark.rb +21 -0
  74. data/lib/eligible/v1_0/reports/accuracy_stats.rb +23 -0
  75. data/lib/eligible/v1_0/reports/estimate_friction.rb +23 -0
  76. data/lib/eligible/v1_0/reports/in_scope_distribution.rb +23 -0
  77. data/lib/eligible/v1_0/rest_api_base.rb +44 -0
  78. data/lib/eligible/v1_0/rule.rb +13 -0
  79. data/lib/eligible/v1_0/session.rb +21 -0
  80. data/lib/eligible/v1_0/transaction.rb +21 -0
  81. data/lib/eligible/v1_0/treatment.rb +9 -0
  82. data/lib/eligible/v1_0/value_list.rb +9 -0
  83. data/lib/eligible/v1_0/value_list_item.rb +9 -0
  84. data/lib/eligible/v1_0/verification.rb +17 -0
  85. data/lib/eligible/version.rb +1 -1
  86. data/lib/eligible/visit_type.rb +11 -0
  87. data/lib/eligible/x12.rb +8 -0
  88. data/lib/eligible.rb +320 -110
  89. metadata +148 -67
  90. data/CONTRIBUTORS +0 -1
  91. data/lib/eligible/plan.rb +0 -42
  92. data/lib/eligible/service.rb +0 -39
  93. data/test/test_eligible.rb +0 -279
  94. data/test/test_helper.rb +0 -67
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Eligible
2
2
 
3
- Ruby bindings for the [Eligible API](https://eligibleapi.com/rest-api-v1)
3
+ [![CircleCI](https://circleci.com/gh/eligible/eligible-ruby/tree/master.svg?style=svg&circle-token=2217025edb5af2901121d277f96ace65dc47f306)](https://circleci.com/gh/eligible/eligible-ruby/tree/master)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/d86aadd0f6670a2548d8/maintainability)](https://codeclimate.com/repos/56cca689c952c60085003f10/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/d86aadd0f6670a2548d8/test_coverage)](https://codeclimate.com/repos/56cca689c952c60085003f10/test_coverage)
6
+
7
+ Ruby bindings for the [Eligible API](https://eligible.com/rest)
4
8
 
5
9
  ## Installation
6
10
 
@@ -19,105 +23,708 @@ Or install it yourself with:
19
23
  ## Usage
20
24
 
21
25
  ### Setup
22
- require eligible
23
- Eligible.api_key = YOUR_KEY
24
-
25
- ### Retrieve Plan object and query it
26
- params = {
27
- :payer_name => "Aetna",
28
- :payer_id => "000001",
29
- :service_provider_last_name => "Last",
30
- :service_provider_first_name => "First",
31
- :service_provider_NPI => "1928384219",
32
- :subscriber_id => "W120923801",
33
- :subscriber_last_name => "Austen",
34
- :subscriber_first_name => "Jane",
35
- :subscriber_dob => "1955-12-14"
36
- }
26
+ ```ruby
27
+ require 'eligible'
28
+ Eligible.api_key = 'YOUR_KEY'
29
+ ```
37
30
 
38
- plan = Eligible::Plan.get(params)
39
- plan.all # returns all fields on the plan, per the plan/all endpoint
40
- plan.status # returns status fields on the plan, per the plan/status endpoint
41
- ## Etc.: plan.deductible, plan.dates, plan.balance, plan.stop_loss
42
-
43
- ### Retrieve Service object and query it
44
- params = {
45
- :payer_name => "Aetna",
46
- :payer_id => "000001",
47
- :service_provider_last_name => "Last",
48
- :service_provider_first_name => "First",
49
- :service_provider_NPI => "1928384219",
50
- :subscriber_id => "W120923801",
51
- :subscriber_last_name => "Austen",
52
- :subscriber_first_name => "Jane",
53
- :subscriber_dob => "1955-12-14"
54
- }
31
+ ### Test
32
+ ```ruby
33
+ Eligible.test = true
34
+ ```
35
+
36
+ ### Parameters overwrite
37
+
38
+ On each api call, you can overwrite the api key or the test parameter:
39
+
40
+ ```ruby
41
+ Eligible::Coverage.get({:api_key => 'NEW_KEY', :test => false})
42
+ ```
43
+
44
+ ### Response Format
45
+
46
+ By default, all responses are in JSON, but you can request raw
47
+ access to X12 by adding is as a parameter on the api call:
48
+
49
+ ```ruby
50
+ Eligible::Coverage.get({:format => "x12"})
51
+ ```
52
+
53
+ # Important notes
54
+
55
+ ## Payer List for Eligibility
56
+
57
+ the parameter `payer_id`, required for most of the api calls, is
58
+ provided by Eligible from its website, in xml and json format, which
59
+ you can embed into your applications.
60
+
61
+ [https://eligible.com/resources/payers/eligibility.xml](https://eligible.com/resources/payers/eligibility.xml)
62
+
63
+ [https://eligible.com/resources/payers/eligibility.json](https://eligible.com/resources/payers/eligibility.json)
64
+
65
+ ## Payer List for Claims
66
+
67
+ the parameter `payer_id`, required for claims, is provided by Eligible
68
+ from its website, in xml and json format, which you can embed into
69
+ your applications.
70
+
71
+ ## Medical
72
+
73
+ [https://eligible.com/resources/payers/claims/medical.xml](https://eligible.com/resources/payers/claims/medical.xml)
74
+
75
+ [https://eligible.com/resources/payers/claims/medical.json](https://eligible.com/resources/payers/claims/medical.json)
76
+
77
+ ## Institutional
78
+
79
+ [https://eligible.com/resources/payers/claims/institutional.xml](https://eligible.com/resources/payers/claims/institutional.xml)
80
+
81
+ [https://eligible.com/resources/payers/claims/institutional.json](https://eligible.com/resources/payers/claims/institutional.json)
82
+
83
+ ## Dental
84
+
85
+ [https://eligible.com/resources/payers/claims/dental.xml](https://eligible.com/resources/payers/claims/dental.xml)
86
+
87
+ [https://eligible.com/resources/payers/claims/dental.json](https://eligible.com/resources/payers/claims/dental.json)
88
+
89
+ ## Service Type Codes
90
+
91
+ the parameter `service_type`, required on the api calls, is provided
92
+ by Eligible from its website, in xml and json format, which you can
93
+ embed into your applications.
94
+
95
+ [https://eligible.com/resources/service-codes.xml](https://eligible.com/resources/service-codes.xml)
96
+ [https://eligible.com/resources/service-codes.json](ttps://eligible.com/resources/service-codes.json)
97
+
98
+ ## Place of Service
99
+
100
+ [https://eligible.com/resources/place_of_service.json](https://eligible.com/resources/place_of_service.json)
101
+
102
+ ## Health Care Provider Taxonomy
103
+
104
+ [https://eligible.com/resources/health-care-provider-taxonomy-code-set.json](https://eligible.com/resources/health-care-provider-taxonomy-code-set.json)
105
+
106
+ ### Api Call Results
107
+
108
+ On all results you can check for errors in `result.error`. The raw
109
+ json format is available by using `result.to_hash`.
110
+
111
+ ```ruby
112
+ coverage = Eligible::Coverage.get(params)
113
+ coverage.error
114
+ coverage.to_hash
115
+ ```
116
+
117
+ ## Coverage
118
+
119
+ ### Reference
120
+
121
+ [https://reference.eligible.com/#coverage](https://reference.eligible.com/#coverage)
122
+
123
+ ### Retrieve eligibility and benefit information
124
+
125
+ ```ruby
126
+ params = {
127
+ :service_type => "33",
128
+ :network => "OUT",
129
+ :payer_id => "000001",
130
+ :provider_last_name => "Last",
131
+ :provider_first_name => "First",
132
+ :provider_npi => "12345678",
133
+ :member_id => "12345678",
134
+ :member_last_name => "Austen",
135
+ :member_first_name => "Jane",
136
+ :member_dob => "1955-12-14"
137
+ }
138
+
139
+ coverage = Eligible::Coverage.get(params)
140
+ coverage.to_hash # returns all coverage info for the request
141
+ coverage.error # return error, if any
142
+ ```
55
143
 
56
- service = Eligible::Service.get(params)
57
- service.all # returns all fields for the service, per service/all
58
- service.visits # returns the visits for the service, per service/visits
59
- ## Etc.: service.copayment, service.coinsurance, service.deductible
60
-
61
- ### Retrieve Demographic object and query it
62
- params = {
63
- :payer_name => "Aetna",
64
- :payer_id => "000001",
65
- :service_provider_last_name => "Last",
66
- :service_provider_first_name => "First",
67
- :service_provider_NPI => "1928384219",
68
- :subscriber_id => "W120923801",
69
- :subscriber_last_name => "Austen",
70
- :subscriber_first_name => "Jane",
71
- :subscriber_dob => "1955-12-14"
144
+ ## Cost Estimate
145
+
146
+ ### Reference
147
+ [https://eligible.com/reference/cost-estimates](https://eligible.com/reference/cost-estimates)
148
+
149
+ ### Retrieve cost estimate information
150
+
151
+ ```ruby
152
+ params = {
153
+ service_type: '98',
154
+ network: 'IN',
155
+ payer_id: '00001',
156
+ provider_npi: '1234567893',
157
+ member_id: 'COST_ESTIMATE_001',
158
+ member_dob: '1886-01-01',
159
+ provider_price: '200',
160
+ level: 'individual'
161
+ }
162
+
163
+ cost_estimate = Eligible::Coverage.cost_estimate(params)
164
+ cost_estimate.to_hash # returns all coverage info along with cost estimate
165
+ ```
166
+
167
+ ## Medicare
168
+
169
+ ### Reference
170
+
171
+ [https://reference.eligible.com/#medicare](https://reference.eligible.com/#medicare)
172
+
173
+ ### Retrieve eligibility and benefit information from CMS Medicare for a patient.
174
+
175
+ ```ruby
176
+ params = {
177
+ :payer_id => "000001",
178
+ :provider_last_name => "Last",
179
+ :provider_first_name => "First",
180
+ :provider_npi => "12345678",
181
+ :member_id => "12345678",
182
+ :member_last_name => "Austen",
183
+ :member_first_name => "Jane",
184
+ :member_dob => "1955-12-14"
185
+ }
186
+ medicare = Eligible::Medicare.get(params)
187
+ medicare.to_hash # returns all coverage info for the request
188
+ medicare.error # return error, if any
189
+ ```
190
+
191
+ ## Enrollment
192
+
193
+ Enrollment requests can have multiple enrollment NPIs. You can repeat
194
+ the enrollment for a NPI multiple times across different enrollment
195
+ requests.
196
+
197
+ ### Reference
198
+ [https://reference.eligible.com/#enrollment-introduction](https://reference.eligible.com/#enrollment-introduction)
199
+
200
+ ### Create an Enrollment Request
201
+
202
+ ```ruby
203
+ params = {
204
+ "service_provider_list" => [
205
+ {
206
+ "facility_name" => "Quality",
207
+ "provider_name" => "Jane Austen",
208
+ "tax_id" => "12345678",
209
+ "address" => "125 Snow Shoe Road",
210
+ "city" => "Sacramento",
211
+ "state" => "CA",
212
+ "zip" => "94107",
213
+ "ptan" => "54321",
214
+ "npi" => "987654321"
215
+ },
216
+ {
217
+ "facility_name" => "Aetna",
218
+ "provider_name" => "Jack Austen",
219
+ "tax_id" => "12345678",
220
+ "address" => "985 Snow Shoe Road",
221
+ "city" => "Menlo Park",
222
+ "state" => "CA",
223
+ "zip" => "94107",
224
+ "ptan" => "54321",
225
+ "npi" => "987654321"
226
+ }
227
+ ],
228
+ "payer_ids" => [
229
+ "00431",
230
+ "00282"
231
+ ]
232
+ }
233
+ result = Eligible::Enrollment.post(params)
234
+ result.to_hash # returns the api call results
235
+ result.error # return error, if any
236
+ ```
237
+
238
+ ### Retrieve an Enrollment Request
239
+
240
+ ```ruby
241
+ params = { :enrollment_request_id => 123 }
242
+ enrollment = Eligible::Enrollment.get(params)
243
+ enrollment.to_hash # return the api call results
244
+ enrollment.error # return error, if any
245
+ enrollment.enrollment_npis # quick access to the enrollment npis within the enrollment request object
246
+
247
+ params = { :npis => %w(123 456 789).join(',') }
248
+ enrollment = Eligible::Enrollment.get(params)
249
+ ```
250
+
251
+ ## Claims
252
+
253
+ ### Reference
254
+
255
+ [https://reference.eligible.com/#create-a-claim](https://reference.eligible.com/#create-a-claim)
256
+
257
+ ### Create Claim object
258
+
259
+ ```ruby
260
+ params = {
261
+ "receiver" => {
262
+ "name" => "AETNA",
263
+ "id" => "60054"
264
+ },
265
+ "billing_provider" => {
266
+ "taxonomy_code" => "332B00000X",
267
+ "practice_name" => "Jane Austen Practice",
268
+ "npi" => "1922222222",
269
+ "address" => {
270
+ "street_line_1" => "419 Fulton",
271
+ "street_line_2" => "",
272
+ "city" => "San Francisco",
273
+ "state" => "CA",
274
+ "zip" => "94102"
275
+ },
276
+ "tin" => "43291023"
277
+ },
278
+ "subscriber" => {
279
+ "last_name" => "Franklin",
280
+ "first_name" => "Benjamin",
281
+ "member_id" => "12312312",
282
+ "group_id" => "455716",
283
+ "group_name" => "",
284
+ "dob" => "1734-05-04",
285
+ "gender" => "M",
286
+ "address" => {
287
+ "street_line_1" => "435 Sugar Lane",
288
+ "street_line_2" => "",
289
+ "city" => "Sweet",
290
+ "state" => "OH",
291
+ "zip" => "436233127"
292
+ }
293
+ },
294
+ "payer" => {
295
+ "name" => "AETNA",
296
+ "id" => "60054",
297
+ "address" => {
298
+ "street_line_1" => "Po Box 981106",
299
+ "street_line_2" => "",
300
+ "city" => "El Paso",
301
+ "state" => "TX",
302
+ "zip" => "799981222"
303
+ }
304
+ },
305
+ "claim" => {
306
+ "total_charge_amount" => "275",
307
+ "claim_frequency" => "1",
308
+ "patient_signature_on_file" => "Y",
309
+ "provider_plan_participation" => "A",
310
+ "direct_payment_authorized" => "Y",
311
+ "release_of_information" => "I",
312
+ "service_lines" => [
313
+ {
314
+ "line_number" => "1",
315
+ "service_start" => "2013-03-07",
316
+ "service_end" => "2013-03-07",
317
+ "place_of_service" => "11",
318
+ "charge_amount" => "275",
319
+ "product_service" => "99213",
320
+ "qualifier" => "HC",
321
+ "diagnosis_1" => "32723"
322
+ }
323
+ ]
72
324
  }
325
+ }
326
+
327
+ result = Eligible::Claim.post(params)
328
+ enrollment.to_hash # return the api call results
329
+ enrollment.error # return error, if any
330
+ ```
331
+
332
+ ### Retrieve all Claim objects/acknowledgments
333
+
334
+ ```ruby
335
+ claims = Eligible::Claim.all # returns acknowledgment information for all claims that have been submitted with the API key
336
+ ```
337
+
338
+ ### Retrieve individual Claim object/acknowledgment
339
+
340
+ ```ruby
341
+ params = {
342
+ :reference_id => "12345"
343
+ }
344
+
345
+ claim = Eligible::Claim.get(params) # returns acknowledgment information on an individual claim identified by its reference_id
346
+ ```
347
+
348
+ ## Payment Status
349
+
350
+ ### Reference
351
+
352
+ [https://reference.eligible.com/#payment-status](https://reference.eligible.com/#payment-status)
353
+
354
+ ### Retrieve Payment status
355
+
356
+ ```ruby
357
+ params = { :payer_id => '00001',
358
+ :provider_tax_id => '4373208923',
359
+ :provider_npi => '1234567890',
360
+ :provider_first_name => 'Thomas',
361
+ :provider_first_name => 'Thomas',
362
+ :member_id => '123',
363
+ :member_first_name => 'Benjamin',
364
+ :member_last_name => 'Franklin',
365
+ :member_dob => '01-01-1980',
366
+ :charge_amount => '100.00',
367
+ :start_date => '2013-03-25',
368
+ :end_date => '2013-03-25' }
369
+
370
+ result = Eligible::Payment.get(params)
371
+ result.to_hash # return the api call results
372
+ result.error # return error, if any
373
+ ```
374
+
375
+ ## X12
376
+
377
+ ### X12 post
378
+
379
+ ```ruby
380
+ params = { :x12 => "ISA*00* *00* *ZZ*SENDERID *ZZ*ELIGIB *130610*0409*^*00501*100000001*0*T*:~GS*HS*SENDERID*ELIGIB*20130610*0409*1*X*005010X279A1~ST*270*0001*005010X279A1~BHT*0022*13*137083739083716126837*20130610*0409~HL*1**20*1~NM1*PR*2*UnitedHealthCare*****PI*112~HL*2*1*21*1~NM1*1P*1*AUSTEN*JANE****XX*1222494919~HL*3*2*22*0~TRN*1*1*1453915417~NM1*IL*1*FRANKLIN*BENJAMIN****MI*23412342~DMG*D8*17371207~DTP*291*D8*20130610~EQ*30~SE*13*0001~GE*1*1~IEA*1*100000001~" }
381
+
382
+ result = Eligible::X12.post(params)
383
+ ```
384
+
385
+ ## Tickets
386
+
387
+ ### Reference
73
388
 
74
- demographic = Eligible::Demographic.get(params)
75
- demographic.all # returns all fields for the demographic, per demographic/all
76
- demographic.zip # returns the patient's zip code, per demographic/zip
77
- ## Etc.: demographic.employer, demographic.address, demographic.dob
78
-
79
- ### Retrieve Claim object
80
-
81
- params = {
82
- :payer_name => "Aetna",
83
- :payer_id => "000001",
84
- :information_receiver_organization_name => "Organization",
85
- :information_receiver_last_name => "Last",
86
- :information_receiver_first_name => "First",
87
- :information_receiver_etin => "1386332",
88
- :service_provider_organization_name => "Marshall Group",
89
- :service_provider_last_name => "Last",
90
- :service_provider_first_name => "First",
91
- :service_provider_npi => "1928384219",
92
- :service_provider_tax_id => "1386332",
93
- :subscriber_id => "W120923801",
94
- :subscriber_last_name => "Last",
95
- :subscriber_first_name => "First",
96
- :subscriber_dob => "1955-12-14",
97
- :dependent_last_name => "Last",
98
- :dependent_first_name => "First",
99
- :dependent_dob => "1975-12-14",
100
- :dependent_gender => "M",
101
- :trace_number => "12345",
102
- :claim_control_number => "67890",
103
- :claim_charge_amount => "45.00",
104
- :claim_start_date => "2013-01-05",
105
- :claim_end_date => "2013-01-05"
106
- }
107
-
108
- claim = Eligible::Claim.get(params)
109
- claim.status # Returns in real time the status (paid, not paid, rejected, denied, etc) of claim specified.
110
-
111
- ## Tests
112
-
113
- You can run tests with
114
-
115
- rake test
116
-
117
- If you do send a pull request, please add passing tests for the new feature/fix.
389
+ [https://reference.eligible.com/#create-a-ticket](https://reference.eligible.com/#create-a-ticket)
390
+
391
+ ### Create a ticket
392
+
393
+ ```ruby
394
+ params = {:priority => 'normal',
395
+ :title => 'TITLE',
396
+ :notification_email => 'admin@eligible.com',
397
+ :body => 'Your comment'}
398
+ result = Eligible::Ticket.create params
399
+ result.to_hash # return the api call results
400
+ enrollment.error # return error, if any
401
+ ```
402
+
403
+ ### Get a ticket
404
+
405
+ ```ruby
406
+ ticket = Eligible::Ticket.get(:id => 1)
407
+ ticket.to_hash # return the api call result
408
+ ticket.error # return error, if any
409
+ ```
410
+
411
+ ### Update a ticket
412
+
413
+ ```ruby
414
+ params = { :id => 1,
415
+ :priority => 'normal',
416
+ :title => 'TITLE',
417
+ :notification_email => 'your_email@test.com',
418
+ :body => 'Your comment'}
419
+ result = Eligible::Ticket.update(params)
420
+ result.to_hash # return the api call results
421
+ enrollment.error # return error, if any
422
+ ```
423
+
424
+ ### Get comments for a ticket
425
+
426
+ ```ruby
427
+ comments = Eligible::Ticket.get(:id => 1)
428
+ comments.to_hash # return the api call result
429
+ comments.error # return error, if any
430
+
431
+ ```
432
+
433
+ ### Delete a ticket
434
+ ```ruby
435
+ result = Eligible::Ticket.delete(:id => 1)
436
+ comments.to_hash # return the api call result
437
+ comments.error # return error, if any
438
+ ```
439
+
440
+ ### Get all tickets
441
+
442
+ ```ruby
443
+ Eligible::Ticket.all
444
+ ```
445
+
446
+ ## Customer
447
+
448
+ ### Reference
449
+
450
+ [https://reference.eligible.com/#customers-introduction](https://reference.eligible.com/#customers-introduction)
451
+
452
+ ### Create a customer
453
+
454
+ ```ruby
455
+ customer_params = { customer: { name: "ABC company",
456
+ site_name: "ABC site name"
457
+ }
458
+ }
459
+ customer_response = Eligible::Customer.post(customer_params)
460
+ customer_response.to_json
461
+ ```
462
+
463
+ ### Get a customer
464
+
465
+ ```ruby
466
+ customer_params = { customer_id: "123" }
467
+ customer_response = Eligible::Customer.get(customer_params)
468
+ customer_response.to_json
469
+ ```
470
+
471
+ ### Update a customer
472
+
473
+ ```ruby
474
+ customer_params = { customer_id: "123",
475
+ customer: { site_name: "XYZ site name" }
476
+ }
477
+ customer_response = Eligible::Customer.update(customer_params)
478
+ customer_response.to_json
479
+ ```
480
+
481
+ ### Get all customers
482
+
483
+ ```ruby
484
+ customer_params = {}
485
+ customer_response = Eligible::Customer.all(customer_params)
486
+ customer_response.to_json
487
+ ```
488
+
489
+ ## Received Pdf
490
+
491
+ ### Reference
492
+
493
+ [https://reference.eligible.com/#view-received-pdf](https://reference.eligible.com/#view-received-pdf)
494
+
495
+ ### Get received pdf
496
+
497
+ ```ruby
498
+ params = { enrollment_npi_id: '123' }
499
+ response = Eligible::ReceivedPdf.get(params)
500
+ response.to_hash
501
+ ```
502
+
503
+ ### Download received pdf
504
+ By default, it downloads to /tmp/received_pdf.pdf
505
+ ```ruby
506
+ params = { enrollment_npi_id: '123', filename: 'file_path_where_to_download' }
507
+ Eligible::ReceivedPdf.download(params)
508
+ ```
509
+
510
+ ## Original Signature Pdf
511
+
512
+ ### Reference
513
+
514
+ [https://reference.eligible.com/#create-original-signature-pdf](https://reference.eligible.com/#create-original-signature-pdf)
515
+
516
+ ### Get original signature pdf
517
+
518
+ ```ruby
519
+ params = { enrollment_npi_id: '123' }
520
+ response = Eligible::OriginalSignaturePdf.get(params)
521
+ response.to_hash
522
+ ```
523
+
524
+ ### Create original signature pdf
525
+
526
+ ```ruby
527
+ params = { enrollment_npi_id: '123' }
528
+ params[:file] = File.new('path_to_file')
529
+ response = Eligible::OriginalSignaturePdf.post(params)
530
+ response.to_hash
531
+ ```
532
+
533
+ ### Update original signature pdf
534
+
535
+ ```ruby
536
+ params = { enrollment_npi_id: '123' }
537
+ params[:file] = File.new('path_to_new_file')
538
+ response = Eligible::OriginalSignaturePdf.update(params)
539
+ response.to_hash
540
+ ```
541
+
542
+ ### Download original signature pdf
543
+ By default, it downloads to /tmp/original_signature_pdf.pdf
544
+ ```ruby
545
+ params = { enrollment_npi_id: '123', filename: 'file_path_where_to_download' }
546
+ Eligible::OriginalSignaturePdf.download(params)
547
+ ```
548
+
549
+ ### Delete original signature pdf
550
+
551
+ ```ruby
552
+ params = { enrollment_npi_id: '123' }
553
+ response = Eligible::OriginalSignaturePdf.delete(params)
554
+ response.to_hash
555
+ ```
556
+
557
+ ## Payer
558
+
559
+ ### Reference
560
+
561
+ [https://reference.eligible.com/#introduction](https://reference.eligible.com/#introduction)
562
+
563
+ ### List all the payers
564
+
565
+ ```ruby
566
+ response = Eligible::Payer.list({})
567
+ response.collect { |payer| payer.to_hash }
568
+ ```
569
+
570
+ ### View a single payer
571
+
572
+ ```ruby
573
+ params = { payer_id: '12345' }
574
+ response = Eligible::Payer.get(params)
575
+ response.to_hash
576
+ ```
577
+
578
+ ### Search options for a payer
579
+
580
+ ```ruby
581
+ params = { payer_id: '12345' }
582
+ response = Eligible::Payer.search_options(params)
583
+ response.to_hash
584
+ ```
585
+
586
+ ### Search options for all payers
587
+
588
+ ```ruby
589
+ response = Eligible::Payer.search_options({})
590
+ response.collect { |payer| payer.to_hash }
591
+ ```
592
+
593
+ ## Precertification
594
+
595
+ ### Reference
596
+
597
+ [https://reference.eligible.com/#precertification](https://reference.eligible.com/#precertification)
598
+
599
+ ### Inquiry
600
+
601
+ ```ruby
602
+ params = { provider_npi: '1234567893',
603
+ member_id: 'ABCDEF',
604
+ member_dob: '2016-03-04'
605
+ }
606
+ response = Eligible::Precert.inquiry(params)
607
+ response.to_hash
608
+ ```
609
+
610
+ ### Create
611
+
612
+ ```ruby
613
+ params = { 'requester' => { 'information' => 'test' },
614
+ 'subscriber' => { 'last_name' => 'XYZ',
615
+ 'first_name' => 'AVC',
616
+ 'id' => '231213'
617
+ },
618
+ 'event' => { 'provider' => 'information' },
619
+ 'services' => [{ 'service' => 'test' }]
620
+ }
621
+ response = Eligible::Precert.create(params)
622
+ response.to_hash
623
+ ```
624
+
625
+ ## Referral
626
+
627
+ ### Inquiry
628
+
629
+ ```ruby
630
+ params = { provider_npi: '1234567893',
631
+ member_id: 'ABCDEF',
632
+ member_dob: '2016-03-04'
633
+ }
634
+ response = Eligible::Referral.inquiry(params)
635
+ response.to_hash
636
+ ```
637
+
638
+ ### Create
639
+
640
+ ```ruby
641
+ params = { 'requester' => { 'information' => 'test' },
642
+ 'subscriber' => { 'last_name' => 'XYZ',
643
+ 'first_name' => 'AVC',
644
+ 'id' => '231213'
645
+ },
646
+ 'event' => { 'provider' => 'information' },
647
+ 'services' => [{ 'service' => 'test' }]
648
+ }
649
+ response = Eligible::Referral.create(params)
650
+ response.to_hash
651
+ ```
652
+
653
+ ## Session Tokens
654
+
655
+ ### Reference
656
+ [https://account.eligible.com/docs/account#session-tokens](https://account.eligible.com/docs/account#session-tokens)
657
+
658
+ ### Retrieve session token
659
+
660
+ ```ruby
661
+ params = { endpoints: 'coverage, cost_estimates, visit_types, payer_list',
662
+ ttl_seconds: 300,
663
+ max_calls: 50
664
+ }
665
+ result = Eligible::SessionToken.create(params)
666
+ result.to_hash # returns all session token info for the request
667
+ result.error # returns error, if any
668
+ ```
669
+
670
+ ### Revoke session token
671
+
672
+ ```ruby
673
+ params = { session_token: 'session-token-to-revoke' }
674
+ result = Eligible::SessionToken.revoke(params)
675
+ result.to_hash # returns all session token info for the request
676
+ result.error # returns error, if any
677
+ ```
678
+
679
+ ### Use session token without api_key
680
+
681
+ ```ruby
682
+ Eligible::Coverage.get({:session_token => 'SESSION_TOKEN', :test => false})
683
+ ```
684
+
685
+
686
+ ## Errors
687
+
688
+ This is the list of errors thrown from the eligible ruby gem.
689
+
690
+ 1. Eligible::EligibleError - Base class for the customized errors raised from Eligible gem.
691
+ 2. Eligible::APIError - Raised when there is some invalid response from the api call. Raised for error codes other than 400, 401 and 404.
692
+ 3. Eligible::APIConnectionError - Raised when there is some network issue like socket error, not able to connect to Eligible etc.
693
+ 4. Eligible::InvalidRequestError - Raised when error code is 400 or 404.
694
+ 5. Eligible::AuthenticationError - Raised when authentication fails. Mostly due to wrong api key.
695
+ 6. NotImplementedError - Raised when the functionality you are trying to use doesn't exist.
696
+ 7. ArgumentError - Raised when all the required params are not provided.
697
+
698
+ ### Error Handling
699
+
700
+ Raised errors have details in `message`, `http_code`, `http_body`, `json_body`, and `errors` attributes:
701
+
702
+ ```ruby
703
+ def call_eligible(request_params)
704
+ Eligible::Coverage.cost_estimate request_params
705
+ rescue Eligible::AuthenticationError => auth_error # handle any specific error
706
+ auth_error.message # readable message
707
+ auth_error.http_status # HTTP Status Code
708
+ auth_error.http_body # HTTP Response body
709
+ auth_error.json_body # HTTP Response body as Hash
710
+ auth_error.errors # Errors from Response Hash
711
+ rescue Eligible::EligibleError => error # handle generic error
712
+ ## Similar format
713
+ error.message
714
+ error.http_status
715
+ error.http_body
716
+ error.json_body
717
+ error.errors
718
+ end
719
+ ```
118
720
 
119
721
  ## Contributing
120
722
 
723
+ Running `rake` will run the test suite along with rubocop as a basic
724
+ style assessment. If you are going to submit a pull request, please
725
+ verify that all tests pass and there are no rubocop errors. Please add
726
+ additional tests for any features or fixes provided.
727
+
121
728
  1. Fork it
122
729
  2. Create your feature branch (`git checkout -b my-new-feature`)
123
730
  3. Commit your changes (`git commit -am 'Add some feature'`)