Ruby bindings for the Eligible API
Add this line to your application's Gemfile:
gem 'eligible'
And then execute:
$ bundle
Or install it yourself with:
$ gem install eligible
require 'eligible'
Eligible.api_key = 'YOUR_KEY'
Eligible.test = true
On each api call, you can overwrite the api key or the test parameter:
Eligible::Coverage.get({:api_key => 'NEW_KEY', :test => false})
By default, all responses are in JSON, but you can request raw access to X12 by adding is as a parameter on the api call:
Eligible::Coverage.get({:format => "x12"})
the parameter payer_id
, required for most of the api calls, is
provided by Eligible from its website, in xml and json format, which
you can embed into your applications.
https://eligible.com/resources/payers/eligibility.xml
https://eligible.com/resources/payers/eligibility.json
the parameter payer_id
, required for claims, is provided by Eligible
from its website, in xml and json format, which you can embed into
your applications.
https://eligible.com/resources/payers/claims/medical.xml
https://eligible.com/resources/payers/claims/medical.json
https://eligible.com/resources/payers/claims/institutional.xml
https://eligible.com/resources/payers/claims/institutional.json
https://eligible.com/resources/payers/claims/dental.xml
https://eligible.com/resources/payers/claims/dental.json
the parameter service_type
, required on the api calls, is provided
by Eligible from its website, in xml and json format, which you can
embed into your applications.
https://eligible.com/resources/service-codes.xml https://eligible.com/resources/service-codes.json
https://eligible.com/resources/place_of_service.json
https://eligible.com/resources/health-care-provider-taxonomy-code-set.json
On all results you can check for errors in result.error
. The raw
json format is available by using result.to_hash
.
coverage = Eligible::Coverage.get(params)
coverage.error
coverage.to_hash
https://reference.eligible.com/#coverage
params = {
:service_type => "33",
:network => "OUT",
:payer_id => "000001",
:provider_last_name => "Last",
:provider_first_name => "First",
:provider_npi => "12345678",
:member_id => "12345678",
:member_last_name => "Austen",
:member_first_name => "Jane",
:member_dob => "1955-12-14"
}
coverage = Eligible::Coverage.get(params)
coverage.to_hash # returns all coverage info for the request
coverage.error # return error, if any
https://eligible.com/reference/cost-estimates
params = {
service_type: '98',
network: 'IN',
payer_id: '00001',
provider_npi: '1234567893',
member_id: 'COST_ESTIMATE_001',
member_dob: '1886-01-01',
provider_price: '200',
level: 'individual'
}
cost_estimate = Eligible::Coverage.cost_estimate(params)
cost_estimate.to_hash # returns all coverage info along with cost estimate
https://reference.eligible.com/#medicare
params = {
:payer_id => "000001",
:provider_last_name => "Last",
:provider_first_name => "First",
:provider_npi => "12345678",
:member_id => "12345678",
:member_last_name => "Austen",
:member_first_name => "Jane",
:member_dob => "1955-12-14"
}
medicare = Eligible::Medicare.get(params)
medicare.to_hash # returns all coverage info for the request
medicare.error # return error, if any
Enrollment requests can have multiple enrollment NPIs. You can repeat the enrollment for a NPI multiple times across different enrollment requests.
https://reference.eligible.com/#enrollment-introduction
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"
]
}
result = Eligible::Enrollment.post(params)
result.to_hash # returns the api call results
result.error # return error, if any
params = { :enrollment_request_id => 123 }
enrollment = Eligible::Enrollment.get(params)
enrollment.to_hash # return the api call results
enrollment.error # return error, if any
enrollment.enrollment_npis # quick access to the enrollment npis within the enrollment request object
params = { :npis => %w(123 456 789).join(',') }
enrollment = Eligible::Enrollment.get(params)
https://reference.eligible.com/#create-a-claim
params = {
"receiver" => {
"name" => "AETNA",
"id" => "60054"
},
"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"
},
"subscriber" => {
"last_name" => "Franklin",
"first_name" => "Benjamin",
"member_id" => "12312312",
"group_id" => "455716",
"group_name" => "",
"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"
}
},
"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",
"place_of_service" => "11",
"charge_amount" => "275",
"product_service" => "99213",
"qualifier" => "HC",
"diagnosis_1" => "32723"
}
]
}
}
result = Eligible::Claim.post(params)
enrollment.to_hash # return the api call results
enrollment.error # return error, if any
claims = Eligible::Claim.all # returns acknowledgment information for all claims that have been submitted with the API key
params = {
:reference_id => "12345"
}
claim = Eligible::Claim.get(params) # returns acknowledgment information on an individual claim identified by its reference_id
https://reference.eligible.com/#payment-status
params = { :payer_id => '00001',
:provider_tax_id => '4373208923',
:provider_npi => '1234567890',
:provider_first_name => 'Thomas',
:provider_first_name => 'Thomas',
:member_id => '123',
:member_first_name => 'Benjamin',
:member_last_name => 'Franklin',
:member_dob => '01-01-1980',
:charge_amount => '100.00',
:start_date => '2013-03-25',
:end_date => '2013-03-25' }
result = Eligible::Payment.get(params)
result.to_hash # return the api call results
result.error # return error, if any
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~" }
result = Eligible::X12.post(params)
https://reference.eligible.com/#create-a-ticket
params = {:priority => 'normal',
:title => 'TITLE',
:notification_email => '[email protected]',
:body => 'Your comment'}
result = Eligible::Ticket.create params
result.to_hash # return the api call results
enrollment.error # return error, if any
ticket = Eligible::Ticket.get(:id => 1)
ticket.to_hash # return the api call result
ticket.error # return error, if any
params = { :id => 1,
:priority => 'normal',
:title => 'TITLE',
:notification_email => '[email protected]',
:body => 'Your comment'}
result = Eligible::Ticket.update(params)
result.to_hash # return the api call results
enrollment.error # return error, if any
comments = Eligible::Ticket.get(:id => 1)
comments.to_hash # return the api call result
comments.error # return error, if any
result = Eligible::Ticket.delete(:id => 1)
comments.to_hash # return the api call result
comments.error # return error, if any
Eligible::Ticket.all
https://reference.eligible.com/#customers-introduction
customer_params = { customer: { name: "ABC company",
site_name: "ABC site name"
}
}
customer_response = Eligible::Customer.post(customer_params)
customer_response.to_json
customer_params = { customer_id: "123" }
customer_response = Eligible::Customer.get(customer_params)
customer_response.to_json
customer_params = { customer_id: "123",
customer: { site_name: "XYZ site name" }
}
customer_response = Eligible::Customer.update(customer_params)
customer_response.to_json
customer_params = {}
customer_response = Eligible::Customer.all(customer_params)
customer_response.to_json
https://reference.eligible.com/#view-received-pdf
params = { enrollment_npi_id: '123' }
response = Eligible::ReceivedPdf.get(params)
response.to_hash
By default, it downloads to /tmp/received_pdf.pdf
params = { enrollment_npi_id: '123', filename: 'file_path_where_to_download' }
Eligible::ReceivedPdf.download(params)
https://reference.eligible.com/#create-original-signature-pdf
params = { enrollment_npi_id: '123' }
response = Eligible::OriginalSignaturePdf.get(params)
response.to_hash
params = { enrollment_npi_id: '123' }
params[:file] = File.new('path_to_file')
response = Eligible::OriginalSignaturePdf.post(params)
response.to_hash
params = { enrollment_npi_id: '123' }
params[:file] = File.new('path_to_new_file')
response = Eligible::OriginalSignaturePdf.update(params)
response.to_hash
By default, it downloads to /tmp/original_signature_pdf.pdf
params = { enrollment_npi_id: '123', filename: 'file_path_where_to_download' }
Eligible::OriginalSignaturePdf.download(params)
params = { enrollment_npi_id: '123' }
response = Eligible::OriginalSignaturePdf.delete(params)
response.to_hash
https://reference.eligible.com/#introduction
response = Eligible::Payer.list({})
response.collect { |payer| payer.to_hash }
params = { payer_id: '12345' }
response = Eligible::Payer.get(params)
response.to_hash
params = { payer_id: '12345' }
response = Eligible::Payer.search_options(params)
response.to_hash
response = Eligible::Payer.search_options({})
response.collect { |payer| payer.to_hash }
https://reference.eligible.com/#precertification
params = { provider_npi: '1234567893',
member_id: 'ABCDEF',
member_dob: '2016-03-04'
}
response = Eligible::Precert.inquiry(params)
response.to_hash
params = { 'requester' => { 'information' => 'test' },
'subscriber' => { 'last_name' => 'XYZ',
'first_name' => 'AVC',
'id' => '231213'
},
'event' => { 'provider' => 'information' },
'services' => [{ 'service' => 'test' }]
}
response = Eligible::Precert.create(params)
response.to_hash
params = { provider_npi: '1234567893',
member_id: 'ABCDEF',
member_dob: '2016-03-04'
}
response = Eligible::Referral.inquiry(params)
response.to_hash
params = { 'requester' => { 'information' => 'test' },
'subscriber' => { 'last_name' => 'XYZ',
'first_name' => 'AVC',
'id' => '231213'
},
'event' => { 'provider' => 'information' },
'services' => [{ 'service' => 'test' }]
}
response = Eligible::Referral.create(params)
response.to_hash
https://account.eligible.com/docs/account#session-tokens
params = { endpoints: 'coverage, cost_estimates, visit_types, payer_list',
ttl_seconds: 300,
max_calls: 50
}
result = Eligible::SessionToken.create(params)
result.to_hash # returns all session token info for the request
result.error # returns error, if any
params = { session_token: 'session-token-to-revoke' }
result = Eligible::SessionToken.revoke(params)
result.to_hash # returns all session token info for the request
result.error # returns error, if any
This is the list of errors thrown from the eligible ruby gem.
- Eligible::EligibleError - Base class for the customized errors raised from Eligible gem.
- Eligible::APIError - Raised when there is some invalid response from the api call. Raised for error codes other than 400, 401 and 404.
- Eligible::APIConnectionError - Raised when there is some network issue like socket error, not able to connect to Eligible etc.
- Eligible::InvalidRequestError - Raised when error code is 400 or 404.
- Eligible::AuthenticationError - Raised when authentication fails. Mostly due to wrong api key.
- NotImplementedError - Raised when the functionality you are trying to use doesn't exist.
- ArgumentError - Raised when all the required params are not provided.
Raised errors have details in message
, http_code
, http_body
, json_body
, and errors
attributes:
def call_eligible(request_params)
Eligible::Coverage.cost_estimate request_params
rescue Eligible::AuthenticationError => auth_error # handle any specific error
auth_error.message # readable message
auth_error.http_status # HTTP Status Code
auth_error.http_body # HTTP Response body
auth_error.json_body # HTTP Response body as Hash
auth_error.errors # Errors from Response Hash
rescue Eligible::EligibleError => error # handle generic error
## Similar format
error.message
error.http_status
error.http_body
error.json_body
error.errors
end
Running rake
will run the test suite along with rubocop as a basic
style assessment. If you are going to submit a pull request, please
verify that all tests pass and there are no rubocop errors. Please add
additional tests for any features or fixes provided.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Run tests (see above)
- Push to the branch (
git push origin my-new-feature
) - Create new Pull Request