callback_cncpt: Concept callback functions

pafiR Documentation

Concept callback functions


Owing to increased complexity and more diverse applications, recursive concepts (class rec_cncpt) may specify callback functions to be called on corresponding data objects and perform post-processing steps.


  match_win = hours(2L),
  mode = c("match_vals", "extreme_vals", "fill_gaps"),
  fix_na_fio2 = TRUE,
  interval = NULL

  match_win = hours(2L),
  mode = c("match_vals", "extreme_vals", "fill_gaps"),
  fix_na_fio2 = TRUE,
  interval = NULL

vent_ind(..., match_win = hours(6L), min_length = mins(30L), interval = NULL)

  valid_win = hours(6L),
  sed_impute = c("max", "prev", "none", "verb"),
  set_na_max = TRUE,
  interval = NULL

  min_win = hours(12L),
  limits = NULL,
  start_var = "start",
  end_var = "end",
  interval = NULL

vaso60(..., max_gap = mins(5L), interval = NULL)

vaso_ind(..., interval = NULL)

supp_o2(..., interval = NULL)

avpu(..., interval = NULL)

bmi(..., interval = NULL)

norepi_equiv(..., interval = NULL)



Data input used for concept calculation


Time-span during which matching of values is allowed


Method for matching PaO\subs2 and FiO\subs2 values


Logical flag indicating whether to impute missing FiO\subs2 values with 21


Expected time series step size (determined from data if NULL)


Minimal time span between a ventilation start and end time


Maximal time window for which a GCS value is valid if no newer measurement is available


Imputation scheme for values taken when patient was sedated (i.e. unconscious).


Logical flag controlling imputation of missing GCS values with the respective maximum values


Minimal time span required for calculation of urine/24h


Passed to fill_gaps() in order to expand the time series beyond first and last measurements

start_var, end_var

Passed to fill_gaps()


Maximum time gap between administration windows that are merged (can be negative).


Several concept callback functions are exported, mainly for documenting their arguments, as default values oftentimes represent somewhat arbitrary choices and passing non-default values might be of interest for investigating stability with respect to such choices. Furthermore, default values might not be ideal for some datasets and/or analysis tasks.


In order to calculate the PaO\subs2/FiO\subs2 (or Horowitz index), for a given time point, both a PaO\subs2 and an FiO\subs2 measurement is required. As the two are often not measured at the same time, some form of imputation or matching procedure is required. Several options are available:

  • match_vals allows for a time difference of maximally match_win between two measurements for calculating their ratio

  • extreme_vals uses the worst PaO\subs2 and FiO\subs2 values within the time window spanned by match_win

  • fill_gaps represents a variation of extreme_vals, where ratios are evaluated at every time-point as specified by intervalas opposed to only the time points where either a PaO\subs2 or an FiO\subs2 measurement is available

Finally, fix_na_fio2 imputes all remaining missing FiO\subs2 with 21, the percentage (by volume) of oxygen in (tropospheric) air.


Building on the atomic concepts vent_start and vent_end, vent_ind determines time windows during which patients are mechanically ventilated by combining start and end events that are separated by at most match_win and at least min_length. Durations are represented by the dur_var column in the returned win_tbl and the data_var column simply indicates the ventilation status with TRUE values. Currently, no clear distinction between invasive an non-invasive ventilation is made.


In order to construct an indicator for patient sedation (used within the context of gcs), information from the two concepts ett_gcs and rass is pooled: A patient is considered sedated if intubated or has less or equal to -2 on the Richmond Agitation-Sedation Scale.


Aggregating components of the Glasgow Coma Scale into a total score (whenever the total score tgcs is not already available) requires coinciding availability of an eye (egcs), verbal (vgcs) and motor (mgcs) score. In order to match values, a last observation carry forward imputation scheme over the time span specified by valid_win is performed. Furthermore passing "max" as sed_impute will assume maximal points for time steps where the patient is sedated (as indicated by sed_gcs), while passing "prev", will assign the last observed value previous to the current sedation window and finally passing FALSE will in turn use raw values. Finally, passing TRUE as set_na_max will assume maximal points for missing values (after matching and potentially applying sed_impute).


Single urine output events are aggregated into a 24 hour moving window sum. At default value of limits = NULL, moving window evaluation begins with the first and ends with the last available measurement. This can however be extended by passing an id_tbl object, such as for example returned by stay_windows() to full stay windows. In order to provide data earlier than 24 hours before the evaluation start point, min_win specifies the minimally required data window and the evaluation scheme is adjusted for shorter than 24 hour windows.


Building on concepts for drug administration rate and drug administration durations, administration events are filtered if they do not fall into administrations windows of at least 1h. The max_gap argument can be used to control how far apart windows can be in order to be merged (negative times are possible as well, meaning that even overlapping windows can be considered as individual windows).


Either an id_tbl or ts_tbl depending on the type of concept.

ricu documentation built on Sept. 8, 2023, 5:45 p.m.