---
title: "Implementation Details"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{implementation}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

```{r setup}
library(icdpicr2)
```

*Version 250706*


### Background

ICDPIC -- International Classification of Diseases Programs for Injury Categorization was originally developed using ICD Version 9 Clinical Modification (ICD-9-CM) diagnosis codes and Stata statistical software (Statacorp, College Station, Texas).  After the introduction of ICD-10-CM to US hospitals in 2015, an update to accommodate this change was developed using R statistical software (R Project, Vienna, Austria). The context for ICDPIC and the R package “icdpicr”, along with a general history of injury severity scoring, has been presented in a previous publication.[1]

Initial development of the ICDPIC Stata programs occurred as part of research projects funded by the National Center for Injury Prevention and Control through the Harvard Injury Control Research Center (CDC R49/CCR 115279) and by the Maine Medical Center (MMC) Research Strategic Plan. The translation of ICDPIC to R was initially supported by funding from the MMC Division of Trauma and Surgical Critical Care and MMC Center for Outcomes Research and Evaluation. The authors are grateful for this support.

The R package “icdpicr2” was developed using the American College of Surgeons (ACS) Trauma Quality Program (TQP) Participant Use File (PUF) and the Agency for Healthcare Research and Quality (AHRQ) Healthcare Cost and Utilization Project (HCUP) National Inpatient Sample (NIS).  The TQP PUF is the successor to the ACS Trauma Quality Improvement Program (TQIP) Research Data File and the ACS National Trauma Data Bank (NTDB) Research Data Set; NIS was previously called the Nationwide Inpatient Sample.  The original data are not provided as part of “icdpicr2”, but can be obtained by others following the Data Use Agreements of the sponsoring organizations.  Content reproduced from the TQP PUF remains the full and exclusive copyrighted property of the ACS, which is not responsible for any claims arising from works based on the original data.  Content reproduced from the NIS does not constitute the findings, policies, or recommendations of the U.S. Government, the U.S. Department of Health, or AHRQ.

Version 0 of “icdpicr” was provided on github.com, and Version 1 was added to the Comprehensive R Archive Network (CRAN) in January 2021.  This transition responded to issues raised by Sebastião and colleagues[2], and attempted to address the concerns of Airiksinen and colleagues[3] that methods developed for the ICD-10-CM modification used in the United States did not work well for other countries.  An independent evaluation of “icdpicr” Version 1 by Wan and colleagues[4] has found that it works quite well for ICD-10-CM data, but studies from other countries have still found it less satisfactory.[5,6]  Eskesen and colleagues[6] have pointed out that it does not even include all valid ICD-10 diagnoses published by the World Health Organization (WHO).     

Version 2 of “icdpicr”, named “icdpicr2”, is a further update in response to these studies and numerous other inquiries and suggestions.  Because of copyright restrictions, it only attempts to approximate the original version of the Abbreviated Injury Score (AIS).[7]  


### The most important changes from Version 1 to Version 2 are as follows:

* Version 1 of “icdpicr” used TQIP and NIS data from 2016-2017.  Version 2 (“icdpicr2”) uses data from 2020.  Version 2 makes no attempt to accommodate ICD-9 data and requires that data be in ICD-10 format.

* Version 1 of “icdpicr” required the user to specify whether data were in ICD-10-CM or a basic ICD-10 format.  Version 2 (“icdpicr2”) combines all ICD-10-CM and other simpler ICD-10 codes (including those previously omitted) in the same table.  

* The “ROCmax” option in Version 1 of “icdpicr” replaced the original *ad hoc* algorithm with the well-established methodology of ridge regression to estimate the independent effect of each injury diagnosis.  Version 1 also required the user to choose either the TQIP PUF or the NIS as the reference database.  Version 2 (“icdpicr2”) only uses the ROCmax method, again based on ridge regression.  It provides regression results from both the TQP and NIS models, and a single estimated AIS averaged from both sources and adjusted as described below.  
 
* In response to user feedback, Version 2 (“icdpicr2”) modifies the AIS assignments to make them more internally consistent (e.g., a right-sided injury has the same AIS as an otherwise identical left-sided injury).  The lookup table of injury codes now also includes valid codes not in either reference database (including basic or truncated ICD-10 codes) and AIS values are assigned to these codes using a weighted average of similar codes.  Where possible, ICD-10 injury codes published by the WHO now have AIS assigned directly based upon the data gathered from seven different countries as part of an International Collaborative Effort on Injury Statistics.[8] 

* As before, Version 2 (“icdpicr2”) reports Maximum AIS for each body region and overall, Injury Severity Score (ISS),[9] and “New Injury Severity Score”,[10] and now reports the mortality predictions both from TQP and from NIS for each individual.

* Version 2 (“icdpicr2”) reports mechanism and intent categories following the most recent CDC publication.[11]  It adds the CDC framework for body area and nature of injury,[12] and calculates an approximate survival probability based on the empirical survival for each cell of the framework.[13]  It computes two versions (“multiplicative injury” and “worst injury”) of an “ICD-based Injury Severity Score” (ICISS) based on international data.[8,14]  It also computes similar versions of ICISS based on TQP and NIS.   

* Version 2 (“icdpicr2”) has also been modified in several ways so that it will run faster than previous versions, mostly by using more efficient methods of calculation.


### **The following programs were used to develop Version 2 (“icdpicr2”):**

* **icd10aisA** – Reads in raw data from the 2020 TQP PUF or the 2020 NIS.  Identifies cases with a principal injury diagnosis specified by an ICD-10-CM code.  The National Trauma Data Standard used by TQP considers valid ICD-10-CM injury codes to be those in the ranges S00-S99, T07, T14, T20-T28, and T30-T32, so icd10aisA recognizes only these codes in the calculation of injury severity.  The program also requires that ICD-10-CM injury codes starting with the letter “S” conclude with the letter “A” (indicating an initial encounter), except for codes indicating a fracture, where codes concluding with the letters “B” or “C” indicate an initial encounter with an open fracture.
 
* **icd10aisB** – Reads in each of the data sets prepared by icd10aisA, transforms them into matrices, and performs logistic ridge regression with death as an outcome, using R package “glmnet”, which is described in detail in the documentation for that package.  For each reference dataset (TQP PUF or NIS), the logistic ridge regression results in an independent estimate of effect (log odds ratio) for each diagnosis code. These are tabulated and can be combined with the estimated model intercept to estimate the probability of mortality for individual subjects.  Body regions as defined for the original ISS [8] are determined for each ICD-10-CM code.

* **icd10aisC** – Reads in the tabulated effect estimates for each diagnosis code produced by icd10aisB and determines the largest effect estimate in each ISS body region for each subject, which will subsequently be stratified into Abbreviated Injury Scores (AIS) [7] and used to estimate ISS.[8]  For each reference dataset, icd10aisC initializes cutpoints categorizing the largest effect estimate for each body region into an AIS score of 1, 2, 3, 4, or 5.  The program then uses an adaptive algorithm that randomly varies the cutpoints to determine the combination of cutpoints for which the c-statistic (area under a Receiver Operator Characteristic curve) for ISS to predict mortality is maximized.  For each diagnosis and reference dataset, the program tabulates the optimal AIS estimates along with the effect estimates and intercepts from ridge regression. 

* **icd10aisD** (New in Version 2) – Modifies the AIS scores obtained by icd10aisC in the following ways:

	1. Creates a common AIS score for each ICD-10-CM code as a weighted average of the results from TQP PUF and NIS.

	2. Creates a common AIS score for ICD-10-CM codes S06.##2A … S06.##9A, which specify lengths of coma and in some cases whether a subject lived or died after intracranial injury.  Retaining outcome information in the diagnosis code would result in overfitting of the ISS model.

	3. Creates a common AIS score for otherwise identical ICD-10-CM codes that specify whether an injury was right-sided, left-sided, or unspecified with respect to laterality.

	4. Assigns an AIS score to truncated ICD-10-CM codes (3-6 digits long) as a weighted average of the corresponding 7-digit ICD-10-CM codes. This includes most basic ICD-10 codes.

	5. Assigns an AIS score to ICD-10 injury codes published by the WHO, using a modification of the data published by Gedeborg and colleagues.[8]  When available, these AIS scores replace those determined in the step above.  Creates a table of all valid ICD-10 diagnosis codes with associated body region and AIS in order to calculate ISS; this table also includes the direct effects from regression.  Creates another table with “Diagnosis-specific Survival Probabilities” (DSP) for 4-digit ICD-10 codes, either obtained directly from the data published by Gedeborg and colleagues [8] or indirectly by assignment of DSP to a 4-digit truncation of longer diagnosis codes; these can be used to calculate several versions of the “ICD-based Injury Severity Score” (ICISS).[8,14]

* **icd10aisE** (New in Version 2) – Produces a table of injury mechanisms and intents based upon codes starting with T, V, W, X, or Y in ICD-10 data.[11]  Produces a table corresponding to the “Framework for Presenting Injury Data” developed by the CDC,[12] modeled after the “Barell Matrix” previously developed for ICD-9.  The TQP PUF and NIS survival for subjects with an ICD-10-CM diagnosis in each cell of the framework is also calculated, and the minimum cell survival for a given subject is provided as a rough estimate of severity.[13]

Programs icd10aisA, icd10aisB, icd10aisC, icd10aisD, and icd10aisE, and a modification of the data table published by Gedeborg and colleagues[8] can be found at https://github.com/clark-david/icdpicr2/tree/main/prelim/.


### **The following tables are available in R after downloading “icdpicr2”:**

* **i10_map_sev:** This table is new in Version 2, replacing i10_map_roc.  It uses the results of icd10aisC and icd10aisD to produce an approximate AIS score and body region for any ICD-10 code and effect estimates from the ridge regression for any ICD-10-CM code contained either in TQP or NIS.

* **i10_map_mech:**  This table is new in Version 2, replacing i10_ecode.  It uses the results of icd10aisE to assign a mechanism category for any ICD-10 external cause of injury code (starting with letters T, V, W, X, or Y), using a table proposed by the CDC.[11]

* **i10_map_iciss:**  This table is new in Version 2.  It uses the results of icd10aisD to assign ICD-10 injury codes to a 4-digit ICD-10 code (or a truncated version of longer modified ICD-10 codes) and its associated “Diagnosis-specific Survival Probability” (DSP) based on data published by Gedeborg and colleagues.[8]  Assigns similar DSPs based on data from TQP and NIS.

* **i10_map_frame:**  This table is new in Version 2.  It uses the results of icd10aisE to assign ICD-10 injury codes to a cell in the CDC “Framework for Presenting Injury Data”.[12]  It also includes an estimated survival for patients with a diagnosis in that cell, based upon the results of icd10aisE.

* **testdata:**  Sample data that can be used to demonstrate the functioning of the programs.


### **The following functions are available in R after downloading “icdpicr2”:**

* **Program “cat_trauma2”**
Reads in user data in the specified format.  Returns AIS, ISS, NISS, mortality predictions from the TQP and NIS models, and injury mechanisms.  Further details about the available options are provided in the help file for this function.

* **Program “iciss”**
Reads in user data in the specified format.  Returns “multiplicative” and “minimum” versions of the “ICD-based” Injury Severity Score (ICISS) based on international data, TQP, and NIS.  Further details about the available options are provided in the help file for this function.

* **Program “framework”**
Reads in user data in the specified format.  Assigns each ICD-10 injury code to a cell in the CDC “Framework for Presenting Injury Data”.[12]  Returns a predicted survival for each case.  Further details about the available options are provided in the help file for this function.



### **Updates from 2.0 - 2.1**

* Add some newer diagnosis codes to lookup tables (see icd10aisD and icd10aisE)

* Add ICISS calculations based on TQP and NIS

* Reprogram functions to run faster (especially for large databases)

* Modify format to be compatible with CRAN

* Update documentation




### **References**

1. Clark DE, Black AW, Skavdahl DH, Hallagan LD. Open-access programs for injury categorization using ICD-9 or ICD-10. Inj Epidemiol 2018; 5:11.

2. Sebastião YV, Metzger GA, Chisolm DJ, Xiang H, Cooper JN. Impact of ICD-9-CM to ICD-10-CM coding transition on trauma hospitalization trends among young adults in 12 states. Inj Epidemiol 2021; 8:4

3. Airaksinen NK, Heinänen MT, Handolin LE. The reliability of the ICD-AIS map in identifying serious road traffic injuries from the Helsinki Trauma Registry. Injury 2019; 50:1545-1551.

4. Wan V, Reddy S, Thomas A, Issa N, Posluszny J, Schwulst S, Shapiro M, Alam H, Bilimoria KY, Stey AM.  How does Injury Severity Score derived from ICDPIC utilizing ICD-10-CM codes perform compared to Injury Severity Score derived from TQIP?  J Trauma Acute Care Surg 2023; 94:141-147.

5. Niemann M, Märdian S, Niemann P, Tetteh L, Tsitsilonis S, Braun KF, Stöckle U, Graef F.  Transforming the German ICD-10 (ICD-10-GM) into Injury Severity Score (ISS) – Introducing a new method for automated re-coding.  Plos One 2021: 16(9):e0257183.

6. Eskesen TO, Sillesen M, Rasmussen LS, Steinmetz J.  Agreement between standard and ICD-10-based Injury Severity Scores.  Clin Epidemiol 2022; 14:201-210.

7. Committee on Medical Aspects of Automotive Safety, AMA. Rating the severity of tissue damage. I. The abbreviated scale. JAMA 1971; 215:277-280.

8. Gedeborg R, Warner M, Chen L-H, Gulliver P, Cryer C, Robitaille Y, Bauer R, Ubeda C, Lauritsen J, Harrison J, Henley G, Langley J.  Internationally comparable diagnosis-specific survival probabilities for calculation of the ICD-10-based Injury Severity Score.  J Trauma Acute Care Surg 2014; 76:358-365.

9. Baker SP, O’Neill B, Haddon W Jr., Long WB. The injury severity score: A method for describing patients with multiple injuries and evaluating emergency care. J Trauma 1974; 14:187-196.

10. Osler T, Baker SP, Long WA. Modification of the injury severity score that both improves accuracy and simplifies scoring. J Trauma 1997; 43:922-925.

11. Hedegaard H, Johnson RL, Garnett MF, Thomas KE.  The International Classification of Diseases, 10th Revision, Clinical Modification (ICD-10-CM) external cause of injury framework for categorizing mechanism and intent of injury.  Nat Health Stat Reports 2019; 136:1-21.

12. Hedegaard H, Johnson RL, Garnett MF, Thomas KE.  The 2020 International Classification of Diseases, 10th Revision, Clinical Modification injury diagnosis framework for categorizing injuries by body region and nature of injury.  Nat Health Stat Reports 2020; 150:1-26.

13. Clark DE, Ahmad S.  Estimating injury severity using the Barell matrix.  Inj Prev 2006; 12:111-116.

14. Berecki-Gisolf J, Rezaei-Darzi E, Fernando DT, D’Elia A.  International Classification of Disease based Injury Severity Score (ICISS): a comparison of methodologies applied to linked data from New South Wales, Australia.  Inj Prev 2024; 0:1-8 ePub ahead of print.




### **Contents**

* Background

* Principal changes from Version 1 to Version 2

* Programs used in calculating severity scores

* Tables available in “icdpicr2”

* Functions available in “icdpicr2”

* Updates from Version 2.0 to Version 2.1

* References

