This API exposes a system for extracting Adverse Drug Reaction (ADR) spans from user generated texts like tweets from Twitter or posts in Reddit. The project uses off-the-shelf named entity recognition (NER) and classification tools to accomplish the above tasks.
DRIP provides one service through a POST request. The parameters, is a list of keywords with the following JSON format:
[{
"id_str": "01",
"text": "I take Seroquel every morning and afternoon and during evenings i have a back ache."
},
{
"id_str": "02",
"text": "I've been on percocet for my withdrawls since beggining of the year."
},
{
"id_str": "03",
"text": "Humira helps me with the pain so that I can exercise again. It does not help with the fatigue."
}]
If the process is successful, DRIP service will return a JSON with the following format:
[
{
"id_str": "01",
"spans": [
{
"confidence": 0.99,
"end_pos": 15,
"meddra": [],
"start_pos": 7,
"text": "Seroquel",
"type": "Drug"
},
{
"confidence": 0.6,
"end_pos": 82,
"meddra": [
{
"probability": 1.0,
"pt": "Back pain",
"ptid": "10003988"
}
],
"start_pos": 73,
"text": "back ache",
"type": "ADR"
}
],
"text": "I take Seroquel every morning and afternoon and during evenings i have a back ache."
},
{
"id_str": "02",
"spans": [
{
"confidence": 1.0,
"end_pos": 21,
"meddra": [],
"start_pos": 13,
"text": "percocet",
"type": "Drug"
},
{
"confidence": 0.57,
"end_pos": 39,
"meddra": [
{
"probability": 1.0,
"pt": "Withdrawal syndrome",
"ptid": "10048010"
}
],
"start_pos": 29,
"text": "withdrawls",
"type": "ADR"
}
],
"text": "I've been on percocet for my withdrawls since beggining of the year."
},
{
"id_str": "03",
"spans": [
{
"confidence": 1.0,
"end_pos": 6,
"meddra": [],
"start_pos": 0,
"text": "Humira",
"type": "Drug"
},
{
"confidence": 1.0,
"end_pos": 29,
"meddra": [
{
"probability": 1.0,
"pt": "Pain",
"ptid": "10033371"
}
],
"start_pos": 25,
"text": "pain",
"type": "Indication"
},
{
"confidence": 1.0,
"end_pos": 93,
"meddra": [
{
"probability": 0.99,
"pt": "Fatigue",
"ptid": "10016256"
}
],
"start_pos": 86,
"text": "fatigue",
"type": "Indication"
}
],
"text": "Humira helps me with the pain so that I can exercise again. It does not help with the fatigue."
}
]
import requests
import json
if __name__ == '__main__':
exJSON = {}
#For testing the service if needed:
exJSON = [{
"id_str": "01",
"text": "I take Seroquel every morning and afternoon and during evenings i have a back ache."
},
{
"id_str": "02",
"text": "I've been on percocet for my withdrawls since beggining of the year."
},
{
"id_str": "03",
"text": "Humira helps me with the pain so that I can exercise again. It does not help with the fatigue."
}]
# POST
resp = requests.post('http://hlp.ibi.upenn.edu/drip/extracts', json=exJSON)
if resp.status_code != 200:
raise Exception(f'POST /predict/ ERROR: {resp.status_code}')
else:
exJSON = resp.json()
if 'errors' in exJSON:
raise Exception(f'POST /predict/ ERROR: {resp.json()}')
else:
print(exJSON)