The ingredient_2_meds.py python script will find all of the medications related to a list of ingredients.
The input to this script is a list of ingredient RXNorm CUIs provided by the user. The script uses an RXNav REST API (/rxcui/{rxcui}/related) to find related medications and output these medication names and RXNorm CUIs. The strength and unit will also be parsed from the medication name and output. If an MME factor is provided in the ingredient input file, that will be assigned to the related medications.
More information on the RXNav API can be found here: RxNav API documentation
The input to the script is a CSV file containing base ingredients. The input file must be in the following format:
Column Heading | Field Description | required or optional |
---|---|---|
INGREDIENT_RXNORM_CUI | The RxNorm CUI of the ingredient | required |
INGREDIENT_NAME | The ingredient name | required |
MME_FACTOR | The MME factor of the ingredient, for opioids | optional |
Example:
INGREDIENT_RXNORM_CUI,INGREDIENT_NAME,MME_FACTOR
480,ALFENTANIL,
1819,BUPRENORPHINE,
1841,BUTORPHANOL,7
2670,CODEINE,0.15
23088,DIHYDROCODEINE,0.25
Values for opioids below, also in repo file: ingredients.csv
INGREDIENT_RXNORM_CUI | INGREDIENT_NAME | MME_FACTOR |
---|---|---|
480 | ALFENTANIL | |
1819 | BUPRENORPHINE | |
1841 | BUTORPHANOL | 7 |
2670 | CODEINE | 0.15 |
23088 | DIHYDROCODEINE | 0.25 |
4337 | FENTANYL | |
5489 | HYDROCODONE | 1 |
3423 | HYDROMORPHONE | 4 |
237005 | LEVOMETHADYL ACETATE | |
6378 | LEVORPHANOL TARTRATE | 11 |
6754 | MEPERIDINE | 0.1 |
6813 | METHADONE | |
7052 | MORPHINE | 1 |
477468 | MORPHINE LIPOSOMAL | |
7238 | NALBUPHINE | |
7676 | OPIUM | 1 |
7804 | OXYCODONE | 1.5 |
7814 | OXYMORPHONE | 3 |
8001 | PENTAZOCINE | 0.37 |
8785 | PROPOXYPHENE | |
73032 | REMIFENTANIL | |
56795 | SUFENTANIL | |
787390 | TAPENTADOL | 0.4 |
10689 | TRAMADOL | 0.1 |
Column Heading | Field Description |
---|---|
INGREDIENT_RXNORM_CUI | Input ingredient RXNorm CUI |
INGREDIENT_NAME | Input ingredient name |
TTY | Related medication RXNorm Term Type |
RXNORM_CUI | Related medication RXNorm CUI |
NAME | Related medication name |
INGREDIENT_STRENGTH | Related medication strength (if available in name) |
UNIT | Related medication unit (if available in name) |
MME_FACTOR | Related medication MME factor (if provided for the base ingredient in the input file) |
This script was tested with python 3.7
For instructions:
python ingredient_2_meds.py –h
To run:
python ingredient_2_meds.py –input <CSV input file name> --output <CSV output file name>