Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time out of sync in animate_process? #42

Open
dkipb opened this issue Oct 11, 2022 · 0 comments
Open

Time out of sync in animate_process? #42

dkipb opened this issue Oct 11, 2022 · 0 comments

Comments

@dkipb
Copy link

dkipb commented Oct 11, 2022

I am trying to create an animated process map that gives us insight on if ER episodes that begin at a certain time of the day tend to pile up based on staffing patterns. In other words, we want to see if overnight episodes pile up in the morning.

To do this, we thought, in our data, to create a flag for when the episode starts and color-code the bubble in animate_process accordingly.

Unfortunately, it seems like the process map might go out-of-sync over time (it's also entirely possible there is a detail of using animate_process that I've missed). I think the time-of-day labels are correct, but the timeline might become inaccurate over time? Or timezones could be at play?

Can you take a look at the code below that I wrote based on the patients dataset?

That patient ids that stuck out to me in this test dataset were 243 and 244. Are we missing something?

library(tidyverse)
library(lubridate)
library(processanimateR)
library(bupaR)

patients_df <- patients %>% as_tibble()

time_of_day_labels <- patients %>%
  as_tibble() %>%
  filter(handling == "Registration" &
           registration_type == "start") %>%
  select(patient, time) %>% 
  mutate(time_of_day_registration = 
           cut(
             x = hour(time),
             breaks = c(0, 5, 11, 17, 23),
             labels = c("0-6", "6-12", "12-18", "18-24"),
             include.lowest = TRUE
           )) %>% 
  select(-time) %>%
  unique()

patients_rev <- patients %>% 
  left_join(time_of_day_labels, "patient") %>%
  as_tibble() %>%
  eventlog(
    case_id = "patient",
    activity_id = "handling",
    activity_instance_id = "handling_id",
    lifecycle_id = "registration_type",
    timestamp = "time",
    resource_id = "employee")

animate_process(
  patients_rev,
  duration = 2500,
  legend = "color",
  mapping = token_aes(
    color = token_scale(
      "time_of_day_registration",
      scale = "ordinal",
      range = RColorBrewer::brewer.pal(4, "Paired")
    )
  )
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant