Module: BloomApi

Defined in:
lib/bloom_api.rb,
lib/bloom_api/address.rb,
lib/bloom_api/version.rb,
lib/bloom_api/provider.rb,
lib/bloom_api/specialty.rb,
lib/bloom_api/identifier.rb,
lib/bloom_api/individual.rb,
lib/bloom_api/organization.rb,
lib/bloom_api/organization_official.rb

Overview

A module which contains all code necessary for looking up health care providers via the Bloom API.

For more details visit www.bloomapi.com/

Author:

  • Dan Carpenter

Defined Under Namespace

Classes: Address, Identifier, Individual, Organization, OrganizationOfficial, Provider, ProviderNotFound, Specialty

Constant Summary collapse

BASE_URL =

The base url for the bloom api.

"www.bloomapi.com"
NPI_SEARCH_PATH =
"/api/search/npi"
VERSION =

the gem’s version

"0.0.3"

Class Method Summary collapse

Class Method Details

.find_by(options, limit = 20, offset = 0) ⇒ Object

Look up a health care provider or organization by the provided criteria



33
34
35
36
37
38
39
40
# File 'lib/bloom_api.rb', line 33

def self.find_by(options, limit=20, offset=0)
criteria = options.each_with_index.map {|x,i| "key#{i+1}=#{URI::escape(x[0].to_s)}&op#{i+1}=eq&value#{i+1}=#{URI::escape(x[1])}"} || []
criteria << "limit=#{limit}&offset=#{offset}"
uri = URI::HTTP.build(host: BASE_URL, path: NPI_SEARCH_PATH, query: criteria.join('&'))
response = Net::HTTP.get_response(uri)

build_provider(JSON.parse(response.body)['result']) if response && response.code == "200"
end

.find_by_npi(npi) ⇒ BloomApi::Individual, BloomApi::Organization

Look up a health care provider by their national provider identifier

Returns:

Raises:



49
50
51
52
53
# File 'lib/bloom_api.rb', line 49

def self.find_by_npi(npi)
  response = Net::HTTP.get_response(BASE_URL, "/api/npis/#{npi}")

  build_provider(JSON.parse(response.body)['result']) if response && response.code == "200"
end