Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
updates to support procedures and diagnoses as well as icd code redir…
Browse files Browse the repository at this point in the history
…ects for those that include decimals
  • Loading branch information
mkorvink committed Jan 29, 2016
1 parent ecfe54a commit 378dfaa
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ wget -P download -N 'https://www.cms.gov/Medicare/Coding/ICD10/Downloads/2016-Co

unzip -o download/2016-Code-Descriptions-in-Tabular-Order.zip -d download

wget -P download -N 'www.cdc.gov/nchs/data/icd/icd10cm/2016/ICD10CM_FY2016_code_descriptions.zip';

unzip -o download/ICD10CM_FY2016_code_descriptions.zip -d download
131 changes: 88 additions & 43 deletions share/fathead/international_classification_for_diseases_icd/parse.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,92 @@
url = "https://www.cms.gov/Medicare/Coding/ICD10/"
title = "International Classification of Diseases 10 Clinical Modification Code (ICD-10 CM)"
title = "International Classification of Diseases Code (ICD-10)"
article_type = "A"

outp = "output.txt"
inp = "download/icd10cm_codes_2016.txt" #reference the ICD file here

#Open input file
input_file = open(inp, "r" )

#Read and throw out first line
input_file.readline()

output_file = open( outp, "w")

#Loop thru the remainder of the file, format each line
#and print it to the output file.
for line in input_file.readlines() :
line = line.strip();
pair = line.split( ' ' );
if len(pair ) < 2 :
continue;

pair[0] = unicode(pair[0])

abstract = "ICD-10 Description: " + pair[1]

output_file.write( "\t".join([
pair[0], # Title
article_type, # Type
'', # Redirect
'', # Other uses
'', # Categories
'', # References
'', # See also
'', # Further reading
'', # External links
'', # Disambiguation
'', # Images
abstract, # Abstract
url, # Source URL
] ))

output_file.write( "\n" );

input_file.close();
output_file.close();
cm_inp = "download/icd10cm_codes_2016.txt" # reference the ICD file here
pcs_inp = "download/icd10pcs_codes_2016.txt"

# Open input files
cm_input_file = open(cm_inp, "r")
pcs_input_file = open(pcs_inp, "r")

# Open output file
output_file = open(outp, "w")

# Read and throw out first line
cm_input_file.readline()

# Loop through the remainder of the file, format each line
# and print it to the output file.
for line in cm_input_file.readlines():

line = line.strip();
icd_cm_code = line[0:7]
if len(icd_cm_code.strip()) > 3:
icd_cm_alt_code = icd_cm_code[0:3]+"."+icd_cm_code[3:7]
icd_cm_desc = line[8:200]
print icd_cm_code
print icd_cm_alt_code
print icd_cm_desc


icd_cm_code = unicode(icd_cm_code)

abstract = "ICD-10 CM Description: " + icd_cm_desc

output_file.write("\t".join([
icd_cm_code, # Title
article_type, # Type
'R', # Redirect
icd_cm_alt_code, # Other uses
'', # Categories
'', # References
'', # See also
'', # Further reading
'', # External links
'', # Disambiguation
'', # Images
abstract, # Abstract
url, # Source URL
]))

output_file.write("\n");

# Read and throw out first line
pcs_input_file.readline()

# Loop through the remainder of the file, format each line
# and print it to the output file.
for line in pcs_input_file.readlines():
line = line.strip();
icd_pcs_code = line[0:7]
icd_pcs_desc = line[8:200]
print line[0:7]
print line[8:200]

icd_pcs_code = unicode(icd_pcs_code)

abstract = "ICD-10 Description: " + icd_pcs_desc

output_file.write("\t".join([
icd_pcs_code, # Title
article_type, # Type
'', # Redirect
'', # Other uses
'', # Categories
'', # References
'', # See also
'', # Further reading
'', # External links
'', # Disambiguation
'', # Images
abstract, # Abstract
url, # Source URL
]))

output_file.write("\n");


cm_input_file.close();
pcs_input_file.close();
output_file.close();

0 comments on commit 378dfaa

Please sign in to comment.