37  Geospatial

Rural Health Clinics

rhc <- care_group("rhc")

res <- rhc@members$rhc_enrollments@identifier |> 
  request() |> 
  req_url_query("filter[STATE]" = "GA") |>
  req_perform() |> 
  providertwo:::resp_simple_json() |> 
  get_elem("^data$|headers", regex = TRUE)

rhc_enr <- as_tbl(res$data) |> 
  set_names(res$meta) |> 
  providertwo:::map_na_if() |> 
  roworder(`ORGANIZATION NAME`) |>
  janitor::clean_names() |>
  mtt(incorporation_date = providertwo:::as_date(incorporation_date),
      multiple_npi_flag = charbin(multiple_npi_flag),
      address = providertwo:::make_address(address_line_1, address_line_2)) |>
  slt(
    npi,
    has_mult_npi = multiple_npi_flag,
    ccn,
    pac = associate_id,
    enid = enrollment_id,
    enid_state = enrollment_state,
    org_name = organization_name,
    dba = doing_business_as_name,
    inc_date = incorporation_date,
    inc_state = incorporation_state,
    org_type = organization_type_structure,
    org_type_2 = organization_other_type_text,
    prop_non = proprietary_nonprofit,
    address,
    city,
    state,
    zip = zip_code)

rhc_enr |> 
  purse()
$npi          c83 1639774714                        1174104657            ...
• $has_mult_npi i83 0                                 0                     ...
• $ccn          c83 118915                            118917                ...
• $pac          c83 2961814694                        2961814694            ...
• $enid         c83 O20210409001138                   O20211123003251       ...
• $enid_state   c83 GA                                GA                    ...
• $org_name     c83 ACCESS MEDICAL CLINIC GEORGIA LLC ACCESS MEDICAL CLINIC ...
• $dba          c83 NA                                NA                    ...
• $inc_date     D83 2020-07-29                        2021-01-11            ...
• $inc_state    c83 GA                                GA                    ...
• $org_type     c83 LLC                               LLC                   ...
• $org_type_2   c83 NA                                NA                    ...
• $prop_non     c83 P                                 P                     ...
• $address      c83 304 N WESTBERRY ST                37 341 BYP            ...
• $city         c83 SYLVESTER                         HAWKINSVILLE          ...
• $state        c83 GA                                GA                    ...
• $zip          c83 317912125                         310364839             ...
res2 <- rhc@members$rhc_owners@identifier |> 
  request() |> 
  req_url_query("filter[STATE - OWNER]" = "GA") |>
  req_perform() |> 
  providertwo:::resp_simple_json() |> 
  get_elem("^data$|headers", regex = TRUE)

rhc_own <- as_tbl(res2$data) |> 
  set_names(res2$meta) |> 
  providertwo:::map_na_if() |> 
  janitor::clean_names() |> 
  mtt(assoc_date = providertwo:::as_date(association_date_owner),
      address = providertwo:::make_address(
        address_line_1_owner, 
        address_line_2_owner),
      pct_own = as.numeric(percentage_ownership),
      role_code = as.integer(role_code_owner)) |>
  slt(
    enid = enrollment_id, 
    pac_own = associate_id_owner, 
    org_name = organization_name,
    org_name_own = organization_name_owner,
    entity_own = type_owner,
    role_code,
    role_text = role_text_owner,
    assoc_date,
    first_own = first_name_owner,
    middle_own = middle_name_owner,
    last_own = last_name_owner,
    title_own = title_owner,
    dba_own = doing_business_as_name_owner,
    addr_own = address,
    city_own = city_owner,
    state_own = state_owner,
    zip_own = zip_code_owner,
    pct_own,
    is_for_acq = created_for_acquisition_owner,
    is_corp = corporation_owner,
    is_llc = llc_owner,
    is_med_prov_supp = medical_provider_supplier_owner,
    is_mgmt_serv_co = management_services_company_owner,
    is_med_staff_co = medical_staffing_company_owner,
    is_holding_co = holding_company_owner,
    is_invest_firm = investment_firm_owner,
    is_fin_inst = financial_institution_owner,
    is_consult_firm = consulting_firm_owner,
    is_for_profit = for_profit_owner,
    is_non_profit = non_profit_owner,
    is_other_type = other_type_owner,
    other_type = other_type_text_owner
  ) |> 
  mtt(
    is_for_acq = charbin(is_for_acq),
    is_corp = charbin(is_corp),
    is_llc = charbin(is_llc),
    is_med_prov_supp = charbin(is_med_prov_supp),
    is_mgmt_serv_co = charbin(is_mgmt_serv_co),
    is_med_staff_co = charbin(is_med_staff_co),
    is_holding_co = charbin(is_holding_co),
    is_invest_firm = charbin(is_invest_firm),
    is_fin_inst = charbin(is_fin_inst),
    is_consult_firm = charbin(is_consult_firm),
    is_for_profit = charbin(is_for_profit),
    is_non_profit = charbin(is_non_profit),
    is_other_type = charbin(is_other_type)
  )

rhc_own
# A tibble: 85 × 32
   enid  pac_own org_name org_name_own entity_own role_code role_text assoc_date
                                       
 1 O200… 054717… TMC HAR… TMC/HIGGINS… O                 34 5% OR GR… 2003-02-01
 2 O200… 155727… HIAWASS… HIAWASSEE F… O                 43 OPERATIO… 2000-08-01
 3 O200… 599161… TMC WES… TMC WEST CA… O                 34 5% OR GR… 1999-11-01
 4 O200… 185029… BACON C… BACON COUNT… O                 34 5% OR GR… 2012-12-17
 5 O200… 185029… BACON C… BACON COUNT… O                 43 OPERATIO… 2002-11-20
 6 O200… 226441… BOWDON-… BOWDON- MT.… O                 36 5% OR GR… 2012-06-01
 7 O200… 226441… BOWDON-… BOWDON- MT.… O                 43 OPERATIO… 1980-10-09
 8 O200… 498150… HOSPITA… JOHN D. ARC… O                 43 OPERATIO… 2014-05-29
 9 O200… 498150… HOSPITA… JOHN D. ARC… O                 43 OPERATIO… 1990-07-02
10 O200… 418352… PHOEBE … PHOEBE PUTN… O                 34 5% OR GR… 2008-02-12
# ℹ 75 more rows
# ℹ 24 more variables: first_own , middle_own , last_own ,
#   title_own , dba_own , addr_own , city_own ,
#   state_own , zip_own , pct_own , is_for_acq ,
#   is_corp , is_llc , is_med_prov_supp , is_mgmt_serv_co ,
#   is_med_staff_co , is_holding_co , is_invest_firm ,
#   is_fin_inst , is_consult_firm , is_for_profit , …

Geocode

geo_census <- tidygeocoder::geocode(
  mtt(rhc_enr, 
      zip = substr(zip, 1, 5)),
  street = address,
  city = city,
  state = state,
  postalcode = zip,
  method = "census", 
  full_results = TRUE)
Passing 82 addresses to the US Census batch geocoder
Query completed in: 1 seconds
geo_census |> 
  slt(lat:matched_address) |> 
  sbt(cheapr::is_na(lat))
# A tibble: 15 × 7
     lat  long    id input_address    match_indicator match_type matched_address
                                             
 1    NA    NA     6 41 WELLINGTON M… No_Match        NA         NA             
 2    NA    NA    11 1 MAGNOLIA CT, … No_Match        NA         NA             
 3    NA    NA    13 216 HOSPITAL DR… No_Match        NA         NA             
 4    NA    NA    16 246 BENJAMIN H … No_Match        NA         NA             
 5    NA    NA    20 97 HEFNER ST ST… No_Match        NA         NA             
 6    NA    NA    24 115 GILLIKIN ST… No_Match        NA         NA             
 7    NA    NA    38 134 FLEETWOOD A… No_Match        NA         NA             
 8    NA    NA    39 11045 COLUMBIA … No_Match        NA         NA             
 9    NA    NA    42 12978 N MAIN ST… No_Match        NA         NA             
10    NA    NA    52 180 LEGACY PT S… No_Match        NA         NA             
11    NA    NA    55 218 FALLS RD, T… No_Match        NA         NA             
12    NA    NA    65 103 R E JENNING… No_Match        NA         NA             
13    NA    NA    66 8 LAUREL CT, MO… No_Match        NA         NA             
14    NA    NA    74 2908 BUSINESS 2… No_Match        NA         NA             
15    NA    NA    80 51 LINDSEY LN, … No_Match        NA         NA             
geo_census |> 
  sbt(match_type == "Non_Exact") |> 
  slt(input_address, matched_address) |> 
  print(n = Inf)
# A tibble: 21 × 2
   input_address                                           matched_address      
                                                                      
 1 1301 PETERSON AVE S STE B, DOUGLAS, GA, 31533           1301 S PETERSON AVE,…
 2 118 NORMAN DORMINY DR, FITZGERALD, GA, 31750            118 NORMAN DORMING D…
 3 1451 HIGHWAY 21 S STE H, SPRINGFIELD, GA, 31329         1451 STATE RTE 21, S…
 4 119 VICTORY DR SUITE A, SWAINSBORO, GA, 30401           119 VICTORY DR, SWAI…
 5 56 HOSPITAL ST, HIAWASSEE, GA, 30546                    56 HOSPITAL DR, HIAW…
 6 259 US HIGHWAY 19 N, CAMILLA, GA, 31730                 259 US HWY 19, CAMIL…
 7 611 N WASHINGTON ST STE A, LINCOLNTON, GA, 30817        611 WASHINGTON ST, L…
 8 406 EAST BROAD ST, WRENS, GA, 30833                     406 BROAD ST, WRENS,…
 9 64A JONES MILL RD, WOODBURY, GA, 30293                  64A JONES MILL RD, W…
10 139 E BROAD, NORMAN PARK, GA, 31771                     139 E BROAD ST, NORM…
11 1000 N VETERANS BLVD STE B, GLENNVILLE, GA, 30427       1000 S VETERANS BLVD…
12 380A CEDAR ST, METTER, GA, 30439                        380A CEDAR ST, METTE…
13 222 PERRY HWY BLDG A SUITE 104, HAWKINSVILLE, GA, 31036 222 PERRY HWY, HAWKI…
14 105 E TOLLISON ST STE D, BAXLEY, GA, 31513              105 TOLLISON ST, BAX…
15 105 E TOLLISON ST STE B, BAXLEY, GA, 31513              105 TOLLISON ST, BAX…
16 208N CUTHBERT ST, COLQUITT, GA, 39837                   208 N CUTHBERT ST, C…
17 416 E MCPHERSON AVE STE A, NASHVILLE, GA, 31639         416 E MCPHERSON AVE,…
18 25W LYON ST, TALLAPOOSA, GA, 30176                      25W LYON ST, TALLAPO…
19 1125E HIGHWAY 166, BOWDON, GA, 30108                    1125 E HWY 166, BOWD…
20 162 HOSPITAL RD STE A, BLAIRSVILLE, GA, 30512           162 HOSPITAL ST, BLA…
21 103 CHURCH ST STE A, HIAWASSEE, GA, 30546               103 CHURCH ST, HIAWA…
geo_census <- sbt(geo_census, !cheapr::is_na(lat))

Georgia Counties Shapefile

ga_county <- tigris::counties(state = "GA", year = 2024)
ga_county_simple <- rmapshaper::ms_simplify(ga_county)
ga_county_simple$mid <- sf::st_centroid(ga_county_simple$geometry)
ga_county_simple
Simple feature collection with 159 features and 18 fields
Active geometry column: geometry
Geometry type: GEOMETRY
Dimension:     XY
Bounding box:  xmin: -85.6 ymin: 30.4 xmax: -80.8 ymax: 35
Geodetic CRS:  NAD83
First 10 features:
   CBSAFP CSAFP COUNTYNS CLASSFP METDIVFP     NAME        GEOIDFQ
1   12260   00348794      H1      McDuffie 0500000US13189
2   15260   00351605      H1      Brantley 0500000US13025
3     00326713      H1         Lamar 0500000US13171
4   40660   122 00353665      H1         Floyd 0500000US13115
5   10500   00352238      H1       Terrell 0500000US13273
6   12060   122 01672399      H1    12054  Clayton 0500000US13063
7   12260   00348865      H1      Columbia 0500000US13073
8     00346957      H1         Macon 0500000US13193
9     00357747      H1      Charlton 0500000US13049
10  16340   122 00343585      H1          Polk 0500000US13233
          NAMELSAD GEOID COUNTYFP FUNCSTAT    INTPTLAT LSAD MTFCC STATEFP
1  McDuffie County 13189      189        A +33.4806102   06 G4020      13
2  Brantley County 13025      025        A +31.1973339   06 G4020      13
3     Lamar County 13171      171        A +33.0744405   06 G4020      13
4     Floyd County 13115      115        A +34.2636901   06 G4020      13
5   Terrell County 13273      273        A +31.7771909   06 G4020      13
6   Clayton County 13063      063        A +33.5522420   06 G4020      13
7  Columbia County 13073      073        A +33.5520746   06 G4020      13
8     Macon County 13193      193        A +32.3626859   06 G4020      13
9  Charlton County 13049      049        A +30.7799036   06 G4020      13
10     Polk County 13233      233        A +33.9960153   06 G4020      13
        ALAND   AWATER     INTPTLON                       geometry
1   666608438 23095606 -082.4795718 POLYGON ((-82.6 33.6, -82.6...
2  1147972265 10291548 -081.9829779 POLYGON ((-81.9 31, -81.9 3...
3   475264402  6044329 -084.1466893 POLYGON ((-84.2 33.2, -84.2...
4  1320461793 22356808 -085.2136849 POLYGON ((-85 34.1, -85 34....
5   869695790  4951325 -084.4394464 POLYGON ((-84.3 31.7, -84.3...
6   367009134  6914194 -084.4129728 POLYGON ((-84.3 33.6, -84.4...
7   751599702 45344735 -082.2496077 POLYGON ((-82.4 33.7, -82.4...
8  1037709939 13841916 -084.0512306 MULTIPOLYGON (((-83.8 32.3,...
9  2020415649  5963237 -082.1396442 POLYGON ((-82.1 31, -82.2 3...
10  803776466  4663881 -085.1883384 POLYGON ((-85.4 33.9, -85.3...
                  mid
1  POINT (-82.5 33.5)
2    POINT (-82 31.2)
3  POINT (-84.1 33.1)
4  POINT (-85.2 34.3)
5  POINT (-84.4 31.8)
6  POINT (-84.4 33.5)
7  POINT (-82.3 33.5)
8    POINT (-84 32.4)
9  POINT (-82.1 30.8)
10   POINT (-85.2 34)

Georgia RHCs Map

ggplot(ga_county_simple) +
  geom_sf(
    fill = "skyblue",
    colour = "white",
    alpha = 0.5) +
  geom_sf_text(
    aes(geometry = geometry, 
        label = NAME),
    size = 2.5,
    check_overlap = TRUE) +
  geom_jitter(
    data = geo_census,
    mapping = aes(long, lat),
    fill = "yellow",
    color = "darkred",
    alpha = 0.75,
    size = 3,
    shape = 21,
    stroke = 1) +
  theme_void()