Builds the same feature row as score_cohort() for a single visit_occurrence_id, but takes the LATEST vital or lab recorded
between admission and as_of instead of the admission-day value, for discharge-alert hooks. Utilization history, age and
extra_features are as in extract_velocity_features(); validation, imputation, blending and calibration are those of
score_cohort(). Mirror of Python omop_etl.encounter.score_encounter.
Usage
score_encounter(
con,
visit_occurrence_id,
bundle,
as_of = NULL,
extra_features = NULL,
on_violation = "raise",
risk_tiers = NULL,
concepts = NULL,
explain = FALSE,
top_k = 5L
)Arguments
- con
DuckDB DBI connection to the OMOP CDM.
- visit_occurrence_id
The encounter to score.
- bundle
A
model_bundleor a bundle directory (load once and reuse it in a long-running service).- as_of
Only measurements on or before this date count. Default: the earlier of the visit end date and today. CDM 5.4 end dates cannot be NULL, so for a live open stay with a placeholder end date pass
as_of = Sys.Date().- extra_features
Optional data.frame keyed by
subject_id+cohort_start_date.- on_violation
"raise","clip"or"nullify".- risk_tiers
Optional
list(list(name =, min =), ...)replacing the bundle's tiers (seefit_capacity_thresholds()).- concepts
Overrides for VELOCITY_CONCEPTS.
- explain
If
TRUE, addtop_drivers: thetop_kpatient-specific risk contributors (feature,name,value, signedimpacton the probability), seeexplain_rows().- top_k
Number of drivers.
