Skip to contents

Add patient to visit-based simulation pathway

Usage

add_patient(
  in_system,
  id = parent.frame()$id,
  npat = parent.frame()$npat,
  req_visits = parent.frame()$req_visits,
  patients = parent.frame()$patients,
  resources = parent.frame()$resources,
  t = parent.frame()$t,
  z = parent.frame()$z,
  srv_dist_visit = parent.frame()$srv_dist_visit,
  srv_params_visit = parent.frame()$srv_params_visit,
  mean_los_visit = parent.frame()$mean_los_visit,
  sd_los_visit = parent.frame()$sd_los_visit,
  isr = parent.frame()$isr,
  sd_isr = parent.frame()$sd_isr,
  n_slots = parent.frame()$n_slots,
  end_sr = parent.frame()$end_sr,
  sd_esr = parent.frame()$sd_esr
)

Arguments

in_system

Boolean (TRUE or FALSE) - is the patient already in the system? If so, will produce adjusted length of stay and visit rates.

id

Integer - ID number

npat

Integer - number of patients

req_visits

List to store require visit vectors for each patient

patients

Dataframe to store information about each patient (from create_patient_df())

resources

Dataframe to capture information on available resources

t

Integer - day of simulation, e.g. 1

z

Integer - refers to the current scenario and location as the simulation loops through pathway_vector_visit, e.g. 4

srv_dist_visit

List with distribution for length of stay, e.g. list("lnorm", "lnorm")

srv_params_visit

List containing mean and SD for the lnorm length of stay distribution, e.g. list(c(1.52, 1.32), c(1.60, 1.33))

mean_los_visit

List of floats - each float is the mean of the normal length of stay distribution, e.g. list(12.08, 10)

sd_los_visit

List with the standard deviation of the normal length of stay distribution, e.g. list(3, 3)

isr

Integer vector - initial service rate (ISR) or initial visit rate (IVR) - used in estimation of initial number of visits required for each patient, e.g. c(4, 4)

sd_isr

Float vector - each float is standard deviation for initial service rate distribution, e.g. c(0.5, 0.5)

n_slots

Float vector - number of visit slots available per day

end_sr

Integer vector - end service rate (end_sr) or final visit rate (FVR) - used in estimation of final number of visits required for each patient, e.g. c(1, 1)

sd_esr

Float vector - each float is standard deviation for end service rate distribution, e.g. c(0.5, 0.5)

Value

List with updated id, npat, req_visits, patients, resources objects

Details

When run add_patient(), it will increment the ID and n_pat, find length of stay, initial visit rate and end visit rate. It will save these results in a dataframe, and then check availability in service and modify resources accordingly.