time_to_onset: Calculates time to onset for inpatients

View source: R/time_to_onset.R

time_to_onsetR Documentation

Calculates time to onset for inpatients

Description

Only applicable for inpatients. Where date of specimen is before the date of admission, NA will be returned.

Usage

time_to_onset(date_admitted, date_specimen, patient_category, patient_location)

Arguments

date_admitted

Admission date in date format

date_specimen

Date specimen taken in date format

patient_category

Category of patient at time of specimen. One of: "In-patient", "Day patient" or "Emergency Assessment"

patient_location

Location of patient at time of specimen

Value

A numeric value

Examples

onset <- lubridate::dmy("05-01-2011")
admitted <- lubridate::dmy("01-01-2011")
patient_cat <- "In-patient"
patient_loc <- "NHS Acute Trust"
time_to_onset(admitted, onset, patient_cat, patient_loc)
dat <- data.frame(onset = onset, admitted = admitted, patient_cat = patient_cat,
patient_loc = patient_loc)
dat$tto <- time_to_onset(dat$admitted, dat$onset, dat$patient_cat, dat$patient_loc)
## Not run: 
## Should return NA
onset <- NA
time_to_onset(admitted, onset, patient_cat, patient_loc)
patient_cat <- ""
onset <- lubridate::dmy("05-01-2011")
time_to_onset(admitted, onset, patient_cat)
time_to_onset(date_admitted = lubridate::dmy("01-01-2011"),
 date_specimen = lubridate::dmy("05-01-2011"),
 patient_category = "Outpatient", patient_location = "NHS Acute Trust")

## End(Not run)

PublicHealthEngland/hcaidcs documentation built on Jan. 19, 2024, 8:38 a.m.