R/clinical_features.R
clinical_feature_mean.Rd
Add a clinical feature (variable) to a therapy or encounter
longitudinal table. The feature corresponds to the arithmetic mean of
clinical observations of interest over a time span set by hours
.
clinical_feature_mean(
x,
observation_code,
hours,
observation_code_system = NULL,
compute = TRUE
)
# S4 method for RamsesObject
clinical_feature_mean(
x,
observation_code,
hours,
observation_code_system = NULL,
compute = TRUE
)
an object of class TherapyEpisode
or Encounter
a character vector of clinical investigation codes
matching the observation_code
field in the inpatient_investigation
table (see validate_investigations()
).
the maximum number of hours the observations included in the mean
should date back from t_start
, the starting time of every row
in the therapy table
(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.
if TRUE
(the default), the remote therapy table will
be computed on the remote server. This is generally faster.
an object of class TherapyEpisode
or
Encounter
The feature will be computed exclusively on numeric investigations
marked with status "final"
, "preliminary"
, "corrected"
,
or "amended"
.
if (FALSE) {
fake_db <- create_mock_database("example.duckdb")
temperature_check <- clinical_feature_mean(
TherapyEpisode(fake_db, "4d611fc8886c23ab047ad5f74e5080d7"),
observation_code = "8310-5",
hours = 24
)
str(longitudinal_table(temperature_check, collect = TRUE))
}