Skip to content

Instantly share code, notes, and snippets.

@andriyor
Created January 11, 2021 13:08
Show Gist options
  • Save andriyor/ac42edb7ee4b871bc5ffa9284fceeed5 to your computer and use it in GitHub Desktop.
Save andriyor/ac42edb7ee4b871bc5ffa9284fceeed5 to your computer and use it in GitHub Desktop.
hl7-fhir-codes-table-parser
const puppeteer = require('puppeteer');
const fs = require("fs");
const path = require("path");
(async () => {
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
await page.goto('https://www.hl7.org/fhir/valueset-allergyintolerance-code.html');
const codes = await page.evaluate(() => {
const codes = [...document.querySelectorAll("table.codes tbody tr")].map((tr, index) => {
return {
values: [tr.querySelectorAll("td")[0].textContent.trim(), tr.querySelectorAll("td")[1].textContent, "", "{}"],
index
}
})
codes.shift()
return codes;
});
fs.writeFileSync(path.resolve(__dirname, 'result.json'), JSON.stringify(codes, null, 2))
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment