convert_rfv {parseRPDR}R Documentation

Searches columns for given reason for visit defined by ERFV codes.

Description

Analyzes reason for visit data loaded using load_rfv. If requested, the data.table is returned with new columns corresponding to boolean values, whether given group of ERFV are present in the given columns. If collapse is given, then the information is aggregated based-on the collapse column and the earliest of latest time of the given reason for visit is provided.

Usage

convert_rfv(
  d,
  code = "rfv_concept_id",
  codes_to_find = NULL,
  collapse = NULL,
  code_time = "time_rfv_start",
  aggr_type = "earliest",
  nThread = parallel::detectCores() - 1
)

Arguments

d

data.table, database containing reason for visit information data loaded using the load_rfv function.

code

string vector, an array of column names to search.

codes_to_find

list, a list of arrays corresponding to sets of ERFV codes. The function searches the columns in code and the name of each list element will be created. These columns are indicators whether the given disease is present in the set of ERFV codes or not.

collapse

string, a column name on which to collapse the data.table. Used in case we wish to assess whether multiple ERFV are present within the same instances of collapse. See vignette for details.

code_time

string, column name of the time column. Defaults to time_rfv_start. Used in case collapse is present to provide the earliest or latest instance of reason for visit.

aggr_type

string, if multiple reason for visits are present within the same case of collapse, which timepoint to return. Supported are: "earliest" or "latest". Defaults to earliest.

nThread

integer, number of threads to use for parallelization. If it is set to 1, then no parallel backends are created and the function is executed sequentially.

Value

data.table, with indicator columns if provided. If collapse is present, then only unique ID and the summary columns are returned.

Examples

## Not run: 
#Parse reason for visit columns
#and create indicator variables for the following reasons and summarize per patient,
#whether there are any encounters where the given reasons were registered
reasons <- list(Pain = c("ERFV:160357", "ERFV:140012"), Visit = c("ERFV:501"))
data_rfv_disease <-  convert_rfv(d = data_rfv, keep = FALSE,
codes_to_find = reasons, nThread = 2, collapse = "ID_MERGE")

## End(Not run)

[Package parseRPDR version 1.1.1 Index]