Skip to content

Commit

Permalink
fix handling of inactive sct codes in app
Browse files Browse the repository at this point in the history
  • Loading branch information
rmgpanw committed Feb 1, 2024
1 parent a16efbc commit dab28c9
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions R/mod_codelistBuilder.R
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,9 @@ codelistBuilderServer <-
} else {
query_code_deps <- dependencies %>%
purrr::map(~ {
rlang::call2(
.fn = "=",
rlang::sym(.x),
saved_queries()$results_meta[[.x]]$query
)
rlang::call2(.fn = "=",
rlang::sym(.x),
saved_queries()$results_meta[[.x]]$query)
})
}

Expand All @@ -410,24 +408,28 @@ codelistBuilderServer <-
dplyr::case_when(x$result$code %in% saved_queries()$results[[dep]]$code ~ "1",
TRUE ~ ".")
}
}
# add indicator column for inactive snomed codes
if (input$code_type == "sct") {
inactive_codes <- CODES(
x$result$code,
code_type = "sct",
preferred_description_only = TRUE,
standardise_output = TRUE,
unrecognised_codes = "warning",
col_filters = list(
sct_description = list(
active_concept = '0',
active_description = '1'
)
)
) %>%
.$code %>%
suppressWarnings()

# add indicator column for inactive snomed codes
if (input$code_type == "sct") {
inactive_codes <- CODES(
x$result$code,
code_type = "sct",
preferred_description_only = TRUE,
standardise_output = TRUE,
unrecognised_codes = "warning",
col_filters = list(sct_description = list(active = "0"))
) %>%
.$code %>%
suppressWarnings()

x$result <- x$result %>%
dplyr::mutate("...inactive_sct" = dplyr::case_when(.data[["code"]] %in% inactive_codes ~ "1",
TRUE ~ "."))
}
x$result <- x$result %>%
dplyr::mutate("...inactive_sct" = dplyr::case_when(.data[["code"]] %in% inactive_codes ~ "1",
TRUE ~ "."))
}

x$query_code <- query_code
Expand Down Expand Up @@ -554,7 +556,7 @@ inactive_codes <- CODES(
preferred_description_only = TRUE,
standardise_output = TRUE,
unrecognised_codes = 'warning',
col_filters = list(sct_description = list(active = '0'))
col_filters = list(sct_description = list(active_concept = '0', active_description = '1'))
) %>%
.$code %>%
suppressWarnings()
Expand Down

0 comments on commit dab28c9

Please sign in to comment.