Skip to content

vericred/vericred-perl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

VericredClient::Role - a Moose role for the Vericred API

Vericred's API allows you to search for Health Plans that a specific doctor accepts.

Getting Started

Visit our Developer Portal to create an account.

Once you have created an account, you can create one Application for Production and another for our Sandbox (select the appropriate Plan when you create the Application).

SDKs

Our API follows standard REST conventions, so you can use any HTTP client to integrate with us. You will likely find it easier to use one of our autogenerated SDKs, which we make available for several common programming languages.

Authentication

To authenticate, pass the API Key you created in the Developer Portal as a Vericred-Api-Key header.

curl -H 'Vericred-Api-Key: YOUR_KEY' "https://api.vericred.com/providers?search_term=Foo&zip_code=11215"

Versioning

Vericred's API default to the latest version. However, if you need a specific version, you can request it with an Accept-Version header.

The current version is v3. Previous versions are v1 and v2.

curl -H 'Vericred-Api-Key: YOUR_KEY' -H 'Accept-Version: v2' "https://api.vericred.com/providers?search_term=Foo&zip_code=11215"

Pagination

Endpoints that accept page and per_page parameters are paginated. They expose four additional fields that contain data about your position in the response, namely Total, Per-Page, Link, and Page as described in RFC-5988.

For example, to display 5 results per page and view the second page of a GET to /networks, your final request would be GET /networks?....page=2&per_page=5.

Sideloading

When we return multiple levels of an object graph (e.g. Providers and their States we sideload the associated data. In this example, we would provide an Array of States and a state_id for each provider. This is done primarily to reduce the payload size since many of the Providers will share a State

{
  providers: [{ id: 1, state_id: 1}, { id: 2, state_id: 1 }],
  states: [{ id: 1, code: 'NY' }]
}

If you need the second level of the object graph, you can just match the corresponding id.

Selecting specific data

All endpoints allow you to specify which fields you would like to return. This allows you to limit the response to contain only the data you need.

For example, let's take a request that returns the following JSON by default

{
  provider: {
    id: 1,
    name: 'John',
    phone: '1234567890',
    field_we_dont_care_about: 'value_we_dont_care_about'
  },
  states: [{
    id: 1,
    name: 'New York',
    code: 'NY',
    field_we_dont_care_about: 'value_we_dont_care_about'
  }]
}

To limit our results to only return the fields we care about, we specify the select query string parameter for the corresponding fields in the JSON document.

In this case, we want to select name and phone from the provider key, so we would add the parameters select=provider.name,provider.phone. We also want the name and code from the states key, so we would add the parameters select=states.name,staes.code. The id field of each document is always returned whether or not it is requested.

Our final request would be GET /providers/12345?select=provider.name,provider.phone,states.name,states.code

The response would be

{
  provider: {
    id: 1,
    name: 'John',
    phone: '1234567890'
  },
  states: [{
    id: 1,
    name: 'New York',
    code: 'NY'
  }]
}

Benefits summary format

Benefit cost-share strings are formatted to capture:

  • Network tiers
  • Compound or conditional cost-share
  • Limits on the cost-share
  • Benefit-specific maximum out-of-pocket costs

Example #1 As an example, we would represent this Summary of Benefits & Coverage as:

  • Hospital stay facility fees:

    • Network Provider: $400 copay/admit plus 20% coinsurance
    • Out-of-Network Provider: $1,500 copay/admit plus 50% coinsurance
    • Vericred's format for this benefit: In-Network: $400 before deductible then 20% after deductible / Out-of-Network: $1,500 before deductible then 50% after deductible
  • Rehabilitation services:

    • Network Provider: 20% coinsurance
    • Out-of-Network Provider: 50% coinsurance
    • Limitations & Exceptions: 35 visit maximum per benefit period combined with Chiropractic care.
    • Vericred's format for this benefit: In-Network: 20% after deductible / Out-of-Network: 50% after deductible | limit: 35 visit(s) per Benefit Period

Example #2 In this other Summary of Benefits & Coverage, the specialty_drugs cost-share has a maximum out-of-pocket for in-network pharmacies.

  • Specialty drugs:
    • Network Provider: 40% coinsurance up to a $500 maximum for up to a 30 day supply
    • Out-of-Network Provider Not covered
    • Vericred's format for this benefit: In-Network: 40% after deductible, up to $500 per script / Out-of-Network: 100%

BNF

Here's a description of the benefits summary string, represented as a context-free grammar:

<cost-share>     ::= <tier> <opt-num-prefix> <value> <opt-per-unit> <deductible> <tier-limit> "/" <tier> <opt-num-prefix> <value> <opt-per-unit> <deductible> "|" <benefit-limit>
<tier>           ::= "In-Network:" | "In-Network-Tier-2:" | "Out-of-Network:"
<opt-num-prefix> ::= "first" <num> <unit> | ""
<unit>           ::= "day(s)" | "visit(s)" | "exam(s)" | "item(s)"
<value>          ::= <ddct_moop> | <copay> | <coinsurance> | <compound> | "unknown" | "Not Applicable"
<compound>       ::= <copay> <deductible> "then" <coinsurance> <deductible> | <copay> <deductible> "then" <copay> <deductible> | <coinsurance> <deductible> "then" <coinsurance> <deductible>
<copay>          ::= "$" <num>
<coinsurace>     ::= <num> "%"
<ddct_moop>      ::= <copay> | "Included in Medical" | "Unlimited"
<opt-per-unit>   ::= "per day" | "per visit" | "per stay" | ""
<deductible>     ::= "before deductible" | "after deductible" | ""
<tier-limit>     ::= ", " <limit> | ""
<benefit-limit>  ::= <limit> | ""

VERSION

Automatically generated by the Swagger Codegen project:

  • API version: 1.0.0
  • Package version: 0.0.7
  • Build date: 2017-01-26T16:04:02.241-05:00
  • Build package: class io.swagger.codegen.languages.PerlClientCodegen

A note on Moose

This role is the only component of the library that uses Moose. See VericredClient::ApiFactory for non-Moosey usage.

SYNOPSIS

The Perl Swagger Codegen project builds a library of Perl modules to interact with a web service defined by a OpenAPI Specification. See below for how to build the library.

This module provides an interface to the generated library. All the classes, objects, and methods (well, not quite *all*, see below) are flattened into this role.

    package MyApp;
    use Moose;
    with 'VericredClient::Role';
    
    package main;
    
    my $api = MyApp->new({ tokens => $tokens });
    
    my $pet = $api->get_pet_by_id(pet_id => $pet_id);

Structure of the library

The library consists of a set of API classes, one for each endpoint. These APIs implement the method calls available on each endpoint.

Additionally, there is a set of "object" classes, which represent the objects returned by and sent to the methods on the endpoints.

An API factory class is provided, which builds instances of each endpoint API.

This Moose role flattens all the methods from the endpoint APIs onto the consuming class. It also provides methods to retrieve the endpoint API objects, and the API factory object, should you need it.

For documentation of all these methods, see AUTOMATIC DOCUMENTATION below.

Configuring authentication

In the normal case, the OpenAPI Spec will describe what parameters are required and where to put them. You just need to supply the tokens.

my $tokens = {
    # basic
    username => $username,
    password => $password,
    
    # oauth
    access_token => $oauth_token,
    
    # keys
    $some_key => { token => $token,
                   prefix => $prefix, 
                   in => $in,             # 'head||query',     
                   },
                   
    $another => { token => $token,
                  prefix => $prefix, 
                  in => $in,              # 'head||query',      
                  },                   
    ...,
    
    };
    
    my $api = MyApp->new({ tokens => $tokens });

Note these are all optional, as are prefix and in, and depend on the API you are accessing. Usually prefix and in will be determined by the code generator from the spec and you will not need to set them at run time. If not, in will default to 'head' and prefix to the empty string.

The tokens will be placed in the VericredClient::Configuration namespace as follows, but you don't need to know about this.

  • $VericredClient::Configuration::username

    String. The username for basic auth.

  • $VericredClient::Configuration::password

    String. The password for basic auth.

  • $VericredClient::Configuration::api_key

    Hashref. Keyed on the name of each key (there can be multiple tokens).

          $VericredClient::Configuration::api_key = {
                  secretKey => 'aaaabbbbccccdddd',
                  anotherKey => '1111222233334444',
                  };
    
  • $VericredClient::Configuration::api_key_prefix

    Hashref. Keyed on the name of each key (there can be multiple tokens). Note not all api keys require a prefix.

          $VericredClient::Configuration::api_key_prefix = {
                  secretKey => 'string',
                  anotherKey => 'same or some other string',
                  };
    
  • $VericredClient::Configuration::access_token

    String. The OAuth access token.

METHODS

base_url

The generated code has the base_url already set as a default value. This method returns (and optionally sets, but only if the API client has not been created yet) the current value of base_url.

api_factory

Returns an API factory object. You probably won't need to call this directly.

    $self->api_factory('Pet'); # returns a VericredClient::PetApi instance
    
    $self->pet_api;            # the same

MISSING METHODS

Most of the methods on the API are delegated to individual endpoint API objects (e.g. Pet API, Store API, User API etc). Where different endpoint APIs use the same method name (e.g. new()), these methods can't be delegated. So you need to call $api->pet_api->new().

In principle, every API is susceptible to the presence of a few, random, undelegatable method names. In practice, because of the way method names are constructed, it's unlikely in general that any methods will be undelegatable, except for:

    new()
    class_documentation()
    method_documentation()

To call these methods, you need to get a handle on the relevant object, either by calling $api->foo_api or by retrieving an object, e.g. $api->get_pet_by_id(pet_id => $pet_id). They are class methods, so you could also call them on class names.

BUILDING YOUR LIBRARY

See the homepage https://github.com/swagger-api/swagger-codegen for full details. But briefly, clone the git repository, build the codegen codebase, set up your build config file, then run the API build script. You will need git, Java 7 or 8 and Apache maven 3.0.3 or better already installed.

The config file should specify the project name for the generated library:

    {"moduleName":"WWW::MyProjectName"}

Your library files will be built under WWW::MyProjectName.

      $ git clone https://github.com/swagger-api/swagger-codegen.git
      $ cd swagger-codegen
      $ mvn package
      $ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i [URL or file path to JSON swagger API spec] \
-l perl \
-c /path/to/config/file.json \
-o /path/to/output/folder

Bang, all done. Run the autodoc script in the bin directory to see the API you just built.

AUTOMATIC DOCUMENTATION

You can print out a summary of the generated API by running the included autodoc script in the bin directory of your generated library. A few output formats are supported:

      Usage: autodoc [OPTION]

-w           wide format (default)
-n           narrow format
-p           POD format 
-H           HTML format 
-m           Markdown format
-h           print this help message
-c           your application class

The -c option allows you to load and inspect your own application. A dummy namespace is used if you don't supply your own class.

DOCUMENTATION FROM THE OpenAPI Spec

Additional documentation for each class and method may be provided by the Swagger spec. If so, this is available via the class_documentation() and method_documentation() methods on each generated object class, and the method_documentation() method on the endpoint API classes:

    my $cmdoc = $api->pet_api->method_documentation->{$method_name}; 
    
    my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation;                                  
    my $omdoc = $api->get_pet_by_id->(pet_id => $pet_id)->method_documentation->{method_name}; 

Each of these calls returns a hashref with various useful pieces of information.

LOAD THE MODULES

To load the API packages:

use VericredClient::DrugPackagesApi;
use VericredClient::DrugsApi;
use VericredClient::NetworkSizesApi;
use VericredClient::NetworksApi;
use VericredClient::PlansApi;
use VericredClient::ProvidersApi;
use VericredClient::ZipCountiesApi;

To load the models:

use VericredClient::Object::Applicant;
use VericredClient::Object::Base;
use VericredClient::Object::Carrier;
use VericredClient::Object::CarrierSubsidiary;
use VericredClient::Object::County;
use VericredClient::Object::CountyBulk;
use VericredClient::Object::Drug;
use VericredClient::Object::DrugCoverage;
use VericredClient::Object::DrugCoverageResponse;
use VericredClient::Object::DrugPackage;
use VericredClient::Object::DrugSearchResponse;
use VericredClient::Object::Formulary;
use VericredClient::Object::FormularyDrugPackageResponse;
use VericredClient::Object::FormularyResponse;
use VericredClient::Object::Meta;
use VericredClient::Object::Network;
use VericredClient::Object::NetworkDetails;
use VericredClient::Object::NetworkDetailsResponse;
use VericredClient::Object::NetworkSearchResponse;
use VericredClient::Object::NetworkSize;
use VericredClient::Object::Plan;
use VericredClient::Object::PlanCounty;
use VericredClient::Object::PlanCountyBulk;
use VericredClient::Object::PlanSearchResponse;
use VericredClient::Object::PlanSearchResponseMeta;
use VericredClient::Object::PlanSearchResult;
use VericredClient::Object::PlanShowResponse;
use VericredClient::Object::Pricing;
use VericredClient::Object::Provider;
use VericredClient::Object::ProviderDetails;
use VericredClient::Object::ProviderGeocode;
use VericredClient::Object::ProviderShowResponse;
use VericredClient::Object::ProvidersGeocodeResponse;
use VericredClient::Object::ProvidersSearchResponse;
use VericredClient::Object::RatingArea;
use VericredClient::Object::RequestPlanFind;
use VericredClient::Object::RequestPlanFindApplicant;
use VericredClient::Object::RequestPlanFindDrugPackage;
use VericredClient::Object::RequestPlanFindProvider;
use VericredClient::Object::RequestProvidersSearch;
use VericredClient::Object::ServiceArea;
use VericredClient::Object::ServiceAreaZipCounty;
use VericredClient::Object::State;
use VericredClient::Object::StateNetworkSizeRequest;
use VericredClient::Object::StateNetworkSizeResponse;
use VericredClient::Object::VendoredPlanBulk;
use VericredClient::Object::ZipCode;
use VericredClient::Object::ZipCountiesResponse;
use VericredClient::Object::ZipCounty;
use VericredClient::Object::ZipCountyBulk;
use VericredClient::Object::ZipCountyResponse;

GETTING STARTED

Put the Perl SDK under the 'lib' folder in your project directory, then run the following

#!/usr/bin/perl
use lib 'lib';
use strict;
use warnings;
# load the API package
use VericredClient::DrugPackagesApi;
use VericredClient::DrugsApi;
use VericredClient::NetworkSizesApi;
use VericredClient::NetworksApi;
use VericredClient::PlansApi;
use VericredClient::ProvidersApi;
use VericredClient::ZipCountiesApi;

# load the models
use VericredClient::Object::Applicant;
use VericredClient::Object::Base;
use VericredClient::Object::Carrier;
use VericredClient::Object::CarrierSubsidiary;
use VericredClient::Object::County;
use VericredClient::Object::CountyBulk;
use VericredClient::Object::Drug;
use VericredClient::Object::DrugCoverage;
use VericredClient::Object::DrugCoverageResponse;
use VericredClient::Object::DrugPackage;
use VericredClient::Object::DrugSearchResponse;
use VericredClient::Object::Formulary;
use VericredClient::Object::FormularyDrugPackageResponse;
use VericredClient::Object::FormularyResponse;
use VericredClient::Object::Meta;
use VericredClient::Object::Network;
use VericredClient::Object::NetworkDetails;
use VericredClient::Object::NetworkDetailsResponse;
use VericredClient::Object::NetworkSearchResponse;
use VericredClient::Object::NetworkSize;
use VericredClient::Object::Plan;
use VericredClient::Object::PlanCounty;
use VericredClient::Object::PlanCountyBulk;
use VericredClient::Object::PlanSearchResponse;
use VericredClient::Object::PlanSearchResponseMeta;
use VericredClient::Object::PlanSearchResult;
use VericredClient::Object::PlanShowResponse;
use VericredClient::Object::Pricing;
use VericredClient::Object::Provider;
use VericredClient::Object::ProviderDetails;
use VericredClient::Object::ProviderGeocode;
use VericredClient::Object::ProviderShowResponse;
use VericredClient::Object::ProvidersGeocodeResponse;
use VericredClient::Object::ProvidersSearchResponse;
use VericredClient::Object::RatingArea;
use VericredClient::Object::RequestPlanFind;
use VericredClient::Object::RequestPlanFindApplicant;
use VericredClient::Object::RequestPlanFindDrugPackage;
use VericredClient::Object::RequestPlanFindProvider;
use VericredClient::Object::RequestProvidersSearch;
use VericredClient::Object::ServiceArea;
use VericredClient::Object::ServiceAreaZipCounty;
use VericredClient::Object::State;
use VericredClient::Object::StateNetworkSizeRequest;
use VericredClient::Object::StateNetworkSizeResponse;
use VericredClient::Object::VendoredPlanBulk;
use VericredClient::Object::ZipCode;
use VericredClient::Object::ZipCountiesResponse;
use VericredClient::Object::ZipCounty;
use VericredClient::Object::ZipCountyBulk;
use VericredClient::Object::ZipCountyResponse;

# for displaying the API response data
use Data::Dumper;
use VericredClient::Configuration;
use VericredClient::;

# Configure API key authorization: Vericred-Api-Key
$VericredClient::Configuration::api_key->{'Vericred-Api-Key'} = 'YOUR_API_KEY';
# uncomment below to setup prefix (e.g. Bearer) for API key, if needed
#$VericredClient::Configuration::api_key_prefix->{'Vericred-Api-Key'} = 'Bearer';

my $api_instance = VericredClient::DrugPackagesApi->new();
my $formulary_id = '123'; # string | ID of the Formulary in question
my $ndc_package_code = '07777-3105-01'; # string | ID of the DrugPackage in question

eval {
    my $result = $api_instance->show_formulary_drug_package_coverage(formulary_id => $formulary_id, ndc_package_code => $ndc_package_code);
    print Dumper($result);
};
if ($@) {
    warn "Exception when calling DrugPackagesApi->show_formulary_drug_package_coverage: $@\n";
}

DOCUMENTATION FOR API ENDPOINTS

All URIs are relative to https://api.vericred.com/

Class Method HTTP request Description
DrugPackagesApi show_formulary_drug_package_coverage GET /formularies/{formulary_id}/drug_packages/{ndc_package_code} Formulary Drug Package Search
DrugsApi get_drug_coverages GET /drug_packages/{ndc_package_code}/coverages Search for DrugCoverages
DrugsApi list_drugs GET /drugs Drug Search
NetworkSizesApi list_state_network_sizes GET /states/{state_id}/network_sizes State Network Sizes
NetworkSizesApi search_network_sizes POST /network_sizes/search Network Sizes
NetworksApi list_networks GET /networks Networks
NetworksApi show_network GET /networks/{id} Network Details
PlansApi find_plans POST /plans/search Find Plans
PlansApi show_plan GET /plans/{id} Show Plan
ProvidersApi get_provider GET /providers/{npi} Find a Provider
ProvidersApi get_providers POST /providers/search Find Providers
ProvidersApi get_providers_1 POST /providers/search/geocode Find Providers
ZipCountiesApi get_zip_counties GET /zip_counties Search for Zip Counties

DOCUMENTATION FOR MODELS

DOCUMENTATION FOR AUTHORIZATION

Vericred-Api-Key

  • Type: API key
  • API key parameter name: Vericred-Api-Key
  • Location: HTTP header