Public
Edited
Jul 18, 2023
Insert cell
Insert cell
medicaid = (await fetch("https://data.medicaid.gov/api/1/metastore/schemas/dataset/items")).json()
Insert cell
Insert cell
nadac_distrID= Promise.all(medicaid.map(({ title}) => title).sort().filter(el => el.includes("NADAC (National Average Drug Acquisition Cost) 2023")).map(title=> {return medicaid.find(obj => obj.title === title)["identifier"]}).map(id=> sdk.convertDatasetToDistributionId(id)))
Insert cell
nadac = Promise.all(nadac_distrID.map(id => {return sdk.getDatastoreQuerySql(`[SELECT * FROM ${id}][LIMIT 500000]`)}))
Insert cell
acne_med = nadac.map(nadacYear => { return nadacYear.filter(row => row.ndc_description.includes("ACNE MEDICATION") & row.classification_for_rate_setting == "G" )} )//"ACNE MEDICATION"
Insert cell
Insert cell
viewof datasets = Inputs.select( medicaid.map(({ title}) => title).sort().filter(el => el.includes("Utilization")), {multiple: 14, width: 500,label: "Select Medicaid datasets"})//el.includes("NADAC (National")
Insert cell
datastoreId = Promise.all(datasets.map(title=> {return medicaid.find(obj => obj.title === title)["identifier"]}))
Insert cell
distrID= Promise.all(datasets.map(title=> {return medicaid.find(obj => obj.title === title)["identifier"]}).map(id=> sdk.convertDatasetToDistributionId(id)))
Insert cell
utilization_data = Promise.all(distrID.map(id => {return sdk.getDatastoreQuerySql(`[SELECT * FROM ${id}][LIMIT 100]`)}))
Insert cell
Insert cell
sdk = await import ("https://kunaalagarwal.github.io/medicaid/sdk.js");
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
plotData = sdk.getMedData(['HM LANSOPRAZOLE DR 15 MG CAP'], {xAxis: "as_of_date", yAxis: "nadac_per_unit"})
Insert cell
Insert cell
Insert cell
//effective, dec 21: 0.06273, 0.06667, 0.07094, 0.22185
//as-of-date, dec 7: 0.06273, 0.04663
//as-of-date, dec 14: 0.06273
//as-of-date, dec 21: 0.06273
//as-of-date, dec 28: 0.06667
//as-of-date, jan 4: 0.07094, 0.22185
//as-of-date, jan 11: 0.07094, 0.22185

// as-of-date, dec 14-Jan 11 (4 weeks) = effective date, dec 21
Insert cell
sdk.plotNadacMed('ACNE MEDICATION 10% GEL', ndcLayout, )//as_of_date
Insert cell
sdk.plotNadacMed('ACNE MEDICATION 10% GEL',ndcLayout,document.createElement('div'),{xAxis:"effective_date",yAxis:"nadac_per_unit"})//"effective_date
Insert cell
Insert cell
Insert cell
data = sdk.getDatastoreQuerySql('[SELECT state,state_rate FROM 11196f15-1a77-5b80-97f3-c46c0ce19894][WHERE measure_name = "Percentage of Eligibles Who Received Preventive Dental Services: Ages 1-20"]')
Insert cell
Insert cell
Insert cell
sdk.plot([{x: states.sort(), y: state_rates}], layout, 'bar')
Insert cell
Insert cell
Insert cell
Insert cell
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