Created
July 21, 2021 21:22
-
-
Save ctsstc/a24b98a364412e71c624ddb7f20f9119 to your computer and use it in GitHub Desktop.
Copy Medication List from MyChart to CSV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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