-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconvertICD9toICD10.R
33 lines (28 loc) · 1.79 KB
/
convertICD9toICD10.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#######################################################################################
#### convertICD9toICD10 function
######################################################################################
### this function returns possible icd10
convertICD9toICD10 <- function(icd) {
icd.version <- guess_version(icd)
# check whether it's icd9 or icd10
if (icd.version == "icd9") { # check if it's "icd9"
#print("OK!")
#return(icd)
# check whether it's short or decimal
if (icd:::guess_short(icd)){
return(findICD10B(icd)) # return the converted icd9 to icd10
} # if short or decimal
else { # for decimal format
icd.converted <- decimal_to_short(icd) # converts decimal to short
return(findICD10B(icd.converted)) # return the converted icd9 to icd10
} # else short or decimal
} # if icd9 or icd10
else { # "icd10"
if (icd:::guess_short(icd)) { # checks whether it's short or decimal
return(icd) # returns icd10 in short format
} # if short or decimal
else { # if FALSE
return(decimal_to_short(icd)) # returns icd10 in short format
} # else short or decimal
} # else icd 9 or icd10
} # end of function