bloom_api 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +36 -0
- data/.yardopts +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +31 -0
- data/LICENSE.txt +22 -0
- data/README.md +40 -0
- data/Rakefile +2 -0
- data/bloom_api.gemspec +24 -0
- data/lib/bloom_api/address.rb +56 -0
- data/lib/bloom_api/identifier.rb +41 -0
- data/lib/bloom_api/individual.rb +82 -0
- data/lib/bloom_api/organization.rb +61 -0
- data/lib/bloom_api/organization_official.rb +54 -0
- data/lib/bloom_api/provider.rb +118 -0
- data/lib/bloom_api/specialty.rb +43 -0
- data/lib/bloom_api/version.rb +4 -0
- data/lib/bloom_api.rb +46 -0
- data/spec/bloom_api/address_spec.rb +64 -0
- data/spec/bloom_api/api_spec.rb +24 -0
- data/spec/bloom_api/identifier_spec.rb +37 -0
- data/spec/bloom_api/individual_spec.rb +144 -0
- data/spec/bloom_api/organization_official_spec.rb +64 -0
- data/spec/bloom_api/organization_spec.rb +156 -0
- data/spec/bloom_api/provider_lookup_spec.rb +7 -0
- data/spec/bloom_api/provider_spec.rb +222 -0
- data/spec/bloom_api/specialty_spec.rb +51 -0
- data/spec/bloom_api_spec.rb +50 -0
- data/spec/spec_helper.rb +7 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 79978a9d395de7d6641f7d7e7c701303fe64a2f8
|
4
|
+
data.tar.gz: 471a65706596e3e316327446a825558383cac87d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 68cd0f7cfae9037ffe1bae9b85d14f944c49966883ba8531ba0a6fb90b21f93ceeaa888cbd5c6d944c97434c6b9fee51d6df257ab94edb953d098c36b9b4b78b
|
7
|
+
data.tar.gz: 82ef03b48b114787326117066163cea9c0a243859aac751e45cd495913e6ae4ed266aaea4a9f5a46360bfe37c1d0f2550a2a4bce5c2591208d3a09d6b157d6b0
|
data/.gitignore
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
35
|
+
|
36
|
+
.idea
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
lib/**/*.rb
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
bloom_api (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.2.5)
|
10
|
+
rake (10.4.0)
|
11
|
+
rspec (3.1.0)
|
12
|
+
rspec-core (~> 3.1.0)
|
13
|
+
rspec-expectations (~> 3.1.0)
|
14
|
+
rspec-mocks (~> 3.1.0)
|
15
|
+
rspec-core (3.1.7)
|
16
|
+
rspec-support (~> 3.1.0)
|
17
|
+
rspec-expectations (3.1.2)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.1.0)
|
20
|
+
rspec-mocks (3.1.3)
|
21
|
+
rspec-support (~> 3.1.0)
|
22
|
+
rspec-support (3.1.2)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
bloom_api!
|
29
|
+
bundler (~> 1.7)
|
30
|
+
rake (~> 10.0)
|
31
|
+
rspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Daniel Carpenter
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# BloomApi
|
2
|
+
|
3
|
+
This gem provides a client for accessing healthcare provider information
|
4
|
+
via Bloom Api. For detailed information on Bloom Api visit the
|
5
|
+
web site (http://www.bloomapi.com/).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'bloom_api'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install bloom_api
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
### Look up a provider
|
26
|
+
provider = BloomApi.find_by_npi('1841223922')
|
27
|
+
provider.npi # => '1841223922'
|
28
|
+
provider.first_name # => 'PETER'
|
29
|
+
provider.business_address.state # => 'OH'
|
30
|
+
|
31
|
+
For a list of all data available visit the Bloom Api site above and / or
|
32
|
+
check out the ruby docs here: http://www.rubydoc.info/github/carp47/bloom_api/master
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. Fork it ( https://github.com/[my-github-username]/bloom_api/fork )
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bloom_api.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bloom_api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bloom_api"
|
8
|
+
spec.version = BloomApi::VERSION
|
9
|
+
spec.authors = ["Daniel Carpenter"]
|
10
|
+
spec.email = ["daniel.carpenter01@gmail.com"]
|
11
|
+
spec.summary = %q{A gem for retrieving data from the Bloom API.}
|
12
|
+
spec.description = %q{A ruby gem for accessing data from any instance of the Bloom API. For more informatoin, visit http://www.bloomapi.com/}
|
13
|
+
spec.homepage = "https://github.com/carp47/bloom_api"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module BloomApi
|
2
|
+
# An address object containing the availabile
|
3
|
+
# data of business or practice addresses in Bloom API
|
4
|
+
class Address
|
5
|
+
|
6
|
+
# Creats a new BloomApi::Address
|
7
|
+
#
|
8
|
+
# @param [Hash]
|
9
|
+
# A hash representation of a JSON address as it would be
|
10
|
+
# returned from the Bloom API
|
11
|
+
def initialize raw_address
|
12
|
+
@raw_address = raw_address
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [String] The address's city
|
16
|
+
def city
|
17
|
+
@raw_address['city']
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [String] The address's country code
|
21
|
+
def country
|
22
|
+
@raw_address['country_code']
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [String] The fax number for the address
|
26
|
+
def fax
|
27
|
+
@raw_address['fax']
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [String] Line 1 of the address
|
31
|
+
def line1
|
32
|
+
@raw_address['address_line']
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [String] Line 2 of the address
|
36
|
+
def line2
|
37
|
+
@raw_address['address_details_line']
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [String] The contact phone number for the address
|
41
|
+
def phone
|
42
|
+
@raw_address['phone']
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [String] The 2-digit state code for the address
|
46
|
+
def state
|
47
|
+
@raw_address['state']
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [String] The zip code for the address
|
51
|
+
def zip
|
52
|
+
@raw_address['zip']
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module BloomApi
|
2
|
+
# An alternate unique identifier for a provider
|
3
|
+
class Identifier
|
4
|
+
|
5
|
+
# Creates a new Identifier
|
6
|
+
# @param raw_identifier [Hash]
|
7
|
+
def initialize raw_identifier
|
8
|
+
@raw_identifier = raw_identifier
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [String] the unique identifier
|
12
|
+
def identifier
|
13
|
+
@raw_identifier['identifier']
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [String] The issuing party for the identifier
|
17
|
+
def issuer
|
18
|
+
@raw_identifier['issuer']
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [String] The U.S. state in which the identifier applies
|
22
|
+
def state
|
23
|
+
@raw_identifier['state']
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [String]
|
27
|
+
# The type of identifier.
|
28
|
+
# Possible values are:
|
29
|
+
# * other
|
30
|
+
# * medicare upin
|
31
|
+
# * medicare id-type unspecified
|
32
|
+
# * medicaid
|
33
|
+
# * medicare oscar/certification
|
34
|
+
# * medicare nsc
|
35
|
+
# * medicare pin
|
36
|
+
def type
|
37
|
+
@raw_identifier['type']
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module BloomApi
|
2
|
+
# A class representing an individual provider
|
3
|
+
class Individual < Provider
|
4
|
+
|
5
|
+
# @return [String] the provider's professional credential
|
6
|
+
def credential
|
7
|
+
@raw_provider['credential']
|
8
|
+
end
|
9
|
+
|
10
|
+
# @return [String] the provider's first name
|
11
|
+
def first_name
|
12
|
+
@raw_provider['first_name']
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [String] the provider's gender
|
16
|
+
def gender
|
17
|
+
@raw_provider['gender']
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [String] the provider's last name
|
21
|
+
def last_name
|
22
|
+
@raw_provider['last_name']
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [String] the provider's middle name
|
26
|
+
def middle_name
|
27
|
+
@raw_provider['middle_name']
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [String] the providers name prefix (Mr., Ms., etc.)
|
31
|
+
def name_prefix
|
32
|
+
@raw_provider['name_prefix']
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [String] the provider's name suffix (Jr., Sr., Etc.)
|
36
|
+
def name_suffix
|
37
|
+
@raw_provider['name_suffix']
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [String] an additional professional credential
|
41
|
+
def other_credential
|
42
|
+
@raw_provider['other_credential']
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [String] an alternate first name for the provider
|
46
|
+
def other_first_name
|
47
|
+
@raw_provider['other_first_name']
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [String] an alternate last name for the provider
|
51
|
+
def other_last_name
|
52
|
+
@raw_provider['other_last_name']
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [String]
|
56
|
+
# a code describing the purpose of the provider's alternate
|
57
|
+
# last name. Possible values are:
|
58
|
+
# * former name
|
59
|
+
# * professional name
|
60
|
+
# * doing business as
|
61
|
+
# * former legal business name
|
62
|
+
# * other name
|
63
|
+
def other_last_name_type_code
|
64
|
+
@raw_provider['provider_other_last_name_type_code']
|
65
|
+
end
|
66
|
+
|
67
|
+
# @return [String] the provider's alternate last name
|
68
|
+
def other_middle_name
|
69
|
+
@raw_provider['other_middle_name']
|
70
|
+
end
|
71
|
+
|
72
|
+
# @return [String] the provider's alternate name prefix
|
73
|
+
def other_name_prefix
|
74
|
+
@raw_provider['other_name_prefix']
|
75
|
+
end
|
76
|
+
|
77
|
+
# @return [String] the provider's altername name suffix
|
78
|
+
def other_name_suffix
|
79
|
+
@raw_provider['other_name_suffix']
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module BloomApi
|
2
|
+
|
3
|
+
#A class representing an organizational provider
|
4
|
+
class Organization < Provider
|
5
|
+
|
6
|
+
# @return [String] the organization's employer identification number
|
7
|
+
def employer_identification_number
|
8
|
+
case @raw_provider['employer_identification_number']
|
9
|
+
when '<UNAVAIL>'
|
10
|
+
nil
|
11
|
+
else
|
12
|
+
@raw_provider['employer_identification_number']
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# designates whether the organization is a part of another
|
17
|
+
# @return [boolean] true if part of another organization
|
18
|
+
# @return [boolean] false if not part of another organization
|
19
|
+
def is_subpart?
|
20
|
+
case @raw_provider['organization_subpart']
|
21
|
+
when 'yes'
|
22
|
+
true
|
23
|
+
when 'no'
|
24
|
+
false
|
25
|
+
else
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [String] the business name of the organization
|
31
|
+
def name
|
32
|
+
@raw_provider['business_name']
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [OrganizationOfficial] the organization's administrative official
|
36
|
+
def official
|
37
|
+
unless @raw_provider['organization_official'].nil?
|
38
|
+
OrganizationOfficial.new(@raw_provider['organization_official'])
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# @return [String] an alternate name for the organization
|
43
|
+
def other_name
|
44
|
+
@raw_provider['other_name']
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [Organization] if the provider has a parent organization
|
48
|
+
# @return nil if there is no parent organization
|
49
|
+
def parent_organization
|
50
|
+
unless @raw_provider['parent_org'].nil?
|
51
|
+
Organization.new(@raw_provider['parent_org'])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [String] the organization's tax identification number
|
56
|
+
def tax_identification_number
|
57
|
+
@raw_provider['tax_identification_number']
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module BloomApi
|
2
|
+
# A class representing an organization official
|
3
|
+
class OrganizationOfficial
|
4
|
+
|
5
|
+
# Creates a new OrganizationOfficial
|
6
|
+
# @param raw_official [Hash]
|
7
|
+
# A hash representation of the organization_official object
|
8
|
+
# available in the BloomApi
|
9
|
+
def initialize(raw_official)
|
10
|
+
@raw_official = raw_official
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [String] the official's professional credential
|
14
|
+
def credential
|
15
|
+
@raw_official['credential']
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [String] the official's first name
|
19
|
+
def first_name
|
20
|
+
@raw_official['first_name']
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [String] the official's last name
|
24
|
+
def last_name
|
25
|
+
@raw_official['last_name']
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [String] the official's middle name
|
29
|
+
def middle_name
|
30
|
+
@raw_official['middle_name']
|
31
|
+
end
|
32
|
+
|
33
|
+
# @return [String] the official's name prefix
|
34
|
+
def name_prefix
|
35
|
+
@raw_official['name_prefix']
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [String] the official's name suffix
|
39
|
+
def name_suffix
|
40
|
+
@raw_official['name_suffix']
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [String] the official's phone number
|
44
|
+
def phone
|
45
|
+
@raw_official['phone']
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [String] the official's professional title
|
49
|
+
def title
|
50
|
+
@raw_official['title']
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
module BloomApi
|
2
|
+
|
3
|
+
# A class representing a generic provider. This is a base
|
4
|
+
# class for individuals and organizations.
|
5
|
+
class Provider
|
6
|
+
|
7
|
+
# Create a new provider
|
8
|
+
# @param [Hash]
|
9
|
+
# a hash representation of a json provider
|
10
|
+
# object from the bloom API
|
11
|
+
def initialize(raw_provider)
|
12
|
+
@raw_provider = raw_provider
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [BloomApi::Address] the provider's business address
|
16
|
+
def business_address
|
17
|
+
Address.new(@raw_provider['business_address'])
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [Date]
|
21
|
+
# if the provider has been deactivated returns the date of deactivation
|
22
|
+
# @return [nil] if the the provider has not been deactivated
|
23
|
+
def deactivation_date
|
24
|
+
unless @raw_provider['deactivation_date'].nil?
|
25
|
+
Time.parse(@raw_provider['deactivation_date']).to_date
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [String] the reason the provider was deactivated
|
30
|
+
def deactivation_reason
|
31
|
+
@raw_provider['deactivation_reason']
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [String] the provider's national provider identifier
|
35
|
+
def npi
|
36
|
+
@raw_provider['npi']
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [BloomApi::Address] the provider's practice address
|
40
|
+
def practice_address
|
41
|
+
Address.new(@raw_provider['practice_address'])
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [Array] A list of alternate identifiers for the provider
|
45
|
+
def other_identifiers
|
46
|
+
unless @raw_provider['other_identifiers'].nil?
|
47
|
+
@raw_provider['other_identifiers'].collect { |i| BloomApi::Identifier.new(i) }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# @return [String]
|
52
|
+
# a type describing the purpose of the provider's alternate name
|
53
|
+
def other_name_type
|
54
|
+
@raw_provider['other_name_type']
|
55
|
+
end
|
56
|
+
|
57
|
+
# @return [Date]
|
58
|
+
# the reactivation date for the provider if it's been reactivated
|
59
|
+
# @return [nil] if the provider has not been reactivated
|
60
|
+
def reactivation_date
|
61
|
+
unless @raw_provider['reactivation_date'].nil?
|
62
|
+
Time.parse(@raw_provider['reactivation_date']).to_date
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# @return [Date]
|
67
|
+
# the date that the provider information was recorded
|
68
|
+
def recorded_at
|
69
|
+
Time.parse(@raw_provider['enumeration_date']).to_date
|
70
|
+
end
|
71
|
+
|
72
|
+
# @return [String]
|
73
|
+
# the provider's replacement npi
|
74
|
+
def replacement_npi
|
75
|
+
@raw_provider['replacement_npi']
|
76
|
+
end
|
77
|
+
|
78
|
+
# @return [boolean] true if the provider is a sole proprietor
|
79
|
+
# @return [boolean] false if the provider is not a sole proprietor
|
80
|
+
def sole_proprietor?
|
81
|
+
case @raw_provider['sole_proprietor']
|
82
|
+
when 'yes'
|
83
|
+
true
|
84
|
+
when 'no'
|
85
|
+
false
|
86
|
+
else
|
87
|
+
nil
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# @return [Array] an array of specialties held by the provider
|
92
|
+
def specialties
|
93
|
+
unless @raw_provider['provider_details'].nil?
|
94
|
+
@raw_provider['provider_details'].collect { |s| Specialty.new(s) }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# @return [Array] an array of taxonomy groups for the provider
|
99
|
+
def taxonomy_groups
|
100
|
+
unless @raw_provider['taxonomy_groups'].nil?
|
101
|
+
@raw_provider['taxonomy_groups'].collect { |g| g['taxonomy']}
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# @return [String]
|
106
|
+
# The provider type. Possible values are:
|
107
|
+
# * individual
|
108
|
+
# * organization
|
109
|
+
def type
|
110
|
+
@raw_provider['type']
|
111
|
+
end
|
112
|
+
|
113
|
+
# @return [Date] the date that the provider's data was last updated
|
114
|
+
def updated_at
|
115
|
+
Time.parse(@raw_provider['last_update_date']).to_date
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module BloomApi
|
2
|
+
# An class representing a provider specialty
|
3
|
+
class Specialty
|
4
|
+
|
5
|
+
# Creates a new specialty
|
6
|
+
# @param raw_detail [Hash]
|
7
|
+
# A hash representation of a json specialty object
|
8
|
+
# from the Bloom Api
|
9
|
+
def initialize raw_detail
|
10
|
+
@raw_detail = raw_detail
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [String]
|
14
|
+
# the license number associated with the specialty
|
15
|
+
def license_number
|
16
|
+
@raw_detail['license_number']
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [String]
|
20
|
+
# the U.S. state in which the specialty applies
|
21
|
+
def license_number_state
|
22
|
+
@raw_detail['license_number_state']
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [boolean] true if this is the provider's primary specialty
|
26
|
+
# @return [boolean] false if this is not the provider's primary specialty
|
27
|
+
def primary_specialty?
|
28
|
+
case @raw_detail['taxonomy_switch']
|
29
|
+
when 'yes'
|
30
|
+
true
|
31
|
+
when 'no'
|
32
|
+
false
|
33
|
+
else
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [String] the specialty's code
|
39
|
+
def specialty_code
|
40
|
+
@raw_detail['healthcare_taxonomy_code']
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/bloom_api.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require "bloom_api/version"
|
2
|
+
|
3
|
+
# A module which contains all code necessary for
|
4
|
+
# looking up health care providers via the Bloom API.
|
5
|
+
#
|
6
|
+
# For more details visit http://www.bloomapi.com/
|
7
|
+
#
|
8
|
+
# @author Dan Carpenter
|
9
|
+
module BloomApi
|
10
|
+
|
11
|
+
require "bloom_api/provider"
|
12
|
+
require "bloom_api/address"
|
13
|
+
require "bloom_api/identifier"
|
14
|
+
require "bloom_api/individual"
|
15
|
+
require "bloom_api/organization"
|
16
|
+
require "bloom_api/organization_official"
|
17
|
+
require "bloom_api/specialty"
|
18
|
+
|
19
|
+
# A custom exception for when no provider is found when performing a lookup.
|
20
|
+
class ProviderNotFound < Exception; end
|
21
|
+
|
22
|
+
# The base url for the bloom api.
|
23
|
+
BASE_URL = "www.bloomapi.com"
|
24
|
+
|
25
|
+
# Look up a health care provider by their national provider identifier
|
26
|
+
#
|
27
|
+
# @params npi [String] The national provider identifier to be used for lookup
|
28
|
+
# @return [BloomApi::Individual] if the npi references an individual provider
|
29
|
+
# @return [BloomApi::Organization] if the npi references an organization
|
30
|
+
#
|
31
|
+
# @raise [ProviderNotFound] if the provided npi does not reference a provider
|
32
|
+
def self.find_by_npi(npi)
|
33
|
+
response = Net::HTTP.get_response(BASE_URL, "/api/npis/#{npi}")
|
34
|
+
|
35
|
+
build_provider(JSON.parse(response.body)['result']) if response.code == "200"
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def self.build_provider(response)
|
41
|
+
return Individual.new(response) if response['type'] == 'individual'
|
42
|
+
return Organization.new(response) if response['type'] == 'organization'
|
43
|
+
Provider.new(response)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|