Skip to content

Instantly share code, notes, and snippets.

@ctsstc
Created July 21, 2021 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctsstc/a24b98a364412e71c624ddb7f20f9119 to your computer and use it in GitHub Desktop.
Save ctsstc/a24b98a364412e71c624ddb7f20f9119 to your computer and use it in GitHub Desktop.
Copy Medication List from MyChart to CSV
// Goto the medications page in mychart
// Then click through any additional tabs for different offices/locations at the top to load them up
// Run this in the console
// Open notepad paste and save as a .csv
// Note using "let" so that you can copy/paste multiple times w/o refreshing
let headers = [...document.querySelectorAll('.card.medcard[data-med-id]')];
let cleanup = (el) => el?.innerText.split(/\r\n|\r|\n|\,/).join(' ');
let data = headers.map(header => {
const name = cleanup(header.querySelector('.medtitle'));
const extraName = cleanup(header.querySelector('.commonname'));
const instructions = cleanup(header.querySelector('.sigtop'));
const message = cleanup(header.querySelector('.medmessage'));
return { name, extraName, instructions, message };
});
let flat = data.map(d => [d.name, d.extraName, d.instructions, d.message]); // Order them
flat.unshift(['Name', 'Extra Name', 'Instructions', 'Message']);
let csv = flat.map(line => line.join(',')).join("\r\n");
copy(csv);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment