Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated the API url to the 2.1 version of the NPPES API #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/nppes_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ module NPPESApi
# @param limit [Integer] Limit results, default = 10, max = 200
# @param skip [Integer] Skip first N results, max = 1000
def self.search(options = {})
SearchResults.new(RestClient.get('https://npiregistry.cms.hhs.gov/api', params: options).body)
SearchResults.new(RestClient.get('https://npiregistry.cms.hhs.gov/api/?version=2.1', params: options).body)
end
end
2 changes: 1 addition & 1 deletion lib/nppes_api/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module NPPESApi
VERSION = '0.1.1'.freeze
VERSION = '2.0.1'.freeze
end
10 changes: 10 additions & 0 deletions nppes_api-0.1.1/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/.bundle/
/.yardoc
/Gemfile.lock
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/
*.gem
2 changes: 2 additions & 0 deletions nppes_api-0.1.1/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--format documentation
--color
209 changes: 209 additions & 0 deletions nppes_api-0.1.1/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
AllCops:
TargetRubyVersion: 2.3
Include:
- 'Rakefile'
Exclude:
- 'config.ru'
- 'bin/**/*'
- 'cache/**/*'
- 'db/**/*'

Metrics/LineLength:
Max: 140

# Removes the requirement for using double quotes only for string interpolation.
Style/StringLiterals:
Enabled: false

# These complexity and length metrics tend to require a bunch of high-touch refactoring
# in existing projects. Leaving them high for now, and we can slowly lower them to standard
# levels in the near future.
Metrics/ModuleLength:
Max: 200

Metrics/ClassLength:
Max: 200

Metrics/MethodLength:
Max: 50

Metrics/AbcSize:
Max: 75

Metrics/CyclomaticComplexity:
Max: 20

Metrics/PerceivedComplexity:
Max: 20

# Allow long keyword parameter lists
Metrics/ParameterLists:
Max: 15
CountKeywordArgs: false

# This enforces bad style and can break things.
# See: https://github.com/bbatsov/rubocop/issues/2614
Performance/Casecmp:
Enabled: false

# This requires the use of alias rather than alias_method, which seems totally arbitrary
Style/Alias:
Enabled: false

# This cop enforces that submodules/subclasses be defined like this:
#
# class Foo::Bar
#
# rather than like this:
#
# module Foo
# class Bar
#
# This is actually semantically different, and there are valid reasons for wanting to use the latter
# form because of the way the former does funky stuff to the namespace.
Style/ClassAndModuleChildren:
Enabled: false

# This forces you to use class instance variables rather than class variables, which seems pretty
# situation-specific
Style/ClassVars:
Enabled: false

# This makes you do things like this:
# variable = if test
# 'abc-123'
# else
# 'def-456'
# end
#
# I think this is harder to read than assigning the variable within the conditional.
Style/ConditionalAssignment:
Enabled: false

# This cop forces you to put a return at the beginning of a block of code rather than having an if statement
# whose body carries to the end of the function. For example:
#
# def foo
# ...
# if test
# ...
# end
# end
#
# would be considered bad, and the cop would force you to put a `return if !test` before that block and
# then remove the if. The problem is that this hides intent, since the if test does have a purpose in
# readability, and it could also be easier for future changes to miss the return statement and add code
# after it expecting it to be executed.
Style/GuardClause:
Enabled: false

# This is pretty much the same thing as the one above. Inside a loop, it forces you to use next to skip
# iteration rather than using an if block that runs to the end of the loop, and it suffers from the same
# problems as above.
Style/Next:
Enabled: false

Style/IndentArray:
EnforcedStyle: consistent

# This forces you to change simple if/unless blocks to the conditional form like: `return 2 if badness`.
# Unfortunately there are a number of cases where it makes sense to use the block form even for simple statements,
# and the modifier form can be easy to miss when scanning code.
Style/IfUnlessModifier:
Enabled: false

# This cop forces the use of unless in all negated if statements. Since unless is a source of so many arguments
# and there seems to be no purpose in enforcing its use, disable it.
Style/NegatedIf:
Enabled: false

# This one enforces that functions with names like has_value? be renamed to value?. There are many cases where
# doing so would make the code more difficult to parse.
Style/PredicateName:
Enabled: false

# By default this will force you to use specific names for arguments for enumerable and other methods,
# which I don't understand even a little bit.
Style/SingleLineBlockParams:
Methods: []

# Allow trivial methods that have ? at the end.
Style/TrivialAccessors:
AllowPredicates: true

# It's ok to make a small array of words without using a %w
Style/WordArray:
MinSize: 5

# Some people really like to put lines at the beginning and end of class bodies, while other people
# really don't. It doesn't really seem to matter.
Style/EmptyLinesAroundClassBody:
Enabled: false

# This forces you to put a comment like this at the top of every single file:
# frozen_string_literal: true
# In Ruby 3, string literals will be frozen by default, so doing so future-proofs
# the code, but in the meantime it's a huge pain in the ass.
Style/FrozenStringLiteralComment:
Enabled: false

# this forces you to use the lambda keyword rather than -> for multiline lambdas, which seems totally arbitrary
Style/Lambda:
Enabled: false

# Force indentation for milti-line expressions and method calls
Style/MultilineOperationIndentation:
EnforcedStyle: indented

Style/MultilineMethodCallIndentation:
EnforcedStyle: indented

# This disallows the use of $1, $2 from regular expressions, which seems to make no sense whatsoever
Style/PerlBackrefs:
Enabled: false

# This enforces that multi-line array literals do not end in a comma. For example:
#
# foo = [
# 1,
# 2
# ]
Style/TrailingCommaInLiteral:
EnforcedStyleForMultiline: no_comma

# Same as above but for method arguments rather than array entries.
Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: no_comma

# This forces you to replace things like: `[1, 2, 3].length == 0` with `[1,2,3].empty?`. The problem is that
# not all things that implement length also implement empty? so you will get errors that cannot be resolved,
# and the cop will encourage you to do things that are incorrect.
Style/ZeroLengthPredicate:
Enabled: false

# Enforce alignment of multi-line assignments to be like this:
# variable = if test
# ...
# end
Lint/EndAlignment:
AlignWith: variable

# This cop will require you to replace or prefix method arguments that go unused with underscores. The problem
# is that while seeming to solve no problem this could easily cause issues where someone editing the code to
# begin using the variable forgets to remove the underscore. Also, if you replace the argument with _, then
# information about the meaning of that argument is lost.
Lint/UnusedMethodArgument:
Enabled: false

# Same as above but with block arguments.
Lint/UnusedBlockArgument:
Enabled: false

# This cop forces all rescue blocks to do something with the exception. Sometimes you just have an exception
# you want to rescue but do nothing about.
Lint/HandleExceptions:
Enabled: false

# This isn't a library, so let's not enforce documentation.
Documentation:
Enabled: false
5 changes: 5 additions & 0 deletions nppes_api-0.1.1/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sudo: false
language: ruby
rvm:
- 2.3.1
before_install: gem install bundler -v 1.12.5
4 changes: 4 additions & 0 deletions nppes_api-0.1.1/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in nppes_api.gemspec
gemspec
21 changes: 21 additions & 0 deletions nppes_api-0.1.1/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Aubrey Holland

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
46 changes: 46 additions & 0 deletions nppes_api-0.1.1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# NPPES Api

This is a Ruby wrapper for the [NPPES NPI Registry API](https://npiregistry.cms.hhs.gov/registry/help-api). It provides a simple
query interface and returns data either in raw JSON format or wrapped with queryable Ruby objects.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'nppes_api'
```

And then execute:

$ bundle

Or install it yourself as:

$ gem install nppes_api

## Usage

The entrypoint for searches is at NPPESApi.search. See the code in lib/nppes_api.rb for information on the options that you can pass,
which are the same as the ones [described by NPPES](https://npiregistry.cms.hhs.gov/api/demo). A successful search will return an
NPPESApi::SearchResults object, from which you can call methods to retrieve data or call the raw_data method to get the original JSON.
Here is an example query:

```
NPPESApi.search(number: 1932494937).results.first.taxonomies.first.state #=> 'NC'
```

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/nppes_api.


## License

The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
6 changes: 6 additions & 0 deletions nppes_api-0.1.1/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec)

task default: :spec
14 changes: 14 additions & 0 deletions nppes_api-0.1.1/bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby

require "bundler/setup"
require "nppes_api"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

require "irb"
IRB.start
8 changes: 8 additions & 0 deletions nppes_api-0.1.1/bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
set -vx

bundle install

# Do any other automated setup that you need to do here
43 changes: 43 additions & 0 deletions nppes_api-0.1.1/lib/nppes_api.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require 'nppes_api/version'

require 'rest-client'

require_relative 'nppes_api/address'
require_relative 'nppes_api/basic'
require_relative 'nppes_api/provider'
require_relative 'nppes_api/search_results'
require_relative 'nppes_api/taxonomy'

module NPPESApi
ENUMERATION_TYPES = [
NPI_1 = 'NPI-1'.freeze,
NPI_2 = 'NPI-2'.freeze
].freeze

ADDRESS_PURPOSES = [
LOCATION = 'LOCATION'.freeze,
MAILING = 'MAILING'.freeze
].freeze

# This is the main entry point for searches. Provide params as described below to parameterize the search. Search results can consist
# of at most 1200 results, and each search can return at most 200 of them. Use the limit and skip parameters as described below to
# perform pagination of the data.
# {https://npiregistry.cms.hhs.gov/registry/help-api}
# @param number [Integer] An NPI number to search with. Must be exactly 10 characters
# @param enumeration_type [String] One of the ENUMERATION_TYPES from above. NPI_1 is an individual search, and NPI_2 is organizations.
# Will search across both types if unspecified.
# @param taxonomy_description [String] Specialty or Description. Can include a wildcard (*) after at least two characters
# @param first_name [String] Exact name or include a wildcard after two characters. Only valid for type 1 searches.
# @param last_name [String] Exact name or include a wildcard after two characters. Only valid for type 1 searches.
# @param organization_name [String] Exact name or include a wildcard after two characters. Only valid for type 2 searches.
# @param address_purpose [String] One of the ADDRESS_PURPOSES above. Requires other criteria.
# @param city [String] Exact city name, no wildcards
# @param state [String] 2-character abbreviation, requires other criteria
# @param postal_code [String] At least two characters, wildcard is implied
# @param country_code [String] Exactly two characters. If "US" other criteria are required
# @param limit [Integer] Limit results, default = 10, max = 200
# @param skip [Integer] Skip first N results, max = 1000
def self.search(options = {})
SearchResults.new(RestClient.get('https://npiregistry.cms.hhs.gov/api/?version=2.1', params: options).body)
end
end
Loading