diff --git a/articles/openFDA.html b/articles/openFDA.html index 55ef364..a1bbf4d 100644 --- a/articles/openFDA.html +++ b/articles/openFDA.html @@ -304,19 +304,19 @@

Write your own search term purrr::pluck(x, "openfda", "brand_name", 1) }) #> [[1]] -#> [1] "GOOD SENSE DUAL ACTION BACK PAIN" +#> [1] "FOSTER AND THRIVE NICOTINE" #> #> [[2]] -#> [1] "ALL DAY ALLERGY" +#> [1] "COUNTERACT ALLERGY" #> #> [[3]] -#> [1] "NICOTINE MINI" +#> [1] "IBUPROFEN 200 MG AND DIPHENHYDRAMINE CITRATE 38 MG" #> #> [[4]] -#> [1] "NAPROXEN SODIUM 220MG" +#> [1] "PURELAX" #> #> [[5]] -#> [1] "AMAZON BASIC CARE ACETAMINOPHEN" +#> [1] "OMEPRAZOLE"

Let openFDA() construct the search term diff --git a/articles/using_openFDA.html b/articles/using_openFDA.html index 48e56c6..b4a0e9c 100644 --- a/articles/using_openFDA.html +++ b/articles/using_openFDA.html @@ -142,136 +142,19 @@

Get brand names and EPC # The JSON object contains information including the generic and brand names bnf_search_json$results[[1]][4][[1]][1:3] -#> [[1]] -#> [[1]]$product_number -#> [1] "002" +#> $application_number +#> $application_number[[1]] +#> [1] "ANDA207807" #> -#> [[1]]$reference_drug -#> [1] "No" #> -#> [[1]]$brand_name -#> [1] "LISINOPRIL AND HYDROCHLOROTHIAZIDE" +#> $brand_name +#> $brand_name[[1]] +#> [1] "AMLODIPINE AND OLMESARTAN MEDOXOMIL" #> -#> [[1]]$active_ingredients -#> [[1]]$active_ingredients[[1]] -#> [[1]]$active_ingredients[[1]]$name -#> [1] "HYDROCHLOROTHIAZIDE" #> -#> [[1]]$active_ingredients[[1]]$strength -#> [1] "12.5MG" -#> -#> -#> [[1]]$active_ingredients[[2]] -#> [[1]]$active_ingredients[[2]]$name -#> [1] "LISINOPRIL" -#> -#> [[1]]$active_ingredients[[2]]$strength -#> [1] "20MG" -#> -#> -#> -#> [[1]]$reference_standard -#> [1] "No" -#> -#> [[1]]$dosage_form -#> [1] "TABLET" -#> -#> [[1]]$route -#> [1] "ORAL" -#> -#> [[1]]$marketing_status -#> [1] "Prescription" -#> -#> [[1]]$te_code -#> [1] "AB" -#> -#> -#> [[2]] -#> [[2]]$product_number -#> [1] "003" -#> -#> [[2]]$reference_drug -#> [1] "No" -#> -#> [[2]]$brand_name -#> [1] "LISINOPRIL AND HYDROCHLOROTHIAZIDE" -#> -#> [[2]]$active_ingredients -#> [[2]]$active_ingredients[[1]] -#> [[2]]$active_ingredients[[1]]$name -#> [1] "HYDROCHLOROTHIAZIDE" -#> -#> [[2]]$active_ingredients[[1]]$strength -#> [1] "25MG" -#> -#> -#> [[2]]$active_ingredients[[2]] -#> [[2]]$active_ingredients[[2]]$name -#> [1] "LISINOPRIL" -#> -#> [[2]]$active_ingredients[[2]]$strength -#> [1] "20MG" -#> -#> -#> -#> [[2]]$reference_standard -#> [1] "No" -#> -#> [[2]]$dosage_form -#> [1] "TABLET" -#> -#> [[2]]$route -#> [1] "ORAL" -#> -#> [[2]]$marketing_status -#> [1] "Prescription" -#> -#> [[2]]$te_code -#> [1] "AB" -#> -#> -#> [[3]] -#> [[3]]$product_number -#> [1] "001" -#> -#> [[3]]$reference_drug -#> [1] "No" -#> -#> [[3]]$brand_name -#> [1] "LISINOPRIL AND HYDROCHLOROTHIAZIDE" -#> -#> [[3]]$active_ingredients -#> [[3]]$active_ingredients[[1]] -#> [[3]]$active_ingredients[[1]]$name -#> [1] "HYDROCHLOROTHIAZIDE" -#> -#> [[3]]$active_ingredients[[1]]$strength -#> [1] "12.5MG" -#> -#> -#> [[3]]$active_ingredients[[2]] -#> [[3]]$active_ingredients[[2]]$name -#> [1] "LISINOPRIL" -#> -#> [[3]]$active_ingredients[[2]]$strength -#> [1] "10MG" -#> -#> -#> -#> [[3]]$reference_standard -#> [1] "No" -#> -#> [[3]]$dosage_form -#> [1] "TABLET" -#> -#> [[3]]$route -#> [1] "ORAL" -#> -#> [[3]]$marketing_status -#> [1] "Prescription" -#> -#> [[3]]$te_code -#> [1] "AB"

+#> $generic_name +#> $generic_name[[1]] +#> [1] "AMLODIPINE AND OLMESARTAN MEDOXOMIL"

Extracting openFDA fields programmatically

@@ -307,9 +190,9 @@

Brand namesopenFDA_brand_names <- extract_openFDA_field(bnf_search_json, "brand_name") print(openFDA_brand_names[25:30]) -#> [1] "RYBELSUS" "BENICAR HCT" -#> [3] "TELMISARTAN AND HYDROCHLOROTHIAZIDE" "OLMESARTAN MEDOXOMIL" -#> [5] "FELODIPINE" "TELMISARTAN"

+#> [1] "AMLODIPINE AND VALSARTAN" "VALSARTAN" +#> [3] "AVAPRO" "BYETTA" +#> [5] "GLUCOTROL XL" "GLIPIZIDE XL"

Established pharmacological classes @@ -323,7 +206,7 @@

Established pharmacological classes lengths(list(brand_names = openFDA_brand_names, EPCs = openfda_EPCs)) #> brand_names EPCs -#> 171 18

+#> 175 21 @@ -337,24 +220,27 @@

Query openFDA with EPCsopenfda_EPCs <- stringr::str_remove(openfda_EPCs, pattern = " \\[.*\\]")
 openfda_EPCs
-#>  [1] "GLP-1 Receptor Agonist"                        
-#>  [2] "Angiotensin 2 Receptor Blocker"                
-#>  [3] "Thiazide Diuretic"                             
-#>  [4] "Potassium-sparing Diuretic"                    
-#>  [5] "Dietary Cholesterol Absorption Inhibitor"      
-#>  [6] "Insulin Analog"                                
-#>  [7] "Dihydropyridine Calcium Channel Blocker"       
-#>  [8] "Angiotensin Converting Enzyme Inhibitor"       
-#>  [9] "Sulfonylurea"                                  
-#> [10] "Loop Diuretic"                                 
+#>  [1] "Thiazide Diuretic"                             
+#>  [2] "Dihydropyridine Calcium Channel Blocker"       
+#>  [3] "Angiotensin 2 Receptor Blocker"                
+#>  [4] "Angiotensin Converting Enzyme Inhibitor"       
+#>  [5] "Peroxisome Proliferator Receptor alpha Agonist"
+#>  [6] "Peroxisome Proliferator Receptor gamma Agonist"
+#>  [7] "Thiazolidinedione"                             
+#>  [8] "Thiazide-like Diuretic"                        
+#>  [9] "Potassium-sparing Diuretic"                    
+#> [10] "Sulfonylurea"                                  
 #> [11] "HMG-CoA Reductase Inhibitor"                   
-#> [12] "Dipeptidyl Peptidase 4 Inhibitor"              
-#> [13] "Thiazide-like Diuretic"                        
-#> [14] "Aldosterone Antagonist"                        
-#> [15] "Sodium-Glucose Cotransporter 2 Inhibitor"      
-#> [16] "PCSK9 Inhibitor"                               
-#> [17] "Adenosine Triphosphate-Citrate Lyase Inhibitor"
-#> [18] "Calcium Channel Blocker"
+#> [12] "GLP-1 Receptor Agonist" +#> [13] "Dipeptidyl Peptidase 4 Inhibitor" +#> [14] "Calcium Channel Blocker" +#> [15] "Aldosterone Antagonist" +#> [16] "Sodium-Glucose Cotransporter 2 Inhibitor" +#> [17] "Dietary Cholesterol Absorption Inhibitor" +#> [18] "Insulin Analog" +#> [19] "Loop Diuretic" +#> [20] "PCSK9 Inhibitor" +#> [21] "Adenosine Triphosphate-Citrate Lyase Inhibitor"

Query openFDA with our EPCs

@@ -390,25 +276,27 @@

Compare new generic names to BNF epc_generics |> tolower() |> grep(pattern = bnf_regex, value = TRUE, invert = TRUE) -#> [1] "tirzepatide" "sparsentan" -#> [3] "chlorothiazide" "triamterene capsules" -#> [5] "triamterene" "insulin lispro-aabc" -#> [7] "insulin detemir" "insulin lispro" -#> [9] "insulin aspart injection" "insulin aspart" -#> [11] "insulin glulisine" "insulin glargine-yfgn" -#> [13] "insulin degludec" "insulin glargine-aglr" -#> [15] "water injection" "insulin glargine" -#> [17] "nisoldipine" "isradipine" -#> [19] "clevidipine" "clevipidine" -#> [21] "glyburide" "furosemide" -#> [23] "ethacrynic acid" "torsemide" -#> [25] "furosemide injection 80 mg/ 10 ml" "lovastatin" -#> [27] "pitavastatin magnesium" "pitavastatin" -#> [29] "atenolol and chlorthalidone" "chlorthalidone" -#> [31] "metolazone" "atenolol and chlorthalidone tablet" -#> [33] "spironolactone" "eplerenone" -#> [35] "carospir" "bexagliflozin" -#> [37] "sotagliflozin" "bempedoic acid"

+#> [1] "chlorothiazide" "nisoldipine" +#> [3] "clevidipine" "clevipidine" +#> [5] "isradipine" "sparsentan" +#> [7] "fenofibrate" "gemfibrozil" +#> [9] "fenofibric acid" "chlorthalidone" +#> [11] "atenolol and chlorthalidone" "metolazone" +#> [13] "atenolol and chlorthalidone tablet" "triamterene" +#> [15] "triamterene capsules" "glyburide" +#> [17] "lovastatin" "pitavastatin magnesium" +#> [19] "pitavastatin" "tirzepatide" +#> [21] "eplerenone" "spironolactone" +#> [23] "carospir" "sotagliflozin" +#> [25] "bexagliflozin" "insulin aspart" +#> [27] "insulin lispro-aabc" "insulin detemir" +#> [29] "insulin lispro" "insulin aspart injection" +#> [31] "insulin glulisine" "insulin glargine-yfgn" +#> [33] "insulin degludec" "insulin glargine-aglr" +#> [35] "water injection" "insulin glargine" +#> [37] "furosemide injection 80 mg/ 10 ml" "furosemide" +#> [39] "torsemide" "ethacrynic acid" +#> [41] "bempedoic acid"

Of these drugs, the following are of interest:

 fda_generics <- c("pitavastatin", "lovastatin",
@@ -443,14 +331,14 @@ 

Compare new generic names to BNF more_brand_names[1:3] #> $pitavastatin -#> [1] "pitavastatin" "livalo" "zypitamag" -#> [4] "nikita" "pitavastatin calcium" +#> [1] "pitavastatin" "pitavastatin calcium" "livalo" +#> [4] "zypitamag" "nikita" #> #> $lovastatin #> [1] "lovastatin" "altoprev" #> #> $chlorothiazide -#> [1] "chlorothiazide sodium" "chlorothiazide" "diuril"

+#> [1] "diuril" "chlorothiazide sodium" "chlorothiazide" diff --git a/authors.html b/authors.html index 38e241b..e2a5184 100644 --- a/authors.html +++ b/authors.html @@ -46,7 +46,7 @@

Authors and Citation

Authors

diff --git a/index.html b/index.html index 1138712..72f166b 100644 --- a/index.html +++ b/index.html @@ -14,8 +14,8 @@ - - + + Skip to contents @@ -155,7 +155,7 @@

Citation

Developers

diff --git a/pkgdown.yml b/pkgdown.yml index fff0307..9e972ab 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -4,7 +4,7 @@ pkgdown_sha: ~ articles: openFDA: openFDA.html articles/using_openFDA: using_openFDA.html -last_built: 2024-10-16T23:51Z +last_built: 2024-10-17T09:51Z urls: reference: https://simpar1471.github.io/openFDA/reference article: https://simpar1471.github.io/openFDA/articles diff --git a/reference/openFDA.html b/reference/openFDA.html index 160097e..4590f91 100644 --- a/reference/openFDA.html +++ b/reference/openFDA.html @@ -158,6 +158,13 @@

ArgumentsValue

An httr2 response object from httr2::req_perform(). You can use httr2::resp_body_json() to extract JSON data from the response.

+ +
+

References

+

Kass-Hout TA, Xu Z, Mohebbi M, Nelsen H, Baker A, LEvine J, Johansen E, +Bright RA. OpenFDA: an innovative platform providing access to a wealth of +FDA's publicly available data J Am Med Inform Assoc 2016, +23(3):596-600. doi:10.1093/jamia/ocv153

See also

@@ -185,7 +192,7 @@

Examples#> https://api.fda.gov/drug/drugsfda.json?api_key=[API_KEY]&search=openfda.manufacturer_name:gilead%2A&limit=2&skip=10 #> Status: 200 OK #> Content-Type: application/json -#> Body: In memory (39419 bytes) +#> Body: In memory (29747 bytes) # Bad inputs will cause informative errors - here, a bad API key is supplied try( diff --git a/search.json b/search.json index 5dbcfa6..b4e3ab2 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"GNU General Public License","title":"GNU General Public License","text":"Version 3, 29 June 2007Copyright © 2007 Free Software Foundation, Inc.  Everyone permitted copy distribute verbatim copies license document, changing allowed.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"preamble","dir":"","previous_headings":"","what":"Preamble","title":"GNU General Public License","text":"GNU General Public License free, copyleft license software kinds works. licenses software practical works designed take away freedom share change works. contrast, GNU General Public License intended guarantee freedom share change versions program–make sure remains free software users. , Free Software Foundation, use GNU General Public License software; applies also work released way authors. can apply programs, . speak free software, referring freedom, price. General Public Licenses designed make sure freedom distribute copies free software (charge wish), receive source code can get want , can change software use pieces new free programs, know can things. protect rights, need prevent others denying rights asking surrender rights. Therefore, certain responsibilities distribute copies software, modify : responsibilities respect freedom others. example, distribute copies program, whether gratis fee, must pass recipients freedoms received. must make sure , , receive can get source code. must show terms know rights. Developers use GNU GPL protect rights two steps: (1) assert copyright software, (2) offer License giving legal permission copy, distribute /modify . developers’ authors’ protection, GPL clearly explains warranty free software. users’ authors’ sake, GPL requires modified versions marked changed, problems attributed erroneously authors previous versions. devices designed deny users access install run modified versions software inside , although manufacturer can . fundamentally incompatible aim protecting users’ freedom change software. systematic pattern abuse occurs area products individuals use, precisely unacceptable. Therefore, designed version GPL prohibit practice products. problems arise substantially domains, stand ready extend provision domains future versions GPL, needed protect freedom users. Finally, every program threatened constantly software patents. States allow patents restrict development use software general-purpose computers, , wish avoid special danger patents applied free program make effectively proprietary. prevent , GPL assures patents used render program non-free. precise terms conditions copying, distribution modification follow.","code":""},{"path":[]},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_0-definitions","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"0. Definitions","title":"GNU General Public License","text":"“License” refers version 3 GNU General Public License. “Copyright” also means copyright-like laws apply kinds works, semiconductor masks. “Program” refers copyrightable work licensed License. licensee addressed “”. “Licensees” “recipients” may individuals organizations. “modify” work means copy adapt part work fashion requiring copyright permission, making exact copy. resulting work called “modified version” earlier work work “based ” earlier work. “covered work” means either unmodified Program work based Program. “propagate” work means anything , without permission, make directly secondarily liable infringement applicable copyright law, except executing computer modifying private copy. Propagation includes copying, distribution (without modification), making available public, countries activities well. “convey” work means kind propagation enables parties make receive copies. Mere interaction user computer network, transfer copy, conveying. interactive user interface displays “Appropriate Legal Notices” extent includes convenient prominently visible feature (1) displays appropriate copyright notice, (2) tells user warranty work (except extent warranties provided), licensees may convey work License, view copy License. interface presents list user commands options, menu, prominent item list meets criterion.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_1-source-code","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"1. Source Code","title":"GNU General Public License","text":"“source code” work means preferred form work making modifications . “Object code” means non-source form work. “Standard Interface” means interface either official standard defined recognized standards body, , case interfaces specified particular programming language, one widely used among developers working language. “System Libraries” executable work include anything, work whole, () included normal form packaging Major Component, part Major Component, (b) serves enable use work Major Component, implement Standard Interface implementation available public source code form. “Major Component”, context, means major essential component (kernel, window system, ) specific operating system () executable work runs, compiler used produce work, object code interpreter used run . “Corresponding Source” work object code form means source code needed generate, install, (executable work) run object code modify work, including scripts control activities. However, include work’s System Libraries, general-purpose tools generally available free programs used unmodified performing activities part work. example, Corresponding Source includes interface definition files associated source files work, source code shared libraries dynamically linked subprograms work specifically designed require, intimate data communication control flow subprograms parts work. Corresponding Source need include anything users can regenerate automatically parts Corresponding Source. Corresponding Source work source code form work.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_2-basic-permissions","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"2. Basic Permissions","title":"GNU General Public License","text":"rights granted License granted term copyright Program, irrevocable provided stated conditions met. License explicitly affirms unlimited permission run unmodified Program. output running covered work covered License output, given content, constitutes covered work. License acknowledges rights fair use equivalent, provided copyright law. may make, run propagate covered works convey, without conditions long license otherwise remains force. may convey covered works others sole purpose make modifications exclusively , provide facilities running works, provided comply terms License conveying material control copyright. thus making running covered works must exclusively behalf, direction control, terms prohibit making copies copyrighted material outside relationship . Conveying circumstances permitted solely conditions stated . Sublicensing allowed; section 10 makes unnecessary.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_3-protecting-users-legal-rights-from-anti-circumvention-law","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"3. Protecting Users’ Legal Rights From Anti-Circumvention Law","title":"GNU General Public License","text":"covered work shall deemed part effective technological measure applicable law fulfilling obligations article 11 WIPO copyright treaty adopted 20 December 1996, similar laws prohibiting restricting circumvention measures. convey covered work, waive legal power forbid circumvention technological measures extent circumvention effected exercising rights License respect covered work, disclaim intention limit operation modification work means enforcing, work’s users, third parties’ legal rights forbid circumvention technological measures.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_4-conveying-verbatim-copies","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"4. Conveying Verbatim Copies","title":"GNU General Public License","text":"may convey verbatim copies Program’s source code receive , medium, provided conspicuously appropriately publish copy appropriate copyright notice; keep intact notices stating License non-permissive terms added accord section 7 apply code; keep intact notices absence warranty; give recipients copy License along Program. may charge price price copy convey, may offer support warranty protection fee.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_5-conveying-modified-source-versions","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"5. Conveying Modified Source Versions","title":"GNU General Public License","text":"may convey work based Program, modifications produce Program, form source code terms section 4, provided also meet conditions: ) work must carry prominent notices stating modified , giving relevant date. b) work must carry prominent notices stating released License conditions added section 7. requirement modifies requirement section 4 “keep intact notices”. c) must license entire work, whole, License anyone comes possession copy. License therefore apply, along applicable section 7 additional terms, whole work, parts, regardless packaged. License gives permission license work way, invalidate permission separately received . d) work interactive user interfaces, must display Appropriate Legal Notices; however, Program interactive interfaces display Appropriate Legal Notices, work need make . compilation covered work separate independent works, nature extensions covered work, combined form larger program, volume storage distribution medium, called “aggregate” compilation resulting copyright used limit access legal rights compilation’s users beyond individual works permit. Inclusion covered work aggregate cause License apply parts aggregate.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_6-conveying-non-source-forms","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"6. Conveying Non-Source Forms","title":"GNU General Public License","text":"may convey covered work object code form terms sections 4 5, provided also convey machine-readable Corresponding Source terms License, one ways: ) Convey object code , embodied , physical product (including physical distribution medium), accompanied Corresponding Source fixed durable physical medium customarily used software interchange. b) Convey object code , embodied , physical product (including physical distribution medium), accompanied written offer, valid least three years valid long offer spare parts customer support product model, give anyone possesses object code either (1) copy Corresponding Source software product covered License, durable physical medium customarily used software interchange, price reasonable cost physically performing conveying source, (2) access copy Corresponding Source network server charge. c) Convey individual copies object code copy written offer provide Corresponding Source. alternative allowed occasionally noncommercially, received object code offer, accord subsection 6b. d) Convey object code offering access designated place (gratis charge), offer equivalent access Corresponding Source way place charge. need require recipients copy Corresponding Source along object code. place copy object code network server, Corresponding Source may different server (operated third party) supports equivalent copying facilities, provided maintain clear directions next object code saying find Corresponding Source. Regardless server hosts Corresponding Source, remain obligated ensure available long needed satisfy requirements. e) Convey object code using peer--peer transmission, provided inform peers object code Corresponding Source work offered general public charge subsection 6d. separable portion object code, whose source code excluded Corresponding Source System Library, need included conveying object code work. “User Product” either (1) “consumer product”, means tangible personal property normally used personal, family, household purposes, (2) anything designed sold incorporation dwelling. determining whether product consumer product, doubtful cases shall resolved favor coverage. particular product received particular user, “normally used” refers typical common use class product, regardless status particular user way particular user actually uses, expects expected use, product. product consumer product regardless whether product substantial commercial, industrial non-consumer uses, unless uses represent significant mode use product. “Installation Information” User Product means methods, procedures, authorization keys, information required install execute modified versions covered work User Product modified version Corresponding Source. information must suffice ensure continued functioning modified object code case prevented interfered solely modification made. convey object code work section , , specifically use , User Product, conveying occurs part transaction right possession use User Product transferred recipient perpetuity fixed term (regardless transaction characterized), Corresponding Source conveyed section must accompanied Installation Information. requirement apply neither third party retains ability install modified object code User Product (example, work installed ROM). requirement provide Installation Information include requirement continue provide support service, warranty, updates work modified installed recipient, User Product modified installed. Access network may denied modification materially adversely affects operation network violates rules protocols communication across network. Corresponding Source conveyed, Installation Information provided, accord section must format publicly documented (implementation available public source code form), must require special password key unpacking, reading copying.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_7-additional-terms","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"7. Additional Terms","title":"GNU General Public License","text":"“Additional permissions” terms supplement terms License making exceptions one conditions. Additional permissions applicable entire Program shall treated though included License, extent valid applicable law. additional permissions apply part Program, part may used separately permissions, entire Program remains governed License without regard additional permissions. convey copy covered work, may option remove additional permissions copy, part . (Additional permissions may written require removal certain cases modify work.) may place additional permissions material, added covered work, can give appropriate copyright permission. Notwithstanding provision License, material add covered work, may (authorized copyright holders material) supplement terms License terms: ) Disclaiming warranty limiting liability differently terms sections 15 16 License; b) Requiring preservation specified reasonable legal notices author attributions material Appropriate Legal Notices displayed works containing ; c) Prohibiting misrepresentation origin material, requiring modified versions material marked reasonable ways different original version; d) Limiting use publicity purposes names licensors authors material; e) Declining grant rights trademark law use trade names, trademarks, service marks; f) Requiring indemnification licensors authors material anyone conveys material (modified versions ) contractual assumptions liability recipient, liability contractual assumptions directly impose licensors authors. non-permissive additional terms considered “restrictions” within meaning section 10. Program received , part , contains notice stating governed License along term restriction, may remove term. license document contains restriction permits relicensing conveying License, may add covered work material governed terms license document, provided restriction survive relicensing conveying. add terms covered work accord section, must place, relevant source files, statement additional terms apply files, notice indicating find applicable terms. Additional terms, permissive non-permissive, may stated form separately written license, stated exceptions; requirements apply either way.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_8-termination","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"8. Termination","title":"GNU General Public License","text":"may propagate modify covered work except expressly provided License. attempt otherwise propagate modify void, automatically terminate rights License (including patent licenses granted third paragraph section 11). However, cease violation License, license particular copyright holder reinstated () provisionally, unless copyright holder explicitly finally terminates license, (b) permanently, copyright holder fails notify violation reasonable means prior 60 days cessation. Moreover, license particular copyright holder reinstated permanently copyright holder notifies violation reasonable means, first time received notice violation License (work) copyright holder, cure violation prior 30 days receipt notice. Termination rights section terminate licenses parties received copies rights License. rights terminated permanently reinstated, qualify receive new licenses material section 10.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_9-acceptance-not-required-for-having-copies","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"9. Acceptance Not Required for Having Copies","title":"GNU General Public License","text":"required accept License order receive run copy Program. Ancillary propagation covered work occurring solely consequence using peer--peer transmission receive copy likewise require acceptance. However, nothing License grants permission propagate modify covered work. actions infringe copyright accept License. Therefore, modifying propagating covered work, indicate acceptance License .","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_10-automatic-licensing-of-downstream-recipients","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"10. Automatic Licensing of Downstream Recipients","title":"GNU General Public License","text":"time convey covered work, recipient automatically receives license original licensors, run, modify propagate work, subject License. responsible enforcing compliance third parties License. “entity transaction” transaction transferring control organization, substantially assets one, subdividing organization, merging organizations. propagation covered work results entity transaction, party transaction receives copy work also receives whatever licenses work party’s predecessor interest give previous paragraph, plus right possession Corresponding Source work predecessor interest, predecessor can get reasonable efforts. may impose restrictions exercise rights granted affirmed License. example, may impose license fee, royalty, charge exercise rights granted License, may initiate litigation (including cross-claim counterclaim lawsuit) alleging patent claim infringed making, using, selling, offering sale, importing Program portion .","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_11-patents","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"11. Patents","title":"GNU General Public License","text":"“contributor” copyright holder authorizes use License Program work Program based. work thus licensed called contributor’s “contributor version”. contributor’s “essential patent claims” patent claims owned controlled contributor, whether already acquired hereafter acquired, infringed manner, permitted License, making, using, selling contributor version, include claims infringed consequence modification contributor version. purposes definition, “control” includes right grant patent sublicenses manner consistent requirements License. contributor grants non-exclusive, worldwide, royalty-free patent license contributor’s essential patent claims, make, use, sell, offer sale, import otherwise run, modify propagate contents contributor version. following three paragraphs, “patent license” express agreement commitment, however denominated, enforce patent (express permission practice patent covenant sue patent infringement). “grant” patent license party means make agreement commitment enforce patent party. convey covered work, knowingly relying patent license, Corresponding Source work available anyone copy, free charge terms License, publicly available network server readily accessible means, must either (1) cause Corresponding Source available, (2) arrange deprive benefit patent license particular work, (3) arrange, manner consistent requirements License, extend patent license downstream recipients. “Knowingly relying” means actual knowledge , patent license, conveying covered work country, recipient’s use covered work country, infringe one identifiable patents country reason believe valid. , pursuant connection single transaction arrangement, convey, propagate procuring conveyance , covered work, grant patent license parties receiving covered work authorizing use, propagate, modify convey specific copy covered work, patent license grant automatically extended recipients covered work works based . patent license “discriminatory” include within scope coverage, prohibits exercise , conditioned non-exercise one rights specifically granted License. may convey covered work party arrangement third party business distributing software, make payment third party based extent activity conveying work, third party grants, parties receive covered work , discriminatory patent license () connection copies covered work conveyed (copies made copies), (b) primarily connection specific products compilations contain covered work, unless entered arrangement, patent license granted, prior 28 March 2007. Nothing License shall construed excluding limiting implied license defenses infringement may otherwise available applicable patent law.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_12-no-surrender-of-others-freedom","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"12. No Surrender of Others’ Freedom","title":"GNU General Public License","text":"conditions imposed (whether court order, agreement otherwise) contradict conditions License, excuse conditions License. convey covered work satisfy simultaneously obligations License pertinent obligations, consequence may convey . example, agree terms obligate collect royalty conveying convey Program, way satisfy terms License refrain entirely conveying Program.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_13-use-with-the-gnu-affero-general-public-license","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"13. Use with the GNU Affero General Public License","title":"GNU General Public License","text":"Notwithstanding provision License, permission link combine covered work work licensed version 3 GNU Affero General Public License single combined work, convey resulting work. terms License continue apply part covered work, special requirements GNU Affero General Public License, section 13, concerning interaction network apply combination .","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_14-revised-versions-of-this-license","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"14. Revised Versions of this License","title":"GNU General Public License","text":"Free Software Foundation may publish revised /new versions GNU General Public License time time. new versions similar spirit present version, may differ detail address new problems concerns. version given distinguishing version number. Program specifies certain numbered version GNU General Public License “later version” applies , option following terms conditions either numbered version later version published Free Software Foundation. Program specify version number GNU General Public License, may choose version ever published Free Software Foundation. Program specifies proxy can decide future versions GNU General Public License can used, proxy’s public statement acceptance version permanently authorizes choose version Program. Later license versions may give additional different permissions. However, additional obligations imposed author copyright holder result choosing follow later version.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_15-disclaimer-of-warranty","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"15. Disclaimer of Warranty","title":"GNU General Public License","text":"WARRANTY PROGRAM, EXTENT PERMITTED APPLICABLE LAW. EXCEPT OTHERWISE STATED WRITING COPYRIGHT HOLDERS /PARTIES PROVIDE PROGRAM “” WITHOUT WARRANTY KIND, EITHER EXPRESSED IMPLIED, INCLUDING, LIMITED , IMPLIED WARRANTIES MERCHANTABILITY FITNESS PARTICULAR PURPOSE. ENTIRE RISK QUALITY PERFORMANCE PROGRAM . PROGRAM PROVE DEFECTIVE, ASSUME COST NECESSARY SERVICING, REPAIR CORRECTION.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_16-limitation-of-liability","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"16. Limitation of Liability","title":"GNU General Public License","text":"EVENT UNLESS REQUIRED APPLICABLE LAW AGREED WRITING COPYRIGHT HOLDER, PARTY MODIFIES /CONVEYS PROGRAM PERMITTED , LIABLE DAMAGES, INCLUDING GENERAL, SPECIAL, INCIDENTAL CONSEQUENTIAL DAMAGES ARISING USE INABILITY USE PROGRAM (INCLUDING LIMITED LOSS DATA DATA RENDERED INACCURATE LOSSES SUSTAINED THIRD PARTIES FAILURE PROGRAM OPERATE PROGRAMS), EVEN HOLDER PARTY ADVISED POSSIBILITY DAMAGES.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_17-interpretation-of-sections-15-and-16","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"17. Interpretation of Sections 15 and 16","title":"GNU General Public License","text":"disclaimer warranty limitation liability provided given local legal effect according terms, reviewing courts shall apply local law closely approximates absolute waiver civil liability connection Program, unless warranty assumption liability accompanies copy Program return fee. END TERMS CONDITIONS","code":""},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"the-openfda-api","dir":"Articles","previous_headings":"","what":"The openFDA API","title":"openFDA","text":"openFDA API makes public FDA data available simple, public API. Users API access FDA data food, human veterinary drugs, devices, . can read website.","code":""},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"a-simple-openfda-query","dir":"Articles","previous_headings":"","what":"A simple openFDA query","title":"openFDA","text":"simplest way query openFDA API identify endpoint want use provide search terms. example, snippet retrieves 1 record adverse events drugs endpoint. empty search string (\"\") means results non-specific.","code":"search <- openFDA(search = \"\", endpoint = \"drug-event\", limit = 1) search #> #> GET https://api.fda.gov/drug/event.json?api_key=[API_KEY]&search=&limit=1 #> Status: 200 OK #> Content-Type: application/json #> Body: In memory (1819 bytes)"},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"openfda-results","dir":"Articles","previous_headings":"A simple openFDA query","what":"openFDA results","title":"openFDA","text":"function returns httr2 response object, attached JSON data. use httr2::resp_body_json() extract underlying data. don’t specify field count , JSON data two sections - meta results.","code":"json <- httr2::resp_body_json(search)"},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"meta","dir":"Articles","previous_headings":"A simple openFDA query > openFDA results","what":"Meta","title":"openFDA","text":"meta section important metadata results, includes: disclaimer - important disclaimer regarding data provided openFDA. license - webpage license terms govern openFDA API. last_updated - last date openFDA endpoint updated. results.skip - many results skipped? Set skip parameter openFDA(). results.limit - many results retrieved? Set limit parameter openFDA(). results.total - many results total matching search criteria?","code":"json$meta #> $disclaimer #> [1] \"Do not rely on openFDA to make decisions regarding medical care. While we make every effort to ensure that data is accurate, you should assume all results are unvalidated. We may limit or otherwise restrict your access to the API in line with our Terms of Service.\" #> #> $terms #> [1] \"https://open.fda.gov/terms/\" #> #> $license #> [1] \"https://open.fda.gov/license/\" #> #> $last_updated #> [1] \"2024-07-30\" #> #> $results #> $results$skip #> [1] 0 #> #> $results$limit #> [1] 1 #> #> $results$total #> [1] 18029782"},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"results","dir":"Articles","previous_headings":"A simple openFDA query > openFDA results","what":"Results","title":"openFDA","text":"non-count queries, set records found endpoint match search term.","code":"json$results #> [[1]] #> [[1]]$safetyreportid #> [1] \"5801206-7\" #> #> [[1]]$transmissiondateformat #> [1] \"102\" #> #> [[1]]$transmissiondate #> [1] \"20090109\" #> ...."},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"results-when-count-ing","dir":"Articles","previous_headings":"A simple openFDA query > openFDA results","what":"Results when count-ing","title":"openFDA","text":"set count query, openFDA API return full records. Instead, count number records member openFDA field specified count. example, let’s look drug manufacturers Drugs@FDA endpoint \"paracetamol\". ’ll use limit parameter limit results first 3 drug manufacturers found. can count fields date create time series, demonstrated openFDA website.","code":"count <- openFDA(search = \"\", endpoint = \"drug-drugsfda\", limit = 3, count = \"openfda.manufacturer_name.exact\") |> httr2::resp_body_json() count$results #> [[1]] #> [[1]]$term #> [1] \"Aurobindo Pharma Limited\" #> #> [[1]]$count #> [1] 393 #> #> #> [[2]] #> [[2]]$term #> [1] \"Zydus Lifesciences Limited\" #> #> [[2]]$count #> [1] 326 #> #> #> [[3]] #> [[3]]$term #> [1] \"Hikma Pharmaceuticals USA Inc.\" #> #> [[3]]$count #> [1] 318"},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"using-search-terms","dir":"Articles","previous_headings":"","what":"Using search terms","title":"openFDA","text":"can increase complexity query using search parameter, lets us search specific openFDA API fields. fields harmonised different degrees API, need check online.","code":""},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"searching-on-one-field","dir":"Articles","previous_headings":"Using search terms","what":"Searching on one field","title":"openFDA","text":"can provide search strategies openFDA() single strings. constructed [FIELD_NAME]:[STRING], FIELD_NAME openFDA field want search . STRING contains spaces, must surround double quotes, openFDA search word string. , example, search drugs class \"thiazide diuretic” formatted \"openfda.pharm_class_epc:\\\"thiazide diuretic\\\"\", API collect drugs words \"thiazide\" \"diuretic\" established pharmacological class (EPC). Let’s unrefined search first: Let’s compare refined search, add double-quotes around search term: can see, unrefined search picked 93 results, probably non-thiazide diuretics.","code":"search_unrefined <- openFDA( search = \"openfda.pharm_class_epc:thiazide diuretic\", endpoint = \"drug-drugsfda\", limit = 1 ) httr2::resp_body_json(search_unrefined)$meta$results$total #> [1] 211 search_refined <- openFDA( search = \"openfda.pharm_class_epc:\\\"thiazide diuretic\\\"\", endpoint = \"drug-drugsfda\", limit = 1 ) httr2::resp_body_json(search_refined)$meta$results$total #> [1] 118"},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"searching-on-multiple-fields","dir":"Articles","previous_headings":"Using search terms","what":"Searching on multiple fields","title":"openFDA","text":"openFDA API lets search various fields . Simple methods implemented openFDA.","code":""},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"write-your-own-search-term","dir":"Articles","previous_headings":"Using search terms > Searching on multiple fields","what":"Write your own search term","title":"openFDA","text":"Using guides openFDA website, can put together query. example, following query looks 5 records submitted Walmart taken orally. can use purrr functions extract brand name record. Note though single record can multiple brand names, choosing extract first one.","code":"search_term <- \"openfda.manufacturer_name:Walmart+AND+openfda.route=oral\" search <- openFDA(search = search_term, limit = 5, endpoint = \"drug-drugsfda\") json <- httr2::resp_body_json(search) purrr::map(json$results, .f = \\(x) { purrr::pluck(x, \"openfda\", \"brand_name\", 1) }) #> [[1]] #> [1] \"GOOD SENSE DUAL ACTION BACK PAIN\" #> #> [[2]] #> [1] \"ALL DAY ALLERGY\" #> #> [[3]] #> [1] \"NICOTINE MINI\" #> #> [[4]] #> [1] \"NAPROXEN SODIUM 220MG\" #> #> [[5]] #> [1] \"AMAZON BASIC CARE ACETAMINOPHEN\""},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"let-openfda-construct-the-search-term","dir":"Articles","previous_headings":"Using search terms > Searching on multiple fields","what":"Let openFDA() construct the search term","title":"openFDA","text":"can let package heavy lifting openFDA(), providing named character vector many field/search term pairs search parameter. function automatically add double quotes (\"\") around search terms, ’re providing field/value pairs like . can include many fields like, long provide field . default, terms combined operator openFDA(). search strategy therefore pick entries Drugs@FDA taken mouth.","code":"search <- openFDA(search = c(\"openfda.generic_name\" = \"amoxicillin\"), endpoint = \"drug-drugsfda\") httr2::resp_body_json(search)$meta$results$total #> [1] 58 search <- openFDA(search = c(\"openfda.generic_name\" = \"amoxicillin\", \"openfda.route\" = \"oral\"), endpoint = \"drug-drugsfda\", limit = 1) httr2::resp_body_json(search)$meta$results$total #> [1] 6929"},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"pre-construct-a-search-term","dir":"Articles","previous_headings":"Using search terms > Searching on multiple fields","what":"Pre-construct a search term","title":"openFDA","text":"apply multiple search terms operators, use format_search_term() mode = \"\":","code":"search_term <- format_search_term(c(\"openfda.generic_name\" = \"amoxicillin\", \"openfda.route\" = \"oral\"), mode = \"and\") search <- openFDA(search = search_term, endpoint = \"drug-drugsfda\", limit = 1) httr2::resp_body_json(search)$meta$results$total #> [1] 54"},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"wildcards","dir":"Articles","previous_headings":"Using search terms","what":"Wildcards","title":"openFDA","text":"can use wildcard character \"*\" match zero characters. example, take prototypical ending common drug class - e.g. sartans, angiotensin-II receptor blockers - see manufacturers represented Drugs@FDA class. using wildcards, either pre-format string without double-quotes use format_search_term() exact = FALSE. try search double-quotes wildcard character, get 404 error openFDA. looks like \"Alembic Pharmaceuticals\" active space - interesting!","code":"search_term <- format_search_term(c(\"openfda.generic_name\" = \"*sartan\"), exact = FALSE) search <- openFDA(search = search_term, count = \"openfda.manufacturer_name.exact\", endpoint = \"drug-drugsfda\", limit = 5) terms <- purrr::map( .x = httr2::resp_body_json(search)$results, .f = purrr::pluck(\"term\") ) counts <- purrr::map( .x = httr2::resp_body_json(search)$results, .f = purrr::pluck(\"count\") ) setNames(counts, terms) #> $`Alembic Pharmaceuticals Limited` #> [1] 14 #> #> $`Alembic Pharmaceuticals Inc.` #> [1] 13 #> #> $`Aurobindo Pharma Limited` #> [1] 13 #> #> $`Macleods Pharmaceuticals Limited` #> [1] 11 #> #> $`Zydus Lifesciences Limited` #> [1] 11"},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"other-openfda-api-features","dir":"Articles","previous_headings":"","what":"Other openFDA API features","title":"openFDA","text":"short guide cover aspects openFDA. recommended go openFDA API website check resources see information : Date ands ranges Search fields missing values Generating time series Paging larger queries","code":""},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"setup","dir":"Articles","previous_headings":"","what":"Setup","title":"Extracting FDA data with BNF terms","text":"Let’s start loading package.","code":"library(openFDA)"},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"get-brand-names-and-epcs-from-generic-bnf-terms","dir":"Articles","previous_headings":"","what":"Get brand names and EPCs from generic BNF terms","title":"Extracting FDA data with BNF terms","text":"First, ’ll use openFDA() retrieve brand names drugs interested BNF. first initialise vector drug names BNF. can paste single search string, use search \"openfda.generic_name\" field Drugs@FDA endpoint.","code":"bnf <- c(\"captopril\", \"enalapril\", \"fosinopril\", \"imidapril\", \"lisinopril\", \"perindopril\", \"quinapril\", \"ramipril\", \"trandolapril\", \"amlodipine\", \"diltiazem\", \"felodipine\", \"lacidipine\", \"lercanidipine\", \"nicardipine\", \"nifedipine\", \"nimodipine\", \"verapamil\", \"azilsartan\", \"candesartan\", \"eprosartan\", \"irbesartan\", \"losartan\", \"olmesartan\", \"telmisartan\", \"valsartan\", \"bumetanide\", \"bendroflumethiazide\", \"chlortalidone\", \"hydrochlorothiazide\", \"indapamide\", \"atorvastatin\", \"fluvastatin\", \"pravastatin\", \"rosuvastatin\", \"simvastatin\", \"ezetimibe\", \"alirocumab\", \"evolocumab\", \"metformin\", \"gliclazide\", \"glimepiride\", \"tolbutamide\", \"glipizide\", \"alogliptin\", \"linagliptin\", \"saxagliptin\", \"sitagliptin\", \"vildagliptin\", \"canagliflozin\", \"dapagliflozin\", \"empagliflozin\", \"ertugliflozin\", \"dulaglutide\", \"exenatide\", \"liraglutide\", \"lixisenatide\", \"semaglutide\", \"pioglitazone\") bnf_search_term <- format_search_term( c(\"openfda.generic_name\" = paste0(bnf, collapse = \"+\")), exact = FALSE ) bnf_search <- openFDA(search = bnf_search_term, endpoint = \"drug-drugsfda\") bnf_search_json <- httr2::resp_body_json(bnf_search) # The JSON object contains information including the generic and brand names bnf_search_json$results[[1]][4][[1]][1:3] #> [[1]] #> [[1]]$product_number #> [1] \"002\" #> #> [[1]]$reference_drug #> [1] \"No\" #> #> [[1]]$brand_name #> [1] \"LISINOPRIL AND HYDROCHLOROTHIAZIDE\" #> #> [[1]]$active_ingredients #> [[1]]$active_ingredients[[1]] #> [[1]]$active_ingredients[[1]]$name #> [1] \"HYDROCHLOROTHIAZIDE\" #> #> [[1]]$active_ingredients[[1]]$strength #> [1] \"12.5MG\" #> #> #> [[1]]$active_ingredients[[2]] #> [[1]]$active_ingredients[[2]]$name #> [1] \"LISINOPRIL\" #> #> [[1]]$active_ingredients[[2]]$strength #> [1] \"20MG\" #> #> #> #> [[1]]$reference_standard #> [1] \"No\" #> #> [[1]]$dosage_form #> [1] \"TABLET\" #> #> [[1]]$route #> [1] \"ORAL\" #> #> [[1]]$marketing_status #> [1] \"Prescription\" #> #> [[1]]$te_code #> [1] \"AB\" #> #> #> [[2]] #> [[2]]$product_number #> [1] \"003\" #> #> [[2]]$reference_drug #> [1] \"No\" #> #> [[2]]$brand_name #> [1] \"LISINOPRIL AND HYDROCHLOROTHIAZIDE\" #> #> [[2]]$active_ingredients #> [[2]]$active_ingredients[[1]] #> [[2]]$active_ingredients[[1]]$name #> [1] \"HYDROCHLOROTHIAZIDE\" #> #> [[2]]$active_ingredients[[1]]$strength #> [1] \"25MG\" #> #> #> [[2]]$active_ingredients[[2]] #> [[2]]$active_ingredients[[2]]$name #> [1] \"LISINOPRIL\" #> #> [[2]]$active_ingredients[[2]]$strength #> [1] \"20MG\" #> #> #> #> [[2]]$reference_standard #> [1] \"No\" #> #> [[2]]$dosage_form #> [1] \"TABLET\" #> #> [[2]]$route #> [1] \"ORAL\" #> #> [[2]]$marketing_status #> [1] \"Prescription\" #> #> [[2]]$te_code #> [1] \"AB\" #> #> #> [[3]] #> [[3]]$product_number #> [1] \"001\" #> #> [[3]]$reference_drug #> [1] \"No\" #> #> [[3]]$brand_name #> [1] \"LISINOPRIL AND HYDROCHLOROTHIAZIDE\" #> #> [[3]]$active_ingredients #> [[3]]$active_ingredients[[1]] #> [[3]]$active_ingredients[[1]]$name #> [1] \"HYDROCHLOROTHIAZIDE\" #> #> [[3]]$active_ingredients[[1]]$strength #> [1] \"12.5MG\" #> #> #> [[3]]$active_ingredients[[2]] #> [[3]]$active_ingredients[[2]]$name #> [1] \"LISINOPRIL\" #> #> [[3]]$active_ingredients[[2]]$strength #> [1] \"10MG\" #> #> #> #> [[3]]$reference_standard #> [1] \"No\" #> #> [[3]]$dosage_form #> [1] \"TABLET\" #> #> [[3]]$route #> [1] \"ORAL\" #> #> [[3]]$marketing_status #> [1] \"Prescription\" #> #> [[3]]$te_code #> [1] \"AB\""},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"extracting-openfda-fields-programmatically","dir":"Articles","previous_headings":"Get brand names and EPCs from generic BNF terms","what":"Extracting openFDA fields programmatically","title":"Extracting FDA data with BNF terms","text":"JSON data openFDA() useful, can easily parsed tools purrr vctrs. following function dips JSON data openFDA() pulls data specific fields. extracts occurrences data within requested field, condenses single character vector.","code":"#' Extract openFDA field data from openFDA JSON objects #' @param json #' @param openFDA_field A single string denoting an openFDA field to extract. #' Should be a valid field name, e.g. `\"openfda.generic_name\"` or #' `\"openfda.pharm_class_moa\"`. #' @returns A character vector with all unique values of `openfda_field` for #' your given search. extract_openFDA_field <- function(json, openfda_field) { json |> purrr::pluck(\"results\") |> purrr::map(.f = \\(x) purrr::pluck(x, \"openfda\", openfda_field)) |> vctrs::list_drop_empty() |> unlist() |> unique() }"},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"brand-names","dir":"Articles","previous_headings":"Get brand names and EPCs from generic BNF terms > Extracting openFDA fields programmatically","what":"Brand names","title":"Extracting FDA data with BNF terms","text":"Now function data extraction, can pull brand names associated generic drugs queried API .","code":"openFDA_brand_names <- extract_openFDA_field(bnf_search_json, \"brand_name\") print(openFDA_brand_names[25:30]) #> [1] \"RYBELSUS\" \"BENICAR HCT\" #> [3] \"TELMISARTAN AND HYDROCHLOROTHIAZIDE\" \"OLMESARTAN MEDOXOMIL\" #> [5] \"FELODIPINE\" \"TELMISARTAN\""},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"established-pharmacological-classes","dir":"Articles","previous_headings":"Get brand names and EPCs from generic BNF terms > Extracting openFDA fields programmatically","what":"Established pharmacological classes","title":"Extracting FDA data with BNF terms","text":"’ll also extract established pharmacological classes (EPCs) drugs. use EPCs query term , find generic drugs within BNF drug list.","code":"openfda_EPCs <- extract_openFDA_field(bnf_search_json, \"pharm_class_epc\") lengths(list(brand_names = openFDA_brand_names, EPCs = openfda_EPCs)) #> brand_names EPCs #> 171 18"},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"query-openfda-with-epcs","dir":"Articles","previous_headings":"","what":"Query openFDA with EPCs","title":"Extracting FDA data with BNF terms","text":"can use EPCs run queries openFDA API. removing \"[EPC]\" tags retrieved data, supplying search strategy.","code":"openfda_EPCs <- stringr::str_remove(openfda_EPCs, pattern = \" \\\\[.*\\\\]\") openfda_EPCs #> [1] \"GLP-1 Receptor Agonist\" #> [2] \"Angiotensin 2 Receptor Blocker\" #> [3] \"Thiazide Diuretic\" #> [4] \"Potassium-sparing Diuretic\" #> [5] \"Dietary Cholesterol Absorption Inhibitor\" #> [6] \"Insulin Analog\" #> [7] \"Dihydropyridine Calcium Channel Blocker\" #> [8] \"Angiotensin Converting Enzyme Inhibitor\" #> [9] \"Sulfonylurea\" #> [10] \"Loop Diuretic\" #> [11] \"HMG-CoA Reductase Inhibitor\" #> [12] \"Dipeptidyl Peptidase 4 Inhibitor\" #> [13] \"Thiazide-like Diuretic\" #> [14] \"Aldosterone Antagonist\" #> [15] \"Sodium-Glucose Cotransporter 2 Inhibitor\" #> [16] \"PCSK9 Inhibitor\" #> [17] \"Adenosine Triphosphate-Citrate Lyase Inhibitor\" #> [18] \"Calcium Channel Blocker\""},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"query-openfda-with-our-epcs","dir":"Articles","previous_headings":"Query openFDA with EPCs","what":"Query openFDA with our EPCs","title":"Extracting FDA data with BNF terms","text":"supplying strings search terms openFDA, surround double-quotation marks (\"). ensures openFDA considers term single string, instead set strings. Without quotes, term \"Thiazide Diuretic\" treated search drugs either “Thiazide” “Diuretic” EPC, instead search specifically thiazide diuretics.","code":"epc_search <- purrr::map( .x = openfda_EPCs, .f = \\(epc) { openFDA(search = c(\"openfda.pharm_class_epc\" = epc), endpoint = \"drug-drugsfda\") |> httr2::resp_body_json() }) epc_generics <- purrr::map( .x = epc_search, .f = \\(json) extract_openFDA_field(json, openfda_field = \"generic_name\")) |> purrr::flatten_chr() |> unique()"},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"compare-new-generic-names-to-bnf-terms","dir":"Articles","previous_headings":"Query openFDA with EPCs > Query openFDA with our EPCs","what":"Compare new generic names to BNF terms","title":"Extracting FDA data with BNF terms","text":"Using pattern matching, can see new generic drug terms retrieved searching EPCs. drugs, following interest: can use generic names interest get even brand names:","code":"bnf_regex <- paste0(\"(\", paste0(bnf, collapse = \"|\"), \")\") epc_generics |> tolower() |> grep(pattern = bnf_regex, value = TRUE, invert = TRUE) #> [1] \"tirzepatide\" \"sparsentan\" #> [3] \"chlorothiazide\" \"triamterene capsules\" #> [5] \"triamterene\" \"insulin lispro-aabc\" #> [7] \"insulin detemir\" \"insulin lispro\" #> [9] \"insulin aspart injection\" \"insulin aspart\" #> [11] \"insulin glulisine\" \"insulin glargine-yfgn\" #> [13] \"insulin degludec\" \"insulin glargine-aglr\" #> [15] \"water injection\" \"insulin glargine\" #> [17] \"nisoldipine\" \"isradipine\" #> [19] \"clevidipine\" \"clevipidine\" #> [21] \"glyburide\" \"furosemide\" #> [23] \"ethacrynic acid\" \"torsemide\" #> [25] \"furosemide injection 80 mg/ 10 ml\" \"lovastatin\" #> [27] \"pitavastatin magnesium\" \"pitavastatin\" #> [29] \"atenolol and chlorthalidone\" \"chlorthalidone\" #> [31] \"metolazone\" \"atenolol and chlorthalidone tablet\" #> [33] \"spironolactone\" \"eplerenone\" #> [35] \"carospir\" \"bexagliflozin\" #> [37] \"sotagliflozin\" \"bempedoic acid\" fda_generics <- c(\"pitavastatin\", \"lovastatin\", \"chlorothiazide\", \"sparsentan\", \"nisoldipine\", \"isradipine\", \"clevidipine\", \"glyburide\", \"glibenclamide\", \"tirzepatide\", \"bexagliflozin\", \"sotagliflozin\", \"chlorthalidone\", \"metolazone\", \"spironolactone\", \"eplerenone\", \"bempedoic acid\", \"fenofibrate\", \"fenofibric acid\", \"gemfibrozil\") more_brand_names <- purrr::map( .x = fda_generics, .f = \\(generic) { openFDA(c(\"openfda.generic_name\" = paste0(\"\\\"\", generic, \"\\\"\"))) |> httr2::resp_body_json() |> extract_openFDA_field(openfda_field = \"brand_name\") |> tolower() } ) |> setNames(fda_generics) #> Warning in openFDA(c(openfda.generic_name = paste0(\"\\\"\", generic, \"\\\"\"))): The openFDA API returned a 404 error. #> ! This indicates that openFDA had no results to return. #> This can be due to: #> • A restrictive search term. Yours was #> \"openfda.generic_name:\\\"\\\"glibenclamide\\\"\\\"\". more_brand_names[1:3] #> $pitavastatin #> [1] \"pitavastatin\" \"livalo\" \"zypitamag\" #> [4] \"nikita\" \"pitavastatin calcium\" #> #> $lovastatin #> [1] \"lovastatin\" \"altoprev\" #> #> $chlorothiazide #> [1] \"chlorothiazide sodium\" \"chlorothiazide\" \"diuril\""},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"queries-about-angplt3-inhibitors","dir":"Articles","previous_headings":"","what":"Queries about ANGPLT3 inhibitors","title":"Extracting FDA data with BNF terms","text":"Finally, let’s collect data angiopoietin-like 3 (ANGPLT3) inhibitors, can used familial homozygous hypercholesteremia UK US.","code":"evinacumab_search <- openFDA(search = c(\"openfda.generic_name\" = \"evinacumab\"), endpoint = \"drug-drugsfda\") evinacumab_epc <- evinacumab_search |> httr2::resp_body_json() |> extract_openFDA_field(\"pharm_class_epc\") |> stringr::str_remove(pattern = \" \\\\[.*\\\\]\") agplt3_inhibitors_search <- openFDA( search = c(\"openfda.pharm_class_epc\" = evinacumab_epc), endpoint = \"drug-drugsfda\" ) agplt3_inhibitors_brands <- agplt3_inhibitors_search |> httr2::resp_body_json() |> extract_openFDA_field(\"brand_name\") agplt3_inhibitors_generics <- agplt3_inhibitors_search |> httr2::resp_body_json() |> extract_openFDA_field(\"generic_name\") c(\"AGPLT3-I brands\" = agplt3_inhibitors_brands, \"AGPLT3-I generics\" = agplt3_inhibitors_generics) #> AGPLT3-I brands AGPLT3-I generics #> \"EVKEEZA\" \"EVINACUMAB\""},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"session-info","dir":"Articles","previous_headings":"Queries about ANGPLT3 inhibitors","what":"Session info","title":"Extracting FDA data with BNF terms","text":"","code":"sessionInfo() #> R version 4.4.1 (2024-06-14) #> Platform: x86_64-pc-linux-gnu #> Running under: Ubuntu 22.04.5 LTS #> #> Matrix products: default #> BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 #> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0 #> #> locale: #> [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 #> [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 #> [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C #> [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C #> #> time zone: UTC #> tzcode source: system (glibc) #> #> attached base packages: #> [1] stats graphics grDevices utils datasets methods base #> #> other attached packages: #> [1] openFDA_0.0.0.9000 #> #> loaded via a namespace (and not attached): #> [1] vctrs_0.6.5 cli_3.6.3 knitr_1.48 rlang_1.1.4 #> [5] xfun_0.48 stringi_1.8.4 purrr_1.0.2 textshaping_0.4.0 #> [9] jsonlite_1.8.9 glue_1.8.0 backports_1.5.0 htmltools_0.5.8.1 #> [13] ragg_1.3.3 sass_0.4.9 rappdirs_0.3.3 rmarkdown_2.28 #> [17] evaluate_1.0.1 jquerylib_0.1.4 fastmap_1.2.0 yaml_2.3.10 #> [21] lifecycle_1.0.4 httr2_1.0.5 stringr_1.5.1 compiler_4.4.1 #> [25] fs_1.6.4 systemfonts_1.1.0 digest_0.6.37 R6_2.5.1 #> [29] curl_5.2.3 magrittr_2.0.3 bslib_0.8.0 checkmate_2.3.2 #> [33] tools_4.4.1 pkgdown_2.1.1 cachem_1.1.0 desc_1.4.3"},{"path":"https://simpar1471.github.io/openFDA/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Simon Parker. Author, maintainer.","code":""},{"path":"https://simpar1471.github.io/openFDA/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Parker S (2024). openFDA: 'openFDA' API. R package version 0.0.0.9000, https://simpar1471.github.io/openFDA/, https://github.com/simpar1471/openFDA.","code":"@Manual{, title = {openFDA: 'openFDA' API}, author = {Simon Parker}, year = {2024}, note = {R package version 0.0.0.9000, https://simpar1471.github.io/openFDA/}, url = {https://github.com/simpar1471/openFDA}, }"},{"path":"https://simpar1471.github.io/openFDA/index.html","id":"openfda","dir":"","previous_headings":"","what":"openFDA API","title":"openFDA API","text":"openFDA makes querying openFDA API R breeze. API serves publicly available data FDA foods, drugs, devices, . data includes data recall enforcement reports, adverse events, manufacturer details, - - even ! Note data openFDA validated clinical production use.","code":""},{"path":"https://simpar1471.github.io/openFDA/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"openFDA API","text":"can install development version openFDA GitHub using either pak devtools:","code":"# install.packages(\"pak\") pak::pkg_install(\"simpar1471/openFDA\") # install.packages(\"devtools\") devtools::install_github(\"simpar1471/openFDA\")"},{"path":"https://simpar1471.github.io/openFDA/index.html","id":"using-openfda","dir":"","previous_headings":"","what":"Using openFDA","title":"openFDA API","text":"full documentation API online, look openFDA website get full feel API . R package lets query API directly R, using httr2. underlying response JSON data - can use httr2::resp_body_json() get JSON data nested list, extract fields want. ’ve found purrr useful parsing data quickly.","code":"library(openFDA) search <- openFDA( search = \"openfda.generic_name:furosemide\", limit = 5 ) search #> #> GET #> https://api.fda.gov/drug/drugsfda.json?api_key=[API_KEY]&search=openfda.generic_name:furosemide&limit=5 #> Status: 200 OK #> Content-Type: application/json #> Body: In memory (17286 bytes) json <- httr2::resp_body_json(search) json$results[[1]]$openfda$brand_name #> [[1]] #> [1] \"FUROSEMIDE\" json$results[[1]]$openfda$pharm_class_epc #> [[1]] #> [1] \"Loop Diuretic [EPC]\" purrr::map_chr( .x = json$results, .f = \\(result) purrr::pluck(result, \"openfda\", \"manufacturer_name\", 1) ) #> [1] \"Amneal Pharmaceuticals LLC\" \"Gland Pharma Limited\" #> [3] \"Solco Healthcare LLC\" \"Lifestar Pharma LLC\" #> [5] \"Ipca Laboratories Limited\""},{"path":"https://simpar1471.github.io/openFDA/index.html","id":"other-r-packages-for-openfda","dir":"","previous_headings":"","what":"Other R packages for openFDA","title":"openFDA API","text":"openfda package rOpenHealth also wraps openFDA API R, available GitHub. ’s got pretty neat structure whereby build query using individual functions parameter - though ’s personal preference keep parameters single function. also makes results available data frames, nice, think working response object parsing underlying JSON permits powerful interactions API. also FDAopenR, couldn’t quite wrap head around. package appears working order, though!","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/api_key.html","id":null,"dir":"Reference","previous_headings":"","what":"Get and set your openFDA API keys — set_api_key","title":"Get and set your openFDA API keys — set_api_key","text":"Get set openFDA API keys","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/api_key.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get and set your openFDA API keys — set_api_key","text":"","code":"set_api_key(api_key) get_api_key()"},{"path":"https://simpar1471.github.io/openFDA/reference/api_key.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get and set your openFDA API keys — set_api_key","text":"api_key single-length character vector openFDA API key. can generate API key FDA website.","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/api_key.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get and set your openFDA API keys — set_api_key","text":"single length character vector API key. set_api_key(), returned invisibly. get_api_key(), error thrown key set.","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/api_key.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Get and set your openFDA API keys — set_api_key","text":"permanently set API key given project, set OPENFDA_TOKEN .Renviron.","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/api_key.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get and set your openFDA API keys — set_api_key","text":"","code":"# Set your openFDA API key with `set_api_key()` api_key <- \"example_api_key\" set_api_key(api_key) # Retrieve it with `get_api_key()` get_api_key() #> [1] \"example_api_key\" # An error will be thrown if your API key is an empty string. set_api_key(\"\") try(get_api_key()) #> Error in get_api_key() : #> To use openFDA, you must set an openFDA API key. #> ℹ Go to to get an openFDA API key, #> then supply it to `set_api_key()` to cache it for use in this session."},{"path":"https://simpar1471.github.io/openFDA/reference/format_search_term.html","id":null,"dir":"Reference","previous_headings":"","what":"Format character vectors into search terms for openFDA API queries — format_search_term","title":"Format character vectors into search terms for openFDA API queries — format_search_term","text":"function helper constructing search queries. Whilst handles available formatting openFDA APIs, recapture search term syntax available . get full appreciation openFDA search syntax, see https://open.fda.gov/apis/advanced-syntax/.","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/format_search_term.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format character vectors into search terms for openFDA API queries — format_search_term","text":"","code":"format_search_term(search, exact = TRUE, mode = \"or\")"},{"path":"https://simpar1471.github.io/openFDA/reference/format_search_term.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format character vectors into search terms for openFDA API queries — format_search_term","text":"search character vector length 1 . scalar unnamed, assumed already formatted search string work API. named, vector collapsed include various search terms, separated terms based value operator. exact single-length logical vector. TRUE (default), individual search terms surrounded double quotes (\"\"). Set exact FALSE search term contains multiple words searched , e.g. c(\"openfda.generic_name\" = \"losartan+candesartan\"). parameter applies search named character vector. mode single-length character vector, defines searches multiple fields combined. default (\"\") combined '' operator, can make '' operator used instead (\"\"). argument case-sensitive throw error mode one either \"\" \"\". parameter applies search named character vector.","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/format_search_term.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format character vectors into search terms for openFDA API queries — format_search_term","text":"character vector S3 class , formatted search term can supplied openFDA().","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/format_search_term.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Format character vectors into search terms for openFDA API queries — format_search_term","text":"function check providing accurate field names search terms. make sure provided correctly spelt fields search terms.","code":""},{"path":[]},{"path":"https://simpar1471.github.io/openFDA/reference/format_search_term.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format character vectors into search terms for openFDA API queries — format_search_term","text":"","code":"# Provide a formatted search string and the function will do no formatting format_search_term(\"openfda.generic_name:verapamil\") #> [1] \"openfda.generic_name:verapamil\" # Provide a named vector and the function will format it for you format_search_term(c(\"openfda.generic_name\" = \"verapamil\")) #> [1] \"openfda.generic_name:%22verapamil%22\" # If providing multiple elements in your search term, use `exact = FALSE` # to prevent the function from surrounding the term with double quotes. format_search_term(c(\"openfda.generic_name\" = \"verapamil+amlodipine\"), exact = FALSE) #> [1] \"openfda.generic_name:verapamil+amlodipine\" # Provide a longer named vector and function will merge these with an OR # operator format_search_term(c(\"openfda.generic_name\" = \"verapamil\", \"openfda.manufacturer_name\" = \"glaxo*\")) #> [1] \"openfda.generic_name:%22verapamil%22+openfda.manufacturer_name:%22glaxo%2A%22\" # Or you can set the `mode` argument to merge your search terms with an AND # operator format_search_term(c(\"openfda.generic_name\" = \"verapamil\", \"openfda.manufacturer_name\" = \"glaxo*\"), mode = \"and\") #> [1] \"openfda.generic_name:%22verapamil%22+AND+openfda.manufacturer_name:%22glaxo%2A%22\""},{"path":"https://simpar1471.github.io/openFDA/reference/format_sort_term.html","id":null,"dir":"Reference","previous_headings":"","what":"Format character vectors into sort terms for openFDA API queries — format_sort_term","title":"Format character vectors into sort terms for openFDA API queries — format_sort_term","text":"function acts helper constructing sort term openFDA API.","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/format_sort_term.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format character vectors into sort terms for openFDA API queries — format_sort_term","text":"","code":"format_sort_term(sort)"},{"path":"https://simpar1471.github.io/openFDA/reference/format_sort_term.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format character vectors into sort terms for openFDA API queries — format_sort_term","text":"sort single-length character vector length 1. unnamed, assumed already formatted search string work API. named, vector collapsed include field sorting choice.","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/format_sort_term.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format character vectors into sort terms for openFDA API queries — format_sort_term","text":"character vector S3 class , formatted search term can supplied openFDA().","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/format_sort_term.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Format character vectors into sort terms for openFDA API queries — format_sort_term","text":"function check providing accurate field names search terms. make sure provided correctly spelt fields search terms.","code":""},{"path":[]},{"path":"https://simpar1471.github.io/openFDA/reference/format_sort_term.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format character vectors into sort terms for openFDA API queries — format_sort_term","text":"","code":"# Provide a formatted search string and the function will do no formatting format_sort_term(\"openfda.generic_name:asc\") #> [1] \"openfda.generic_name:asc\" # Provide a named vector and the function will format it for you format_sort_term(c(\"openfda.generic_name\" = \"asc\")) #> [1] \"openfda.generic_name:asc\" # Errors will be thrown if you supply a bad input try(format_sort_term(\"receivedate:no_order\")) #> Error in format_sort_term(\"receivedate:no_order\") : #> `sort` must end with either \"asc\" or \"desc\". #> ! `sort` was \"receivedate:no_order\". try(format_sort_term(c(\"receivedate\" = \"ascending\"))) #> Error in format_sort_term(c(receivedate = \"ascending\")) : #> `sort` must be either \"asc\" or \"desc\". #> ! `sort` was \"ascending\"."},{"path":"https://simpar1471.github.io/openFDA/reference/openFDA.html","id":null,"dir":"Reference","previous_headings":"","what":"Send requests to the openFDA API — openFDA","title":"Send requests to the openFDA API — openFDA","text":"Send requests openFDA API","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/openFDA.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Send requests to the openFDA API — openFDA","text":"","code":"openFDA( search = \"\", sort = NULL, count = NULL, limit = 1000, skip = NULL, endpoint = \"drug-drugsfda\", api_key = get_api_key(), warn_on_http_error = TRUE )"},{"path":"https://simpar1471.github.io/openFDA/reference/openFDA.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Send requests to the openFDA API — openFDA","text":"search character vector passed format_search_term(). search \"\" (default), openFDA retrieve records filtering. error thrown elements search missing (NA). sort single string scalar named character vector describing sort results. sort term either formatted \"[FIELD]:[asc/desc]\", c(\"[FIELD]\" = \"[asc/desc]\"). example, sort results Drugs@FDA endpoint ascending submission status dates. values \"asc\", \"desc\" supplied, function throw error. count single string denoting field count results. NULL (default), results returned full user. Specify parameter want count occurrences results within search term - go https://open.fda.gov/apis/query-syntax/ information. limit single integerish value describing limit number records retrieve. error thrown limit 1000 (default). skip single integer describing many records skipped. records skipped found search, openFDA API return 404 error. endpoint single-length character vector describing openFDA endpoint target. \"animal-event\": Adverse event reports animal/veterinary drugs. \"drug-event\": Adverse event reports FDA Adverse Event Reporting System \"drug-label\": Drug documentation Structured Product Labeling (SPL) format. \"drug-ndc\": Data National Drug Code Directory (NDC). \"drug-enforcement\": Data FDA Recall Enterprise System drug products. \"drug-drugsfda\": Data products approved human use FDA since 1939, mostly complete data 1998. \"device-510k\": Data 510(k) submissions FDA regarding medical devices. \"device-classification\": Data FDA Product Classification Database medical devices. \"device-enforcement\": Data FDA Recall Enterprise System (RES) medical devices. \"device-event\": Data adverse events associated FDA-approved medical devices. \"device-pma\": Pre-market approval data medical devices submitted FDA. \"device-recall\": Data product recalls medical devices violate FDA law. \"device-reglist\": Data FDA Device Registrations Listings. \"device-covid19serology\": Data independent evaluations COVID-19 serological tests. \"device-udi\": Data FDA's Global Unique Device Identification Database (GUDID). \"food-enforcement\": Data FDA Recall Enterprise System food products. \"food-event\": Data Center Food Safety Applied Nutrition Adverse Event Reporting System. \"-historicaldocument\": majority FDA Press Releases, 1913 2014. \"-nsde\": Data National Drug Code Structured Product Labeling Data Elements. \"-substance\": Data regarding substances - individual molecules, proteins, nucleic acids, . \"-unii\": Data FDA's Global Substance Registration System. \"tobacco-problem\": Data problems (e.g. damage, defects, contamination, bad smell) tobacco products. argument case-sensitive. default, package target Drugs@FDA endpoint (\"drugs-drugsfda\"). api_key single-length character vector openFDA API key. default result get_api_key(). api_key empty string, error thrown. warn_on_http_error scalar logical value. TRUE (default), common openFDA HTTP errors cause explanatory warnings printed FALSE, underlying httr2 response object returned extra warnings.","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/openFDA.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Send requests to the openFDA API — openFDA","text":"httr2 response object httr2::req_perform(). can use httr2::resp_body_json() extract JSON data response.","code":""},{"path":[]},{"path":"https://simpar1471.github.io/openFDA/reference/openFDA.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Send requests to the openFDA API — openFDA","text":"","code":"if (httr2::secret_has_key(\"OPENFDA_KEY\")) { set_api_key(httr2::secret_decrypt( \"TEaDtqdFMq9_Montij5p9IY6T57IyqkbF8IYFVOpk-ttxotFUNdJSxgccAnkq4nQhplaf-r3deQ\", \"OPENFDA_KEY\" )) resp <- openFDA(search = \"openfda.manufacturer_name:gilead*\", limit = 2, skip = 10) # The function returns an `httr2` object print(resp) } #> #> GET #> https://api.fda.gov/drug/drugsfda.json?api_key=[API_KEY]&search=openfda.manufacturer_name:gilead%2A&limit=2&skip=10 #> Status: 200 OK #> Content-Type: application/json #> Body: In memory (39419 bytes) # Bad inputs will cause informative errors - here, a bad API key is supplied try( openFDA(search = \"openfda.manufacturer_name:gilead*\", api_key = \"BAD_API_KEY\", limit = 1) ) #> Warning: The openFDA API returned a 403 error. #> ! This usually means that an invalid `api_key` was used. #> ℹ Your API key was \"BAD_API_KEY\". #> #> GET #> https://api.fda.gov/drug/drugsfda.json?api_key=[API_KEY]&search=openfda.manufacturer_name:gilead%2A&limit=1 #> Status: 403 Forbidden #> Content-Type: application/json #> Body: In memory (136 bytes)"},{"path":"https://simpar1471.github.io/openFDA/news/index.html","id":"openfda-010","dir":"Changelog","previous_headings":"","what":"openFDA 0.1.0","title":"openFDA 0.1.0","text":"openFDA() run queries openFDA API. format_search_term() format_sort_term() help construct openFDA() query components. set_api_key() get_api_key() working openFDA API keys. Initial CRAN submission.","code":""}] +[{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"GNU General Public License","title":"GNU General Public License","text":"Version 3, 29 June 2007Copyright © 2007 Free Software Foundation, Inc.  Everyone permitted copy distribute verbatim copies license document, changing allowed.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"preamble","dir":"","previous_headings":"","what":"Preamble","title":"GNU General Public License","text":"GNU General Public License free, copyleft license software kinds works. licenses software practical works designed take away freedom share change works. contrast, GNU General Public License intended guarantee freedom share change versions program–make sure remains free software users. , Free Software Foundation, use GNU General Public License software; applies also work released way authors. can apply programs, . speak free software, referring freedom, price. General Public Licenses designed make sure freedom distribute copies free software (charge wish), receive source code can get want , can change software use pieces new free programs, know can things. protect rights, need prevent others denying rights asking surrender rights. Therefore, certain responsibilities distribute copies software, modify : responsibilities respect freedom others. example, distribute copies program, whether gratis fee, must pass recipients freedoms received. must make sure , , receive can get source code. must show terms know rights. Developers use GNU GPL protect rights two steps: (1) assert copyright software, (2) offer License giving legal permission copy, distribute /modify . developers’ authors’ protection, GPL clearly explains warranty free software. users’ authors’ sake, GPL requires modified versions marked changed, problems attributed erroneously authors previous versions. devices designed deny users access install run modified versions software inside , although manufacturer can . fundamentally incompatible aim protecting users’ freedom change software. systematic pattern abuse occurs area products individuals use, precisely unacceptable. Therefore, designed version GPL prohibit practice products. problems arise substantially domains, stand ready extend provision domains future versions GPL, needed protect freedom users. Finally, every program threatened constantly software patents. States allow patents restrict development use software general-purpose computers, , wish avoid special danger patents applied free program make effectively proprietary. prevent , GPL assures patents used render program non-free. precise terms conditions copying, distribution modification follow.","code":""},{"path":[]},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_0-definitions","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"0. Definitions","title":"GNU General Public License","text":"“License” refers version 3 GNU General Public License. “Copyright” also means copyright-like laws apply kinds works, semiconductor masks. “Program” refers copyrightable work licensed License. licensee addressed “”. “Licensees” “recipients” may individuals organizations. “modify” work means copy adapt part work fashion requiring copyright permission, making exact copy. resulting work called “modified version” earlier work work “based ” earlier work. “covered work” means either unmodified Program work based Program. “propagate” work means anything , without permission, make directly secondarily liable infringement applicable copyright law, except executing computer modifying private copy. Propagation includes copying, distribution (without modification), making available public, countries activities well. “convey” work means kind propagation enables parties make receive copies. Mere interaction user computer network, transfer copy, conveying. interactive user interface displays “Appropriate Legal Notices” extent includes convenient prominently visible feature (1) displays appropriate copyright notice, (2) tells user warranty work (except extent warranties provided), licensees may convey work License, view copy License. interface presents list user commands options, menu, prominent item list meets criterion.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_1-source-code","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"1. Source Code","title":"GNU General Public License","text":"“source code” work means preferred form work making modifications . “Object code” means non-source form work. “Standard Interface” means interface either official standard defined recognized standards body, , case interfaces specified particular programming language, one widely used among developers working language. “System Libraries” executable work include anything, work whole, () included normal form packaging Major Component, part Major Component, (b) serves enable use work Major Component, implement Standard Interface implementation available public source code form. “Major Component”, context, means major essential component (kernel, window system, ) specific operating system () executable work runs, compiler used produce work, object code interpreter used run . “Corresponding Source” work object code form means source code needed generate, install, (executable work) run object code modify work, including scripts control activities. However, include work’s System Libraries, general-purpose tools generally available free programs used unmodified performing activities part work. example, Corresponding Source includes interface definition files associated source files work, source code shared libraries dynamically linked subprograms work specifically designed require, intimate data communication control flow subprograms parts work. Corresponding Source need include anything users can regenerate automatically parts Corresponding Source. Corresponding Source work source code form work.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_2-basic-permissions","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"2. Basic Permissions","title":"GNU General Public License","text":"rights granted License granted term copyright Program, irrevocable provided stated conditions met. License explicitly affirms unlimited permission run unmodified Program. output running covered work covered License output, given content, constitutes covered work. License acknowledges rights fair use equivalent, provided copyright law. may make, run propagate covered works convey, without conditions long license otherwise remains force. may convey covered works others sole purpose make modifications exclusively , provide facilities running works, provided comply terms License conveying material control copyright. thus making running covered works must exclusively behalf, direction control, terms prohibit making copies copyrighted material outside relationship . Conveying circumstances permitted solely conditions stated . Sublicensing allowed; section 10 makes unnecessary.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_3-protecting-users-legal-rights-from-anti-circumvention-law","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"3. Protecting Users’ Legal Rights From Anti-Circumvention Law","title":"GNU General Public License","text":"covered work shall deemed part effective technological measure applicable law fulfilling obligations article 11 WIPO copyright treaty adopted 20 December 1996, similar laws prohibiting restricting circumvention measures. convey covered work, waive legal power forbid circumvention technological measures extent circumvention effected exercising rights License respect covered work, disclaim intention limit operation modification work means enforcing, work’s users, third parties’ legal rights forbid circumvention technological measures.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_4-conveying-verbatim-copies","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"4. Conveying Verbatim Copies","title":"GNU General Public License","text":"may convey verbatim copies Program’s source code receive , medium, provided conspicuously appropriately publish copy appropriate copyright notice; keep intact notices stating License non-permissive terms added accord section 7 apply code; keep intact notices absence warranty; give recipients copy License along Program. may charge price price copy convey, may offer support warranty protection fee.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_5-conveying-modified-source-versions","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"5. Conveying Modified Source Versions","title":"GNU General Public License","text":"may convey work based Program, modifications produce Program, form source code terms section 4, provided also meet conditions: ) work must carry prominent notices stating modified , giving relevant date. b) work must carry prominent notices stating released License conditions added section 7. requirement modifies requirement section 4 “keep intact notices”. c) must license entire work, whole, License anyone comes possession copy. License therefore apply, along applicable section 7 additional terms, whole work, parts, regardless packaged. License gives permission license work way, invalidate permission separately received . d) work interactive user interfaces, must display Appropriate Legal Notices; however, Program interactive interfaces display Appropriate Legal Notices, work need make . compilation covered work separate independent works, nature extensions covered work, combined form larger program, volume storage distribution medium, called “aggregate” compilation resulting copyright used limit access legal rights compilation’s users beyond individual works permit. Inclusion covered work aggregate cause License apply parts aggregate.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_6-conveying-non-source-forms","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"6. Conveying Non-Source Forms","title":"GNU General Public License","text":"may convey covered work object code form terms sections 4 5, provided also convey machine-readable Corresponding Source terms License, one ways: ) Convey object code , embodied , physical product (including physical distribution medium), accompanied Corresponding Source fixed durable physical medium customarily used software interchange. b) Convey object code , embodied , physical product (including physical distribution medium), accompanied written offer, valid least three years valid long offer spare parts customer support product model, give anyone possesses object code either (1) copy Corresponding Source software product covered License, durable physical medium customarily used software interchange, price reasonable cost physically performing conveying source, (2) access copy Corresponding Source network server charge. c) Convey individual copies object code copy written offer provide Corresponding Source. alternative allowed occasionally noncommercially, received object code offer, accord subsection 6b. d) Convey object code offering access designated place (gratis charge), offer equivalent access Corresponding Source way place charge. need require recipients copy Corresponding Source along object code. place copy object code network server, Corresponding Source may different server (operated third party) supports equivalent copying facilities, provided maintain clear directions next object code saying find Corresponding Source. Regardless server hosts Corresponding Source, remain obligated ensure available long needed satisfy requirements. e) Convey object code using peer--peer transmission, provided inform peers object code Corresponding Source work offered general public charge subsection 6d. separable portion object code, whose source code excluded Corresponding Source System Library, need included conveying object code work. “User Product” either (1) “consumer product”, means tangible personal property normally used personal, family, household purposes, (2) anything designed sold incorporation dwelling. determining whether product consumer product, doubtful cases shall resolved favor coverage. particular product received particular user, “normally used” refers typical common use class product, regardless status particular user way particular user actually uses, expects expected use, product. product consumer product regardless whether product substantial commercial, industrial non-consumer uses, unless uses represent significant mode use product. “Installation Information” User Product means methods, procedures, authorization keys, information required install execute modified versions covered work User Product modified version Corresponding Source. information must suffice ensure continued functioning modified object code case prevented interfered solely modification made. convey object code work section , , specifically use , User Product, conveying occurs part transaction right possession use User Product transferred recipient perpetuity fixed term (regardless transaction characterized), Corresponding Source conveyed section must accompanied Installation Information. requirement apply neither third party retains ability install modified object code User Product (example, work installed ROM). requirement provide Installation Information include requirement continue provide support service, warranty, updates work modified installed recipient, User Product modified installed. Access network may denied modification materially adversely affects operation network violates rules protocols communication across network. Corresponding Source conveyed, Installation Information provided, accord section must format publicly documented (implementation available public source code form), must require special password key unpacking, reading copying.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_7-additional-terms","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"7. Additional Terms","title":"GNU General Public License","text":"“Additional permissions” terms supplement terms License making exceptions one conditions. Additional permissions applicable entire Program shall treated though included License, extent valid applicable law. additional permissions apply part Program, part may used separately permissions, entire Program remains governed License without regard additional permissions. convey copy covered work, may option remove additional permissions copy, part . (Additional permissions may written require removal certain cases modify work.) may place additional permissions material, added covered work, can give appropriate copyright permission. Notwithstanding provision License, material add covered work, may (authorized copyright holders material) supplement terms License terms: ) Disclaiming warranty limiting liability differently terms sections 15 16 License; b) Requiring preservation specified reasonable legal notices author attributions material Appropriate Legal Notices displayed works containing ; c) Prohibiting misrepresentation origin material, requiring modified versions material marked reasonable ways different original version; d) Limiting use publicity purposes names licensors authors material; e) Declining grant rights trademark law use trade names, trademarks, service marks; f) Requiring indemnification licensors authors material anyone conveys material (modified versions ) contractual assumptions liability recipient, liability contractual assumptions directly impose licensors authors. non-permissive additional terms considered “restrictions” within meaning section 10. Program received , part , contains notice stating governed License along term restriction, may remove term. license document contains restriction permits relicensing conveying License, may add covered work material governed terms license document, provided restriction survive relicensing conveying. add terms covered work accord section, must place, relevant source files, statement additional terms apply files, notice indicating find applicable terms. Additional terms, permissive non-permissive, may stated form separately written license, stated exceptions; requirements apply either way.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_8-termination","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"8. Termination","title":"GNU General Public License","text":"may propagate modify covered work except expressly provided License. attempt otherwise propagate modify void, automatically terminate rights License (including patent licenses granted third paragraph section 11). However, cease violation License, license particular copyright holder reinstated () provisionally, unless copyright holder explicitly finally terminates license, (b) permanently, copyright holder fails notify violation reasonable means prior 60 days cessation. Moreover, license particular copyright holder reinstated permanently copyright holder notifies violation reasonable means, first time received notice violation License (work) copyright holder, cure violation prior 30 days receipt notice. Termination rights section terminate licenses parties received copies rights License. rights terminated permanently reinstated, qualify receive new licenses material section 10.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_9-acceptance-not-required-for-having-copies","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"9. Acceptance Not Required for Having Copies","title":"GNU General Public License","text":"required accept License order receive run copy Program. Ancillary propagation covered work occurring solely consequence using peer--peer transmission receive copy likewise require acceptance. However, nothing License grants permission propagate modify covered work. actions infringe copyright accept License. Therefore, modifying propagating covered work, indicate acceptance License .","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_10-automatic-licensing-of-downstream-recipients","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"10. Automatic Licensing of Downstream Recipients","title":"GNU General Public License","text":"time convey covered work, recipient automatically receives license original licensors, run, modify propagate work, subject License. responsible enforcing compliance third parties License. “entity transaction” transaction transferring control organization, substantially assets one, subdividing organization, merging organizations. propagation covered work results entity transaction, party transaction receives copy work also receives whatever licenses work party’s predecessor interest give previous paragraph, plus right possession Corresponding Source work predecessor interest, predecessor can get reasonable efforts. may impose restrictions exercise rights granted affirmed License. example, may impose license fee, royalty, charge exercise rights granted License, may initiate litigation (including cross-claim counterclaim lawsuit) alleging patent claim infringed making, using, selling, offering sale, importing Program portion .","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_11-patents","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"11. Patents","title":"GNU General Public License","text":"“contributor” copyright holder authorizes use License Program work Program based. work thus licensed called contributor’s “contributor version”. contributor’s “essential patent claims” patent claims owned controlled contributor, whether already acquired hereafter acquired, infringed manner, permitted License, making, using, selling contributor version, include claims infringed consequence modification contributor version. purposes definition, “control” includes right grant patent sublicenses manner consistent requirements License. contributor grants non-exclusive, worldwide, royalty-free patent license contributor’s essential patent claims, make, use, sell, offer sale, import otherwise run, modify propagate contents contributor version. following three paragraphs, “patent license” express agreement commitment, however denominated, enforce patent (express permission practice patent covenant sue patent infringement). “grant” patent license party means make agreement commitment enforce patent party. convey covered work, knowingly relying patent license, Corresponding Source work available anyone copy, free charge terms License, publicly available network server readily accessible means, must either (1) cause Corresponding Source available, (2) arrange deprive benefit patent license particular work, (3) arrange, manner consistent requirements License, extend patent license downstream recipients. “Knowingly relying” means actual knowledge , patent license, conveying covered work country, recipient’s use covered work country, infringe one identifiable patents country reason believe valid. , pursuant connection single transaction arrangement, convey, propagate procuring conveyance , covered work, grant patent license parties receiving covered work authorizing use, propagate, modify convey specific copy covered work, patent license grant automatically extended recipients covered work works based . patent license “discriminatory” include within scope coverage, prohibits exercise , conditioned non-exercise one rights specifically granted License. may convey covered work party arrangement third party business distributing software, make payment third party based extent activity conveying work, third party grants, parties receive covered work , discriminatory patent license () connection copies covered work conveyed (copies made copies), (b) primarily connection specific products compilations contain covered work, unless entered arrangement, patent license granted, prior 28 March 2007. Nothing License shall construed excluding limiting implied license defenses infringement may otherwise available applicable patent law.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_12-no-surrender-of-others-freedom","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"12. No Surrender of Others’ Freedom","title":"GNU General Public License","text":"conditions imposed (whether court order, agreement otherwise) contradict conditions License, excuse conditions License. convey covered work satisfy simultaneously obligations License pertinent obligations, consequence may convey . example, agree terms obligate collect royalty conveying convey Program, way satisfy terms License refrain entirely conveying Program.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_13-use-with-the-gnu-affero-general-public-license","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"13. Use with the GNU Affero General Public License","title":"GNU General Public License","text":"Notwithstanding provision License, permission link combine covered work work licensed version 3 GNU Affero General Public License single combined work, convey resulting work. terms License continue apply part covered work, special requirements GNU Affero General Public License, section 13, concerning interaction network apply combination .","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_14-revised-versions-of-this-license","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"14. Revised Versions of this License","title":"GNU General Public License","text":"Free Software Foundation may publish revised /new versions GNU General Public License time time. new versions similar spirit present version, may differ detail address new problems concerns. version given distinguishing version number. Program specifies certain numbered version GNU General Public License “later version” applies , option following terms conditions either numbered version later version published Free Software Foundation. Program specify version number GNU General Public License, may choose version ever published Free Software Foundation. Program specifies proxy can decide future versions GNU General Public License can used, proxy’s public statement acceptance version permanently authorizes choose version Program. Later license versions may give additional different permissions. However, additional obligations imposed author copyright holder result choosing follow later version.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_15-disclaimer-of-warranty","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"15. Disclaimer of Warranty","title":"GNU General Public License","text":"WARRANTY PROGRAM, EXTENT PERMITTED APPLICABLE LAW. EXCEPT OTHERWISE STATED WRITING COPYRIGHT HOLDERS /PARTIES PROVIDE PROGRAM “” WITHOUT WARRANTY KIND, EITHER EXPRESSED IMPLIED, INCLUDING, LIMITED , IMPLIED WARRANTIES MERCHANTABILITY FITNESS PARTICULAR PURPOSE. ENTIRE RISK QUALITY PERFORMANCE PROGRAM . PROGRAM PROVE DEFECTIVE, ASSUME COST NECESSARY SERVICING, REPAIR CORRECTION.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_16-limitation-of-liability","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"16. Limitation of Liability","title":"GNU General Public License","text":"EVENT UNLESS REQUIRED APPLICABLE LAW AGREED WRITING COPYRIGHT HOLDER, PARTY MODIFIES /CONVEYS PROGRAM PERMITTED , LIABLE DAMAGES, INCLUDING GENERAL, SPECIAL, INCIDENTAL CONSEQUENTIAL DAMAGES ARISING USE INABILITY USE PROGRAM (INCLUDING LIMITED LOSS DATA DATA RENDERED INACCURATE LOSSES SUSTAINED THIRD PARTIES FAILURE PROGRAM OPERATE PROGRAMS), EVEN HOLDER PARTY ADVISED POSSIBILITY DAMAGES.","code":""},{"path":"https://simpar1471.github.io/openFDA/LICENSE.html","id":"id_17-interpretation-of-sections-15-and-16","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"17. Interpretation of Sections 15 and 16","title":"GNU General Public License","text":"disclaimer warranty limitation liability provided given local legal effect according terms, reviewing courts shall apply local law closely approximates absolute waiver civil liability connection Program, unless warranty assumption liability accompanies copy Program return fee. END TERMS CONDITIONS","code":""},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"the-openfda-api","dir":"Articles","previous_headings":"","what":"The openFDA API","title":"openFDA","text":"openFDA API makes public FDA data available simple, public API. Users API access FDA data food, human veterinary drugs, devices, . can read website.","code":""},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"a-simple-openfda-query","dir":"Articles","previous_headings":"","what":"A simple openFDA query","title":"openFDA","text":"simplest way query openFDA API identify endpoint want use provide search terms. example, snippet retrieves 1 record adverse events drugs endpoint. empty search string (\"\") means results non-specific.","code":"search <- openFDA(search = \"\", endpoint = \"drug-event\", limit = 1) search #> #> GET https://api.fda.gov/drug/event.json?api_key=[API_KEY]&search=&limit=1 #> Status: 200 OK #> Content-Type: application/json #> Body: In memory (1819 bytes)"},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"openfda-results","dir":"Articles","previous_headings":"A simple openFDA query","what":"openFDA results","title":"openFDA","text":"function returns httr2 response object, attached JSON data. use httr2::resp_body_json() extract underlying data. don’t specify field count , JSON data two sections - meta results.","code":"json <- httr2::resp_body_json(search)"},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"meta","dir":"Articles","previous_headings":"A simple openFDA query > openFDA results","what":"Meta","title":"openFDA","text":"meta section important metadata results, includes: disclaimer - important disclaimer regarding data provided openFDA. license - webpage license terms govern openFDA API. last_updated - last date openFDA endpoint updated. results.skip - many results skipped? Set skip parameter openFDA(). results.limit - many results retrieved? Set limit parameter openFDA(). results.total - many results total matching search criteria?","code":"json$meta #> $disclaimer #> [1] \"Do not rely on openFDA to make decisions regarding medical care. While we make every effort to ensure that data is accurate, you should assume all results are unvalidated. We may limit or otherwise restrict your access to the API in line with our Terms of Service.\" #> #> $terms #> [1] \"https://open.fda.gov/terms/\" #> #> $license #> [1] \"https://open.fda.gov/license/\" #> #> $last_updated #> [1] \"2024-07-30\" #> #> $results #> $results$skip #> [1] 0 #> #> $results$limit #> [1] 1 #> #> $results$total #> [1] 18029782"},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"results","dir":"Articles","previous_headings":"A simple openFDA query > openFDA results","what":"Results","title":"openFDA","text":"non-count queries, set records found endpoint match search term.","code":"json$results #> [[1]] #> [[1]]$safetyreportid #> [1] \"5801206-7\" #> #> [[1]]$transmissiondateformat #> [1] \"102\" #> #> [[1]]$transmissiondate #> [1] \"20090109\" #> ...."},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"results-when-count-ing","dir":"Articles","previous_headings":"A simple openFDA query > openFDA results","what":"Results when count-ing","title":"openFDA","text":"set count query, openFDA API return full records. Instead, count number records member openFDA field specified count. example, let’s look drug manufacturers Drugs@FDA endpoint \"paracetamol\". ’ll use limit parameter limit results first 3 drug manufacturers found. can count fields date create time series, demonstrated openFDA website.","code":"count <- openFDA(search = \"\", endpoint = \"drug-drugsfda\", limit = 3, count = \"openfda.manufacturer_name.exact\") |> httr2::resp_body_json() count$results #> [[1]] #> [[1]]$term #> [1] \"Aurobindo Pharma Limited\" #> #> [[1]]$count #> [1] 393 #> #> #> [[2]] #> [[2]]$term #> [1] \"Zydus Lifesciences Limited\" #> #> [[2]]$count #> [1] 326 #> #> #> [[3]] #> [[3]]$term #> [1] \"Hikma Pharmaceuticals USA Inc.\" #> #> [[3]]$count #> [1] 318"},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"using-search-terms","dir":"Articles","previous_headings":"","what":"Using search terms","title":"openFDA","text":"can increase complexity query using search parameter, lets us search specific openFDA API fields. fields harmonised different degrees API, need check online.","code":""},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"searching-on-one-field","dir":"Articles","previous_headings":"Using search terms","what":"Searching on one field","title":"openFDA","text":"can provide search strategies openFDA() single strings. constructed [FIELD_NAME]:[STRING], FIELD_NAME openFDA field want search . STRING contains spaces, must surround double quotes, openFDA search word string. , example, search drugs class \"thiazide diuretic” formatted \"openfda.pharm_class_epc:\\\"thiazide diuretic\\\"\", API collect drugs words \"thiazide\" \"diuretic\" established pharmacological class (EPC). Let’s unrefined search first: Let’s compare refined search, add double-quotes around search term: can see, unrefined search picked 93 results, probably non-thiazide diuretics.","code":"search_unrefined <- openFDA( search = \"openfda.pharm_class_epc:thiazide diuretic\", endpoint = \"drug-drugsfda\", limit = 1 ) httr2::resp_body_json(search_unrefined)$meta$results$total #> [1] 211 search_refined <- openFDA( search = \"openfda.pharm_class_epc:\\\"thiazide diuretic\\\"\", endpoint = \"drug-drugsfda\", limit = 1 ) httr2::resp_body_json(search_refined)$meta$results$total #> [1] 118"},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"searching-on-multiple-fields","dir":"Articles","previous_headings":"Using search terms","what":"Searching on multiple fields","title":"openFDA","text":"openFDA API lets search various fields . Simple methods implemented openFDA.","code":""},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"write-your-own-search-term","dir":"Articles","previous_headings":"Using search terms > Searching on multiple fields","what":"Write your own search term","title":"openFDA","text":"Using guides openFDA website, can put together query. example, following query looks 5 records submitted Walmart taken orally. can use purrr functions extract brand name record. Note though single record can multiple brand names, choosing extract first one.","code":"search_term <- \"openfda.manufacturer_name:Walmart+AND+openfda.route=oral\" search <- openFDA(search = search_term, limit = 5, endpoint = \"drug-drugsfda\") json <- httr2::resp_body_json(search) purrr::map(json$results, .f = \\(x) { purrr::pluck(x, \"openfda\", \"brand_name\", 1) }) #> [[1]] #> [1] \"FOSTER AND THRIVE NICOTINE\" #> #> [[2]] #> [1] \"COUNTERACT ALLERGY\" #> #> [[3]] #> [1] \"IBUPROFEN 200 MG AND DIPHENHYDRAMINE CITRATE 38 MG\" #> #> [[4]] #> [1] \"PURELAX\" #> #> [[5]] #> [1] \"OMEPRAZOLE\""},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"let-openfda-construct-the-search-term","dir":"Articles","previous_headings":"Using search terms > Searching on multiple fields","what":"Let openFDA() construct the search term","title":"openFDA","text":"can let package heavy lifting openFDA(), providing named character vector many field/search term pairs search parameter. function automatically add double quotes (\"\") around search terms, ’re providing field/value pairs like . can include many fields like, long provide field . default, terms combined operator openFDA(). search strategy therefore pick entries Drugs@FDA taken mouth.","code":"search <- openFDA(search = c(\"openfda.generic_name\" = \"amoxicillin\"), endpoint = \"drug-drugsfda\") httr2::resp_body_json(search)$meta$results$total #> [1] 58 search <- openFDA(search = c(\"openfda.generic_name\" = \"amoxicillin\", \"openfda.route\" = \"oral\"), endpoint = \"drug-drugsfda\", limit = 1) httr2::resp_body_json(search)$meta$results$total #> [1] 6929"},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"pre-construct-a-search-term","dir":"Articles","previous_headings":"Using search terms > Searching on multiple fields","what":"Pre-construct a search term","title":"openFDA","text":"apply multiple search terms operators, use format_search_term() mode = \"\":","code":"search_term <- format_search_term(c(\"openfda.generic_name\" = \"amoxicillin\", \"openfda.route\" = \"oral\"), mode = \"and\") search <- openFDA(search = search_term, endpoint = \"drug-drugsfda\", limit = 1) httr2::resp_body_json(search)$meta$results$total #> [1] 54"},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"wildcards","dir":"Articles","previous_headings":"Using search terms","what":"Wildcards","title":"openFDA","text":"can use wildcard character \"*\" match zero characters. example, take prototypical ending common drug class - e.g. sartans, angiotensin-II receptor blockers - see manufacturers represented Drugs@FDA class. using wildcards, either pre-format string without double-quotes use format_search_term() exact = FALSE. try search double-quotes wildcard character, get 404 error openFDA. looks like \"Alembic Pharmaceuticals\" active space - interesting!","code":"search_term <- format_search_term(c(\"openfda.generic_name\" = \"*sartan\"), exact = FALSE) search <- openFDA(search = search_term, count = \"openfda.manufacturer_name.exact\", endpoint = \"drug-drugsfda\", limit = 5) terms <- purrr::map( .x = httr2::resp_body_json(search)$results, .f = purrr::pluck(\"term\") ) counts <- purrr::map( .x = httr2::resp_body_json(search)$results, .f = purrr::pluck(\"count\") ) setNames(counts, terms) #> $`Alembic Pharmaceuticals Limited` #> [1] 14 #> #> $`Alembic Pharmaceuticals Inc.` #> [1] 13 #> #> $`Aurobindo Pharma Limited` #> [1] 13 #> #> $`Macleods Pharmaceuticals Limited` #> [1] 11 #> #> $`Zydus Lifesciences Limited` #> [1] 11"},{"path":"https://simpar1471.github.io/openFDA/articles/openFDA.html","id":"other-openfda-api-features","dir":"Articles","previous_headings":"","what":"Other openFDA API features","title":"openFDA","text":"short guide cover aspects openFDA. recommended go openFDA API website check resources see information : Date ands ranges Search fields missing values Generating time series Paging larger queries","code":""},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"setup","dir":"Articles","previous_headings":"","what":"Setup","title":"Extracting FDA data with BNF terms","text":"Let’s start loading package.","code":"library(openFDA)"},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"get-brand-names-and-epcs-from-generic-bnf-terms","dir":"Articles","previous_headings":"","what":"Get brand names and EPCs from generic BNF terms","title":"Extracting FDA data with BNF terms","text":"First, ’ll use openFDA() retrieve brand names drugs interested BNF. first initialise vector drug names BNF. can paste single search string, use search \"openfda.generic_name\" field Drugs@FDA endpoint.","code":"bnf <- c(\"captopril\", \"enalapril\", \"fosinopril\", \"imidapril\", \"lisinopril\", \"perindopril\", \"quinapril\", \"ramipril\", \"trandolapril\", \"amlodipine\", \"diltiazem\", \"felodipine\", \"lacidipine\", \"lercanidipine\", \"nicardipine\", \"nifedipine\", \"nimodipine\", \"verapamil\", \"azilsartan\", \"candesartan\", \"eprosartan\", \"irbesartan\", \"losartan\", \"olmesartan\", \"telmisartan\", \"valsartan\", \"bumetanide\", \"bendroflumethiazide\", \"chlortalidone\", \"hydrochlorothiazide\", \"indapamide\", \"atorvastatin\", \"fluvastatin\", \"pravastatin\", \"rosuvastatin\", \"simvastatin\", \"ezetimibe\", \"alirocumab\", \"evolocumab\", \"metformin\", \"gliclazide\", \"glimepiride\", \"tolbutamide\", \"glipizide\", \"alogliptin\", \"linagliptin\", \"saxagliptin\", \"sitagliptin\", \"vildagliptin\", \"canagliflozin\", \"dapagliflozin\", \"empagliflozin\", \"ertugliflozin\", \"dulaglutide\", \"exenatide\", \"liraglutide\", \"lixisenatide\", \"semaglutide\", \"pioglitazone\") bnf_search_term <- format_search_term( c(\"openfda.generic_name\" = paste0(bnf, collapse = \"+\")), exact = FALSE ) bnf_search <- openFDA(search = bnf_search_term, endpoint = \"drug-drugsfda\") bnf_search_json <- httr2::resp_body_json(bnf_search) # The JSON object contains information including the generic and brand names bnf_search_json$results[[1]][4][[1]][1:3] #> $application_number #> $application_number[[1]] #> [1] \"ANDA207807\" #> #> #> $brand_name #> $brand_name[[1]] #> [1] \"AMLODIPINE AND OLMESARTAN MEDOXOMIL\" #> #> #> $generic_name #> $generic_name[[1]] #> [1] \"AMLODIPINE AND OLMESARTAN MEDOXOMIL\""},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"extracting-openfda-fields-programmatically","dir":"Articles","previous_headings":"Get brand names and EPCs from generic BNF terms","what":"Extracting openFDA fields programmatically","title":"Extracting FDA data with BNF terms","text":"JSON data openFDA() useful, can easily parsed tools purrr vctrs. following function dips JSON data openFDA() pulls data specific fields. extracts occurrences data within requested field, condenses single character vector.","code":"#' Extract openFDA field data from openFDA JSON objects #' @param json #' @param openFDA_field A single string denoting an openFDA field to extract. #' Should be a valid field name, e.g. `\"openfda.generic_name\"` or #' `\"openfda.pharm_class_moa\"`. #' @returns A character vector with all unique values of `openfda_field` for #' your given search. extract_openFDA_field <- function(json, openfda_field) { json |> purrr::pluck(\"results\") |> purrr::map(.f = \\(x) purrr::pluck(x, \"openfda\", openfda_field)) |> vctrs::list_drop_empty() |> unlist() |> unique() }"},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"brand-names","dir":"Articles","previous_headings":"Get brand names and EPCs from generic BNF terms > Extracting openFDA fields programmatically","what":"Brand names","title":"Extracting FDA data with BNF terms","text":"Now function data extraction, can pull brand names associated generic drugs queried API .","code":"openFDA_brand_names <- extract_openFDA_field(bnf_search_json, \"brand_name\") print(openFDA_brand_names[25:30]) #> [1] \"AMLODIPINE AND VALSARTAN\" \"VALSARTAN\" #> [3] \"AVAPRO\" \"BYETTA\" #> [5] \"GLUCOTROL XL\" \"GLIPIZIDE XL\""},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"established-pharmacological-classes","dir":"Articles","previous_headings":"Get brand names and EPCs from generic BNF terms > Extracting openFDA fields programmatically","what":"Established pharmacological classes","title":"Extracting FDA data with BNF terms","text":"’ll also extract established pharmacological classes (EPCs) drugs. use EPCs query term , find generic drugs within BNF drug list.","code":"openfda_EPCs <- extract_openFDA_field(bnf_search_json, \"pharm_class_epc\") lengths(list(brand_names = openFDA_brand_names, EPCs = openfda_EPCs)) #> brand_names EPCs #> 175 21"},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"query-openfda-with-epcs","dir":"Articles","previous_headings":"","what":"Query openFDA with EPCs","title":"Extracting FDA data with BNF terms","text":"can use EPCs run queries openFDA API. removing \"[EPC]\" tags retrieved data, supplying search strategy.","code":"openfda_EPCs <- stringr::str_remove(openfda_EPCs, pattern = \" \\\\[.*\\\\]\") openfda_EPCs #> [1] \"Thiazide Diuretic\" #> [2] \"Dihydropyridine Calcium Channel Blocker\" #> [3] \"Angiotensin 2 Receptor Blocker\" #> [4] \"Angiotensin Converting Enzyme Inhibitor\" #> [5] \"Peroxisome Proliferator Receptor alpha Agonist\" #> [6] \"Peroxisome Proliferator Receptor gamma Agonist\" #> [7] \"Thiazolidinedione\" #> [8] \"Thiazide-like Diuretic\" #> [9] \"Potassium-sparing Diuretic\" #> [10] \"Sulfonylurea\" #> [11] \"HMG-CoA Reductase Inhibitor\" #> [12] \"GLP-1 Receptor Agonist\" #> [13] \"Dipeptidyl Peptidase 4 Inhibitor\" #> [14] \"Calcium Channel Blocker\" #> [15] \"Aldosterone Antagonist\" #> [16] \"Sodium-Glucose Cotransporter 2 Inhibitor\" #> [17] \"Dietary Cholesterol Absorption Inhibitor\" #> [18] \"Insulin Analog\" #> [19] \"Loop Diuretic\" #> [20] \"PCSK9 Inhibitor\" #> [21] \"Adenosine Triphosphate-Citrate Lyase Inhibitor\""},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"query-openfda-with-our-epcs","dir":"Articles","previous_headings":"Query openFDA with EPCs","what":"Query openFDA with our EPCs","title":"Extracting FDA data with BNF terms","text":"supplying strings search terms openFDA, surround double-quotation marks (\"). ensures openFDA considers term single string, instead set strings. Without quotes, term \"Thiazide Diuretic\" treated search drugs either “Thiazide” “Diuretic” EPC, instead search specifically thiazide diuretics.","code":"epc_search <- purrr::map( .x = openfda_EPCs, .f = \\(epc) { openFDA(search = c(\"openfda.pharm_class_epc\" = epc), endpoint = \"drug-drugsfda\") |> httr2::resp_body_json() }) epc_generics <- purrr::map( .x = epc_search, .f = \\(json) extract_openFDA_field(json, openfda_field = \"generic_name\")) |> purrr::flatten_chr() |> unique()"},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"compare-new-generic-names-to-bnf-terms","dir":"Articles","previous_headings":"Query openFDA with EPCs > Query openFDA with our EPCs","what":"Compare new generic names to BNF terms","title":"Extracting FDA data with BNF terms","text":"Using pattern matching, can see new generic drug terms retrieved searching EPCs. drugs, following interest: can use generic names interest get even brand names:","code":"bnf_regex <- paste0(\"(\", paste0(bnf, collapse = \"|\"), \")\") epc_generics |> tolower() |> grep(pattern = bnf_regex, value = TRUE, invert = TRUE) #> [1] \"chlorothiazide\" \"nisoldipine\" #> [3] \"clevidipine\" \"clevipidine\" #> [5] \"isradipine\" \"sparsentan\" #> [7] \"fenofibrate\" \"gemfibrozil\" #> [9] \"fenofibric acid\" \"chlorthalidone\" #> [11] \"atenolol and chlorthalidone\" \"metolazone\" #> [13] \"atenolol and chlorthalidone tablet\" \"triamterene\" #> [15] \"triamterene capsules\" \"glyburide\" #> [17] \"lovastatin\" \"pitavastatin magnesium\" #> [19] \"pitavastatin\" \"tirzepatide\" #> [21] \"eplerenone\" \"spironolactone\" #> [23] \"carospir\" \"sotagliflozin\" #> [25] \"bexagliflozin\" \"insulin aspart\" #> [27] \"insulin lispro-aabc\" \"insulin detemir\" #> [29] \"insulin lispro\" \"insulin aspart injection\" #> [31] \"insulin glulisine\" \"insulin glargine-yfgn\" #> [33] \"insulin degludec\" \"insulin glargine-aglr\" #> [35] \"water injection\" \"insulin glargine\" #> [37] \"furosemide injection 80 mg/ 10 ml\" \"furosemide\" #> [39] \"torsemide\" \"ethacrynic acid\" #> [41] \"bempedoic acid\" fda_generics <- c(\"pitavastatin\", \"lovastatin\", \"chlorothiazide\", \"sparsentan\", \"nisoldipine\", \"isradipine\", \"clevidipine\", \"glyburide\", \"glibenclamide\", \"tirzepatide\", \"bexagliflozin\", \"sotagliflozin\", \"chlorthalidone\", \"metolazone\", \"spironolactone\", \"eplerenone\", \"bempedoic acid\", \"fenofibrate\", \"fenofibric acid\", \"gemfibrozil\") more_brand_names <- purrr::map( .x = fda_generics, .f = \\(generic) { openFDA(c(\"openfda.generic_name\" = paste0(\"\\\"\", generic, \"\\\"\"))) |> httr2::resp_body_json() |> extract_openFDA_field(openfda_field = \"brand_name\") |> tolower() } ) |> setNames(fda_generics) #> Warning in openFDA(c(openfda.generic_name = paste0(\"\\\"\", generic, \"\\\"\"))): The openFDA API returned a 404 error. #> ! This indicates that openFDA had no results to return. #> This can be due to: #> • A restrictive search term. Yours was #> \"openfda.generic_name:\\\"\\\"glibenclamide\\\"\\\"\". more_brand_names[1:3] #> $pitavastatin #> [1] \"pitavastatin\" \"pitavastatin calcium\" \"livalo\" #> [4] \"zypitamag\" \"nikita\" #> #> $lovastatin #> [1] \"lovastatin\" \"altoprev\" #> #> $chlorothiazide #> [1] \"diuril\" \"chlorothiazide sodium\" \"chlorothiazide\""},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"queries-about-angplt3-inhibitors","dir":"Articles","previous_headings":"","what":"Queries about ANGPLT3 inhibitors","title":"Extracting FDA data with BNF terms","text":"Finally, let’s collect data angiopoietin-like 3 (ANGPLT3) inhibitors, can used familial homozygous hypercholesteremia UK US.","code":"evinacumab_search <- openFDA(search = c(\"openfda.generic_name\" = \"evinacumab\"), endpoint = \"drug-drugsfda\") evinacumab_epc <- evinacumab_search |> httr2::resp_body_json() |> extract_openFDA_field(\"pharm_class_epc\") |> stringr::str_remove(pattern = \" \\\\[.*\\\\]\") agplt3_inhibitors_search <- openFDA( search = c(\"openfda.pharm_class_epc\" = evinacumab_epc), endpoint = \"drug-drugsfda\" ) agplt3_inhibitors_brands <- agplt3_inhibitors_search |> httr2::resp_body_json() |> extract_openFDA_field(\"brand_name\") agplt3_inhibitors_generics <- agplt3_inhibitors_search |> httr2::resp_body_json() |> extract_openFDA_field(\"generic_name\") c(\"AGPLT3-I brands\" = agplt3_inhibitors_brands, \"AGPLT3-I generics\" = agplt3_inhibitors_generics) #> AGPLT3-I brands AGPLT3-I generics #> \"EVKEEZA\" \"EVINACUMAB\""},{"path":"https://simpar1471.github.io/openFDA/articles/using_openFDA.html","id":"session-info","dir":"Articles","previous_headings":"Queries about ANGPLT3 inhibitors","what":"Session info","title":"Extracting FDA data with BNF terms","text":"","code":"sessionInfo() #> R version 4.4.1 (2024-06-14) #> Platform: x86_64-pc-linux-gnu #> Running under: Ubuntu 22.04.5 LTS #> #> Matrix products: default #> BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 #> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0 #> #> locale: #> [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 #> [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 #> [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C #> [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C #> #> time zone: UTC #> tzcode source: system (glibc) #> #> attached base packages: #> [1] stats graphics grDevices utils datasets methods base #> #> other attached packages: #> [1] openFDA_0.0.0.9000 #> #> loaded via a namespace (and not attached): #> [1] vctrs_0.6.5 cli_3.6.3 knitr_1.48 rlang_1.1.4 #> [5] xfun_0.48 stringi_1.8.4 purrr_1.0.2 textshaping_0.4.0 #> [9] jsonlite_1.8.9 glue_1.8.0 backports_1.5.0 htmltools_0.5.8.1 #> [13] ragg_1.3.3 sass_0.4.9 rappdirs_0.3.3 rmarkdown_2.28 #> [17] evaluate_1.0.1 jquerylib_0.1.4 fastmap_1.2.0 yaml_2.3.10 #> [21] lifecycle_1.0.4 httr2_1.0.5 stringr_1.5.1 compiler_4.4.1 #> [25] fs_1.6.4 systemfonts_1.1.0 digest_0.6.37 R6_2.5.1 #> [29] curl_5.2.3 magrittr_2.0.3 bslib_0.8.0 checkmate_2.3.2 #> [33] tools_4.4.1 pkgdown_2.1.1 cachem_1.1.0 desc_1.4.3"},{"path":"https://simpar1471.github.io/openFDA/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Simon Parker. Author, maintainer, copyright holder.","code":""},{"path":"https://simpar1471.github.io/openFDA/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Parker S (2024). openFDA: 'openFDA' API. R package version 0.0.0.9000, https://simpar1471.github.io/openFDA/, https://github.com/simpar1471/openFDA.","code":"@Manual{, title = {openFDA: 'openFDA' API}, author = {Simon Parker}, year = {2024}, note = {R package version 0.0.0.9000, https://simpar1471.github.io/openFDA/}, url = {https://github.com/simpar1471/openFDA}, }"},{"path":"https://simpar1471.github.io/openFDA/index.html","id":"openfda","dir":"","previous_headings":"","what":"openFDA API","title":"openFDA API","text":"openFDA makes querying openFDA API R breeze. API serves publicly available data FDA foods, drugs, devices, . data includes data recall enforcement reports, adverse events, manufacturer details, - - even ! Note data openFDA validated clinical production use.","code":""},{"path":"https://simpar1471.github.io/openFDA/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"openFDA API","text":"can install development version openFDA GitHub using either pak devtools:","code":"# install.packages(\"pak\") pak::pkg_install(\"simpar1471/openFDA\") # install.packages(\"devtools\") devtools::install_github(\"simpar1471/openFDA\")"},{"path":"https://simpar1471.github.io/openFDA/index.html","id":"using-openfda","dir":"","previous_headings":"","what":"Using openFDA","title":"openFDA API","text":"full documentation API online, look openFDA website get full feel API . R package lets query API directly R, using httr2. underlying response JSON data - can use httr2::resp_body_json() get JSON data nested list, extract fields want. ’ve found purrr useful parsing data quickly.","code":"library(openFDA) search <- openFDA( search = \"openfda.generic_name:furosemide\", limit = 5 ) search #> #> GET #> https://api.fda.gov/drug/drugsfda.json?api_key=[API_KEY]&search=openfda.generic_name:furosemide&limit=5 #> Status: 200 OK #> Content-Type: application/json #> Body: In memory (17286 bytes) json <- httr2::resp_body_json(search) json$results[[1]]$openfda$brand_name #> [[1]] #> [1] \"FUROSEMIDE\" json$results[[1]]$openfda$pharm_class_epc #> [[1]] #> [1] \"Loop Diuretic [EPC]\" purrr::map_chr( .x = json$results, .f = \\(result) purrr::pluck(result, \"openfda\", \"manufacturer_name\", 1) ) #> [1] \"Amneal Pharmaceuticals LLC\" \"Gland Pharma Limited\" #> [3] \"Solco Healthcare LLC\" \"Lifestar Pharma LLC\" #> [5] \"Ipca Laboratories Limited\""},{"path":"https://simpar1471.github.io/openFDA/index.html","id":"other-r-packages-for-openfda","dir":"","previous_headings":"","what":"Other R packages for openFDA","title":"openFDA API","text":"openfda package rOpenHealth also wraps openFDA API R, available GitHub. ’s got pretty neat structure whereby build query using individual functions parameter - though ’s personal preference keep parameters single function. also makes results available data frames, nice, think working response object parsing underlying JSON permits powerful interactions API. also FDAopenR, couldn’t quite wrap head around. package appears working order, though!","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/api_key.html","id":null,"dir":"Reference","previous_headings":"","what":"Get and set your openFDA API keys — set_api_key","title":"Get and set your openFDA API keys — set_api_key","text":"Get set openFDA API keys","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/api_key.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get and set your openFDA API keys — set_api_key","text":"","code":"set_api_key(api_key) get_api_key()"},{"path":"https://simpar1471.github.io/openFDA/reference/api_key.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get and set your openFDA API keys — set_api_key","text":"api_key single-length character vector openFDA API key. can generate API key FDA website.","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/api_key.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get and set your openFDA API keys — set_api_key","text":"single length character vector API key. set_api_key(), returned invisibly. get_api_key(), error thrown key set.","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/api_key.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Get and set your openFDA API keys — set_api_key","text":"permanently set API key given project, set OPENFDA_TOKEN .Renviron.","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/api_key.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get and set your openFDA API keys — set_api_key","text":"","code":"# Set your openFDA API key with `set_api_key()` api_key <- \"example_api_key\" set_api_key(api_key) # Retrieve it with `get_api_key()` get_api_key() #> [1] \"example_api_key\" # An error will be thrown if your API key is an empty string. set_api_key(\"\") try(get_api_key()) #> Error in get_api_key() : #> To use openFDA, you must set an openFDA API key. #> ℹ Go to to get an openFDA API key, #> then supply it to `set_api_key()` to cache it for use in this session."},{"path":"https://simpar1471.github.io/openFDA/reference/format_search_term.html","id":null,"dir":"Reference","previous_headings":"","what":"Format character vectors into search terms for openFDA API queries — format_search_term","title":"Format character vectors into search terms for openFDA API queries — format_search_term","text":"function helper constructing search queries. Whilst handles available formatting openFDA APIs, recapture search term syntax available . get full appreciation openFDA search syntax, see https://open.fda.gov/apis/advanced-syntax/.","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/format_search_term.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format character vectors into search terms for openFDA API queries — format_search_term","text":"","code":"format_search_term(search, exact = TRUE, mode = \"or\")"},{"path":"https://simpar1471.github.io/openFDA/reference/format_search_term.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format character vectors into search terms for openFDA API queries — format_search_term","text":"search character vector length 1 . scalar unnamed, assumed already formatted search string work API. named, vector collapsed include various search terms, separated terms based value operator. exact single-length logical vector. TRUE (default), individual search terms surrounded double quotes (\"\"). Set exact FALSE search term contains multiple words searched , e.g. c(\"openfda.generic_name\" = \"losartan+candesartan\"). parameter applies search named character vector. mode single-length character vector, defines searches multiple fields combined. default (\"\") combined '' operator, can make '' operator used instead (\"\"). argument case-sensitive throw error mode one either \"\" \"\". parameter applies search named character vector.","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/format_search_term.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format character vectors into search terms for openFDA API queries — format_search_term","text":"character vector S3 class , formatted search term can supplied openFDA().","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/format_search_term.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Format character vectors into search terms for openFDA API queries — format_search_term","text":"function check providing accurate field names search terms. make sure provided correctly spelt fields search terms.","code":""},{"path":[]},{"path":"https://simpar1471.github.io/openFDA/reference/format_search_term.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format character vectors into search terms for openFDA API queries — format_search_term","text":"","code":"# Provide a formatted search string and the function will do no formatting format_search_term(\"openfda.generic_name:verapamil\") #> [1] \"openfda.generic_name:verapamil\" # Provide a named vector and the function will format it for you format_search_term(c(\"openfda.generic_name\" = \"verapamil\")) #> [1] \"openfda.generic_name:%22verapamil%22\" # If providing multiple elements in your search term, use `exact = FALSE` # to prevent the function from surrounding the term with double quotes. format_search_term(c(\"openfda.generic_name\" = \"verapamil+amlodipine\"), exact = FALSE) #> [1] \"openfda.generic_name:verapamil+amlodipine\" # Provide a longer named vector and function will merge these with an OR # operator format_search_term(c(\"openfda.generic_name\" = \"verapamil\", \"openfda.manufacturer_name\" = \"glaxo*\")) #> [1] \"openfda.generic_name:%22verapamil%22+openfda.manufacturer_name:%22glaxo%2A%22\" # Or you can set the `mode` argument to merge your search terms with an AND # operator format_search_term(c(\"openfda.generic_name\" = \"verapamil\", \"openfda.manufacturer_name\" = \"glaxo*\"), mode = \"and\") #> [1] \"openfda.generic_name:%22verapamil%22+AND+openfda.manufacturer_name:%22glaxo%2A%22\""},{"path":"https://simpar1471.github.io/openFDA/reference/format_sort_term.html","id":null,"dir":"Reference","previous_headings":"","what":"Format character vectors into sort terms for openFDA API queries — format_sort_term","title":"Format character vectors into sort terms for openFDA API queries — format_sort_term","text":"function acts helper constructing sort term openFDA API.","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/format_sort_term.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format character vectors into sort terms for openFDA API queries — format_sort_term","text":"","code":"format_sort_term(sort)"},{"path":"https://simpar1471.github.io/openFDA/reference/format_sort_term.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format character vectors into sort terms for openFDA API queries — format_sort_term","text":"sort single-length character vector length 1. unnamed, assumed already formatted search string work API. named, vector collapsed include field sorting choice.","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/format_sort_term.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format character vectors into sort terms for openFDA API queries — format_sort_term","text":"character vector S3 class , formatted search term can supplied openFDA().","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/format_sort_term.html","id":"note","dir":"Reference","previous_headings":"","what":"Note","title":"Format character vectors into sort terms for openFDA API queries — format_sort_term","text":"function check providing accurate field names search terms. make sure provided correctly spelt fields search terms.","code":""},{"path":[]},{"path":"https://simpar1471.github.io/openFDA/reference/format_sort_term.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format character vectors into sort terms for openFDA API queries — format_sort_term","text":"","code":"# Provide a formatted search string and the function will do no formatting format_sort_term(\"openfda.generic_name:asc\") #> [1] \"openfda.generic_name:asc\" # Provide a named vector and the function will format it for you format_sort_term(c(\"openfda.generic_name\" = \"asc\")) #> [1] \"openfda.generic_name:asc\" # Errors will be thrown if you supply a bad input try(format_sort_term(\"receivedate:no_order\")) #> Error in format_sort_term(\"receivedate:no_order\") : #> `sort` must end with either \"asc\" or \"desc\". #> ! `sort` was \"receivedate:no_order\". try(format_sort_term(c(\"receivedate\" = \"ascending\"))) #> Error in format_sort_term(c(receivedate = \"ascending\")) : #> `sort` must be either \"asc\" or \"desc\". #> ! `sort` was \"ascending\"."},{"path":"https://simpar1471.github.io/openFDA/reference/openFDA.html","id":null,"dir":"Reference","previous_headings":"","what":"Send requests to the openFDA API — openFDA","title":"Send requests to the openFDA API — openFDA","text":"Send requests openFDA API","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/openFDA.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Send requests to the openFDA API — openFDA","text":"","code":"openFDA( search = \"\", sort = NULL, count = NULL, limit = 1000, skip = NULL, endpoint = \"drug-drugsfda\", api_key = get_api_key(), warn_on_http_error = TRUE )"},{"path":"https://simpar1471.github.io/openFDA/reference/openFDA.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Send requests to the openFDA API — openFDA","text":"search character vector passed format_search_term(). search \"\" (default), openFDA retrieve records filtering. error thrown elements search missing (NA). sort single string scalar named character vector describing sort results. sort term either formatted \"[FIELD]:[asc/desc]\", c(\"[FIELD]\" = \"[asc/desc]\"). example, sort results Drugs@FDA endpoint ascending submission status dates. values \"asc\", \"desc\" supplied, function throw error. count single string denoting field count results. NULL (default), results returned full user. Specify parameter want count occurrences results within search term - go https://open.fda.gov/apis/query-syntax/ information. limit single integerish value describing limit number records retrieve. error thrown limit 1000 (default). skip single integer describing many records skipped. records skipped found search, openFDA API return 404 error. endpoint single-length character vector describing openFDA endpoint target. \"animal-event\": Adverse event reports animal/veterinary drugs. \"drug-event\": Adverse event reports FDA Adverse Event Reporting System \"drug-label\": Drug documentation Structured Product Labeling (SPL) format. \"drug-ndc\": Data National Drug Code Directory (NDC). \"drug-enforcement\": Data FDA Recall Enterprise System drug products. \"drug-drugsfda\": Data products approved human use FDA since 1939, mostly complete data 1998. \"device-510k\": Data 510(k) submissions FDA regarding medical devices. \"device-classification\": Data FDA Product Classification Database medical devices. \"device-enforcement\": Data FDA Recall Enterprise System (RES) medical devices. \"device-event\": Data adverse events associated FDA-approved medical devices. \"device-pma\": Pre-market approval data medical devices submitted FDA. \"device-recall\": Data product recalls medical devices violate FDA law. \"device-reglist\": Data FDA Device Registrations Listings. \"device-covid19serology\": Data independent evaluations COVID-19 serological tests. \"device-udi\": Data FDA's Global Unique Device Identification Database (GUDID). \"food-enforcement\": Data FDA Recall Enterprise System food products. \"food-event\": Data Center Food Safety Applied Nutrition Adverse Event Reporting System. \"-historicaldocument\": majority FDA Press Releases, 1913 2014. \"-nsde\": Data National Drug Code Structured Product Labeling Data Elements. \"-substance\": Data regarding substances - individual molecules, proteins, nucleic acids, . \"-unii\": Data FDA's Global Substance Registration System. \"tobacco-problem\": Data problems (e.g. damage, defects, contamination, bad smell) tobacco products. argument case-sensitive. default, package target Drugs@FDA endpoint (\"drugs-drugsfda\"). api_key single-length character vector openFDA API key. default result get_api_key(). api_key empty string, error thrown. warn_on_http_error scalar logical value. TRUE (default), common openFDA HTTP errors cause explanatory warnings printed FALSE, underlying httr2 response object returned extra warnings.","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/openFDA.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Send requests to the openFDA API — openFDA","text":"httr2 response object httr2::req_perform(). can use httr2::resp_body_json() extract JSON data response.","code":""},{"path":"https://simpar1471.github.io/openFDA/reference/openFDA.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Send requests to the openFDA API — openFDA","text":"Kass-Hout TA, Xu Z, Mohebbi M, Nelsen H, Baker , LEvine J, Johansen E, Bright RA. OpenFDA: innovative platform providing access wealth FDA's publicly available data J Med Inform Assoc 2016, 23(3):596-600. doi:10.1093/jamia/ocv153","code":""},{"path":[]},{"path":"https://simpar1471.github.io/openFDA/reference/openFDA.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Send requests to the openFDA API — openFDA","text":"","code":"if (httr2::secret_has_key(\"OPENFDA_KEY\")) { set_api_key(httr2::secret_decrypt( \"TEaDtqdFMq9_Montij5p9IY6T57IyqkbF8IYFVOpk-ttxotFUNdJSxgccAnkq4nQhplaf-r3deQ\", \"OPENFDA_KEY\" )) resp <- openFDA(search = \"openfda.manufacturer_name:gilead*\", limit = 2, skip = 10) # The function returns an `httr2` object print(resp) } #> #> GET #> https://api.fda.gov/drug/drugsfda.json?api_key=[API_KEY]&search=openfda.manufacturer_name:gilead%2A&limit=2&skip=10 #> Status: 200 OK #> Content-Type: application/json #> Body: In memory (29747 bytes) # Bad inputs will cause informative errors - here, a bad API key is supplied try( openFDA(search = \"openfda.manufacturer_name:gilead*\", api_key = \"BAD_API_KEY\", limit = 1) ) #> Warning: The openFDA API returned a 403 error. #> ! This usually means that an invalid `api_key` was used. #> ℹ Your API key was \"BAD_API_KEY\". #> #> GET #> https://api.fda.gov/drug/drugsfda.json?api_key=[API_KEY]&search=openfda.manufacturer_name:gilead%2A&limit=1 #> Status: 403 Forbidden #> Content-Type: application/json #> Body: In memory (136 bytes)"},{"path":"https://simpar1471.github.io/openFDA/news/index.html","id":"openfda-010","dir":"Changelog","previous_headings":"","what":"openFDA 0.1.0","title":"openFDA 0.1.0","text":"openFDA() run queries openFDA API. format_search_term() format_sort_term() help construct openFDA() query components. set_api_key() get_api_key() working openFDA API keys. Initial CRAN submission.","code":""}]