Skip to content

Time out of sync in animate_process?  #42

@dkipb

Description

@dkipb

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")
    )
  )
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions