The comorbidities classification (AHRQ, Charlson ,and Elixhauser Comorbidity) for ICD diagnostic codes is a diagnostic categorization scheme that can employ in many types of projects analyzing data on diagnoses.

icdDxToComorbid(
  dxDataFile,
  idColName,
  icdColName,
  dateColName,
  icdVerColName = NULL,
  icd10usingDate = NULL,
  comorbidMethod,
  isDescription = FALSE
)

Arguments

dxDataFile

A data frame object of clinical diagnostic data with at least 3 columns: ID, ICD, and Date. As for date column, the data format should be YYYY/MM/DD or YYYY-MM-DD.

idColName

Column name of ID column in dxDataFile. Data type of this argumant should be string without quotation marks.

icdColName

Column name of ICD column in dxDataFile. Data type of this argumant should be string without quotation marks.

dateColName

Column name of date column in dxDataFile, and the type of date column should be a date format in R or a string format with date information in YYYY/MM/DD or YYYY-MM-DD. Data type of this argumant should be string without quotation marks.

icdVerColName

(Optional) Column name if there is a columns to record ICD-9/10 version used in dxDataFile. In this column, data format should be numeric 9L or 10L to indicate which ICD version is used for each cell. See examples below to get more information.

icd10usingDate

The date that ICD-10 was started to be used in dxDataFile dataset. The data format should be YYYY/MM/DD or YYYY-MM-DD. Necessary if icdVerColName is null.

comorbidMethod

Three comorbidity methods: AHRQ, Charlson and Elixhauser Comorbidity. Change it to any of the other possible variables (ahrq,charlson, and elix).

isDescription

Category name or category description of standard classification methods for ICD diagnostic codes. By default it is set to FALSE (Comorbidity categories).

Value

Three new data.tables. 1) groupedDT: Based on dxDataFile with two new columns for uniform format diagnostic codes and classified categories. 2) summarised_groupedDT: Summarized the groupedDT dataset and sorted by memberID. 3) Error: Potential error codes from standardization step: dxUniform (`icdDxShortToDecimal` and `icdDxDecimalToShort`).

Details

Collapse ICD codes into a smaller number of clinically meaningful categories that are more useful for presenting descriptive statistics than are individual ICD diagnostic codes.

See also

Other code classification functions: dxPheWAS, dxCustom, DxCCS

Examples

# sample file for example

head(sampleDxFile)
#>     ID  ICD       Date Version
#> 1:  A2 Z992 2020-05-22      10
#> 2:  A5 Z992 2020-01-24      10
#> 3:  A8 Z992 2015-10-27      10
#> 4: A13 Z992 2020-04-26      10
#> 5: A13 Z992 2025-02-02      10
#> 6: A15 Z992 2023-05-12      10

# Group diagnostic codes into charlson comorbidity categories

icdDxToComorbid(sampleDxFile, ID, ICD, Date, icdVerColName = NULL, "2015-10-01", charlson)
#> Wrong ICD format: total 9 ICD codes (the number of occurrences is in brackets)
#> c("A0.11 (20)", "E114 (8)", "Z9.90 (6)", "F42 (6)", "001 (5)", "75.52 (4)", "755.2 (3)", "123.45 (3)", "7552 (2)")
#> 	
#> Wrong ICD version: total 7 ICD codes (the number of occurrences is in brackets)
#> c("V27.0 (18)", "A01.05 (8)", "42761 (7)", "V24.1 (6)", "A0105 (5)", "E03.0 (4)", "650 (4)")
#> 	
#> Warning: The ICD mentioned above matches to "NA" due to the format or other issues.
#> Warning: "Wrong ICD format" means the ICD has wrong format
#> Warning: "Wrong ICD version" means the ICD classify to wrong ICD version (cause the "icd10usingDate" or other issues)
#> $groupedDT
#>       Short  ID    ICD       Date Comorbidity
#>   1:   Z992  A2   Z992 2020-05-22          RD
#>   2:   Z992  A5   Z992 2020-01-24          RD
#>   3:   Z992  A8   Z992 2015-10-27          RD
#>   4:   Z992 A13   Z992 2020-04-26          RD
#>   5:   Z992 A13   Z992 2025-02-02          RD
#>  ---                                         
#> 296:    650  C2    650 2017-10-10        <NA>
#> 297:    650  D4    650 2022-04-04        <NA>
#> 298: 123.45  C3 123.45 2022-09-28        <NA>
#> 299: 123.45  D8 123.45 2018-06-17        <NA>
#> 300: 123.45  C0 123.45 2017-05-09        <NA>
#> 
#> $summarised_groupedDT
#>      ID Comorbidity firstCaseDate endCaseDate count    period
#>  1:  A0          RD    2009-07-25  2013-12-20     5 1609 days
#>  2:  A1          RD    2006-11-29  2014-09-24     5 2856 days
#>  3: A10          RD    2007-11-04  2012-07-30     5 1730 days
#>  4: A11          RD    2008-03-09  2011-09-03     5 1273 days
#>  5: A11      DIAB_C    2015-12-16  2015-12-16     1    0 days
#>  6: A12          RD    2006-05-14  2015-06-29     5 3333 days
#>  7: A13          RD    2006-04-29  2025-02-02     5 6854 days
#>  8: A14          RD    2006-11-28  2014-12-21     5 2945 days
#>  9: A15          RD    2007-05-25  2023-05-12     5 5831 days
#> 10: A16          RD    2007-04-15  2014-12-05     5 2791 days
#> 11: A17          RD    2007-02-19  2014-07-03     5 2691 days
#> 12: A18          RD    2007-04-05  2014-03-04     5 2525 days
#> 13:  A2          RD    2011-09-20  2020-05-22     5 3167 days
#> 14:  A3          RD    2008-07-08  2014-02-24     5 2057 days
#> 15:  A4          RD    2006-10-20  2015-03-09     5 3062 days
#> 16:  A5          RD    2009-09-10  2020-01-24     5 3788 days
#> 17:  A6          RD    2007-10-01  2015-07-12     5 2841 days
#> 18:  A7          RD    2007-02-01  2014-08-14     5 2751 days
#> 19:  A8          RD    2007-11-22  2015-10-27     5 2896 days
#> 20:  A9          RD    2007-03-05  2013-11-09     5 2441 days
#> 21:  B0          RD    2015-12-26  2024-02-12     6 2970 days
#> 22:  B1          RD    2016-08-08  2024-03-04     6 2765 days
#> 23:  B2          RD    2016-03-20  2024-09-20     6 3106 days
#> 24:  B3          RD    2019-05-07  2025-05-25     6 2210 days
#> 25:  B4          RD    2015-12-02  2025-07-21     6 3519 days
#> 26:  C0      CANCER    2015-12-05  2025-02-21     5 3366 days
#> 27:  C1      CANCER    2018-02-13  2025-02-20     5 2564 days
#> 28:  C2      CANCER    2016-09-09  2024-12-12     5 3016 days
#> 29:  C2      DIAB_C    2017-07-08  2017-07-08     1    0 days
#> 30:  C3      CANCER    2015-12-06  2021-10-22     4 2147 days
#> 31:  C4      CANCER    2017-08-29  2025-09-05     5 2929 days
#> 32:  C4      DIAB_C    2015-11-23  2015-11-23     1    0 days
#> 33:  D0         PUD    2017-12-24  2017-12-24     1    0 days
#> 34:  D0      DIAB_C    2017-01-29  2020-04-04     3 1161 days
#> 35:  D1       Rheum    2016-12-06  2016-12-06     1    0 days
#> 36:  D1        MSLD    2024-04-04  2024-04-04     1    0 days
#> 37:  D2      CANCER    2019-10-13  2019-10-13     1    0 days
#> 38:  D3         PVD    2017-11-19  2017-11-19     1    0 days
#> 39:  D4      CANCER    2020-03-10  2020-03-10     1    0 days
#> 40:  D4      DIAB_C    2019-01-03  2019-01-03     1    0 days
#> 41:  D4        CEVD    2020-10-06  2020-10-06     1    0 days
#> 42:  D5      CANCER    2021-02-13  2021-02-13     1    0 days
#> 43:  D5       Rheum    2022-10-10  2022-10-10     1    0 days
#> 44:  D5        COPD    2014-11-15  2014-11-15     1    0 days
#> 45:  D5      DIAB_C    2023-07-23  2023-07-23     1    0 days
#> 46:  D7       Rheum    2021-12-03  2021-12-03     1    0 days
#> 47:  D7      CANCER    2012-07-04  2012-07-04     1    0 days
#> 48:  D7      DIAB_C    2021-08-21  2021-08-21     1    0 days
#> 49:  D8         PVD    2021-03-18  2021-03-18     1    0 days
#> 50:  D8      CANCER    2025-09-10  2025-09-10     1    0 days
#> 51:  D8        PARA    2010-09-27  2010-09-27     1    0 days
#>      ID Comorbidity firstCaseDate endCaseDate count    period
#> 
#> $Error
#>        ICD count IcdVersionInFile     WrongType Suggestion
#>  1:  A0.11    20           ICD 10  Wrong format           
#>  2:  V27.0    18           ICD 10 Wrong version           
#>  3:   E114     8           ICD 10  Wrong format           
#>  4: A01.05     8            ICD 9 Wrong version           
#>  5:  42761     7           ICD 10 Wrong version           
#>  6:  Z9.90     6           ICD 10  Wrong format           
#>  7:    F42     6           ICD 10  Wrong format           
#>  8:  V24.1     6           ICD 10 Wrong version           
#>  9:  A0105     5            ICD 9 Wrong version           
#> 10:    001     5            ICD 9  Wrong format       0019
#> 11:  75.52     4            ICD 9  Wrong format           
#> 12:  E03.0     4            ICD 9 Wrong version           
#> 13:    650     4           ICD 10 Wrong version           
#> 14: 123.45     3           ICD 10  Wrong format           
#> 15:  755.2     3            ICD 9  Wrong format     755.29
#> 16:   7552     2            ICD 9  Wrong format      75529
#>