chars_injury_matrix_count: Generate injury matrix counts from line-level Comprehensive...

View source: R/chars_functions.R

chars_injury_matrix_countR Documentation

Generate injury matrix counts from line-level Comprehensive Hospital Abstract Reporting System (CHARS) data

Description

Generate hospitalization counts for an injury matrix specifying the intent and mechanism of injury. Needs line-level CHARS data with columns beginning with mechanism_ and intent_. Covers both ICD9-cm (2012-2015) and ICD10-cm (2016+).

Usage

chars_injury_matrix_count(
  ph.data = NULL,
  intent = "*",
  mechanism = "*",
  group_by = NULL,
  def = "narrow",
  primary_ecode = T,
  kingco = T
)

Arguments

ph.data

a data.table or data.frame. Must contain CHARS data structured with one person per row and predetermined mechanism_ and intent_ columns. In other words, this ph.data should come from use of get_data_chars().

The default is ph.data = NULL

intent

a character vector. It specifies the intent of the injury related hospitalization that you want returned (e.g., "assault", "intentional", "unintentional", etc.). "none" will ignore the intent and only return the mechanism of the injury leading to hospitalization.

NOTE You do not have to type the entire keyword for the intent, a partial string match is sufficient and is case insensitive. E.g., intent = c("intent") would return both "intentional" and "unintentional" and intent = c("un") would return both "undetermined" and "unintentional".

The default is intent = '*', which selects all possible intents

mechanism

a character vector. It specifies the mechanism of the injury related hospitalization that you want returned (e.g., "cut_pierce", "drowning", "fall", "firearm", etc.). "none" will ignore the mechanism and only return the intent of the injury leading to hospitalization.

To see the complete list of mechanisms, type unique(chars_injury_matrix()$mechanism) in your R console.

NOTE You do not have to type the entire keyword for the mechanism, a partial string match is sufficient and is case insensitive. E.g., mechanism = c("fire") would return both "firearm" and "fire_burn".

The default is mechanism = '*', which selects all possible mechanisms

group_by

a character vector of indeterminate length. This is used to specify all the variables by which you want to group (a.k.a. stratify) the results. For example, if you specified group_by = c('chi_sex', 'chi_race_6'), the results would be stratified by each combination of sex and race.

The default is group_by = NULL

def

a character vector of length one, limited to 'narrow' or 'broad'. It specifies whether you want to use the CDC's recommended 'narrow' approach, which requires that the principal diagnosis of an injury hospitalization be a nature-of-injury ICD10-CM code. Or, alternatively, the 'broad' definition that searches all available diagnosis fields on the hospital discharge record (there can be a maximum of 54 diagnosis fields in CHARS data).

NOTE ph.data must contain the columns named injury_nature_narrow & injury_nature_broad.

The default is def = 'narrow'

primary_ecode

a logical vector of length one. It specifies whether you want to limit the analysis to using just the primary ecode (i.e., the injury_ecode variable), rather than all available ecodes.

As of RADS 1.1.7.7, the only valid argument is TRUE (T). Those wanting to perform an analysis with other ecodes would need to perform a custom analysis in SQL using the chars.stage_diag & chars.stage_ecode tables.

The default is primary_ecode = TRUE

kingco

a logical vector of length one. It specifies whether you want to limit the analysis to King County. Note that this only works when you have the column chi_geo_kc imported from the get_data_chars() function.

The default is kingco = TRUE

Details

Since the injury analysis uses many columns, we suggest that you obtain ph.data with get_data_chars(cols = NA), rather than trying to specify the columns of interest.

This function will only count injuries where the type of injury (from ICD10-CM codes) AND the corresponding external cause information (from an ecode) is present. To examine injuries that do not have an external cause, please examine the analytic data directly.

See Jeremy Whitehurst's documentation for the CHARS ETL to understand exactly which codes are mapped to which intents and mechanisms.

Value

The function returns a data.table with a minimum of three columns: mechanism, intent, & hospitalizations. Any group_by variables would also have their own columns.

The function default is to return the matrix of all intents and mechanisms of injury related hospitalizations. You can choose to only return the intent or only return the mechanism. If you set both to "none", you will receive a summary of all injury hospitalizations without regard to the intent or mechanism.

References

WA DOH CHAT: https://secureaccess.wa.gov/doh/chat/Content/FilesForDownload/CodeSetDefinitions/Hospitalization%20Injury%20Matrix%20ICD10CM.xlsx

Examples

# example: 2019 King County hospitalizations due to intentional injury, by sex

blah = get_data_chars(year = 2019, kingco = TRUE)
myresult <- chars_injury_matrix_count(ph.data = blah,
                                      intent = '^intentional',
                                      mechanism = 'none',
                                      group_by = c('chi_sex'))
print(myresult)


PHSKC-APDE/rads documentation built on April 14, 2025, 10:47 a.m.