eligible-node-typescript
v0.0.35
Published
This package is not maintained by Eligible.com. NextStep LLC saw a need for an updated NodeJS wrapper, and created this package.
Downloads
83
Readme
eligible-node-typescript
This package is not maintained by Eligible.com. NextStep LLC saw a need for an updated NodeJS wrapper, and created this package.
Node.js typescript 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
- Requirements
- Installation
- Usage
- Errors
- Testing
- Developing
- Support Forums
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
Retrieve 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) {
//
});
Retrieve Medicare
eligible.Coverage.medicare({
provider_npi: '0123456789',
member_id: 'ZZZ445554301',
})
.then(function(medicare) {
console.log(medicare);
})
.catch(function(e) {
//
});
Retrieve Cost Estimates
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
Payment Status
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
Create a 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){
//
});
Retrieve Single Claim Acknowledgements
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);
})
Retrieve Multiple Claims Acknowledgements
eligible.Claim.queryAcknowledgements(query)
.then(function(data) {
})
Retrieve Single Claim Payment Report
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);
})
Retrieve Specific Claim 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);
})
Retrieve Multiple Claim Payment Report
eligible.Claim.queryPaymentReports(query)
.then(function(data) {
})
Realtime Adjudication & Estimate
eligible.Claim.realtime(params) // example params can be found in the REST document of this endpoint
.then(function(data) {
})
.catch(function(e){
});
Payer
List All Payers
eligible.Payer.all({
endpoint: 'coverage',
})
.then(function(payers) {
console.log(payers);
})
View a Payer
eligible.Payer.retrieve('62308')
.then(function(payer) {
return payer.searchOptions()
})
//retrieve search options for this payer
.then(function(searchOptions){
console.log(searchOptions)
})
.catch()
Search Options
eligible.Payer.searchOptions()
.then(function(searchOptions) {
console.log(searchOptions)
})
Search Options of a Payer
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
Create a Customer
eligible.Customer.create({
customer: {
name: 'ABC company',
},
})
.then(function(customer) {
console.log(customer.id);
})
.catch();
Update a Customer
eligible.Customer.update('TN344YY67HH09KK', {
customer: {
name: 'XYZ company',
},
})
.then(function(customer) {
console.log(customer.id);
})
.catch(done);
View a Customer
eligible.Customer.get('TN344YY67HH09KK')
.then(function(customer) {
console.log(customer.id);
})
.catch();
List Customers
eligible.Customer.all({
page: 1,
})
.then(function(data) {
console.log(data.customers);
})
.catch();
Enrollment
Create an Enrollment
eligible.Enrollment.create(params) // example params can be found in the REST document of this endpoint
.then(function(enrollment) {
console.log(enrollment);
})
.catch();
Update an Enrollment
eligible.Enrollment.update(params) // example params can be found in the REST document of this endpoint
.then(function(enrollment) {
console.log(enrollment);
})
.catch();
Retrieve an Enrollment
eligible.Enrollment.get(123)
.then(function(enrollment) {
console.log(enrollment);
})
.catch();
List Enrollments
eligible.Enrollment.all({
page: 1,
})
.then(function(data) {
console.log(data.enrollment_npis);
})
.catch();
View Received PDF
eligible.Enrollment.viewReceivedPDF('123')
.then(function(receivedPDF) {
console.log(receivedPDF.download_url);
})
.catch();
Download Received PDF
Returns a readable stream when successful
eligible.Enrollment.downloadReceivedPDF('123')
.then(function(pdf) {
pdf.pipe(fs.createWriteStream('./received_pdf.pdf'))
})
.catch();
Create Original Signature PDF
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();
Update Original Signature PDF
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();
View Original Signature PDF
eligible.Enrollment.viewOriginalSignaturePDF('123')
.then(function(originalSignaturePDF) {
console.log(originalSignaturePDF.download_url);
})
.catch();
Delete Signature PDF
eligible.Enrollment.deleteOriginalSignaturePDF('123')
.then(function(response) {
console.log(response.message);
})
.catch(done);
Download Signature PDF
Returns a readable stream when successful
eligible.Enrollment.downloadOriginalSignaturePDF('123')
then(function(pdf) {
pdf.pipe(fs.createWriteStream('./original_signature_pdf.pdf'))
})
.catch();
Referral
Referral Inquiry
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);
Create A Referral
eligible.Referral.create(params) // example params can be found in the REST document of this endpoint
.then(function(referral) {
})
.catch(done);
Precertification
Precertification Inquiry
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);
Create A Precertification
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:
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Install dependencies:
npm install
- Fix bugs or add features. Make sure the changes pass the coding guidelines by runing:
npm run lint
ornpm run watch
- Write tests for your new features. For HTTP mocking
nock
library is used. Nock definitions are saved intest/fixtures
directory - Run test by
npm test
ornpm run coverage
- If all tests are passed, push to the branch (git push origin my-new-feature)
- Create new Pull Request
Support Forums
If you find an issue with in the client library we would appricate you Send an email to [email protected] or add an issue in the Issue tracker for bug reports.