An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

        

Break down of code, which convert ICD-9 codes to ICD-10 code.



  1. fs: Interating with the file system, such as reading and writing.

  2. path: Working with files and directory paths.

  3. commander: Used for parsing command line arguements. It allow us to define how the script should accept input from the user.

  4. 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.

  5. dataTable: create an empty object that will be used as a dictionary to store icd9 to icd10 mappings.

  6. First try block attempts to read the icd9toicd10dictionary.txt file.

  7. fs.readFileSync(): reads the files content in to a string.

  8. data.split('\n'): splits the string into an array of lines.

  9. lines.shift(): remove the first line of the array, because it is the header.

  10. lines.forEach(...): iterates over each line in the file.

  11. line.split('|').map(part => part.trim()): splits each line into parts based on the "|" delimiter and removes leading/trailing whitespace.

  12. Catch block will handle the error for if dictionary file not found or any other error happen while reading the file.

  13. Second try block reads the input file, process the icd9 codes and writes the results to the output file.

  14. fs.createWriteStream() creates a write stream to the output file (infile.out).

  15. 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.

  16. Catch block handles errors that occur while processing the input file.

  17. The last section uses the commander module to define how the script should accept the input file name from the command line.

  18. .argument('infile', ...) defines that the script expects one argument, which is the input file name.

  19. .action(...) defines the function to be executed when the script is run with the argument.

  20. 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 <--