Add a clinical feature (variable) to a therapy or encounter longitudinal table. The feature corresponds to the number of observations falling (a) above/below a given threshold or (b) inside/outside a given interval depending on values provided to observation_intervals.

clinical_feature_interval(
  x,
  observation_intervals,
  hours,
  observation_code_system = NULL,
  compute = TRUE
)

# S4 method for RamsesObject
clinical_feature_interval(
  x,
  observation_intervals,
  hours,
  observation_code_system = NULL,
  compute = TRUE
)

Arguments

x

an object of class TherapyEpisode or Encounter

observation_intervals

a named list of numeric vectors of length 1 (for a threshold) or 2 (for an interval). Names of vectors must match the observation_code field in the inpatient_investigation table (see validate_investigations()).

hours

the maximum number of hours the observation should date back from t_start, the starting time of every row in the longitudinal table

observation_code_system

(optional, reserved to situations where observation_code is ambiguous across code systems/vocabularies) a single character string specifying the code system identifier of observation_code (for example: "http://snomed.info/sct").

The default (NULL) filters observations using the observation_code only.

compute

if TRUE (the default), the remote therapy table will be computed on the remote server. This is generally faster.

Value

an object of class TherapyEpisode or Encounter

Details

The feature will be computed exclusively on numeric investigations marked with status "final", "preliminary", "corrected", or "amended".

Examples

if (FALSE) {
fake_db <- create_mock_database("example.duckdb")

temperature_interval <- clinical_feature_interval(
   TherapyEpisode(fake_db, "4d611fc8886c23ab047ad5f74e5080d7"),
   observation_intervals = list("8310-5" = c(36, 38)),
   hours = 24
   )
str(longitudinal_table(temperature_interval, collect = TRUE))

temperature_threshold <- clinical_feature_interval(
   TherapyEpisode(fake_db, "4d611fc8886c23ab047ad5f74e5080d7"),
   observation_intervals = list("8310-5" = 38),
   hours = 24
   )
str(longitudinal_table(temperature_threshold, collect = TRUE))
}