This is the main function which extracts co-morbidities from a
set of ICD-9 codes. This is when some trivial post-processing of the
comorbidity data is done, e.g. renaming to human-friendly field names, and
updating fields according to rules. The exact fields from the original
mappings can be obtained using applyHierarchy = FALSE
, but for
comorbidity counting, Charlson Score, etc., the rules should be applied.
For Charlson/Deyo comorbidities, strictly speaking, there is no dropping of more e.g. uncomplicated DM if complicated DM exists, however, this is probaably useful, in general and is essential when calculating the Charlson score.
icd9ComorbidShortCpp(icd9df, icd9Mapping, visitId, icd9Field, threads = 8L, chunkSize = 256L, ompChunkSize = 1L, aggregate = TRUE)
icd9Comorbid(icd9df, icd9Mapping, visitId = NULL, icd9Field = NULL, isShort = icd9GuessIsShort(icd9df[1:100, icd9Field]), isShortMapping = icd9GuessIsShort(icd9Mapping), return.df = FALSE, ...)
icd9ComorbidShort(...)
icd9ComorbidAhrq(..., abbrevNames = TRUE, applyHierarchy = TRUE)
icd9ComorbidQuanDeyo(..., abbrevNames = TRUE, applyHierarchy = TRUE)
icd9ComorbidQuanElix(..., abbrevNames = TRUE, applyHierarchy = TRUE)
icd9ComorbidElix(..., abbrevNames = TRUE, applyHierarchy = TRUE)
icd9Comorbidities(...)
icd9ComorbiditiesAhrq(...)
icd9ComorbiditiesElixHauser(...)
icd9ComorbiditiesQuanDeyo(...)
icd9ComorbiditiesQuanElixhauser(...)
applyHierarchy
below)NULL
, then an
attempt is made to guess which field has the ID for the patient encounter
(not a patient ID, although this can of course be specified directly). The
guesses proceed until a single match is made. Data frames may be wide with
many matching fields, so to avoid false positives, anything but a single
match is rejected. If there are no successful guesses, and visitId
was not specified, then the first column of the data frame is used.NULL
, icd9
will attempt to guess the column name, looking for progressively less
likely possibilities until it matche a single column. Failing this, it will
take the first column in the data frame. Specifying the column using this
argument avoids the guesswork.FALSE
, then each contiguous group of visit
IDs will result in a row of comorbidities in the output data. If you know your visitIds are possible disordered,
then use TRUE
.icd9Mapping
instead of icd9df
. All the codes in a mapping should be of the same
type, i.e. short or decimal.icd9ComorbiditiesAhrq
are passed on
to icd9ComorbidAhrq
TRUE
, in
which case the ishorter human-readable names stored in e.g.
ahrqComorbidNamesAbbrev
are applied to the data frame column names.TRUE
, in
which case the hierarchy defined for the mapping is applied. E.g. in
Elixhauser, you can't have uncomplicated and complicated diabetes both
flagged.aggregate
produced. The threading of the C++ can be controlled using e.g.
option(icd9.threads = 4)
. If it is not set, the number of cores in
the machine is used.
pts <- data.frame(visitId = c("2", "1", "2", "3", "3"),
icd9 = c("39891", "40110", "09322", "41514", "39891"))
icd9ComorbidShort(pts, ahrqComorbid) # visitId is now sorted
Run the code above in your browser using DataLab