Eligible JS Components is a javascript library that aims to give you an easy way to get Eligible Coverage in your website.

The Usage pattern is pretty simple, by using your language of choice, on your web application, you create a Coverage request to our endpoint, so your server side application acts like a proxy doing the request with your secret api key (you don't want to expose the secret api key on the website).

Once you get the json response, it can be included on your webpage within a hidden div, and from there you can include our js library to do a quick parsing of the response and show it to the user.

You can check our C# demo at https://github.com/EligibleAPI/ASP.NET-JS-Coverage-Demo, which shows how to make an api request on the backend and use the js library to parse the result.

Feel free to modify the library for your own usage, to contribute with new samples or enhancements to the library.

Our library needs jQuery to work, and the components use Twitter Bootstrap to render their styles, although you can use your own css styles if you want.

You can link your project to our latest js minified file on https://www.eligibleapi.com/js/coverage.min.js

We have prepared for you three samples that can be used out of the box, within your desktop, without the need to setup a backend or any environment setup; any browser will work:

You can also check the server side example that shows how a view can be rendered from your web framework, and we are in the process of building backend apps with some simple examples.

Library Architecture

This library has been built using Twitter Bootstrap and jQuery. We provide two classes for your use, and we have one internal object and class which are used from the samples to show our api parsing from your browser.

Coverage is the base class for Coverage Parsing. The first parameter should be the json answer from Eligible, and it provides many different utility and check functions.

CoveragePlugin is the class intended for end user usage, which builds the js tables after parsing the coverage answer, and it uses Coverage class to parse the api response.

EligibleEndpoints is a simple object with two attributes, coverage and demographics, which gives you back the EligibleAPI endpoint for making coverage and demographics requests. You may not need to use this object since it's intended for use by EligibleRequest

EligibleRequest is a class wrapper to make requests to EligibleAPI. You may not want to use this class in your project, since we designed it to be used from sample code, and it requires the api key, which should be secretly stored in your server side application, instead of being executed on the client side environment. This class makes an AJAX API Request to Eligible API.

Library Reference

Coverage Reference

Coverage(json)

Constructor. It expects one parameter, which is the json answer from EligibleAPI coverage endpoint.

hasError()

Checks if the coverage answer has any error message. Returns true/false.

parseError()

Gets the error message from the coverage answer.

hasDemographics()

Checks if the coverage answer has demographics information. Returns true/false.

getDemographics()

Gets the demographic information from the coverage answer.

hasSubscriber()

Checks if the coverage answer has subscriber information. Returns true/false.

getSubscriber()

Gets the subscriber information from the coverage answer.

getPatient()

If the coverage answer has dependent information, it returns the dependent, otherwise, it returns the subscriber.

hasInsurance()

Checks if the coverage answer has insurance information. Returns true/false.

getInsurance()

Gets the insurance information from the coverage answer.

hasPlan()

Checks if the coverage answer has plan information (insurance). Returns true/false.

getPlan()

Gets the plan information (insurance) from the coverage answer.

hasFinancials(element)

Checks if element has financial information. Returns true/false.

hasPlanFinancials()

Checks if the coverage answer has financial information. Returns true/false.

getPlanFinancials()

Gets the financials for the plan within the coverage answer.

hasMaximumMinimum(stop_loss)

Checks if stop_loss has maximum and minimum information. Returns true/false.

hasPlanMaximumMinimum()

Checks if the coverage answer has maximum and minimum information for the plan. Returns true/false.

getPlanMaximumMinimum()

Gets the maximum and minimum information for the plan within the coverage answer.

hasDeductibles(deductible)

Checks if deductible has any deductible information on it. Returns true/false.

hasPlanDeductibles()

Checks if the coverage answer has deductible information for the plan. Returns true/false.

getPlanDeductibles()

Gets the deductible information for the plan within the coverage answer.

hasCoinsurance(coinsurance)

Checks if coinsurance has coinsurance information. Returns true/false.

hasPlanCoinsurance()

Checks if the coverage answer has coinsurance information for the plan.

getPlanCoinsurance()

Gets the coinsurance information for the plan within the coverage answer.

hasCopayment(copayment)

Checks if copayment has copayment information. Returns true/false.

hasPlanCopayment()

Checks if the coverage answer has copayment information for the plan.

getPlanCopayment()

Gets the copayment information for the plan within the coverage answer.

hasSpendDown(spend_down)

Checks if spend_down has spend down information. Returns true/false.

hasPlanSpendDown()

Checks if the coverage answer has spend down information for the plan.

getPlanSpendDown()

Gets the spend down information for the plan within the coverage answer.

hasDisclaimer(disclaimer)

Checks if disclaimer has disclaimer information. Returns true/false.

getPlanDisclaimer()

Gets the disclaimer information for the plan within the coverage answer.

hasAdditionalInsurancePolicies()

getAdditionalInsurancePolicies()

Gets the additional insurance policies from the coverage answer.

hasServices()

Checks if the coverage answer has services information. Returns true/false.

getServices()

Gets the service information from the coverage answer.

parseSubscriberInfo(subscriber)

Returns the Member ID, Group ID, Group Name, First and Last Name from the subscriber in an Array.

parseContactDetails(contactDetails)

Returns First and Last Name, Address, Identification Codes and Contact Information in an Array.

parseContacts(contacts)

Returns the contat information from contacts in an Array.

parseNameAndAddress(person)

Returns the name and address parsed from person in an Array.

parseName(data)

If first and last name are present, it returns them. If only first name is present, it returns the first name. If only last name is present, it returns the last name. Otherwise, it returns an empty string.

parseAddress(addressData)

Returns the Street Line 1, Street Line 2, City, State and ZIP from the addressData in an Array.

parseGender(gender)

Returns Male, Female or an empty String based on gender code.

parseComments(comments)

Returns the comments in an Array.

parseDates(dates)

Returns the dates parsed with their type and value in an Array.

parseSpecificDates(dates, type)

Parses the specific "type" date from it, by using their _begin and _end nomenclature.
parseSpecificDates(plan['dates'], "plan") will check for plan_begin, plan_end and plan types from the date and return it with the right format.

formatDates(start, end)

Returns start to end, start or end by checking if any of the parameters start and end are empty or undefined.

parseFinancialAmount(info)

It expects a financial json information in the variable info, and it either returns the amount in U$S or the percent value by checking if any of them are present.

parseAmount(amount)

By checking the amount variable, it returns the money amount with a format $ XX.XX

parseReference(reference)

Returns each one of the references in the variable reference as an Array, with their label and number parsed for each element.

coverageStatus(data)

If coverage status is between 1 and 5, it returns "Active", otherwise it returns "Inactive".

isPresent(object)

Checks if object is empty by comparing it with an undefined type, null or empty string.

capitalise(string)

Returns the first character of string in upper case, and the rest on down case.

CoveragePlugin Reference

CoveragePlugin(coverage, coverageSection)

Constructor. First parametes should be a Coverage object, and the second object is the container where all the elements that this object builds are appened. If you don't provide an html container, a default element <section class="coverage-section" /> will be used.

buildPanelUI(title, content)

It builds a Twitter Bootstrap component, with the title and content provided.

addDemographicsSection(container)

Add demographics panel to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

addInsuranceSection1(container)

Add Insurance Section 1 to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

addInsuranceSection2(container)

Add Insurance Section 2 to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

addInsuranceSection3(container)

Add Insurance Section 3 to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

addPlanMaximumMinimumDeductibles(container)

Add Maximum and Minimum and Deductibles information for the plan to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

addPlanMaximumMinimum(container)

Add Maximum and Minimum information for the plan to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

addPlanDeductibles(container)

Add Deductibles information for the plan to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

addPlanCoinsurance(container)

Add Coinsurance information for the plan to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

addPlanCopayment(container)

Add Copayment information for the plan to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

addPlanSpendDown(container)

Add Spend Down information for the plan to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

addPlanDisclaimer(container)

Add Disclaimer information for the plan to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

addMaximumMinimum(container)

Add Maximum and Minimum information for the plan and services to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

addDeductibles(container)

Add Deductible information for the plan and services to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

addCoinsurance(container)

Add Coinsurance information for the plan and services to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

addCopayment(container)

Add Copayment information for the plan and services to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

addSpendDown(container)

Add Spend Down information for the plan and services to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

addAdditionalInsurancePolicies(container)

Add Additional Insurances Policies to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

addGenericServices(container)

Add Generic Services Information to the provided container. If the container is null, it adds it to the CoveragePlugin default container.

getDemographicsSection()

Gets a table with Demographic information

getInsuranceSection1()

Gets a table with Insurance Section 1

getInsuranceSection2()

Gets a table with Insurance Section 2

getInsuranceSection3()

Gets a table with Insurance Section 3

getPlanMaximumMinimumDeductibles()

Gets a table with Maximum, Minimum and Deductibles information for the plan

getPlanMaximumMinimum()

Gets a table with Maximum and Minimum information for the plan

getPlanDeductibles()

Gets a table with Deductible information for the plan

getPlanCoinsurance()

Gets a table with Coinsurance information for the plan

getPlanCopayment()

Gets a table with Copayment information for the plan

getPlanSpendDown()

Gets a table with Spend Down information for the plan

getPlanDisclaimer()

Gets a table with Disclaimer information for the plan

addServiceHeaderColumn(table)

This is used internally by the library to add a column to the header with the text Services and update the span of the column from 2 to 3

prependBodyColumn(table, text)

This is used internally by the library to add a column to the body of table with the content text

sortTable(a, b)

This is used internally by the library to sort a table based on the IN - OUT text and the amount of columns filled per row

getMaximumMinimum()

Gets a table with Maximum and Minimum information for the plan and services

getDeductibles()

Gets a table with Deductible information for the plan and services

getCoinsurance()

Gets a table with Coinsurance information for the plan and services

getCopayment()

Gets a table with Copayment information for the plan and services

getSpendDown()

Gets a table with Spend Down information for the plan and services

getAdditionalInsuranceLinks()

Gets an Array with links to each one of the additional insurance companies

getAdditionalInsurancePolicies()

Gets a table with Additional Insurance Policies

getGenericServices(columns)

Gets a table with Generic Services information

buildDemographics(person)

Builds a table with Demographic information based on the person information provided

buildInsuranceSection1(insurance, demographic)

Builds a table with Insurance information based on the insurance and demographic information provided

buildInsuranceSection2(plan)

Builds a table with Insurance information based on the insurance information provided

buildInsuranceSection3(plan, subscriber)

Builds a table with Insurance information based on the plan and subscriber information provided

buildAdditionalInsurancePolicies(additionalPolicies)

Builds a table with Additional Policies information based on the additionalPolicies information provided

buildMaximumMinimumDeductibles(data)

Builds a table with Maximum, Minimum and Deductible information based on the data information provided

buildDeductibles(data, headers)

Builds a table with Deductible information based on the data information provided. If headers is false, the table doesn't add any header information.

buildMaximumMinimum(data, headers)

Builds a table with Maximum and Minimum information based on the data information provided. If headers is false, the table doesn't add any header information.

buildCoinsurance(data, headers)

Builds a table with Coinsurance information based on the data information provided. If headers is false, the table doesn't add any header information.

buildCopayment(data, headers)

Builds a table with Copayment information based on the data information provided. If headers is false, the table doesn't add any header information.

buildSpendDown(data, headers)

Builds a table with Spend Down information based on the data information provided. If headers is false, the table doesn't add any header information.

buildDisclaimer(data)

Builds a table with Disclaimer information based on the data information provided.

parseFinancialAdditionalInfo(info)

This function is used internally by the library. Gets an Array with information about a financial json structure provided by info

getFinancialColIdx(level, individual_idx, family_idx)

This function is used internally by the library. If level is "INDIVIDUAL", it returns individual_idx, otherwise it returns family_idx

findFinancialRowIdx(rows, network, additional_information, col_index)

This function is used internally by the library. If the network and additional_information is matched in a row, and the column in the index col_index is empty, it returns the row, otherwise it returns null.

buildFinancialEmptyRow(network, cols)

This function is used internally by the library. It builds a row with the network information as the first column, and the rest of them as empty columns. It builds cols amount of columns for the row.

addAdditionalInfoToFinancialRow(row, additional_information)

This function is used internally by the library. If the row additional information is empty, it adds the additional_information to the column.

buildGenericFinancials(data)

Builds a table with generic financial information for the data.

buildGenericFinancialRows(data, network, level)

This function is used internally by the library. Gets financial rows from data by matching both the network and level in the data structure.

buildGenericFinancialRow(network, level, type, period, item)

This function is used internally by the library. It builds a row by using the parameters provided.

EligibleEndpoints Reference

coverage

Returns the Eligible coverage endpoint.

demographics

Returns the Eligible demographics endpoint.

EligibleRequest Reference

EligibleRequest(endpoint, successCallback, errorCallback, debug)

Constructor. endpoint is the Eligible endpoint the request, successCallback is the callback to be executed if the ajax request succeeds, errorCallback is the callback to be executed if the request fails, and debug is a boolean value for debugging purposes.

objectToUrlParameters(obj)

Converts the object obj to a query request.

request(params)

Makes an ajax request to Eligible.