Coder Social home page Coder Social logo

ropensci / npi Goto Github PK

View Code? Open in Web Editor NEW
27.0 4.0 10.0 1.53 MB

Access the U.S. National Provider Identifier (NPI) Registry Public Search API

Home Page: https://docs.ropensci.org/npi/

License: Other

R 100.00%
api-wrapper r npi-number healthcare health-data r-package rstats

npi's Introduction

rOpenSci

Project Status: Abandoned

This repository has been archived. The former README is now in README-NOT.md.

npi's People

Contributors

frankfarach avatar parmsam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

npi's Issues

Fix deprecated .sep argument in calls to tidyr::unnest()

npi::npi_summarize(npi::npi_search(city = "New York City"))
#> Requesting records 0-10...
#> Warning: The `.sep` argument of `unnest()` is deprecated as of tidyr 1.0.0.
#> Use `names_sep = '_'` instead.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.
#> # A tibble: 10 × 6
#>           npi name      enumeration_type primary_practic… phone primary_taxonomy
#>         <int> <chr>     <chr>            <chr>            <chr> <chr>           
#>  1 1598295529 MUHAMMAD… Individual       475 SEAVIEW AVE… 718-… Student in an O…
#>  2 1710977137 JOHN SCR… Individual       115 WEST 27TH S… 212-… Social Worker C…
#>  3 1346224904 NICULAE … Organization     10 EAST 38TH ST… 212-… Internal Medici…
#>  4 1992776843 NANCY RA… Individual       312 E 94 ST, NE… 212-… Nurse Practitio…
#>  5 1770554206 LYNN KEP… Individual       205 E 64 ST SUI… 212-… Physician Assis…
#>  6 1083687214 SCOTT RI… Individual       33 WEST 42ND ST… 212-… Optometrist     
#>  7 1588637987 CHUNG SO… Individual       901 SIXTH AVENU… 212-… Optometrist     
#>  8 1851366066 BENJAMIN… Individual       150 E 37TH ST A… 212-… Psychiatry & Ne…
#>  9 1629046321 KENNETH … Individual       530 FIRST AVE S… 212-… Otolaryngology  
#> 10 1366405755 HAROLD O… Individual       1737 YORK AVE S… 212-… Dentist

Created on 2022-02-23 by the reprex package (v2.0.1)

Add CodeMeta JSON file to package

Add CodeMeta JSON file to repo to make it easier to discover.

Acceptance criteria:

  1. repo contains codemeta.json
  2. codemeta.json is newer than DESCRIPTION

Idea for future development:

  • Consider adding a pre-commit hook in another issue to require that acceptance criterion 2 above be met prior to committing to the master branch.

Can't use `npi_summarize()` with country code

From ropensci/software-review#505 (comment):

I've found an issue when querying by country code which returns slightly differently formatted query and as such renders npi_summarize() unusable.

reprex:

library("npi")
ki = npi_search(country_code = "DE")
#> Requesting records 0-10...
npi_summarize(ki)
#> Error:
#> ! Tibble columns must have compatible sizes.
#> * Size 10: Existing data.
#> * Size 12: Column `primary_taxonomy`.
#> i Only values of size one are recycled.
#> Run `rlang::last_error()` to see where the error occurred.

Maybe npi_summarize() should take into account this edge case (even if I suppose there are not that many American health professionals outside the US).

Allow response paging

From the NPPES API help page:

An API query will return a maximum of 200 results per request. The Skip field in the API will let you skip up to 1000 records. By using these two fields with your search criteria, you can get up to a maximum of 1,200 records over six requests.

Improve error message when internet off or endpoint unreachable

From ropensci/software-review#505 (comment):

Because this is a recurrent theme for API packages (and CRAN asks them to "fail gracefully" in these cases), I've checked what happens when I turn of the internet and I don't think it is that explicit for the user.

> npi_search(city = "San Francisco")
Requesting records 0-10...
Error in curl::curl_fetch_memory(url, handle = handle) : 
  Could not resolve host: npiregistry.cms.hhs.gov

Maybe there could be a way to display a better error message when internet is off or the website unreachable?
Like check first hand if internet is off and errors explicitly if it is the case.

Handle wildcard special cases

From ropensci/software-review#505 (comment):

some special queries with wildcards used improperly (not trailing) could be caught earlier. I had strange results with some.

reprex:

library("npi")

# Trying to mess up with wildcards
ko = npi_search(last_name = "M*ll*")
#> Requesting records 0-10...
ko$basic  # The answer has nothing to do with the pattern
#> [[1]]
#> # A tibble: 1 x 11
#>   first_name last_name middle_name credential sole_proprietor gender
#>   <chr>      <chr>     <chr>       <chr>      <chr>           <chr> 
#> 1 JENNY      ENSTROM   E           PA         NO              F     
#> # ... with 5 more variables: enumeration_date <chr>, last_updated <chr>,
#> #   status <chr>, name <chr>, certification_date <chr>

# Wildcards in the middle do not work
ko = npi_search(last_name = "M*ll")
#> Requesting records 0-10...
ko$basic  # And I get the same answer instead of an error?!
#> [[1]]
#> # A tibble: 1 x 11
#>   first_name last_name middle_name credential sole_proprietor gender
#>   <chr>      <chr>     <chr>       <chr>      <chr>           <chr> 
#> 1 JENNY      ENSTROM   E           PA         NO              F     
#> # ... with 5 more variables: enumeration_date <chr>, last_updated <chr>,
#> #   status <chr>, name <chr>, certification_date <chr>

Created on 2022-04-04 by the reprex package (v2.0.1)

User agent documentation and customization

From ropensci/software-review#505 (comment):

It's great that the package provides a user-agent. It has been proven to be the best way possible to access an API to provide
a proof of who is accessing the API.

In the README there is a mention of the user agent (https://github.com/frankfarach/npi/blob/d4e98a52ccc0a7f71328582333e5b4191f4796b9/README.Rmd#L114-L120). Which seems a great idea. However, this does not consider that the user may not be familiar with the concept of user-agent. Also, the displayed example doesn't show in which way it can be helpful to change its user-agent. Maybe you could go to a more concrete example. I also wonder if it is a good idea to let the user entirely remove the reference to the package.

To improve the user-agent, which only points to the URL of the repo, it would be good to indicate the version npi in use like it is done in taxize. If it is needed for the user to modify its user agent, then maybe providing a fixed part of the UA with the version of the package and a customizable second part would be even more complete.

NPPES API v2.1 compatibility: Query parameters

Update this package so the query parameters work with the latest version (2.1) of the NPPES registry API. Prior versions will be deprecated in September 2019:

use_first_name_alias (Version 2.1): This field only applies to Individual Providers when not doing a wildcard search. When set to "True", the search results will include Providers with similar First Names. E.g., first_name=Robert, will also return Providers with the first name of Rob, Bob, Robbie, Bobby, etc. Valid Values are:
True: Will include alias/similar names.
False: Will only look for exact matches.
Default Value is True

address_purpose (Version 2.0 and After): Refers to whether the address information entered pertains to the provider's Mailing Address or the provider's Practice Location Address. When not specified, the results will contain the providers where either the Mailing Address or any of Practice Location Addresses match the entered address information. PRIMARY will only search against Primary Location Address. While Secondary will only search against Secondary Location Addresses. Valid values are:
LOCATION
MAILING
PRIMARY
SECONDARY

postal_code (Version 2.1): The Postal Code associated with the provider's address identified in Address Purpose. If you enter a 5 digit postal code, it will match any appropriate 9 digit (zip+4) codes in the data. Trailing wildcard entries are permitted requiring at least two characters to be entered (e.g., "21*").

Unable to 'skip' records

Hi Frank -- this is a fantastic project. Thank you very much for making it available.
I am having a hard time using the skip field (I need it to build out a list of all the providers in D.C. -- not just the first 200.
Creating the first df works fine. It's only from the second one on that I am having issues. Thanks!

dc_200 <- npi_search(city = "Washington",
                     state = "DC",
                     limit = 200)

dc_400 <- npi_search(city = "Washington",
                     state = "DC",
                     limit = 200,
                     skip = 200)
#> Error in npi_search(city = "Washington", state = "DC", limit = 200, skip = 200) : unused argument (skip = 200)

dc_600 <- npi_search(city = "Washington",
                     state = "DC",
                     limit = 200,
                     skip = 400)
#> Error in npi_search(city = "Washington", state = "DC", limit = 200, skip = 400) : unused argument (skip = 400)

dc_800 <- npi_search(city = "Washington",
                     state = "DC",
                     limit = 200,
                     skip = 600)
#> Error in npi_search(city = "Washington", state = "DC", limit = 200, skip = 600) : unused argument (skip = 600)

Clarify API rate limitation

From ropensci/software-review#505 (comment):

Is there a form of rate limitation? It seems reasonable given that we access an API. Nothing is shown from the API standpoint nor the package? (I've seen it mentioned in the "Getting started" vignette but it could be more explicit). If it is the case, that could be a nice thing to mention to the user so that they are aware of the time it would take to get their results back.

Do this in at least two places: README.md and vignettes

Deactivated NPIs

@frankfarach Thank you very much for creating this package. I only discovered it after I miserably failed to create a function of my own.

I am passing about 3000 call to the API and some of these NPIs appear to be deactivated

Is there an approach that can be used to handle deactivated NPIs?

The deactivated NPIs appear to be valid when I pass them to npi_is_valid()

An example of a deactivated NPI is 1710983663

This is an example of what I am trying to run

examples <- data.frame(names = c(1003060377,
                                # 1710983663, this is a deactivated NPI
                                 1003213240,
                                 1003116930,
                                 1003020306,
                                 1003292350,
                                 1003094988,
                                 1003164716,
                                 1003156324,
                                 1003219981))

result <- vector('list', nrow(examples))

for(i in seq(nrow(examples))) {
  #Sleep for 1 minute after every 2 values
  if(i %% 2 == 0) Sys.sleep(5)
  result[[i]] <- npi::npi_search(examples$names[i])
}

x <- bind_rows(result) %>%
  select(npi,addresses) %>% 
  unnest(addresses) %>% 
  filter(address_purpose == "LOCATION") %>% 
  select(npi,
         address_1,
         address_2,
         city,
         state,
         postal_code)

Normalize credentials

Credentials should be:

  • uppercase
  • without commas or periods (hyphens allowed)
  • a list column with one credential per list element

Clarify description of npis dataset

From ropensci/software-review#505 (comment):

The description of npis dataset doesn't seem to fit the dataset as it specifies "list of 0-n tibbles" for one column. It is not clear to me how to read it. Though I think it's nice to indicate the type of element. Maybe a way to make it more explicit would be to indicate "list-column of tibbles with X rows and Y columns".

Handle illegal special characters in query parameters

From ropensci/software-review#505 (comment):

Character arguments of npi_search() allow for some special character as specified by the documentation. But when searching with other special characters, the query is still submitted.

reprex:

library("npi")
npi_search(first_name = "KOŒ*")
#> Requesting records 0-10...
#> Error in `npi_handle_response()`:
#> ! 
#> Field: first_name
#> Field contains special character(s) or wrong number of characters

Created on 2022-04-04 by the reprex package (v2.0.1)

It works well but it fallback on the API when this is the case, I think it could be possible to catch these issues early when processing these arguments to save time and additional queries.

Fix tidyr warning

Note: This is a bug related to #24.

From ropensci/software-review#505 (comment):

At several occasion we face this message:

Warning message:
The `.sep` argument of `unnest()` is deprecated as of tidyr 1.0.0.
Use `names_sep = '_'` instead.
while there is a function to check for installed tidyr version
tidyr_new_interface().

On my computer I had the error when using npi_flatten() even though I had
tidyr v.1.2.0 installed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.