Package: pharmpy
pharmpypharmpyis an umbrella Python library for searching the FDA NDC directory, Established Pharmacologic Class (EPC), Anatomical Therapeutic Chemical (ATC) through RxNav, and some other APIs on RxNav.InstallingInstalling from the source:$ git clone git@github.com:yubin-park/pharmpy.git
$ cd pharmpy
$ python setup.py developOr, simply usingpip:$ pip install pharmpyA NOTE for the users who want to use RxNav functions such as ATC and Drug Interactions. For those, we strongly recommend using theRxNav-in-a-Boxrather than the RxNav REST APIs.
The RxNav-in-a-Box is aDockerconatiner image that installs on your local machine.
To use the image, please follow the set-up instructions, which are available inside thedownloadable zip file, and carefully read theUMLS license agreement.
If you decide to use the RxNAV REST APis, you should control the rate limit (20 calls per second) by yourself.
Thispharmpymodule does not control the rate limit by itself.File Structurepharmpy/: The package source code is located here.data/: The raw data files downloaded fromthe FDA website. If you are using the RxNav functions and data, the caches of the query results will be stored in this folder as well.epc.py: Established Pharmacologic Class (EPC) engine from the FDA websiterxcui.py: A RxNorm Concept Unique Identifier (RxCUI) module that maps from NDC to RxCUI. [Dependancy: RxNav]atc.py: A mapping from NDCs to Level-4 Anatomical Therapeutic Chemical (ATC). [Dependency: RxNav]druginter.py: A mapping from a list of NDCs to a potential drug-drug interactions. [Dependency: RxNav]utils.py: A module for readings data filestests/: test scripts to check the validity of the outputs.LICENSE.txt: Apache 2.0.README.md: This README file.setup.py: a set-up script.Code Examplespharmpyis really simple to use.
Please see some examples below.
NOTE that all functions used below have docstrings.
If you want to see the input parameter specifications,
please typeprint(<instance>.<function>.__doc__).Using EPC>>>frompharmpy.epcimportEPCEngine>>>epe=EPCEngine()>>>res=epe.get_epc("50090347201")>>>importjson>>>print(json.dumps(res,indent=2)){"ndc":"50090-3472","name_proprietary":"JANUVIA","name_generic":"sitagliptin","substance_lst":["SITAGLIPTIN PHOSPHATE"],"pc_lst":["Dipeptidyl Peptidase 4 Inhibitor [EPC]","Dipeptidyl Peptidase 4 Inhibitors [MoA]"]}>>>Using RxCUI>>>frompharmpy.rxcuiimportRxCUIEngine>>>rce=RxCUIEngine()>>>res=rce.get_rxcui("50090347201")>>>print(json.dumps(res,indent=2))"665044">>>Using ATC>>>frompharmpy.atcimportATCEngine>>>ae=ATCEngine()>>>res=ae.get_atc("50090347201")>>>print(json.dumps(res,indent=2))[{"id":"A10BH","name":"Dipeptidyl peptidase 4 (DPP-4) inhibitors"}]>>>Using DrugInter>>>frompharmpy.druginterimportDrugInterEngine>>>dre=DrugInterEngine()>>>res=dre.get_interactions_from_rxcui(["88014","8123"])>>>print(json.dumps(res,indent=2))[{"pair":["8123","88014"],"desc":["[ONCHigh] Triptans - monoamine oxidase (MAO) inhibitors"]}]>>>Warming-up CachesFor the RxNav functions,pharmpykeeps cache, so that you do not need to query again for the same results.
For most use cases, we recommend you warm up the cache before using any of the RxNav functions.
The warm-up process goes through a comprehensive list of NDCs, and store all results into a local drive.
The total process takes up about 6 hours, however, you would rarely need to query new results after warming up the cache.RxCUI Cache Warm-up>>frompharmpy.rxcuiimportRxCUIEngine>>rce=RxCUIEngine()>>rce.run_cache()# this takes about 2-3 hours using RxNav-in-a-BoxATC Cache Warm-upfrompharmpy.atcimportATCEngineae=ATCEngine()ae.run_cache()# takes about 10-20 minutes using RxNav-in-a-BoxDrugInter Cache Warm-upfrompharmpy.druginterimportDrugInterEnginedre=DrugInterEngine()dre.run_cache()# takes about 2 hours using RxNav-in-a-BoxThe caches are stored in a local drive indefinitely.
Thus, you just need to run these warm-up scripts periodically whenever you update the RxNav-in-a-Box monthly images.Please refer to the test scripts under thetests/folder if you want to see other example use cases.LicenseApache 2.0AuthorsYubin Park, PhDReferenceshttps://open.fda.gov/data/ndc/https://www.accessdata.fda.gov/cder/ndctext.ziphttps://www.fda.gov/drugs/drug-approvals-and-databases/ndc-product-file-definitionshttps://rxnav.nlm.nih.gov/RxNav-in-a-Box.htmlhttps://mor.nlm.nih.gov/pubs/pdf/2018-amia-lp-poster.pdfhttps://rxnav.nlm.nih.gov/APIsOverview.html