eligible-node

1.2.8 • Public • Published

eligible-node

Circle CI npm version

Node.js bindings for Eligible APIs (https://eligible.com). Eligible is built for developers needing HIPAA compliant connectivity to health insurance companies.

You can request an account at https://eligible.com/request-access

Documentation

Refer to https://eligible.com/rest for full documentation on Eligible APIs, their request parameters and expected response formats.

Requirements

Node.js 0.12 and above

Installation

npm install eligible-node --save

Usage

Create instance

First create an Eligible object by passing your api key. You can pass the api key directly or as an object. You may also load your api key from environment variables.

var Eligible = require('eligible-node');

// Get values from environment variables if nothing is passed in arguments
// available env variables: ELIGIBLE_API_KEY, ELIGIBLE_IS_TEST
var eligible = Eligible();

//or, pass them as object:
var eligible = Eligible({
    apiKey: 'foobar',
    isTest: true
});

//or, pass Config object
var config = new Eligible.Config;
config.setApiKey('foobar')
config.setTest(true);
var eligible = Eligible(config);

Test Mode

To make the Eligible as explorable as possible, accounts have test-mode as well as live-mode. See above example to enable test mode on any of your requests and hit the sandbox.

Example

Complete example on how to use the library:

var Eligible = require('eligible-node');
var eligible = Eligible({
    apiKey: 'n5Cddnj2KST6YV9J2l2ztQQ2VrdPfzA4JPbn',
    isTest: true
});

// Retrieve a payer and it's search options

eligible.Payer.retrieve('62308')
  .then(function(payer){
    console.log(payer.payer_id);
    return payer.searchOptions(); //retrieve search options
  })
  .then(function(searchOptions){
    console.log(searchOptions)
  })
  .catch(Eligible.APIConnectionError, function(e){
    console.log('Connection Error');
  })
  .catch(Eligible.AuthenticationError, function(e){
      console.log('Authentication Error', e.message, e.code, e.response);
  })
  .catch(Eligible.InvalidRequestError, function(e){
      console.log('InvalidRequestError', e.message, e.code, e.response);
  })
  .catch(function(e){
    console.log(e);
  });

See Errors for a list of Error types.

Coverage

eligible.Coverage.all({
  payer_id: '00001',
  provider_last_name: 'Doe',
  provider_first_name: 'John',
  provider_npi: '0123456789',
  member_id: 'ZZZ445554301',
  member_first_name: 'IDA',
  member_last_name: 'FRANKLIN',
  member_dob: '1701-12-12',
  service_type: '30',
})
.then(function(coverage) {
  console.log(coverage)
})
.catch(function(e) {
  //
});
eligible.Coverage.medicare({
  provider_npi: '0123456789',
  member_id: 'ZZZ445554301',
})
.then(function(medicare) {
  console.log(medicare);
})
.catch(function(e) {
  //
});
eligible.Coverage.costEstimates({
  provider_npi: '0123456789',
  provider_price: '1500.50',
  service_type: '1',
  network: 'IN',
})
.then(function(costEstimates) {
  console.log(costEstimates);
})
.catch(function(e) {
  //
});

Payment

eligible.Payment.status({
  payer_id: '00001',
  provider_last_name: 'Doe',
  provider_first_name: 'John',
  provider_npi: '0123456789',
  member_id: 'ZZZ445554301',
  member_first_name: 'IDA',
  member_last_name: 'FRANKLIN',
  member_dob: '1701-12-12',
  payer_control_number: 123123123,
  charge_amount: 125.00,
  start_date: '2010-06-15',
  end_date: '2010-06-15',
  trace_number: 'BHUYTOK98IK',
})
.then(function(payment) {
  console.log(payment)
})
.catch(function(e) {

});

Claim

eligible.Claim.create(params)  // example params can be found in the REST document of this endpoint
  .then(function(claim) { // returns a claim instance
    console.log(claim);
    return claim.acknowledgements(); // get acknowledgements for this claim
  })
  .then(function(acknowledgements){
    console.log(acknowledgements);
  })
  .catch(function(e){
    //
  });
eligible.Claim.getAcknowledgements('12121212')
  .then(function(data) {
    console.log(data);
  })

or, using claim instance either created manually or returned by Claim.create() method

var claim = new eligible.Claim({'reference_id': '12121212'});
claim.acknowledgements()
  .then(function(data) {
    console.log(data);
  })
eligible.Claim.queryAcknowledgements(query)
  .then(function(data) {
  })
eligible.Claim.getPaymentReport('BDA85HY09IJ')
	.then(function(payment) {
	})

or, using claim instance either created manually or returned by Claim.create() method

var claim = new eligible.Claim({'reference_id': 'BDA85HY09IJ'});
claim.paymentReports()
  .then(function(payment_report) {
    console.log(payment_report);
  })
eligible.Claim.getPaymentReport('BDA85HY09IJ', 'ABX45DGER44')
	.then(function(payment) {
	})

or, using claim instance either created manually or returned by Claim.create() method

var claim = new eligible.Claim({'reference_id': 'BDA85HY09IJ'});
claim.paymentReports('ABX45DGER44')
  .then(function(payment_report) {
    console.log(payment_report);
  })
eligible.Claim.queryPaymentReports(query)
	.then(function(data) {
	})
eligible.Claim.realtime(params) // example params can be found in the REST document of this endpoint
  .then(function(data) {
  })
  .catch(function(e){
  });

Payer

eligible.Payer.all({
    endpoint: 'coverage',
  })
  .then(function(payers) {
    console.log(payers);
  })
eligible.Payer.retrieve('62308')
	.then(function(payer) {
	  return payer.searchOptions()
	})
	//retrieve search options for this payer
	.then(function(searchOptions){
	   console.log(searchOptions)
	})
	.catch()
eligible.Payer.searchOptions()
	.then(function(searchOptions) {
	  console.log(searchOptions)
	})
eligible.Payer.searchOptions('62308')
	.then(function(searchOptions) {
	})

or, using payer instance either:

var payer = new eligible.Payer({payer_id: '62308'});
payer.searchOptions()
  .then(function(searchOptions) {
    console.log(searchOptions);
  })

Customer

eligible.Customer.create({
    customer: {
      name: 'ABC company',
    },
  })
  .then(function(customer) {
    console.log(customer.id);
  })
  .catch();
eligible.Customer.update('TN344YY67HH09KK', {
    customer: {
      name: 'XYZ company',
    },
  })
  .then(function(customer) {
    console.log(customer.id);
  })
  .catch(done);
eligible.Customer.get('TN344YY67HH09KK')
  .then(function(customer) {
    console.log(customer.id);
  })
  .catch();
eligible.Customer.all({
    page: 1,
  })
  .then(function(data) {
    console.log(data.customers);
  })
  .catch();

Enrollment

eligible.Enrollment.create(params) // example params can be found in the REST document of this endpoint
  .then(function(enrollment) {
    console.log(enrollment);
  })
  .catch();
eligible.Enrollment.update(params) // example params can be found in the REST document of this endpoint
  .then(function(enrollment) {
    console.log(enrollment);
  })
  .catch();
eligible.Enrollment.get(123)
  .then(function(enrollment) {
    console.log(enrollment);
  })
  .catch();
eligible.Enrollment.all({
    page: 1,
  })
  .then(function(data) {
    console.log(data.enrollment_npis);
  })
  .catch();
eligible.Enrollment.viewReceivedPDF('123')
  .then(function(receivedPDF) {
    console.log(receivedPDF.download_url);
  })
  .catch();

Returns a readable stream when successful

eligible.Enrollment.downloadReceivedPDF('123')
  .then(function(pdf) {
    pdf.pipe(fs.createWriteStream('./received_pdf.pdf'))
  })
  .catch();

You can either pass a path to PDF or a readable stream of the pdf file:

eligible.Enrollment.createOriginalSignaturePDF('123', {
  file: './upload.pdf',
})
.then(function(originalSignaturePDF) {
  console.log(originalSignaturePDF.download_url);
})
.catch();

You can either pass a path to PDF or a readable stream of the pdf file:

eligible.Enrollment.updateOriginalSignaturePDF('123', {
  file: './upload.pdf',
})
.then(function(originalSignaturePDF) {
  console.log(originalSignaturePDF.download_url);
})
.catch();
eligible.Enrollment.viewOriginalSignaturePDF('123')
  .then(function(originalSignaturePDF) {
    console.log(originalSignaturePDF.download_url);
  })
  .catch();
eligible.Enrollment.deleteOriginalSignaturePDF('123')
  .then(function(response) {
    console.log(response.message);
  })
  .catch(done);

Returns a readable stream when successful

eligible.Enrollment.downloadOriginalSignaturePDF('123')
  then(function(pdf) {
    pdf.pipe(fs.createWriteStream('./original_signature_pdf.pdf'))
  })
  .catch();

Referral

eligible.Referral.inquiry({
  payer_id: '60054',
  payer_name: 'Aetna',
  provider_type: 'attending',
  provider_last_name: 'Doe',
  provider_first_name: 'John',
  provider_npi: '0123456789',
  provider_phone_number: '1234567890',
  provider_taxonomy_code: '291U00000X',
  member_id: 'ZZZ445554301',
  member_first_name: 'IDA',
  member_last_name: 'FRANKLIN',
  member_dob: '1701-12-12',
  from_date: '2014-01-01',
  to_date: '2015-01-01',
})
.then(function(referral) {
})
.catch(done);
eligible.Referral.create(params) // example params can be found in the REST document of this endpoint
  .then(function(referral) {
  })
  .catch(done);

Precertification

eligible.Precertification.inquiry({
  payer_id: '60054',
  payer_name: 'Aetna',
  provider_type: 'attending',
  provider_last_name: 'Doe',
  provider_first_name: 'John',
  provider_npi: '0123456789',
  provider_phone_number: '1234567890',
  provider_taxonomy_code: '291U00000X',
  member_id: 'ZZZ445554301',
  member_first_name: 'IDA',
  member_last_name: 'FRANKLIN',
  member_dob: '1701-12-12',
  from_date: '2014-01-01',
  to_date: '2015-01-01',
})
.then(function(precert) {
})
.catch(done);
eligible.Precertification.create(params) // example params can be found in the REST document of this endpoint
  .then(function(precert) {
  })
  .catch(done);

x12

Simple Post

eligible.config.setApiVersion('v1.1');
eligible.X12.post(params)//
  .then(function(x12) {
  })
  .catch(done);

MIME Post

eligible.config.setApiVersion('v1.1');
eligible.X12.mimePost(params)//
  .then(function(x12) {
  })
  .catch(done);

Tickets

Create a Ticket

eligible.Ticket.create(params)
  .then(function(ticket) {

  })
  .catch();

View a Ticket

eligible.Ticket.retrieve('123')
  .then(function(ticket) {

  })
  .catch();

Update a Ticket

eligible.Ticket.update('123', params)
  .then(function(ticket) {

  })
  .catch();

List Tickets

eligible.Ticket.list()
  .then(function(data) {

  })
  .catch();

Create a Ticket Comment

eligible.Ticket.createComment('123', params)
  .then(function(comment) {

  })
  .catch();

List Comments for a Ticket

eligible.Ticket.comments('123')
  .then(function(comments) {

  })
  .catch();

Errors

The library throws following error objects.

  • Eligible.APIConnectionError
  • Eligible.APIResponseError
  • Eligible.APIError
  • Eligible.AuthenticationError
  • Eligible.InvalidRequestError

The following table describes the properties of the error object.

Property Type Description
message string The error message
code number When the error occurs during an HTTP request, the HTTP status code.
response object or string HTTP response as JSON, if JSON not available raw response is stored

To catch individual errors, use bluebird catch syntax.

Testing

Use the following commands to run tests or test coverage:

ELIGIBLE_API_KEY=API_KEY npm test
ELIGIBLE_API_KEY=API_KEY npm run coverage

Note that, by default running above commands will mock HTTP requests using nock library. To disable mocking and make actaul calls against eligible server, pass NOCK_OFF=true enviroment variable:

NOCK_OFF=true npm test

To filter tests, update grep field in test/mocha.opts.

Developing

To work on the library:

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Install dependencies: npm install
  4. Fix bugs or add features. Make sure the changes pass the coding guidelines by runing: npm run lint or npm run watch
  5. Write tests for your new features. For HTTP mocking nock library is used. Nock definitions are saved in test/fixtures directory
  6. Run test by npm test or npm run coverage
  7. If all tests are passed, push to the branch (git push origin my-new-feature)
  8. Create new Pull Request

Support Forums

If you find an issue with in the client library we would appricate you Send an email to support@eligible.com or add an issue in the Issue tracker for bug reports.

/eligible-node/

    Package Sidebar

    Install

    npm i eligible-node

    Weekly Downloads

    765

    Version

    1.2.8

    License

    MIT

    Unpacked Size

    52.3 kB

    Total Files

    21

    Last publish

    Collaborators

    • eligible-new
    • pavana21
    • katelyngleason
    • ballembs
    • victorce
    • hari-eligible