r-world-devs / shinyCohortBuilder

https://r-world-devs.github.io/shinyCohortBuilder/
Other
6 stars 0 forks source link

Single filter with NULL value during restore failed #65

Closed galachad closed 2 weeks ago

galachad commented 2 weeks ago

Minimal reproducible example:

set.seed(123) # For reproducibility
oko <- iris |> dplyr::mutate(oko = Sys.time() + rnorm(n = dplyr::n(), mean = 0, sd = 5) * 60 * 60 * 24)

source <- cohortBuilder::set_source(
  cohortBuilder::as.tblist(oko)
) |>
  cohortBuilder::add_step(
    cohortBuilder::step(
      cohortBuilder::filter(
        "date_time_range", id = "oko", dataset = "x", 
        variable = "oko", range = NA,
        active = TRUE
      ),
      cohortBuilder::filter(
        "range", id = "adsa", dataset = "x", 
        variable = "Petal.Width", range = c(-Inf, 1),
        activate = TRUE
      )
    )
  )

source_2 <- cohortBuilder::set_source(
  cohortBuilder::as.tblist(oko)
) |>
  cohortBuilder::add_step(
    cohortBuilder::step(
      cohortBuilder::filter(
        "date_time_range", id = "oko", dataset = "x", 
        variable = "oko", range = NA,
        active = TRUE
      )
    )
  )

coh <- cohortBuilder::cohort(source, run_flow = TRUE)
coh_2 <- cohortBuilder::cohort(source_2, run_flow = TRUE)

shinyCohortBuilder::gui(coh_2)

When doing restore, it failed.

This is a really rare use case.

The filter need to handle NULL value. Not every filter is handling NULL values, as not every input allows setting them.

galachad commented 2 weeks ago

Resolved