data_utils.Rd
Two important tools for smoothing out differences among used datasets are
id_origin()
which returns origin times for a given ID and id_map()
which returns a mapping between two ID systems alongside start and end
columns of the target ID system relative to the source ID system. As both
these function are called frequently during data loading and might involve
somewhat expensive operations, both rely on internal helper functions
(id_orig_helper()
and id_map_helper()
) which perform the heavy lifting
and wrap those helper functions, providing a memoization layer. When adding
a new data source, a class specific implementation of the S3 generic
function id_map_helper()
might be required, as this is used during data
loading using load_id()
and load_ts()
via change_id()
.
id_origin(x, id, origin_name = NULL, copy = TRUE)
id_orig_helper(x, id)
# S3 method for src_env
id_orig_helper(x, id)
# S3 method for miiv_env
id_orig_helper(x, id)
id_windows(x, copy = TRUE)
id_win_helper(x)
# S3 method for mimic_env
id_win_helper(x)
# S3 method for eicu_env
id_win_helper(x)
# S3 method for hirid_env
id_win_helper(x)
# S3 method for aumc_env
id_win_helper(x)
# S3 method for miiv_env
id_win_helper(x)
id_map(x, id_var, win_var, in_time = NULL, out_time = NULL)
id_map_helper(x, id_var, win_var)
# S3 method for src_env
id_map_helper(x, id_var, win_var)
Object identify the ID system (passed to as_src_env()
)
ID name for which to return origin times
String-valued name which will be used to label the origin column
Logical flag indicating whether to return a copy of the memoized
0data.table
for safety
Type of ID all returned times are relative to
Type of ID for which the in/out times is returned
column names of the returned in/out times
id_origin()
/id_orig_helper()
: an id_tbl
with admission time stamps
corresponding to the selected ID
id_windows()
/id_win_helper()
: an id_tbl
holding all IDs and their
respective start and end times
id_map()
/id_map_helper()
: an id_tbl
containing the selected IDs and
depending on values passed as in_time
and out_time
, start and end
times of the ID passed as win_var
For the internal datasets, id_map_helper()
relies on yet another S3
generic function id_windows()
, which provides a table containing all
available ID systems, as well as all ID windows for a given data source. As
for the other two functions, the same helper-function approach is in place,
with the data loading function id_win_helper()
. The function
id_map_helper()
is then implemented in a data source agnostic manner
(dispatching on the src_env
class), providing subsetting of this larger
ID map table and ensuring timestamps are relative to the correct ID system.
For adding a new data source however, this layer can be forgone. Similarly
for id_origin()
, this is used for the internal datasets in
load_difftime()
. An implementation of load_difftime()
, specific to a
new data source can be provided that does not rely on id_windows()
,
making this function irrelevant for this specific dataset.