-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNOMED Hydrating, Filtering, Special MR Generation #1648
base: develop
Are you sure you want to change the base?
Changes from 1 commit
6e2f2cf
9dfda6c
f35535f
1565f67
0033587
8c132e8
b5e9d1a
4df103b
bb865d7
28fb18b
4f48c40
b823225
28b190c
9363f91
f3fd24f
21e3e3f
e7eb48f
d0b04b6
960040b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Refs: #1442
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { DOMParser } from "xmldom"; | ||
|
||
import { readFileSync, writeFileSync } from "fs"; | ||
import * as path from "path"; | ||
// This is temporary function that will eventually be introduced | ||
// as another way to render patient data. (Will need refactoring) | ||
export function convertHtmlTablesToCsv(html: string) { | ||
|
@@ -110,3 +111,35 @@ export function convertHtmlTablesToCsv(html: string) { | |
|
||
return convertedCsv; | ||
} | ||
|
||
function main() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. utility to call in the command line |
||
const filePath = process.argv[2]; // Get the file path from command line arguments | ||
|
||
if (!filePath) { | ||
console.error("Please provide an HTML file path."); | ||
process.exit(1); | ||
} | ||
|
||
try { | ||
const htmlContent = readFileSync(filePath, "utf8"); // Read the HTML file content | ||
const csvContent = convertHtmlTablesToCsv(htmlContent); // Convert HTML to CSV | ||
|
||
// Construct the CSV file path by changing the extension | ||
const csvFilePath = path.join( | ||
path.dirname(filePath), | ||
path.basename(filePath, path.extname(filePath)) + ".csv" | ||
); | ||
|
||
// Write the CSV content to the new file | ||
writeFileSync(csvFilePath, csvContent); | ||
console.log(`CSV file has been created at: ${csvFilePath}`); | ||
// eslint-disable-next-line | ||
} catch (error: any) { | ||
console.error("Error processing the HTML file:", error.message); | ||
} | ||
} | ||
|
||
// Call main if this script is run directly | ||
if (require.main === module) { | ||
main(); | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add documentation explaining what it does and how to use it, please. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
import { bundleToHtml } from "@metriport/core/external/aws/lambda-logic/bundle-to-html"; | ||
import fs from "fs"; | ||
|
||
// get xml file from this folder and bundle to html | ||
// Check if a file path is provided | ||
if (process.argv.length < 3) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. utility to call in command line |
||
console.log("Usage: node medical-records-local.js <path-to-json-file>"); | ||
process.exit(1); | ||
} | ||
|
||
const bundle = fs.readFileSync("test-bundle.json", "utf8"); | ||
const filePath = process.argv[2]; | ||
const bundle = fs.readFileSync(filePath, "utf8"); | ||
const bundleParsed = JSON.parse(bundle); | ||
|
||
// FHIR Bundle | ||
const html = bundleToHtml(bundleParsed); | ||
|
||
// Response from FHIR Converter | ||
// const html = bundleToHtml(bundleParsed.fhirResource); | ||
// Determine the output file name by replacing .json with .html | ||
const outputFilePath = filePath.replace(".json", ".html"); | ||
|
||
fs.writeFileSync("test.html", html); | ||
fs.writeFileSync(outputFilePath, html); | ||
console.log(`HTML file created at ${outputFilePath}`); |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add documentation explaining what it does and how to use it, please. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add documentation explaining what it does and how to use it, please.