Skip to contents

Open Payments

ex <- open_payments(year = 2021, npi = 1043218118, na.rm = TRUE)
ex
#> # A tibble: 109 × 47
#>    program_year npi      covered_recipient first last  address city  state zip  
#>           <int> <chr>    <fct>             <chr> <chr> <chr>   <chr> <ord> <chr>
#>  1         2021 1043218… Physician         Ahad  Maho… 6739 G… Zeph… FL    33542
#>  2         2021 1043218… Physician         AHAD  MAHO… 6739 G… ZEPH… FL    33542
#>  3         2021 1043218… Physician         AHAD  MAHO… 6739 G… ZEPH… FL    33542
#>  4         2021 1043218… Physician         AHAD  MAHO… 6739 G… ZEPH… FL    33542
#>  5         2021 1043218… Physician         AHAD  MAHO… 6739 G… ZEPH… FL    33542
#>  6         2021 1043218… Physician         AHAD  MAHO… 6739 G… ZEPH… FL    33542
#>  7         2021 1043218… Physician         AHAD  MAHO… 6739 G… ZEPH… FL    33542
#>  8         2021 1043218… Physician         AHAD  MAHO… 6739 G… ZEPH… FL    33542
#>  9         2021 1043218… Physician         AHAD  MAHO… 6739 G… ZEPH… FL    33542
#> 10         2021 1043218… Physician         AHAD  MAHO… 6739 G… ZEPH… FL    33542
#> # ℹ 99 more rows
#> # ℹ 38 more variables: country <chr>, primary <chr>, specialty <chr>,
#> #   license_state <ord>, physician_ownership <lgl>, third_party_payment <chr>,
#> #   charity <lgl>, publish_date <date>, publish_delay <lgl>,
#> #   publish_dispute <lgl>, related_product <lgl>, payer_id <chr>,
#> #   payer_sub <chr>, payer_name <chr>, payer_state <ord>, payer_country <chr>,
#> #   pay_form <chr>, pay_nature <chr>, pay_total <dbl>, pay_date <date>, …
payment <- ex |> 
  select(payer_name,
         pay_form,
         pay_nature,
         row_id,
         group_id,
         pay_total,
         pay_date, 
         name:category,
         ndc.atc_second)
payment
#> # A tibble: 109 × 12
#>    payer_name     pay_form pay_nature row_id group_id pay_total pay_date   name 
#>    <chr>          <chr>    <chr>       <int>    <int>     <dbl> <date>     <chr>
#>  1 Mobius Therap… Cash or… Compensat…      1        1    2500   2021-05-26 Mito…
#>  2 Johnson & Joh… In-kind… Food and …      2        1      69.9 2021-03-04 Tecn…
#>  3 Horizon Thera… In-kind… Food and …      3        1     108.  2021-08-24 TEPE…
#>  4 Horizon Thera… In-kind… Food and …      4        1      97.1 2021-08-24 TEPE…
#>  5 Horizon Thera… In-kind… Food and …      5        1      23.9 2021-09-30 TEPE…
#>  6 Horizon Thera… In-kind… Food and …      6        1      25.6 2021-11-10 TEPE…
#>  7 EyePoint Phar… In-kind… Food and …      7        1      13.8 2021-12-08 YUTIQ
#>  8 EyePoint Phar… In-kind… Food and …      8        1      16.6 2021-04-15 DEXY…
#>  9 Alcon Vision … In-kind… Food and …      9        1     114.  2021-05-06 Prec…
#> 10 Alcon Vision … In-kind… Food and …     10        1      14.7 2021-10-06 Acry…
#> # ℹ 99 more rows
#> # ℹ 4 more variables: covered <lgl>, type <chr>, category <chr>,
#> #   ndc.atc_second <chr>
payment |> 
  filter(!is.na(pay_total)) |> 
  summarise(payments = n(),
            total = sum(pay_total, na.rm = TRUE),
            avg_per_pmt = total / payments) |> 
  gt::gt_preview() |> 
  gt::fmt_currency(columns = c(total, avg_per_pmt)) |> 
  gt::opt_all_caps()
payments total avg_per_pmt
1 92 $22,678.50 $246.51
payment |> 
  filter(!is.na(pay_total)) |> 
  group_by(payer_name) |> 
  summarise(payments = n(),
            total = sum(pay_total, na.rm = TRUE),
            avg_per_pmt = total / payments) |> 
  arrange(desc(total)) |> 
  gt::gt_preview(30) |> 
  gt::fmt_currency(columns = c(total, avg_per_pmt)) |> 
  gt::opt_all_caps()
payer_name payments total avg_per_pmt
1 Allergan, Inc. 33 $12,454.59 $377.41
2 Bausch & Lomb, a division of Bausch Health US, LLC 2 $3,116.93 $1,558.46
3 Mobius Therapeutics, LLC 1 $2,500.00 $2,500.00
4 Ivantis, Inc 7 $1,804.85 $257.84
5 Iridex Corporation 3 $1,034.87 $344.96
6 Horizon Therapeutics plc 4 $254.57 $63.64
7 Sight Sciences, Inc. 5 $250.27 $50.05
8 SUN PHARMACEUTICAL INDUSTRIES INC. 5 $175.53 $35.11
9 Mallinckrodt Hospital Products Inc. 4 $156.91 $39.23
10 NEW WORLD MEDICAL,INC. 2 $156.86 $78.43
11 Kala Pharmaceuticals, Inc. 7 $138.46 $19.78
12 Alcon Vision LLC 2 $128.93 $64.47
13 Regeneron Healthcare Solutions, Inc. 1 $125.01 $125.01
14 Alimera Sciences, Inc. 5 $89.25 $17.85
15 Johnson & Johnson Surgical Vision, Inc. 1 $69.90 $69.90
16 Ocular Therapeutix, Inc. 2 $69.27 $34.63
17 Novartis Pharmaceuticals Corporation 3 $61.57 $20.52
18 EyePoint Pharmaceuticals US, Inc. 2 $30.49 $15.25
19 Beaver-Visitec International, Inc. 1 $25.02 $25.02
20 Dompe US, Inc. 1 $20.48 $20.48
21 Checkpoint Surgical, Inc 1 $14.74 $14.74
payment |> 
  select(group_id, 
         pay_total, 
         name, 
         type, 
         category) |> 
  group_by(type, category, name) |> 
  summarise(payments = n(),
            total = sum(pay_total, na.rm = TRUE),
            avg_per_pmt = total / payments) |> 
  arrange(desc(total)) |> 
  gt::gt_preview(40) |> 
  gt::fmt_currency(columns = c(total, avg_per_pmt)) |> 
  gt::opt_all_caps()
type category name payments total avg_per_pmt
1 Device GLAUCOMA XEN GLAUCOMA TREATMENT SYSTEM 24 $11,859.00 $494.12
2 Device Ophthalmology STELLARIS 1 $3,000.00 $3,000.00
3 Drug Ophthamology Mitosol 1 $2,500.00 $2,500.00
4 Device Ophthalmic Surgery Hydrus Microstent 7 $1,804.85 $257.84
5 NA NA Blank 4 $1,059.89 $264.97
6 Drug GLAUCOMA DURYSTA 8 $522.35 $65.29
7 Drug TEPEZZA TEPEZZA 4 $254.57 $63.64
8 Drug Ophthalmology Cequa 5 $175.53 $35.11
9 Biological IMMUNOLOGY ACTHAR 4 $156.91 $39.23
10 Device Ophthalmology Ahmed Glaucoma Valve 2 $156.86 $78.43
11 Device Ophthalmology OMNI(R) SURGICAL SYSTEM (US) 4 $153.97 $38.49
12 Drug Ocular INVELTYS 7 $138.46 $19.78
13 Biological OPHTHALMOLOGY EYLEA 1 $125.01 $125.01
14 Device Ophthalmology CRYSTALENS 1 $116.93 $116.93
15 Device Ophthalmology Precision 1 1 $114.20 $114.20
16 Device Ophthalmology TearCare SmartLid 1 $96.30 $96.30
17 Drug OPHTHALMOLOGY ILUVIEN 5 $89.25 $17.85
18 NA NA NA 1 $73.24 $73.24
19 Device Optics Tecnis IOL 1 $69.90 $69.90
20 Drug Corticosteroid intracanalicular insert DEXTENZA 2 $69.27 $34.63
21 Drug OPHTHALMOLOGY BEOVU 3 $61.57 $20.52
22 Drug SOLUTION/ DROPS OXERVATE 1 $20.48 $20.48
23 Drug Postoperative Inflammation DEXYCU 1 $16.64 $16.64
24 Device Surgery Checkpoint Stimulators 1 $14.74 $14.74
25 Device Ophthalmology AcrySof IQ VIVITY IOL 1 $14.73 $14.73
26 Drug Chronic Non-infectious Posterior Segment Uveitis YUTIQ 1 $13.85 $13.85
27 Device Ophthalmology Crystalens Accommodating IOL (AT-52AO) 1 $0.00 $0.00
28 Device Ophthalmology Kahook Dual Blade 2 $0.00 $0.00
29 Device Ophthalmology TEARCARE(TM) (2.2) SYSTEM KIT 1 $0.00 $0.00
30 Device Ophthalmology Trulign IOL 1 $0.00 $0.00
31 Drug Ocular EYSUVIS 7 $0.00 $0.00
32 Drug Ophthalmology BromSite 3 $0.00 $0.00
33 Drug Ophthalmology Xelpros 2 $0.00 $0.00
payment |> 
  filter(row_id == "72")
#> # A tibble: 3 × 12
#>   payer_name      pay_form pay_nature row_id group_id pay_total pay_date   name 
#>   <chr>           <chr>    <chr>       <int>    <int>     <dbl> <date>     <chr>
#> 1 Bausch & Lomb,… Cash or… Consultin…     72        1      3000 2021-01-04 STEL…
#> 2 Bausch & Lomb,… Cash or… Consultin…     72        2        NA 2021-01-04 Crys…
#> 3 Bausch & Lomb,… Cash or… Consultin…     72        3        NA 2021-01-04 Trul…
#> # ℹ 4 more variables: covered <lgl>, type <chr>, category <chr>,
#> #   ndc.atc_second <chr>

Fuzzy Joins

op <- ex |> 
  filter(type == "Drug") |> 
  select(year = program_year, 
         pay_total, 
         group_id,
         brand_name = ndc.brand_name,
         generic_name = ndc.drug_name) |> 
  mutate(brand_name = stringr::str_to_title(brand_name),
         generic_name = stringr::str_to_title(generic_name))
op
#> # A tibble: 50 × 5
#>     year pay_total group_id brand_name generic_name                             
#>    <int>     <dbl>    <int> <chr>      <chr>                                    
#>  1  2021   2500           1 Mitosol    Mitomycin 0.2 Mg/Ml Ophthalmic Solution …
#>  2  2021    108.          1 Tepezza    Teprotumumab-Trbw 500 Mg Injection [Tepe…
#>  3  2021     97.1         1 Tepezza    Teprotumumab-Trbw 500 Mg Injection [Tepe…
#>  4  2021     23.9         1 Tepezza    Teprotumumab-Trbw 500 Mg Injection [Tepe…
#>  5  2021     25.6         1 Tepezza    Teprotumumab-Trbw 500 Mg Injection [Tepe…
#>  6  2021     13.8         1 Yutiq      Fluocinolone Acetonide 0.18 Mg Drug Impl…
#>  7  2021     16.6         1 Dexycu     0.005 Ml Dexamethasone 103.4 Mg/Ml Injec…
#>  8  2021    325           1 Durysta    Bimatoprost 0.01 Mg Drug Implant [Duryst…
#>  9  2021     18.6         1 Durysta    Bimatoprost 0.01 Mg Drug Implant [Duryst…
#> 10  2021      4.05        1 Durysta    Bimatoprost 0.01 Mg Drug Implant [Duryst…
#> # ℹ 40 more rows
rx <- prescribers(year = 2021, 
                  type = 'Drug', 
                  npi = 1043218118) |> 
  select(year,
         brand_name, 
         generic_name, 
         tot_claims, 
         tot_fills, 
         tot_supply, 
         tot_cost, 
         tot_benes)
rx
#> # A tibble: 27 × 8
#>     year brand_name        generic_name tot_claims tot_fills tot_supply tot_cost
#>    <int> <chr>             <chr>             <int>     <dbl>      <int>    <dbl>
#>  1  2021 Acetazolamide Er  Acetazolami…         20      20.5        533     971.
#>  2  2021 Alphagan P        Brimonidine…         34      51         1424   12450.
#>  3  2021 Azithromycin      Azithromycin        661    1588.       45870    7181.
#>  4  2021 Brimonidine Tart… Brimonidine…        306     550.       15746    8700.
#>  5  2021 Bromsite          Bromfenac S…         78      80.5       2387   21943.
#>  6  2021 Carteolol Hcl     Carteolol H…         79     184.        5482    1578.
#>  7  2021 Cephalexin        Cephalexin           57      57          279     444.
#>  8  2021 Combigan          Brimonidine…         63      87.8       2444   17835.
#>  9  2021 Dorzolamide Hcl   Dorzolamide…         71     151.        4533    2189 
#> 10  2021 Dorzolamide-Timo… Dorzolamide…         99     216.        6463    3921.
#> # ℹ 17 more rows
#> # ℹ 1 more variable: tot_benes <int>

More Involved Example

# plan(multisession, workers = 4)
# open  <- open_payments_(npi = 1043218118)
# plan(sequential)
# open <- open |> janitor::remove_empty(which = c('rows', 'cols'))
# open |> 
#   select(program_year, 
#          payer_name, 
#          pay_form,
#          pay_nature,
#          pay_total, 
#          pay_date, 
#          pay_count, 
#          row_id, 
#          group_id, 
#          name, 
#          covered,
#          type, 
#          category, 
#          ndc,
#          pdi)
# open |> 
#   count(payer_name,
#         wt = pay_count,
#         sort = TRUE)
# open |> 
#   count(payer_id,
#         wt = pay_count,
#         sort = TRUE)
# open |> 
#   filter(!is.na(type)) |> 
#   count(type, sort = TRUE)