Skip to content

Commit d045809

Browse files
committed
feat(model): modify trajectory to send ASU patients to rehab (plus minor docstring change in rehab traj)
1 parent 438cce7 commit d045809

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export(model)
1414
export(sample_routing)
1515
export(transform_to_lnorm)
1616
importFrom(simmer,add_generator)
17+
importFrom(simmer,branch)
1718
importFrom(simmer,get_attribute)
1819
importFrom(simmer,get_mon_arrivals)
1920
importFrom(simmer,get_mon_resources)

R/create_asu_trajectory.R

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#' of routing to each destination (e.g.
1414
#' \code{param$asu_routing$stroke$rehab = 0.24}).
1515
#'
16-
#' @importFrom simmer trajectory
16+
#' @importFrom simmer branch trajectory
1717
#' @importFrom stats rlnorm
1818
#'
1919
#' @return Simmer trajectory object. Defines patient journey logic through the
@@ -57,5 +57,19 @@ create_asu_trajectory <- function(env, patient_type, param) {
5757
meanlog = los_params[["meanlog"]],
5858
sdlog = los_params[["sdlog"]]
5959
)
60-
})
60+
}) |>
61+
62+
# If that patient's destination is rehab, then start on that trajectory
63+
branch(
64+
option = function() {
65+
# Retrieve attribute, and use to get post-ASU destination as a string
66+
dest_index <- get_attribute(env, "post_asu_destination")
67+
dest_names <- names(param[["asu_routing"]][[patient_type]])
68+
dest <- dest_names[dest_index]
69+
# Return 1 for rehab and 0 otherwise
70+
if (dest == "rehab") 1L else 0L
71+
},
72+
continue = FALSE, # Do not continue main trajectory after branch
73+
create_rehab_trajectory(env, patient_type, param)
74+
)
6175
}

R/create_rehab_trajectory.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#' Create rehab patient trajectory.
22
#'
3-
#' Represents patient stay on the rehabilitation unit - samples their (1)
4-
#' destination after rehab, and (2) length of stay (LOS) on the unit.
3+
#' Represents patient stay on the rehabilitation unit - samples their (1)
4+
#' destination after rehab, and (2) length of stay (LOS) on the unit.
55
#'
66
#' @param env Simmer environment object. The simulation environment where
77
#' generators will be added.

man/create_rehab_trajectory.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)