-
Notifications
You must be signed in to change notification settings - Fork 38
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
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. This is the main customer facing output of this PR. A script that for a given customer, gets all their patients consolidated data and performs the filtering and MR summary generation 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. Full script for running this whole process |
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. Analysis done on preconditions on sample patient set for reference:
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
import { getCodeDisplay } from "./term-server-api"; | ||
|
||
function processDirectory( | ||
directoryPath: string, | ||
hashTable: { [key: string]: number }, | ||
totalConditionCounts: { count: number } | ||
) { | ||
const filesAndDirectories = fs.readdirSync(directoryPath); | ||
|
||
for (const name of filesAndDirectories) { | ||
const currentPath = path.join(directoryPath, name); | ||
const stat = fs.statSync(currentPath); | ||
|
||
if (stat.isDirectory()) { | ||
processDirectory(currentPath, hashTable, totalConditionCounts); | ||
} else if (name.endsWith(".json")) { | ||
processFile(currentPath, hashTable, totalConditionCounts); | ||
} | ||
} | ||
} | ||
|
||
function processFile( | ||
filePath: string, | ||
hashTable: { [key: string]: number }, | ||
totalConditionCounts: { count: number } | ||
) { | ||
const data = JSON.parse(fs.readFileSync(filePath, "utf8")); | ||
if (data.resourceType === "Bundle" && data.type === "batch") { | ||
for (const entry of data.entry) { | ||
if ( | ||
entry.resource?.resourceType === "Condition" && | ||
entry.resource.verificationStatus === true | ||
) { | ||
const codeInfo = entry.resource.code; | ||
const code = codeInfo.coding[0].code; | ||
if (hashTable[code]) { | ||
hashTable[code] += 1; | ||
} else { | ||
hashTable[code] = 1; | ||
} | ||
} | ||
totalConditionCounts.count += 1; | ||
} | ||
} | ||
} | ||
|
||
async function main() { | ||
const directoryPath = process.argv[2]; | ||
if (!directoryPath) { | ||
console.error("Please provide a directory path as an argument."); | ||
process.exit(1); | ||
} | ||
|
||
const hashTable: { [key: string]: number } = {}; | ||
const totalConditionCount = { count: 0 }; | ||
processDirectory(directoryPath, hashTable, totalConditionCount); | ||
|
||
let disorderCount = 0; | ||
for (const code of Object.keys(hashTable)) { | ||
const codeDetails = await getCodeDisplay(code, "SNOMEDCT_US"); | ||
if (codeDetails && codeDetails.category === "disorder") { | ||
console.log( | ||
`${code} with count ${hashTable[code]} is a disorder: ${codeDetails.display} (${codeDetails.category})` | ||
); | ||
disorderCount += hashTable[code]; | ||
} | ||
} | ||
|
||
const totalCount = Object.values(hashTable).reduce((acc, count) => acc + count, 0); | ||
|
||
console.log(`Total #of Conditions in the directory: ${totalConditionCount.count}`); | ||
console.log(`Total #of Conditions generated from <Precondition> in the directory: ${totalCount}`); | ||
console.log( | ||
`Total #of Conditions generated from <Precondition> in the directory of type disorder: ${disorderCount}` | ||
); | ||
} | ||
|
||
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 |
---|---|---|
|
@@ -75,7 +75,6 @@ async function removeNonRootSnomedCodes( | |
entries.splice(i, 1); | ||
break; | ||
} else { | ||
console.log("Keeping SNOMED code:", coding.code, "Resource.id:", resource.id); | ||
hashTable[coding.code].inserted = true; | ||
allRemainingEnries.add(resource.id); | ||
break; | ||
|
@@ -234,13 +233,7 @@ async function filterMedicationsEntries( | |
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), "utf8"); | ||
} | ||
|
||
async function main() { | ||
const [directoryPath] = process.argv.slice(2); | ||
if (!directoryPath) { | ||
console.error("Please provide a directory path as an argument."); | ||
process.exit(1); | ||
} | ||
|
||
export async function fullProcessing(directoryPath: string) { | ||
const removalStats = createInitialRemovalStats(); | ||
|
||
// Removal of non-disorder SNOMED codes, invalid CPT codes, and duplicate CPT codes | ||
|
@@ -297,4 +290,13 @@ async function main() { | |
prettyPrintRemovalStats(removalStats); | ||
} | ||
|
||
async function main() { | ||
const [directoryPath] = process.argv.slice(2); | ||
if (!directoryPath) { | ||
console.error("Please provide a directory path as an argument."); | ||
process.exit(1); | ||
} | ||
await fullProcessing(directoryPath); | ||
} | ||
Comment on lines
+352
to
+359
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. nit: It's a pain to have to scroll to the bottom and make the way up instead of just following the text from top to bottom as one scrolls it down |
||
|
||
main(); |
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.
grabbing conditions linked to medications.
This gets us a few more conditions but which empirically seem to not be the most valuable. Optional to keep this, though my preference is to default on the side of getting as much data from the convert and filtering out downstream.