chars_icd_ccs_count: Count (non-injury) Comprehensive Hospital Abstract Reporting...

View source: R/chars_functions.R

chars_icd_ccs_countR Documentation

Count (non-injury) Comprehensive Hospital Abstract Reporting System (CHARS) hospitalizations

Description

Generate hospitalization counts from WA State Comprehensive Hospital Abstract Reporting System (CHARS) data using partial strings from the ICD-10-CM or ICD-9-CM descriptions or AHRQ HCUP's CCSR based 'broad' and 'detailed' classifications. Needs line-level CHARS data with a properly formatted ICD-CM column (e.g., the data available from get_data_chars()).

See chars_icd_ccs() for a complete list of available ICD-10-CM, ICD-9-CM, and superlevel, broad, midlevel, and narrow classifications.

¡¡¡REMEMBER!!! ICD-10-CM started in 2016! Be sure to use the correct icdcm_version.

Usage

chars_icd_ccs_count(
  ph.data = NULL,
  icdcm_version = 10,
  CMtable = NULL,
  icdcm = NULL,
  superlevel = NULL,
  broad = NULL,
  midlevel = NULL,
  detailed = NULL,
  icdcol = "diag1",
  group_by = NULL,
  kingco = T,
  mykey = "hhsaw"
)

Arguments

ph.data

a data.table or data.frame. Must contain CHARS data structured with one person per row and with at least one column of ICD CM codes.

NOTE! ph.data must have a column named seq_no, which is a unique patient level identifier.

The default is ph.data = NULL

icdcm_version

an integer vector of length one specifying the ICD CM version that you want to reference. Acceptable options include: 9 & 10.

The default is icdcm_version = 10.

CMtable

An optional data.table containing the reference table of ICD codes and their classifications. This should come from chars_icd_ccs and have the following columns: icdcm_code, icdcm, superlevel, broad, midlevel, detailed, and icdcm_version. If provided, the function will use this table instead of making a new call to chars_icd_ccs, which can significantly improve performance when making multiple calls to this function.

The default is CMtable = NULL, which means the function will fetch the reference table from the database using chars_icd_ccs.

icdcm

a character vector of length 1. An ICD CM description OR code. It is case agnostic and works with partial strings. For example, both 'rotavira' & 'A080' would provide the results for 'Rotaviral enteritis' for ICD-10-CM. You can also combine multiple search terms. For example, 'rotavira|choler' would count all Rotaviral enteritis AND cholera hospitalizations. View available options with chars_icd_ccs(ref_type = 'icdcm', icdcm_version = 10).

The default is icdcm = NULL

superlevel

a character vector of length 1. Case agnostic and works with partial strings. View available options with chars_icd_ccs(ref_type = 'superlevel', icdcm_version = 10).

The default is superlevel = NULL

broad

a character vector of length 1. Case agnostic and works with partial strings. View available options with chars_icd_ccs(ref_type = 'broad', icdcm_version = 10).

The default is broad = NULL

midlevel

a character vector of length 1. Case agnostic and works with partial strings. View available options with chars_icd_ccs(ref_type = 'midlevel', icdcm_version = 10).

The default is midlevel = NULL

detailed

a character vector of length 1. Case agnostic and works with partial strings. View available options with chars_icd_ccs(ref_type = 'detailed', icdcm_version = 10).

The default is detailed = NULL

icdcol

a character vector of length one that specifies the name of the column in ph.data that contains the ICD10-cm codes of interest.

The default is icdcol = 'diag1', which refers to the principal diagnosis code provided by get_data_chars()).

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

kingco

a logical vector of length one. It specifies whether you want to limit the analysis to King County.

NOTE this only works with data imported with the get_data_chars() function because it needs the variable chi_geo_kc.

The default is kingco = TRUE.

mykey

Character vector of length 1. Identifies the keyring:: service that can be used to access the Health & Human Services Analytic Workspace (HHSAW).

The default is mykey = 'hhsaw'

Details

This function needs the user to enter a search string in one or more of the following arguments in order to search the CHARS data for the corresponding ICD CM codes: icdcm, superlevel, broad, midlevel, or detailed. Partial search terms are acceptable and they are case-insensitive. For example, if you set broad = 'ex' with icdcm_version = 10, the function would return counts for "Diseases of the eye and adnEXa" as well as "EXternal causes of morbidity". It also understands simple regex syntax, including ^, $, and |.

Note: If you submit values for more than one of icdcm, superlevel, broad, midlevel, or detailed they must be nested. For example, broad = 'neoplasms', detailed = 'sarcoma' will give results because sarcomas are type of cancers. However, broad = 'neoplasms', detailed = 'intestinal infection' will return an error because your resulting table will have zero rows.

Value

Generates a table with columns for each of the search terms you entered (e.g., icdcm, broad, and/or detailed) as well as any group_by variables and a column named hospitalizations that contains the relevant counts.

Examples

# example #1: 2019 King County hospitalizations for chemotherapy, by sex

blah = get_data_chars(year = 2019, kingco = TRUE)
myresult <- chars_icd_ccs_count(ph.data = blah,
                                detailed = 'headache',
                                group_by = c('chi_sex'))
print(myresult)


# example #2: 2022 King County hospitalizations for asthma using
# an external reference table

myrefTable <- chars_icd_ccs()

mydata = get_data_chars(year = 2022, kingco = TRUE)
myresult <- chars_icd_ccs_count(ph.data = mydata,
                                CMtable = myrefTable,
                                detailed = 'asthma',
                                group_by = c('chi_sex'))
print(myresult)



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