-
Notifications
You must be signed in to change notification settings - Fork 47
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
Draft
jonahkaye
wants to merge
19
commits into
develop
Choose a base branch
from
1442-snomed-filtering
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,355
−29
Draft
Changes from 8 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
6e2f2cf
feat(filter): snomed hydrating
jonahkaye 9dfda6c
feat(snomed): cx specific workflow
jonahkaye f35535f
Merge branch 'develop' into 1442-snomed-filtering
jonahkaye 1565f67
feat(snomed): snomed hierachies computed and filtered
jonahkaye 0033587
feat(snomed): conditions and procedures duplications
jonahkaye 8c132e8
feat(snomed): removing duplicate meds - rxnorm lookups doesnt help wi…
jonahkaye b5e9d1a
feat(snomed): simplified filtering, conditions resource id mapping
jonahkaye 4df103b
feat(snomed): procedures, medications, conditions good
jonahkaye bb865d7
feat(snomed): more complete filtering by full tree search
jonahkaye 28fb18b
feat(snomed): precondition analysis
jonahkaye 4f48c40
feat(snomed): full pipeline done
jonahkaye b823225
feat(snomed): script header
jonahkaye 28b190c
feat(snomed): filtering for only the resources we need
jonahkaye 9363f91
feat(snomed): adding special snomed bundle to html
jonahkaye f3fd24f
Merge branch 'develop' into 1442-snomed-filtering
jonahkaye 21e3e3f
Merge branch 'develop' into 1442-snomed-filtering
jonahkaye e7eb48f
feat(snomed): medications dates good pray
jonahkaye d0b04b6
feat(snomed): dedup med admins too
jonahkaye 960040b
feat(snomed): medadmin to medstatement
jonahkaye File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ | |
{{/with}} | ||
{{/if}} | ||
{{/if}} | ||
|
||
{{/each}} | ||
{{/if}} | ||
|
||
|
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. |
This file contains 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
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(); | ||
} |
42 changes: 42 additions & 0 deletions
42
packages/utils/src/customer-requests/medical-records-and-csvs.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { bundleToHtml } from "@metriport/core/external/aws/lambda-logic/bundle-to-html"; | ||
import fs from "fs"; | ||
import { convertHtmlTablesToCsv } from "./convert-html-to-csv"; | ||
import * as path from "path"; | ||
|
||
// Function to process each JSON file | ||
function processFile(filePath: string) { | ||
const bundle = fs.readFileSync(filePath, "utf8"); | ||
const bundleParsed = JSON.parse(bundle); | ||
|
||
// Convert JSON to HTML | ||
const html = bundleToHtml(bundleParsed); | ||
const htmlOutputFilePath = filePath.replace(".json", ".html"); | ||
fs.writeFileSync(htmlOutputFilePath, html); | ||
console.log(`HTML file created at ${htmlOutputFilePath}`); | ||
|
||
// Convert HTML to CSV | ||
const csvContent = convertHtmlTablesToCsv(html); | ||
const csvOutputFilePath = filePath.replace(".json", ".csv"); | ||
fs.writeFileSync(csvOutputFilePath, csvContent); | ||
console.log(`CSV file created at ${csvOutputFilePath}`); | ||
} | ||
|
||
// Main function to iterate through the directory | ||
function main() { | ||
const targetPath = process.argv[2]; | ||
|
||
if (!targetPath) { | ||
console.log("Usage: node medical-records-local.js <path-to-directory>"); | ||
process.exit(1); | ||
} | ||
|
||
const files = fs.readdirSync(targetPath); | ||
files.forEach(file => { | ||
const fullPath = path.join(targetPath, file); | ||
if (path.extname(fullPath) === ".json") { | ||
processFile(fullPath); | ||
} | ||
}); | ||
} | ||
|
||
main(); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
bug
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.
Ouch, this is stuff that our tooling should catch for us. Isn't there a way we can parse/compile those? At least to check if the variable names are correct and not misspelled?
Also, is there a way we can have unit testing for this? We can def create a ticket to set it up.
Just because w/ unit tests we can also create new tests as we find bugs that would catch those if they were in place.