Skip to contents

An open-source implementation in R similar to the Mapping tool developed by the Agency for Healthcare Research and Quality (AHRQ).

Usage

icd_map(dx, from = 9, to = 10, year = 2018,
        method = c("gem", "reverse-gem", "both", "multi-stage"),
        decimal = FALSE, nomatch = c('""', NA),
        output = c("character", "list", "tidy-data"), cache = TRUE, ...)

Arguments

dx

A character vector representing diagnosis codes. Each element of the vector can either represent individual diagnosis code or a set of diagnosis codes that are concartenated by commas in between.

from

A integer value specifying the original code version. Currently, the available options are 9 or 10.

to

A integer value specifying the original code version. Currently, the available options are 9 or 10. If the input from and to are the same, the function will skip all the translation and return the input dx with a warning.

year

A numeric value specifying the year of the CMS GEMs. The currently available options are 2017 and 2018. By default, 2018 CMS GEMs is used.

method

A character string specifying the translateion method. The available options are "gem" for CMS GEM, "reverse-gem" for the reverse of CMS GEM, "both" for both GEM and reverse GEM, "multi-stage" for multiple stage procedure. See Section Details for more detailed description of the procedure.

decimal

A logical value. If TRUE, the diagnosis codes would be returned with decimal points. The default is FALSE.

nomatch

A character string indicating no translation result can be found through the specified mapping. By default, empty strings, "", will be used. Another available option is NA (or more specific NA_character_). In that case, the code will be translated to NA_character_ if no translataion result can be found.

output

A character value specifying the format of the output. The avaiable options are "character", "list", and "tidy-data". By default, option "character" is used and results in a character vector that consists of element-wise concatenatation by commas of all the translated diagnosis codes from the original codes. If "list" is specified, all the translated codes will not be concartenated and a list of character vectors will be returned by the function. Similarly, if "tidy-data" is specified, a data frame in a tidy format will be returned. The first column of the data frame consists of the original diagnosis codes; the second column consists of the translated diagnosis codes.

cache

A logical value specifying whether to cache all the mappings for method = "both" (both CMS GEM and its reverse mapping), and method = "multi-stage" (the multiple stage procedure). If TRUE by default, the specified mapping will be generated, cached and, applied to the translation. If FALSE, the CMS GEM and its reverse mapping will be used for translatation every time without cache. It is recommended to set cache = TRUE for translation from ICD-9 to ICD-10. For translation from ICD-10 to ICD-9, the caching process only takes noticeable time (usually several minutes at most) for the multi-stage procedure.

...

Other arguments for future usage. A warning will be thrown out if any argument goes into ... accidentally.

Value

A character vector of the same length with the input vector will be returned by default or if output = "charactor". A list of character vectors will be returned if output = "list"; A data frame in tidy-format will be returned if output = "tidy-data". See argument output for details.

Details

This function aims to efficiently translates the ICD diagnosis codes to the a different version by the General Equivalence Mappings (GEMs) developed by the National Center for Health Statistics, Centers for Medicare and Medicaid Services (CMS), AHIMA, the American Hospital Association, and 3M Health Information Systems. The CMS GEMs currently consist of the forward mapping from ICD-9 codes to ICD-10 codes and the backward mapping from ICD-10 codes to ICD-9 codes. In addition to these two mappings, the Agency for Healthcare Research and Quality (AHRQ) also proposed translation by using the reverse mappings and multi-stage procedure.

Taking the translation from ICD-9 codes to ICD-10 codes as an example, the procedure is elaborated as follows: In stage one, the input ICD-9 codes are mapped to ICD-10 codes using the ICD-9 to ICD-10 forward map as well as the reverse of the ICD-10 to ICD-9 backward map. If multiStage = FALSE, the procedure will return the translation results from stage one (and skip the following stages). Otherwise, the procedure will continue and become a multiple stage process. In stage two, the ICD-10 codes output from the stage one are mapped back to ICD-9 codes using the backward map as well as the reverse of the forward map; In stage three, it applies the forward map and reverse-backward map used in stage one again to the ICD-9 codes from the stage two and return the resulting ICD-10 codes.

The flags of the GEMs are not exported from this function. For codes with positive combination flags, the combination of the converted ICD-10 codes is indicated by the plus sign "+". For example, the ICD-9 code "24951" can be translated by 2018 GEMs to ICD-10 code, "E0839", "E0939", or one of the codes from ("E08311", "E08319", "E0836", "E09311" "E09319", "E0936") with "E0865". The plus sign in the output, such as "E08311+E0865", is used to indicate the combination of "E08311" and "E0865".

References

2017-ICD-10-CM-and-GEMs. The U.S. Centers for Medicare & Medicaid Services. 22 August, 2016. https://www.cms.gov/medicare/coding/icd10/2017-icd-10-cm-and-gems. Accessed 5 July, 2022.

2018-ICD-10-CM-and-GEMs. The U.S. Centers for Medicare & Medicaid Services. 11 August, 2017. https://www.cms.gov/medicare/coding/icd10/2018-icd-10-cm-and-gems. Accessed 5 July, 2022.

The AHRQ MapIT Automated In-house Stand-alone Mapping Tool. Agency for Healthcare Research and Quality. 26 March, 2018. https://qualityindicators.ahrq.gov/resources/toolkits. Accessed 5 July, 2022.

See also

Author

Wenjie Wang <[email protected]>

Examples

library(touch)

### some random ICD-9 and ICD-10 codes
icd9codes <- c("0011", "001.1", "316", "29383", "E9808", "V90")
icd10codes <- c("F0390", "F0630", "F54", "F30.13", "A010", "M61019")

### forward mapping from ICD-9 to ICD-10
icd_map(icd9codes)
#> [1] "A001"  "A001"  "F54"   "F0630" ""      ""     
icd_map(icd9codes, decimal = TRUE, nomatch = NA)
#> [1] "A00.1"  "A00.1"  "F54"    "F06.30" NA       NA      

### backward mapping from ICD-10 to ICD-9
icd_map(icd10codes, from = 10, to = 9)
#> [1] "2900,29010,29011,29013,29021,2908,2909,29420"
#> [2] "29383"                                       
#> [3] "316"                                         
#> [4] "29603"                                       
#> [5] ""                                            
#> [6] "72812"                                       
icd_map(icd10codes, from = 10, to = 9, nomatch = NA, output = "list")
#> [[1]]
#> [1] "2900"  "29010" "29011" "29013" "29021" "2908"  "2909"  "29420"
#> 
#> [[2]]
#> [1] "29383"
#> 
#> [[3]]
#> [1] "316"
#> 
#> [[4]]
#> [1] "29603"
#> 
#> [[5]]
#> [1] NA
#> 
#> [[6]]
#> [1] "72812"
#> 
icd_map(icd10codes, from = 10, to = 9,
        decimal = TRUE, nomatch = NA, output = "tidy")
#>    ICD-10  ICD-9
#> 1   F0390  290.0
#> 2   F0390 290.10
#> 3   F0390 290.11
#> 4   F0390 290.13
#> 5   F0390 290.21
#> 6   F0390  290.8
#> 7   F0390  290.9
#> 8   F0390 294.20
#> 9   F0630 293.83
#> 10    F54    316
#> 11  F3013 296.03
#> 12   A010   <NA>
#> 13 M61019 728.12

### reverse-backward mapping from ICD-9 to ICD-10
icd_map(icd9codes, method = "reverse-gem")
#> [1] "A001"                          "A001"                         
#> [3] "F54"                           "F0630,F0631,F0632,F0633,F0634"
#> [5] "T570X4A"                       ""                             
icd_map(icd9codes, method = "reverse", decimal = TRUE, nomatch = NA)
#> [1] "A00.1"                              "A00.1"                             
#> [3] "F54"                                "F06.30,F06.31,F06.32,F06.33,F06.34"
#> [5] "T57.0X4A"                           NA                                  

### reverse-forward mapping from ICD-10 to ICD-9
icd_map(icd10codes, from = 10, to = 9, method = "reverse-gem")
#> [1] "2900,29010,29011,29013,29021,2908,2909,29420,29012,29020,2903"
#> [2] "29383"                                                        
#> [3] "316"                                                          
#> [4] "29603,29613"                                                  
#> [5] ""                                                             
#> [6] ""                                                             
icd_map(icd10codes, from = 10, to = 9, method = "reverse",
        decimal = TRUE, nomatch = NA)
#> [1] "290.0,290.10,290.11,290.13,290.21,290.8,290.9,294.20,290.12,290.20,290.3"
#> [2] "293.83"                                                                  
#> [3] "316"                                                                     
#> [4] "296.03,296.13"                                                           
#> [5] NA                                                                        
#> [6] NA                                                                        

### forward and reverse-backward mapping from ICD-9 to ICD-10
icd_map(icd9codes, method = "both")
#> [1] "A001"                          "A001"                         
#> [3] "F54"                           "F0630,F0631,F0632,F0633,F0634"
#> [5] "T570X4A"                       ""                             
icd_map(icd9codes, method = "both", decimal = TRUE, nomatch = NA)
#> [1] "A00.1"                              "A00.1"                             
#> [3] "F54"                                "F06.30,F06.31,F06.32,F06.33,F06.34"
#> [5] "T57.0X4A"                           NA                                  

### backward and reverse-forward mapping from ICD-10 to ICD-9
icd_map(icd10codes, from = 10, to = 9, method = "both")
#> [1] "2900,29010,29011,29012,29013,29020,29021,2903,2908,2909,29420"
#> [2] "29383"                                                        
#> [3] "316"                                                          
#> [4] "29603,29613"                                                  
#> [5] ""                                                             
#> [6] "72812"                                                        
icd_map(icd10codes, from = 10, to = 9, method = "both",
        decimal = TRUE, nomatch = NA)
#> [1] "290.0,290.10,290.11,290.12,290.13,290.20,290.21,290.3,290.8,290.9,294.20"
#> [2] "293.83"                                                                  
#> [3] "316"                                                                     
#> [4] "296.03,296.13"                                                           
#> [5] NA                                                                        
#> [6] "728.12"                                                                  

### multi-stage process mapping ICD-9 to ICD-10
icd_map(icd9codes, method = "multi-stage")
#> [1] "A001"                            "A001"                           
#> [3] "F54"                             "F0630,F0631,F0632,F0633,F0634"  
#> [5] "T570X1A,T570X2A,T570X3A,T570X4A" ""                               
icd_map(icd9codes, method = "multi-stage", decimal = TRUE, nomatch = NA)
#> [1] "A00.1"                               "A00.1"                              
#> [3] "F54"                                 "F06.30,F06.31,F06.32,F06.33,F06.34" 
#> [5] "T57.0X1A,T57.0X2A,T57.0X3A,T57.0X4A" NA                                   

### multi-stage process mapping ICD-10 to ICD-9
icd_map(icd10codes, from = 10, to = 9,
        method = "multi-stage", cache = FALSE)
#> [1] "2900,29010,29011,29012,29013,29020,29021,2903,2908,2909,2930,2931,29420"
#> [2] "29383"                                                                  
#> [3] "316"                                                                    
#> [4] "29603,29613"                                                            
#> [5] ""                                                                       
#> [6] "72812"                                                                  
icd_map(icd10codes, from = 10, to = 9, method = "multi-stage",
        decimal = TRUE, nomatch = NA, cache = FALSE)
#> [1] "290.0,290.10,290.11,290.12,290.13,290.20,290.21,290.3,290.8,290.9,293.0,293.1,294.20"
#> [2] "293.83"                                                                              
#> [3] "316"                                                                                 
#> [4] "296.03,296.13"                                                                       
#> [5] NA                                                                                    
#> [6] "728.12"                                                                              

### For codes with positive combination flags
icd_map("24951", output = "list")
#> [[1]]
#> [1] "E0839"        "E0939"        "E08311+E0865" "E08319+E0865" "E0836+E0865" 
#> [6] "E09311+E0865" "E09319+E0865" "E0936+E0865" 
#> 
## where the "+" signs indicate the code combinations