This package provides tools for standardizing drug names into a single format. For example; Benadryl and diphenhydramine refer to the same chemical entity. In certain tasks, such as mining the FDA Adverse Event Reporting System database, it is useful to standardize all drug names (i.e. convert all instances of Benadryl to diphenhydramine) in order to compute various statistics. This package uses a database of drug synonyms and brand names to return the generic name for a drug. To handle misspellings the standardize function will return the generic name for the most similar match based on Jaro-Winkler similarity. A threshold can be set in order to specify the minimal similarity required to be considered a match.
sudo pip install drugstandards
# Download this github repository and enter the following
cd drugstandards
sudo python setup.py install
import drugstandards as drugs
# Note that this function is NOT case-sensitive.
drugs.standardize(["lopressor"])
drugs.standardize(["Benadryl"])
drugs.standardize(["Benadril", "lopresor"])
# Will return None if no match is found.
drugs.standardize(["Benadril"], thresh=0.9)
# If a mapping does not exist you may create your own by updating the drug-dictionary.
# For example, we may be interested in mapping the term "MULTI-VITAMIN" to "VITAMIN"
drugs.add_drug_mapping({"MULTI-VITAMIN":"VITAMIN"})
# We can also create many updates simultaneously
drugs.add_drug_mapping({"MULTI-VITAMIN":"VITAMIN", "TYLENOL EXTRA STRENGTH": "ACETAMINOPHEN"})