This repository has been archived by the owner on Oct 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updates to support procedures and diagnoses as well as icd code redir…
…ects for those that include decimals
- Loading branch information
mkorvink
committed
Jan 29, 2016
1 parent
ecfe54a
commit 378dfaa
Showing
2 changed files
with
90 additions
and
43 deletions.
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
131 changes: 88 additions & 43 deletions
131
share/fathead/international_classification_for_diseases_icd/parse.py
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,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(); |