Public
Edited
Sep 18, 2023
1 fork
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
[].concat.apply([],fdaInfo);
Insert cell
Insert cell
Insert cell
sdk.plotNadacNdc(ndcs.map(id => id.ndc), ndcLayout)//costTime)
Insert cell
sdk.plotDrugUtilBar(ndcs.map(id => id.ndc), drugUtilTime)//plotDrugUtil(ndcs.map(id => id.ndc), drugUtilTime)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
sdk = await import("https://kunaalagarwal.github.io/medicaid/sdk.js");
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
getAllDiseases = async function(){
return (await (await fetch(`https://rxnav.nlm.nih.gov/REST/rxclass/allClasses.json?classTypes=DISEASE`)).json()).rxclassMinConceptList.rxclassMinConcept.sort((a,b) => (a.className > b.className) ? 1 : ((b.className > a.className) ? -1 : 0)).map(row =>row.className)
}
Insert cell
Insert cell
ndcToName = async function(nadac_ndc){
var fda_url = "https://api.fda.gov/drug/ndc.json?search=product_ndc:";

//---------------------------------------------------------1
if( nadac_ndc.slice(0,1) != 0 && nadac_ndc.slice(4,5) !== 0 && nadac_ndc.slice(5,6) == 0 ){
console.log("1")
var dt = ( await(await fetch(fda_url+'"'+ nadac_ndc.slice(0,5) + "-" + nadac_ndc.slice(5,9).replace(/^0/,'') +'"')).json())
console.log("dt",dt)

if(dt.error !== undefined){
var results = {product_ndc: dt.error.message}
} else if(dt.results != undefined){
var results = dt.results[0]
}
//---------------------------------------------------------2
}else if(nadac_ndc.slice(0,1) == 0){
console.log("2")
var dt = ( await(await fetch(fda_url+'"'+nadac_ndc.slice(0,5).replace(/^0/,'') + "-"+nadac_ndc.slice(5,9)+'"')).json())
console.log("dt",dt.error)

if(dt.error != undefined){
var results = {product_ndc: dt.error.message}
} else{
var results = dt.results[0]
}
//---------------------------------------------------------3
}else if( nadac_ndc.slice(4,5) == 0 && nadac_ndc.slice(5,6) == 0 ){
console.log("3")
var dt = ( await(await fetch(fda_url+'"'+ nadac_ndc.slice(0,5) + "-" + nadac_ndc.slice(5,9) +'"')).json())
if(dt.error != undefined){
var results = dt.error.message
} else{
var results =dt.results[0]
}
//---------------------------------------------------------4
}else if(nadac_ndc.slice(5,6) == 0 ){
console.log("4")
var dt = ( await(await fetch(fda_url+'"'+ nadac_ndc.slice(0,5) + "-" + nadac_ndc.slice(5,9).replace(/^0/,'') +'"')).json())//.error.message
if(dt.error != undefined){
var results = {product_ndc: dt.error.message}
} else{
var results = dt.results[0]
}
//---------------------------------------------------------5
} else{
console.log("5")
var dt = ( await(await fetch(fda_url+'"'+nadac_ndc.slice(0,5) + "-"+nadac_ndc.slice(5,9)+'"')).json())
if(dt.message==undefined){
var results = {product_ndc: dt.error.message}
} else{
var results = dt.results[0]
}
console.log("5",results)

}
// var resultArray = "";
// if (results.active_ingredients != undefined) {
// var obj = results.active_ingredients[0]
// for (var key in obj)
// resultArray = resultArray.concat(obj[key]," ");
// }else if (results.brand_name != undefined) {
// resultArray = resultArray.concat(results.brand_name)
// } else {
// resultArray = results
// }
// return resultArray
return results
}
Insert cell
ndcLayout = ({
title: {
text: "National Average Drug Acquisition Cost" ,
},
xaxis: {
title: {
text: 'Year',
},
},
yaxis: {
title: {
text: 'Per Unit Price',
}
},
width: 1150,
height: 300,
})
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more