https://github.com/zaheers-dev-lab/javascript-icd-9-to-icd-10-code-converter
Simple command-line tool to convert ICD-9 codes to ICD-10 using a dictionary file (icd9toicd10dictionary.txt). Reads an input file (one ICD-9 code per line) and outputs a converted file (input_file.txt.out). Requires Node.js and the commander package. Basic error handling and empty line detection included.
https://github.com/zaheers-dev-lab/javascript-icd-9-to-icd-10-code-converter
commanderjs dictionary javascript
Last synced: about 1 month ago
JSON representation
Simple command-line tool to convert ICD-9 codes to ICD-10 using a dictionary file (icd9toicd10dictionary.txt). Reads an input file (one ICD-9 code per line) and outputs a converted file (input_file.txt.out). Requires Node.js and the commander package. Basic error handling and empty line detection included.
- Host: GitHub
- URL: https://github.com/zaheers-dev-lab/javascript-icd-9-to-icd-10-code-converter
- Owner: zaheers-dev-Lab
- Created: 2025-03-27T10:14:15.000Z (about 1 month ago)
- Default Branch: master
- Last Pushed: 2025-03-27T11:03:58.000Z (about 1 month ago)
- Last Synced: 2025-03-27T11:40:00.721Z (about 1 month ago)
- Topics: commanderjs, dictionary, javascript
- Language: JavaScript
- Homepage:
- Size: 25.7 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
Break down of code, which convert ICD-9 codes to ICD-10 code.
- fs: Interating with the file system, such as reading and writing.
- path: Working with files and directory paths.
- commander: Used for parsing command line arguements. It allow us to define how the script should accept input from the user.
- async: (Used for to execute multiple task at a time)as it wil read the input file, process the icd-9 codes and write the converted icd-10 code to an output file.
- dataTable: create an empty object that will be used as a dictionary to store icd9 to icd10 mappings.
- First try block attempts to read the icd9toicd10dictionary.txt file.
- fs.readFileSync(): reads the files content in to a string.
- data.split('\n'): splits the string into an array of lines.
- lines.shift(): remove the first line of the array, because it is the header.
- lines.forEach(...): iterates over each line in the file.
- line.split('|').map(part => part.trim()): splits each line into parts based on the "|" delimiter and removes leading/trailing whitespace.
- Catch block will handle the error for if dictionary file not found or any other error happen while reading the file.
- Second try block reads the input file, process the icd9 codes and writes the results to the output file.
- fs.createWriteStream() creates a write stream to the output file (infile.out).
- The code iterates through each line of the input file, checks if the ICD-9 code exists in the dataTable, and writes the corresponding ICD-10 code and description to the output file.
- Catch block handles errors that occur while processing the input file.
- The last section uses the commander module to define how the script should accept the input file name from the command line.
- .argument('infile', ...) defines that the script expects one argument, which is the input file name.
- .action(...) defines the function to be executed when the script is run with the argument.
- program.parse(process.argv) parses the command-line arguments.
--> To run the code you have to create an input file in which you have to write the icd codes each in one line. and then pass the prompt in terminal:
node icd9to10.js your_input_file.txt <--