mirror of
https://github.com/Expand-sys/PharmaBot
synced 2026-03-22 04:17:07 +11:00
added a command
This commit is contained in:
parent
20dc99c2b0
commit
f3f8e964c3
2 changed files with 26 additions and 7 deletions
|
|
@ -1,5 +1,5 @@
|
|||
const Discord = require('discord.js');
|
||||
const { findDrug } = require('../../helpers/OpenFDA')
|
||||
const { findDrug, adverseEvent } = require('../../helpers/OpenFDA')
|
||||
|
||||
|
||||
module.exports = {
|
||||
|
|
@ -7,7 +7,7 @@ module.exports = {
|
|||
aliases: ['openFDA'],
|
||||
description: 'fids drug based on proprietary name',
|
||||
async execute(message, args) {
|
||||
if(args[0] == "find" || args[0] == "Find"){
|
||||
if(args[0].toLowerCase() == "find"){
|
||||
let res = await findDrug(args[1])
|
||||
if(res == 'Couldnt find the Medicine Specified'){
|
||||
message.reply(res)
|
||||
|
|
@ -16,7 +16,7 @@ module.exports = {
|
|||
.setColor('#0099ff')
|
||||
.setTitle('Name: '+res.results[0].proprietary_name)
|
||||
.addFields(
|
||||
{ name:"application_number_or_citation", value: res.results[0].application_number_or_citation},
|
||||
{name:"application_number_or_citation", value: res.results[0].application_number_or_citation},
|
||||
{name:"product_type", value: res.results[0].product_type},
|
||||
{name:"marketing_start_date", value: res.results[0].marketing_start_date},
|
||||
{name:"package_ndc", value: res.results[0].package_ndc},
|
||||
|
|
@ -29,6 +29,9 @@ module.exports = {
|
|||
.setFooter('heh nice');
|
||||
message.reply(embed)
|
||||
}
|
||||
}else if(args[0].toLowerCase() == "adverseevent"){
|
||||
let res = await adverseEvent(args[1])
|
||||
console.log(res)
|
||||
}
|
||||
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,12 +1,28 @@
|
|||
const https = require('https')
|
||||
const got = require('got')
|
||||
|
||||
const apikey= process.env.APIKEY
|
||||
|
||||
async function findDrug(drug){
|
||||
let query = "proprietary_name:"+drug
|
||||
let res
|
||||
try{
|
||||
res = await got("https://api.fda.gov/other/nsde.json?api_key=IbMkYkBOkuTRvQZDaXgfjxYP2wzDtySmg8477KvA&search="+query,{
|
||||
res = await got("https://api.fda.gov/other/nsde.json?api_key="+apikey+"&search="+query,{
|
||||
dnsLookupIpVersion: 'ipv4'
|
||||
});
|
||||
res = res.body
|
||||
res = JSON.parse(res)
|
||||
} catch(err){
|
||||
console.log(err)
|
||||
res = 'Couldnt find the Medicine Specified'
|
||||
}
|
||||
return res
|
||||
}
|
||||
async function adverseEvent(drug){
|
||||
//https://api.fda.gov/other/event.json?search=patient.drug.activesubstance.activesubstancename:Prozac
|
||||
let query = "patient.drug.medicinalproduct:"+drug
|
||||
let res
|
||||
try{
|
||||
res = await got("https://api.fda.gov/drug/event.json?api_key="+apikey+"&search="+query,{
|
||||
dnsLookupIpVersion: 'ipv4'
|
||||
});
|
||||
res = res.body
|
||||
|
|
@ -18,7 +34,7 @@ async function findDrug(drug){
|
|||
return res
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
findDrug
|
||||
findDrug,
|
||||
adverseEvent
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue