Closed groliver-pcci closed 3 years ago
Hi @groliver-pcci, yes we could add a geocodio_hipaa
= TRUE/FALSE parameter. Just to make sure, you are currently able to use the HIPAA endpoint with api_url = https://api-hipaa.geocod.io/v1.6/geocode
and api_url = https://api-hipaa.geocod.io/v1.6/reverse
, correct?
Yes, by subbing the url out manually, but I did not rebuild from base code so some helper functions weren't full working
if you make a branch with it added I can test with my API key
Thanks for your interest Holt Oliver From: Jesse Cambon @.> Sent: Monday, September 20, 2021 8:47 AM To: jessecambon/tidygeocoder @.> Cc: George 'Holt' Oliver @.>; Mention @.> Subject: Re: [jessecambon/tidygeocoder] need hipaa compliant geocodio endpoint (#137)
Hi @groliver-pccihttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fgroliver-pcci&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7C7cf18015cd274476e30808d97c3d1c9c%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677424172820098%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=wM0qGf7QAGCOE8N4q4d7nEqad7sW9dxbHTljbz86s2Y%3D&reserved=0, yes we could add a geocodio_hipaa = TRUE/FALSE parameter. Just to make sure, you are currently able to use the HIPAA endpoint with api_url = https://api-hipaa.geocod.io/v1.6/geocode, correct?
- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjessecambon%2Ftidygeocoder%2Fissues%2F137%23issuecomment-922943435&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7C7cf18015cd274476e30808d97c3d1c9c%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677424172830087%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=JS6L5Y%2F%2FS0nnhrlRZRcUEG337TvBYwyVR3OvtKpObJI%3D&reserved=0, or unsubscribehttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FANJMAWO7Y6CKJ3VRTZ4MG5LUC43M7ANCNFSM5EK7OYPQ&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7C7cf18015cd274476e30808d97c3d1c9c%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677424172830087%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=vIAWNMdvYJF6663lAxEJkkGp5BmT7HcnOmE0C2hJ1xg%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7C7cf18015cd274476e30808d97c3d1c9c%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677424172840082%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=yGykoSWdESgKIp8fUD5bOKtAslWMeD5eEAbi0%2BuMe5g%3D&reserved=0 or Androidhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7C7cf18015cd274476e30808d97c3d1c9c%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677424172840082%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=WnF3%2BkEghwi9XpkIDzf5ljPtoPU2eLnU%2FWGQoAHVXF8%3D&reserved=0.
Sounds good, I'll let you know when I have a branch ready for you to test.
However, I'm not sure I'm following the issue you are running into. You should be able to just use the api_url
parameter to specify the HIPAA endpoint without modifying the current tidygeocoder package code. If this isn't working, could you post a reprex? https://reprex.tidyverse.org/
Just saw the api_url option which allows to function, but I don't quite under stand why the base geocodio wouldn't work
The initial problem I had without that was an error rm_quote(deparse(substitute(address))) : could not find function "rm_quote" which is from the utils.r, I didn't manually load I suppose.
I had tried to just paste the URL into some helpers and see if it would work
get_geocodio_url <- function(api_v ='1.6', reverse = FALSE) {
url_keyword <- if (reverse == TRUE) 'reverse' else 'geocode' return(paste0("https://api-hipaa.geocod.io/v", as.character(api_v), "/", url_keyword)) }
get_api_url <- function(method, reverse = FALSE, return_type = 'locations', search = 'onelineaddress', geocodio_v = 1.6, iq_region = 'us', mapbox_permanent = FALSE, mapquest_open = FALSE) {
api_url <- switch(method, "osm" = get_osm_url(reverse = reverse), "census" = get_census_url(return_type, search), "geocodio" = get_geocodio_url(geocodio_v, reverse = reverse), "iq" = get_iq_url(iq_region, reverse = reverse), "opencage" = get_opencage_url(), # same url as forward geocoding "google" = get_google_url(), # same url as forward geocoding "mapbox" = get_mapbox_url(mapbox_permanent), # same url as fwd geocoding "here" = get_here_url(reverse = reverse), "tomtom" = get_tomtom_url(reverse = reverse), "mapquest" = get_mapquest_url(mapquest_open, reverse = reverse), "bing" = get_bing_url(), "arcgis" = get_arcgis_url(reverse = reverse), "geoapify" = get_geoapify_url(reverse = reverse) )
if (length(api_url) == 0) stop('API URL not found', call. = FALSE) return(api_url) }
library(dplyr)
library(tidygeocoder) library(tibble) library(dplyr) library(tidygeocoder)
address_single <- tibble(singlelineaddress = c( "11 Wall St, NY, NY", "600 Peachtree Street NE, Atlanta, Georgia" )) address_components <- tribble( ~street, ~cty, ~st, "11 Wall St", "NY", "NY", "600 Peachtree Street NE", "Atlanta", "GA" )
sample_addresses %>% slice(1:2) %>% geocode(addr, method = 'geocodio')
lat
and long
don't exist.Sys.getenv("GEOCODIO_API_KEY")
system(paste("curl", paste0("https://api-hipaa.geocod.io/v1.6/geocode?q=Philadelphia&api_key=", Sys.getenv("GEOCODIO_API_KEY"))))
osm_s1 <- geo( address = address_single$singlelineaddress, method = "osm", lat = latitude, long = longitude )
geo( address = address_single$singlelineaddress, method = "geocodio", lat = latitude, long = longitude )
latitude
and longitude
don't exist.geo( address = address_single$singlelineaddress, lat = latitude, long = longitude, method='geocodio', api_url ="https://api-hipaa.geocod.io/v1.6/geocode" )
geo( address = address_single$singlelineaddress, lat = latitude, long = longitude, method='geocodio',geocodio_v ="1.6" )
latitude
and longitude
don't exist.From: Jesse Cambon @.> Sent: Monday, September 20, 2021 10:53 AM To: jessecambon/tidygeocoder @.> Cc: George 'Holt' Oliver @.>; Mention @.> Subject: Re: [jessecambon/tidygeocoder] need hipaa compliant geocodio endpoint (#137)
Sounds good, I'll let you know when I have a branch ready for you to test.
However, I'm not sure I'm following the issue you are running into. You should be able to just use the api_url parameter to specify the HIPAA endpoint without modifying the current tidygeocoder package code. If this isn't working, could you post a reprex? https://reprex.tidyverse.org/https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Freprex.tidyverse.org%2F&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7Ca9c6e6f4b0e24a42a11408d97c4eabba%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677499607542058%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=ZX9L%2Bl4sR1hntYZwEHrIIsMFZDxkKsZIL1x2%2BX%2BL%2BfI%3D&reserved=0
- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjessecambon%2Ftidygeocoder%2Fissues%2F137%23issuecomment-923054265&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7Ca9c6e6f4b0e24a42a11408d97c4eabba%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677499607552052%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=bUL%2BvYbLRGzOVxdN24Cpn6N1%2BFZu%2FiOBwAM1xUGjZmI%3D&reserved=0, or unsubscribehttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FANJMAWJOFH3LMVXMB65O7O3UC5KELANCNFSM5EK7OYPQ&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7Ca9c6e6f4b0e24a42a11408d97c4eabba%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677499607552052%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=HIEQn%2BwJDH6dygEs4w244xX3FmT30joUPGstPvTLBYk%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7Ca9c6e6f4b0e24a42a11408d97c4eabba%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677499607562043%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=N5Mgds2GS14g4YAKVSBfHicOCx1QYClRrKv7Bsxie%2Fc%3D&reserved=0 or Androidhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7Ca9c6e6f4b0e24a42a11408d97c4eabba%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677499607562043%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=5CG6rk6u9ybDoALZbLMUM6U3AqDGw4YAdfLn1itOpFQ%3D&reserved=0.
I see, I typically click the Install and Restart
button in the "Build" panel of RStudio to load new code changes I've made on the package. That might be the step you're missing (for loading the rm_quote
function, etc.).
In any case, I have a branch ready for you to try. You can install it with this command:
devtools::install_github("jessecambon/tidygeocoder", ref = "geocodio-hipaa")
After that installs you should be able to use the geocodio_hipaa
argument like this:
library(tidygeocoder)
results <- geo(address = "Toronto", method = 'geocodio', geocodio_hipaa = TRUE, verbose = TRUE)
Let me know if you run into any issues.
It works in the simple case! Thanks hope this helps the package lifecycle Holt
devtools::install_github("jessecambon/tidygeocoder", ref = "geocodio-hipaa") library(tidygeocoder) results <- geo(address = "Toronto", method = 'geocodio', geocodio_hipaa = TRUE, verbose = TRUE)
From: Jesse Cambon @.> Sent: Monday, September 20, 2021 4:30 PM To: jessecambon/tidygeocoder @.> Cc: George 'Holt' Oliver @.>; Mention @.> Subject: Re: [jessecambon/tidygeocoder] need hipaa compliant geocodio endpoint (#137)
I see, I typically click the Install and Restart button in the "Build" panel of RStudio to load new code changes I've made on the package (I think that might . That might be the step you're missing (for loading the rm_quote function, etc.).
In any case, I have a branch ready for you to try. You can install it with this command:
devtools::install_github("jessecambon/tidygeocoder", ref = "geocodio-hipaa")
After that installs you should be able to use the geocodio_hipaa argument like this:
library(tidygeocoder)
results <- geo(address = "Toronto", method = 'geocodio', geocodio_hipaa = TRUE, verbose = TRUE)
Let me know if you run into any issues.
- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjessecambon%2Ftidygeocoder%2Fissues%2F137%23issuecomment-923330159&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7Cd25e14519422459d93db08d97c7dd6ca%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677702192697270%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=jYqfzDiw2CG%2B4htn78jfdLHHBQ%2FQRZK4XNkP6XCMvvI%3D&reserved=0, or unsubscribehttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FANJMAWMJOVSZFFQRM5LGAUDUC6RWRANCNFSM5EK7OYPQ&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7Cd25e14519422459d93db08d97c7dd6ca%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677702192707267%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=ITtqJyIrnJQnBqjBTS%2BhqtxqADa%2F7hpINsyEp2Hxmeo%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7Cd25e14519422459d93db08d97c7dd6ca%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677702192707267%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=xaBtsp0XMXsdfSx5jYGWccKR%2BDvOdYW5FPTG%2BKh7tLw%3D&reserved=0 or Androidhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7Cgeorge.oliver%40pccinnovation.org%7Cd25e14519422459d93db08d97c7dd6ca%7C9a2a9ade704f4416b09447b8a504ad39%7C0%7C0%7C637677702192717262%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=g5QANtb0Jcra8XQPYTIgO1q%2BCFQtNWNlXkQoM5VxEPo%3D&reserved=0.
Since it is possible to query the HIPAA geocod.io API with the api_url
parameter, I am wondering whether an additional parameter is really necessary. One could use purrr::partial
to save some typing in case geo()
is called more than once in a script.
library(tidygeocoder)
library(purrr)
address <- "600 Peachtree Street NE, Atlanta, GA"
# Query to the main geocod.io API
geo(address, method = "geocodio", verbose = TRUE)
#> Number of Unique Addresses: 1
#> Querying API URL: https://api.geocod.io/v1.6/geocode
#> Passing the following parameters to the API:
#> q : "600 Peachtree Street NE, Atlanta, GA"
#> api_key : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#> limit : "1"
#> HTTP Status Code: 200
#> Query completed in: 1 seconds
#>
#> # A tibble: 1 x 3
#> address lat long
#> <chr> <dbl> <dbl>
#> 1 600 Peachtree Street NE, Atlanta, GA 33.8 -84.4
# use purrr:partial to build a custom geo() function.
hipaa_geo <- partial(geo, method = "geocodio", api_url = "https://api-hipaa.geocod.io/v1.6/geocode")
# hipaa_geo() works just like geo(method = "geocodio", api_url = "https://api-hipaa.geocod.io/v1.6/geocode") would
# The query fails here, because I don't have a key for the HIPAA geocod.io API,
# which is different from the main geocod.io key
hipaa_geo(address, verbose = TRUE)
#> Number of Unique Addresses: 1
#> Querying API URL: https://api-hipaa.geocod.io/v1.6/geocode
#> Passing the following parameters to the API:
#> q : "600 Peachtree Street NE, Atlanta, GA"
#> api_key : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#> limit : "1"
#> Warning in query_api(api_url, api_query_parameters, method = method): Forbidden
#> (HTTP 403).
#> HTTP Status Code: 403
#> Error: Invalid API key
#> Query completed in: 0.5 seconds
#>
#> # A tibble: 1 x 3
#> address lat long
#> <chr> <dbl> <dbl>
#> 1 600 Peachtree Street NE, Atlanta, GA NA NA
Maybe we should advertise the purrr::partial approach a bit for this use-case.
@dpprdan that's a nice approach for customizing the API endpoint that we could offer.
In geo()
we already have a number of parameters that are there to facilitate changing the API endpoint: geocodio_v
(Geocodio API version number), mapbox_permanent
, iq_region
, return_type
(for US Census), and mapquest_open
. One solution could be to wrap all of these parameters into a single named list parameter api_options
. For instance:
geo(address = 'Seoul', method = 'geocodio', api_options = list(geocodio_v = 1.6, geocodio_hipaa = TRUE))
This would allow us to accommodate some API endpoint customization shortcuts while reducing the number of parameters in geo()
(and reverse_geo()
). For additional API endpoint customization that we aren't offering a shortcut for, we could offer your purrr::partial
approach.
The api_options
parameter described above is now implemented in the development version (main branch). See the geo function documentation for details.
geocodio service has a separate hipaa compliant endpoint, access is restricted to this address only.
Can future release add a geocodio-hipaa, flag or api-url alias in api_url "geocodio" = get_geocodio_url(geocodio_v, reverse = reverse , hipaa= F),
or
get_geocodio_hipaa_url <- function(api_v ='1.6', reverse = FALSE) {
return API URL based on api version (ex. 1.6)
url_keyword <- if (reverse == TRUE) 'reverse' else 'geocode' return(paste0("https://api-hipaa.geocod.io/v", as.character(api_v), "/", url_keyword)) }