Public
Edited
Oct 8, 2024
1 star
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
Insert cell
Insert cell
Insert cell
Insert cell
createdDates = Object.values(costPlusMeds).map(d=>d.created).sort().filter((v,i,a)=>!i || v!==a[i-1]);
Insert cell
drugNames = Object.values(costPlusMeds).map(d=>d.name).sort()
Insert cell
import {Plot} from "@mkfreeman/plot-tooltip"
Insert cell
Insert cell
origMedHTML = await FileAttachment("cost-plus-meds.txt").json()
Insert cell
origCostPlusMeds = processMedHTML(origMedHTML)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
costcoData = fetch("https://cors.lvab.workers.dev/?u=https://cmppapi.cervey.com/api/pricecheck/43598034490?quantity=60&zipCode=89101").then(async (response) => {
let text = await response.text();
console.log(text);
return JSON.parse(text);
}).then(r=>r.items[0])
Insert cell
costcoData1 = fetch("https://cmppapi.cervey.com/api/pricecheck/50111039801?quantity=60&zipCode=89101").then((response) => response.json()).then(r=>r.items[0])
Insert cell
costcoData2 = fetch("https://cmppapi.cervey.com/api/pricecheck/69452029020?quantity=60&zipCode=89101").then((response) => response.json()).then(r=>r.items[0])
Insert cell
Insert cell
goodrxUrls = html`${costPlusMeds.slice(100).sort((b,a)=>a.retailPriceFor301 - b.retailPriceFor301).map(med => "<a target='_blank' href='https://www.goodrx.com/"+med.name.toLowerCase()+"'>" + med.name + " $" + med.ourPrice + "</a>").join("<br>\n")}`;
Insert cell
async function getGoodrx(drugName) {
//const goodrxURL = "https://www.goodrx.com/";
const goodrxURL = "https://www.goodrx.com/widget/low-price?drug_name=" ;
//const corsURL = "https://cors.lvab.workers.dev/?u=";
const corsURL ="";

window.open(goodrxURL + drugName,"_blank");
//return ;

let url = corsURL+goodrxURL + drugName ;
let html = await fetch(url).then((response) => response.text());
console.log(html);
return html;
}

Insert cell
//getGoodrx(selectedDrugName)
Insert cell
selectedDrugCostcoData = getCostcoData(selectedDrugData,30)
Insert cell
import { SummaryTable } from "@observablehq/summary-table"
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