Learn R Programming

icd9 (version 0.2.1)

icd9Comorbidities: merge comorbidities with icd9 codes per visitId (or other identity)

Description

default comorbidity mapping is with AHRQ data. This is slow with long lists of patients, so intended to be used as intermediate step to save files like comorbidPoaInpt

this is not a simple binary, since many codes are exempt, unspecified, or unknown. Therefore, two options are given: get all the comorbidities where the POA flag was definitely -ve, coded as "N" or definitely +ve and coded as "Y". Negating one set won't give the other set unless all codes were either Y or N. #describeIn icd9Comorbidities

gets those comorbidities where the "Present on Arrival" (POA) flag is set to "Y"

Usage

icd9Comorbidities(icd9df, visitId = "visitId", icd9Field = "icd9",
  icd9Mapping = ahrqComorbid, validateMapping = F, shortMapping = T)

icd9ComorbiditiesNotPoa(icd9df, icd9Mapping, visitId = "visitId", icd9Field = "icd9Code", poaField = "poa")

icd9ComorbiditiesPoa(icd9df, icd9Mapping, visitId = "visitId", icd9Field = "icd9Code", poaField = "poa")

Arguments

icd9df
data.frame with fields specified by visitId and icd9Code. icd9Code is assumed to be a non-decimal 'short' form ICD9 code. There is a many to many ratio of icd9:visitId. This table contains multiple visitId rows, with one row per ICD-9 code. Therefore, eve
visitId
The name of the column in the data frame which contains the patient or visit identifier. Typically this is the visit identifier, since patients come leave and enter hospital with different ICD-9 codes. It is a character vector of length one. Defaults to "
icd9Field
The column in the data frame which contains the ICD-9 codes. This is a character vector of length one.
icd9Mapping
list (or name of a list if character vector of length one is given as argument) of the comorbidities with each top-level list item containing a vector of decimal ICD9 codes. This is in the form of a list, with the names of the items corresponding to the c
validateMapping
logical, whether to validate all the ICD-9 codes in the mapping list. Default is not to check. If validation fails, stop with an error. This is probably worth doing at least once for each mapping used, since there should never be an error in mapping. Ther
shortMapping
logical, whether the mapping is defined with short ICD-9 codes (TRUE, the default), or decimal if set to FALSE.
poaField
The name of column in the data frame which contains the Present On Arrival flag. The flag itself is a single character, typically one of "Y", "N", "E", "X", "U" or empty. The poaField is a character vector of length one.