This function will loop through each site and visit type provided and execute the provided check function to compute facts stratified by visit type. Primarily intended for use in the Patient Facts module, but can be adapted for use elsewhere.
Usage
loop_through_visits(
cohort_tbl,
omop_or_pcornet,
check_func,
site_col,
time = FALSE,
visit_type_tbl,
visit_tbl,
site_list,
visit_list = c("outpatient", "inpatient"),
domain_tbl
)Arguments
- cohort_tbl
tabular input || required
The cohort to be used for data quality testing. This table should contain, at minimum:
site| character | the name(s) of institutions included in your cohortperson_id/patid| integer / character | the patient identifierstart_date| date | the start of the cohort periodend_date| date | the end of the cohort period
Note that the start and end dates included in this table will be used to limit the search window for the analyses in this module. It is recommended that this table has been passed through the prepare_cohort function as well.
- omop_or_pcornet
string || required
A string, either
omoporpcornet, indicating the CDM format of the dataomop: run theloop_through_visits_omop()function against an OMOP CDM instancepcornet: run theloop_through_visits_pcnt()function against a PCORnet CDM instance
- check_func
function || required
The function that should be executed within each time period in the loop. This parameter should be structured as the following, where
chtis the cohort table andtis the input data for the function:function(cht, t){check_function(param1 = cht, param2 = t, param3 = param3_input, ..., paramX = paramX_input)}Make sure to include all parameters required for the original function where default values are not being used.
- site_col
string || required
The name of the column in the cohort table that contains the site names. This will typically be either
siteorsite_summ- time
boolean || defaults to
FALSEA boolean to indicate whether to execute a longitudinal analysis
- visit_type_tbl
tabular input || required
A table that defines visit types of interest called in
visit_list.This input should contain:visit_concept_id/visit_detail_concept_idorenc_type| integer or character | thevisit_(detail)_concept_idorenc_typethat represents the visit type of interest (i.e. 9201 or IP)visit_type| character | the string label to describe the visit type
- visit_tbl
tabular input || defaults to
cdm_tbl('visit_occurrence')The CDM table with visit information (i.e. visit_occurrence or encounter)
- site_list
list || required
A list of sites for which you would like to examine clinical facts. Can be one site (single-site) or multiple (multi-site). Ensure that all sites listed here exist in the provided cohort table.
- visit_list
string or vector || defaults to
c('outpatient', 'inpatient')A string or vector of visit types by which the output should be stratified. Each visit type listed in this parameter should match an associated visit type defined in the
visit_type_tbl- domain_tbl
tabular input || required
A table that defines the fact domains to be investigated in the analysis. This input should contain:
domain| character | a string label for the domain being examined (i.e. prescription drugs)domain_tbl| character | the CDM table where information for this domain can be found (i.e. drug_exposure)filter_logic| character | logic to be applied to the domain_tbl in order to achieve the definition of interest; should be written as if you were applying it in a dplyr::filter command in R