The Washington Post’s series The Opioid Files focused extensively on Oxycodone and Hydrocodone but the ARCOS database includes 12 other drugs that did not get as much attention.

This is an exploratory analysis that highlights possibilities from drilling into ARCOS data inspired by this story from The Boston Globe about Methadone Mile, an area near the South End of Boston with many recovery clinics but plagued by the effects of drug use.

First, let’s get a list of the types of drugs tracked in this ARCOS data.

# what drugs are there

drugs <- drug_list(key="WaPo")

drugs
#>          DRUG_NAME
#> 1         FENTANYL
#> 2         MORPHINE
#> 3       MEPERIDINE
#> 4      HYDROCODONE
#> 5        OXYCODONE
#> 6          CODEINE
#> 7    HYDROMORPHONE
#> 8        METHADONE
#> 9    BUPRENORPHINE
#> 10     OXYMORPHONE
#> 11 OPIUM, POWDERED
#> 12      TAPENTADOL
#> 13     LEVORPHANOL
#> 14  DIHYDROCODEINE

We have 14 options, but let’s focus on methadone, which is used to treat narcotic drug addiction.

And Boston is in Suffolk County in Massachusetts. Let’s pull that data.

# okay, we want METHADONE from Suffolk County

methadone <- drug_county_biz(drug = "METHADONE", county = "Suffolk", state = "MA", key = "WaPo")

# how big is this file

nrow(methadone)
#> [1] 37214

That’s a lot of orders.

Who’s been ordering methadone?

# What type of buyers

methadone %>% 
  select(BUYER_DEA_NO, BUYER_BUS_ACT) %>% 
  unique() %>% 
  count(BUYER_BUS_ACT)
#>        BUYER_BUS_ACT   n
#> 1     ANALYTICAL LAB   3
#> 2     CHAIN PHARMACY 119
#> 3   COMP/MAINT/DETOX   2
#> 4     DETOXIFICATION   1
#> 5     HOSP/CLINIC-VA   3
#> 6    HOSPITAL/CLINIC  43
#> 7      MAINT & DETOX   9
#> 8        MAINTENANCE   1
#> 9       PRACTITIONER   1
#> 10 RESEARCHER (II-V)   1
#> 11   RETAIL PHARMACY  47

There are many clinics and pharmacies in Boston.

Just curious, but which type of buyer orders the most methadone?

# Clean up and consolidate the categories

methadone <- methadone %>% 
  mutate(type=case_when(
    grepl("PHARMACY", BUYER_BUS_ACT) ~ "PHARMACY",
    grepl("DETOX", BUYER_BUS_ACT) ~ "DETOX/MAINTENANCE",
    grepl("MAINT", BUYER_BUS_ACT) ~ "DETOX/MAINTENANCE",
    grepl("-VA", BUYER_BUS_ACT) ~ "VA",
    grepl("CLINIC", BUYER_BUS_ACT) ~ "CLINIC",
    TRUE ~ BUYER_BUS_ACT
  ))

# totals
methadone_summary <- methadone %>% 
  # focus only on purchase orders, which is transaction code S
  filter(TRANSACTION_CODE=="S") %>% 
  group_by(type) %>% 
  # calculate amount
  mutate(amount=CALC_BASE_WT_IN_GM*MME_Conversion_Factor) %>% 
  summarize(total=sum(amount, na.rm=T)) %>% 
  arrange(desc(total))

# chart it  
ggplot(methadone_summary, aes(x=total, y=type)) +
  geom_col() +
  scale_x_continuous(label=comma) +
  theme_minimal() +
  labs(title="Methadone dosages ordered by buyer type")

So even though there are only 14 detox and maintenance clinics in Suffolk County, they out-order everyone else when it comes to Methadone.

Map

Alright, let’s map out where these orders are happening.

We need to bring in a couple new data sets from ARCOS.

Buyer details such as name and address of business using buyer_addresses() as well as the available latitude and longitude data for pharmacies using pharm_latlon().

# Let's calculate the amount of methadone purchased by every buyer in Suffolk County, MA
methadone_by_buyer <- methadone %>% 
  filter(TRANSACTION_CODE=="S") %>% 
  group_by(BUYER_DEA_NO, type) %>% 
  mutate(amount=CALC_BASE_WT_IN_GM*MME_Conversion_Factor) %>% 
  summarize(total=sum(amount, na.rm=T)) %>% 
  arrange(desc(total))

# Saving the BUYER_DEA_NO of each purchaser from our data set so far
buyer_ids <- methadone %>% 
  select(BUYER_DEA_NO) %>% 
  unique()

# Download the addresses of buyers in Suffolk County, MA
buyer_addresses <- buyer_addresses(county = "Suffolk", state = "MA", key = "WaPo")

glimpse(buyer_addresses)
#> Rows: 652
#> Columns: 10
#> $ BUYER_DEA_NO       <chr> "BB1832268", "AB2729789", "BG8631930", "BM3972747"…
#> $ BUYER_BUS_ACT      <chr> "HOSPITAL/CLINIC", "RETAIL PHARMACY", "RETAIL PHAR…
#> $ BUYER_NAME         <chr> "BOSTON UNIVERSITY GOLDMAN", "BROWN'S REXALL DRUG"…
#> $ BUYER_ADDL_CO_INFO <chr> "SCHOOL OF DENTAL MEDICINE", NA, NA, NA, NA, NA, N…
#> $ BUYER_ADDRESS1     <chr> "ORAL SURGERY CLINIC", "214 WINTHROP STREET", "186…
#> $ BUYER_ADDRESS2     <chr> "100 E NEWTON ST G407", NA, NA, NA, NA, NA, "151 V…
#> $ BUYER_CITY         <chr> "BOSTON", "WINTHROP", "WEST ROXBURY", "DORCHESTER"…
#> $ BUYER_STATE        <chr> "MA", "MA", "MA", "MA", "MA", "MA", "MA", "MA", "M…
#> $ BUYER_ZIP          <int> 2118, 2152, 2132, 2122, 2132, 2134, 2151, 2151, 21…
#> $ BUYER_COUNTY       <chr> "SUFFOLK", "SUFFOLK", "SUFFOLK", "SUFFOLK", "SUFFO…

# We only care about the addresses of buyers who purchased methadone
buyers <- left_join(buyer_ids, buyer_addresses)

# Let's bring over the methadone order amounts
buyers <- left_join(buyers, methadone_by_buyer)

# Download the lat and lon of pharmacies in Suffolk County, MA
buyer_latlon <- pharm_latlon(county = "Suffolk", state = "MA", key = "WaPo")

glimpse(buyer_latlon)
#> Rows: 181
#> Columns: 5
#> $ BUYER_DEA_NO <chr> "AB2729789", "AS6650027", "BC5456771", "FS4577586", "BT4…
#> $ BUYER_STATE  <chr> "MA", "MA", "MA", "MA", "MA", "MA", "MA", "MA", "MA", "M…
#> $ BUYER_COUNTY <chr> "SUFFOLK", "SUFFOLK", "SUFFOLK", "SUFFOLK", "SUFFOLK", "…
#> $ lat          <dbl> 42.3765, 42.3749, 42.3756, 42.4074, 42.4108, 42.3993, 42…
#> $ lon          <dbl> -70.9841, -70.9867, -70.9878, -70.9945, -70.9950, -70.99…

# Let's just focus on pharmacies and detox/maintenence facilities

buyers_pharm <- buyers %>% 
  filter(type=="PHARMACY")
buyers_detox <- buyers %>% 
  filter(type=="DETOX/MAINTENANCE")

# We can easily join buyer_latlon because pharmacies are geolocated
buyers_pharm <- left_join(buyers_pharm, buyer_latlon)

# But non-pharmacies are not geolocated.
# So I'm going to geolocate these detox/maintenance locations by hand
# Here's the result

detox <- tribble(
  ~BUYER_DEA_NO, ~lat,  ~lon,
  "PV0130562",  42.366429,  -71.058752,
  "PA0203024",  42.327501,  -71.083288,
  "RB0192574",  42.363672,  -71.05972,
  "RC0304395",  42.319285,  -71.052785,
  "RH0102549",  42.333502,  -71.066541,
  "RH0345783",  42.333502,  -71.066541,
  "RC0252558",  42.333435,  -71.073025,
  "RB0307480",  42.334507,  -71.0741,
  "RC0441751",  42.300033,  -71.101911,
  "RD0284581",  42.319239,  -71.096921,
  "RR0198336",  42.300033,  -71.101911,
  "RC0463327",  42.333138,  -71.070542
)
  

# okay, let's join the detox dataframe to this locations dataframe above
buyers_detox <- left_join(buyers_detox, detox)

# Now that buyers_pharm and buyers_detox both have lat and lon data, we can join them
buyers <- rbind(buyers_pharm, buyers_detox) 

buyers <- buyers %>% 
  filter(!is.na(lon))

# Just ordering the data frame for mapping purposes
buyers <- buyers %>% 
  arrange(desc(total))

# Setting up some color options
cof <- colorFactor(c("#ffa500", "#13ED3F"), domain=c("PHARMACY", "DETOX/MAINTENANCE"))

# mapping with leaflet
m <- leaflet(buyers) %>% 
  addProviderTiles(providers$CartoDB.DarkMatter) %>% 
  setView(-71.091112, 42.338827, zoom = 12) %>% 
  addCircleMarkers(~lon, ~lat, 
                   popup=paste0(buyers$BUYER_NAME, "<br />",
                                buyers$total, " total methadone"),
                   weight = 3,
                   radius=sqrt(buyers$total)/30, 
                   color=~cof(type),
                   stroke = FALSE, 
                   fillOpacity = 0.3)%>% 
  addLegend("bottomright", 
            colors= c("#ffa500", "#13ED3F"), 
            labels=c("Detox", "Pharmacy"), 
            title="Buyer type") 
m

Zoom into central Boston and you can see the cluster of 4-5 orange circles representing the methadone clinics.

That’s Methadone Mile.