icd9 (version 1.3.1)

icd9FilterPoa: Filters data frame based on present-on-arrival flag

Description

Present On Arrival (POA) is not a simple flag, 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 icd9Comorbid

Usage

icd9FilterPoa(icd9df, poaField = "poa", poa = icd9PoaChoices)
icd9FilterPoaYes(icd9df, poaField = "poa")
icd9FilterPoaNo(icd9df, poaField = "poa")
icd9FilterPoaNotNo(icd9df, poaField = "poa")
icd9FilterPoaNotYes(icd9df, poaField = "poa")

Arguments

icd9df
data frame containing columns for visitId (which is the feault name), icd9 (default for the icd9 code), and maybe also a POA flag.
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.
poa
single character value, being one of poaChoices whether to account for co-morbidities flagged as present-on-arrival. This is not a simple binary, since many codes are exempt, unspecified, or unknown. poaField gives the choices: yes, not no, no, not yes. The intermediate codes, such as "exempt", "unknown" and NA mean that "yes" is not the same as "not no."

Functions

  • icd9FilterPoaYes: Select rows where Present-on-Arrival flag is explicitly "Yes."
  • icd9FilterPoaNo: Select rows where Present-on-Arrival flag is explicitly "No."
  • icd9FilterPoaNotNo: Select rows where Present-on-Arrival flag is anything but "No." This includes unknown, exempt, other codes, and of course all those marked "Yes."
  • icd9FilterPoaNotYes: Select rows where Present-on-Arrival flag is anything byt "Yes." This would group exempt, unknown and other codes under "Not POA" which is unlikely to be a good choice, since exempt codes, of which there are a quite large number, tend to describe chronic or out-of-hospital characteristics.

Examples

Run this code
## Not run: 
# # using magrittr is beautiful:
# library("magrittr", quietly = TRUE, warn.conflicts = FALSE)
# myData <- data.frame(
#   visitId = c("v1", "v2", "v3", "v4"),
#   diag = c("39891", "39790", "41791", "4401"),
#   poa = c("Y", "N", NA, "Y"),
#   stringsAsFactors = FALSE
# )
# myData %>% icd9FilterPoaNotNo() %>% icd9ComorbidAhrq
# # can fill out named fields also:
# myData %>% icd9FilterPoaYes(poaField="poa") %>%
#   icd9ComorbidAhrq(icd9Field = "diag", visitId = "visitId", isShort = TRUE)
# # can call the core icd9Comorbid function with an arbitrary mapping
# myData %>%
# icd9FilterPoaYes() %>%
# icd9Comorbid(icd9Field = "diag", visitId = "visitId",
#   icd9Mapping = quanElixComorbid,
#  isShortMapping = TRUE)
# ## End(Not run)

Run the code above in your browser using DataCamp Workspace