apply_time_restriciton {DQAstats}R Documentation

Time filtering of data.table or sql-strings.

Description

Internal function to filter the input data (or SQL) depending on provided time information. Sensitive to SQL dialects.

Usage

apply_time_restriciton(
  data,
  key,
  lower_limit,
  upper_limit,
  system_name = NULL,
  system_type,
  mdr,
  logfile_dir = NULL,
  db_con = NULL,
  sql_create_view_all = list(),
  verify_on_db = TRUE
)

Arguments

data

If system_type is a database, the sql-string goes here. If system_type is 'csv', the data.table of this csv goes here. Sensitive to SQL dialects.

key

The key from the mdr.

lower_limit

The posixct timestamp of the lower filtering boundary.

upper_limit

The posixct timestamp of the upper filtering boundary.

system_name

(Optional for non-database-changes) 'i2b2'/'p21csv'/'omop'/...

system_type

'postgres'/'oracle'/'csv'

mdr

(Optional for non-database-changes) The internal MDR (get it from rv$mdr)

logfile_dir

(Optional) The directory to store the logfile in. Defaults to NULL.

db_con

(Optional for non-database-changes) The connection to the database. Used to create the views we need later to apply the SQLs to.

sql_create_view_all

(Optional, list). A list containing the SQLs to create all Views for the time-filtering. This is needed for the printing-friendly SQL including this view-creating SQLs and the actual data-extracting SQL query.

verify_on_db

A boolean. If the view should be verified on the database (default: TRUE).

Value

If system_type is a database, a list with the new sql-string containing the temporal filtering will be returned under $sql ('order by' parts will be removed) and a printable sql containing the commands to create the view needed to run the sql under $sql_extended. If system_type is 'csv', the filtered data.table will be returned.


[Package DQAstats version 0.3.5 Index]