icdConvert - How to Use the Package
icdConvert.Rmd
Installing icdConvert
The package can be installed from github with the
devtools
package using the following command:
devtools::install_github("https://github.com/jradack/icdConvert")
You might get a warning about needing Rtools to build the package, but you should be able to ignore this.
Then it can be loaded like any other R package:
library(icdConvert)
The package contains three primary functions(map_code
,
get_description
, and map_describe
) and a
dataframe (example_data_icd9_pc
). The example dataframe has
the character column icd9_pc
, which is a list of ICD-9
procedure codes.
x |
---|
456 |
4561 |
4562 |
4563 |
457 |
4571 |
4572 |
4573 |
4574 |
4575 |
Function demos
get_description
Suppose we have the following list of ICD-9 procedure code:
icd9_pc_codes <- c("1421","1422","1423","1424","1425","1426")
We can get it’s description using the get_description
command.
get_description_test <- get_description(icd9_pc_codes, icdVer = 9, code_type = "pc")
codes | desc |
---|---|
1421 | Destruction of chorioretinal lesion by diathermy |
1422 | Destruction of chorioretinal lesion by cryotherapy |
1423 | Destruction of chorioretinal lesion by xenon arc photocoagulation |
1424 | Destruction of chorioretinal lesion by laser photocoagulation |
1425 | Destruction of chorioretinal lesion by photocoagulation of unspecified type |
1426 | Destruction of chorioretinal lesion by radiation therapy |
This function takes a list of ICD codes and gets the code descriptions using CMS provided tables. For consistency with the GEM files, the 2018 version of the tables were used for ICD-10.
map_code
Next, suppose we would like to map the list of ICD-9 procedure codes
to ICD-10. We can use the map_code
function, which takes a
vector of ICD codes and converts them to the desired ICD version. The
user must specify the destination ICD version (i.e. which ICD version
they want to convert the codes to) and the type of code being converted
("dg"
for diagnosis codes, "pc"
for procedure
codes). This package handles one-to-many mappings of codes, as well as
implementing the four methods of mapping codes, as outlined in the
touch
package. The four methods are "gem"
,
"reverse-gem"
, "both"
, and
"multi-stage"
.
"gem"
performs a single forward map
map_code_test_gem <- map_code(icd9_pc_codes, icdVer_dest = 10, code_type = "pc", method = "gem")
origin_code | src_code | dest_code | map_code |
---|---|---|---|
1421 | 1421 | 085E3ZZ | 10000 |
1421 | 1421 | 085F3ZZ | 10000 |
1422 | 1422 | 085E3ZZ | 10000 |
1422 | 1422 | 085F3ZZ | 10000 |
1423 | 1423 | 085E3ZZ | 10000 |
1423 | 1423 | 085F3ZZ | 10000 |
1424 | 1424 | 085E3ZZ | 10000 |
1424 | 1424 | 085F3ZZ | 10000 |
1425 | 1425 | 085E3ZZ | 10000 |
1425 | 1425 | 085F3ZZ | 10000 |
1426 | 1426 | 085E3ZZ | 10000 |
1426 | 1426 | 085F3ZZ | 10000 |
"reverse-gem"
performs a single reverse map, in this
case finding all ICD-10 codes that map to the ICD-9 code that we pass.
The following are the first 10 results for ICD-9 procedure code
0142
.
map_code_test_reverse_gem <- map_code("0142", icdVer_dest = 10, code_type = "pc", method = "reverse-gem")
origin_code | src_code | dest_code | map_code |
---|---|---|---|
0142 | 0142 | 00580ZZ | 10000 |
0142 | 0142 | 00583ZZ | 10000 |
0142 | 0142 | 00584ZZ | 10000 |
0142 | 0142 | 00880ZZ | 10000 |
0142 | 0142 | 00883ZZ | 10000 |
0142 | 0142 | 00884ZZ | 10000 |
0142 | 0142 | 009800Z | 10000 |
0142 | 0142 | 00980ZZ | 10000 |
0142 | 0142 | 009830Z | 10000 |
0142 | 0142 | 00983ZZ | 10000 |
"both"
performs the "gem"
and
"reverse-gem"
mappings and combines the results.
"multi-stage"
performs the multi-stage mapping that the
icd_convert
function in the touch
package
performs. See here
for details on how the mapping is done. The following are the first 10
results for ICD-9 procedure code 1421
.
map_code_test_multi_stage <- map_code(icd9_pc_codes, icdVer_dest = 10, code_type = "pc", method = "multi-stage")
origin_code | src_code | dest_code | map_code |
---|---|---|---|
1421 | 1421 | 085E3ZZ | 10000 |
1421 | 1421 | 085F3ZZ | 10000 |
1421 | 1421 | 08BE3ZZ | 10000 |
1421 | 1421 | 08BF3ZZ | 10000 |
1422 | 1422 | 085E3ZZ | 10000 |
1422 | 1422 | 085F3ZZ | 10000 |
1422 | 1422 | 08BE3ZZ | 10000 |
1422 | 1422 | 08BF3ZZ | 10000 |
1423 | 1423 | 085E3ZZ | 10000 |
1423 | 1423 | 085F3ZZ | 10000 |
The mapping is performed using General Equivalence Mapping (GEM) files provided by CMS. This package uses the 2018 version of the GEMs files which were the last year which the GEMs files were updated (see here):
As stated in the FY 2016 IPPS/LTCH PPS final rule (80 FR 49388), the GEMs have been updated on an annual basis as part of the ICD-10 Coordination and Maintenance Committee meetings process and will continue to be updated for approximately 3 years after ICD-10 is implemented.
Prefix Matching
In addition to converting an exact ICD code to its counterpart, the
function map_code
allows for a user to search for all ICD
codes matching a prefix. This is useful when converting from ICD 9 to
ICD 10, where ICD 9 used identified subcodes using an overarching code
as the prefix.
For example, if we try to do an exact match on the diagnosis code
7641
, we get no matching codes, and no mapped codes.
map_code_exact <- map_code("7641", icdVer_dest = 10, code_type = "dg", method = "multi-stage", match_method = "exact")
origin_code | src_code | dest_code | map_code |
---|---|---|---|
7641 | NA | NA | NA |
If we switch the match_method
argument to
prefix
, then we are able to find all the subcodes starting
with 7641
and their resulting mapped codes.
map_code_prefix <- map_code("7641", icdVer_dest = 10, code_type = "dg", method = "multi-stage", match_method = "prefix")
origin_code | src_code | dest_code | map_code |
---|---|---|---|
7641 | 76410 | P0500 | 10000 |
7641 | 76410 | P0509 | 10000 |
7641 | 76410 | P0510 | 10000 |
7641 | 76410 | P0519 | 10000 |
7641 | 76411 | P0501 | 10000 |
7641 | 76411 | P0511 | 10000 |
7641 | 76412 | P0502 | 10000 |
7641 | 76412 | P0512 | 10000 |
7641 | 76413 | P0503 | 10000 |
7641 | 76413 | P0513 | 10000 |
The default matching method is exact
.
map_describe
Finally, the map_describe
function combines the
functionality of map_code
and get_description
into one. It maps the codes to the desired ICD version and gets the
corresponding descriptions for the mapped codes. The following are the
first 10 results for ICD-9 procedure code 1421
.
map_describe_test <- map_describe(icd9_pc_codes, icdVer_dest = 10, code_type = "pc", method = "multi-stage")
origin_code | src_code | src_desc | dest_code | dest_desc |
---|---|---|---|---|
1421 | 1421 | Destruction of chorioretinal lesion by diathermy | 085E3ZZ | Destruction of Right Retina, Percutaneous Approach |
1421 | 1421 | Destruction of chorioretinal lesion by diathermy | 085F3ZZ | Destruction of Left Retina, Percutaneous Approach |
1421 | 1421 | Destruction of chorioretinal lesion by diathermy | 08BE3ZZ | Excision of Right Retina, Percutaneous Approach |
1421 | 1421 | Destruction of chorioretinal lesion by diathermy | 08BF3ZZ | Excision of Left Retina, Percutaneous Approach |
1422 | 1422 | Destruction of chorioretinal lesion by cryotherapy | 085E3ZZ | Destruction of Right Retina, Percutaneous Approach |
1422 | 1422 | Destruction of chorioretinal lesion by cryotherapy | 085F3ZZ | Destruction of Left Retina, Percutaneous Approach |
1422 | 1422 | Destruction of chorioretinal lesion by cryotherapy | 08BE3ZZ | Excision of Right Retina, Percutaneous Approach |
1422 | 1422 | Destruction of chorioretinal lesion by cryotherapy | 08BF3ZZ | Excision of Left Retina, Percutaneous Approach |
1423 | 1423 | Destruction of chorioretinal lesion by xenon arc photocoagulation | 085E3ZZ | Destruction of Right Retina, Percutaneous Approach |
1423 | 1423 | Destruction of chorioretinal lesion by xenon arc photocoagulation | 085F3ZZ | Destruction of Left Retina, Percutaneous Approach |