Skip to contents

Flag discharges whose procedure codes match your clinical definition.

Usage

nis_flag_pr(
  .data,
  ...,
  position = c("any", "principal"),
  system = c("icd10", "icd9", "both")
)

Arguments

.data

A data frame or lazy DuckDB query.

...

Named flag definitions, such as ablation = "02L"; see nis_flag_dx() for list definitions with exclusions or regexes.

position

Slots to check: all slots or the principal slot only.

system

Code system of the slots to check: "icd10" (default) or "icd9" (experimental, NIS 2012 to Q3 2015), or "both" (experimental).

Value

.data with one logical column per named definition.

Details

Use the nis_flag_dx() rules for prefixes, exact exclusions, regular expressions, and mixed coding eras. For ICD-10 the slots are I10_PR1, I10_PR2, and so on. For ICD-9 they are PR1, PR2, and so on. Use position = "principal" to check slot 1 only.

Examples

nis <- nis_open(nis_example(years = 2019:2020))
nis |>
  nis_flag_pr(ablation = "02L") |>
  dplyr::count(ablation) |>
  dplyr::collect()
#> # A tibble: 2 × 2
#>   ablation     n
#>   <lgl>    <dbl>
#> 1 FALSE      144
#> 2 TRUE        48