Skip to contents

This function requires that each source of register data is represented as a single DuckDB object in R (e.g. a connection to Parquet files). Each DuckDB object must contain a single table covering all years of that data source, or at least the years you have and are interested in.

Usage

classify_diabetes(
  kontakter,
  diagnoser,
  lpr_diag,
  lpr_adm,
  sysi,
  sssy,
  lab_forsker,
  bef,
  lmdb,
  stable_inclusion_start_date = "1998-01-01"
)

Arguments

kontakter

The contacts information table from the LPR3 patient register

diagnoser

The diagnoses information table from the LPR3 patient register

lpr_diag

The diagnoses information table from the LPR2 patient register

lpr_adm

The administrative information table from the LPR2 patient register

sysi

The SYSI table from the health service register

sssy

The SSSY table from the health service register

lab_forsker

The register for laboratory results for research

bef

The BEF table from the civil register

lmdb

The LMDB table from the prescription register

stable_inclusion_start_date

Cutoff date after which inclusion events are considered true incident diabetes cases. Defaults to "1998-01-01", which is one year after the data on pregnancy events from the Patient Register are considered valid for dropping gestational diabetes-related purchases of glucose-lowering drugs. This default assumes that the user is using LPR and LMDB data from at least Jan 1 1997 onward. If the user only has access to LPR and LMDB data from a later date, this parameter should be set to one year after the beginning of the user's data coverage.

Value

The same object type as the input data, which would be a duckplyr::duckdb_tibble() type object.

See also

See the osdc vignette for a detailed description of the internal implementation of this classification function.

Examples

# Can't run this multiple times, will cause an error as the table
# has already been created in the DuckDB connection.
register_data <- registers() |>
  names() |>
  simulate_registers() |>
  purrr::map(duckplyr::as_duckdb_tibble) |>
  purrr::map(duckplyr::as_tbl)

classify_diabetes(
  kontakter = register_data$kontakter,
  diagnoser = register_data$diagnoser,
  lpr_diag = register_data$lpr_diag,
  lpr_adm = register_data$lpr_adm,
  sysi = register_data$sysi,
  sssy = register_data$sssy,
  lab_forsker = register_data$lab_forsker,
  bef = register_data$bef,
  lmdb = register_data$lmdb
)
#> # Source:   SQL [?? x 5]
#> # Database: DuckDB 1.4.4 [unknown@Linux 6.14.0-1017-azure:R 4.5.2//tmp/Rtmp7YvlDu/duckplyr/duckplyr1a035401fb90.duckdb]
#>   pnr          stable_inclusion_date raw_inclusion_date has_t1d has_t2d
#>   <chr>        <date>                <date>             <lgl>   <lgl>  
#> 1 146605139851 2020-11-07            2020-11-07         FALSE   TRUE   
#> 2 732715981647 2020-08-24            2020-08-24         FALSE   TRUE   
#> 3 409442575549 2010-05-24            2010-05-24         FALSE   TRUE   
#> 4 108839343181 2018-08-30            2018-08-30         FALSE   TRUE   
#> 5 706974528463 2016-08-01            2016-08-01         FALSE   TRUE   
#> 6 745611946809 2018-10-29            2018-10-29         FALSE   TRUE   
#> 7 240771768588 2016-11-28            2016-11-28         FALSE   TRUE   
#> 8 298944792608 2007-11-26            2007-11-26         FALSE   TRUE   
#> 9 498989088479 2014-11-09            2014-11-09         FALSE   TRUE