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

Ensure concept IDs are always returned as integers #21

Merged
merged 5 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ License: Apache License (>= 2)
Encoding: UTF-8
LazyData: true
Imports:
dplyr (>= 1.0),
glue (>= 1.0),
purrr (>= 1.0),
readr (>= 2.0),
vroom (>= 1.0)
dplyr (>= 1.0),
glue (>= 1.0),
purrr (>= 1.0),
readr (>= 2.0),
rlang (>= 1.1),
vroom (>= 1.0)
Suggests:
devtools,
pak,
pkgload,
lintr,
stringr,
styler,
testthat (>= 3.0.0),
usethis
devtools,
pak,
pkgload,
lintr,
stringr,
styler,
testthat (>= 3.0.0),
usethis
Config/testthat/edition: 3
RoxygenNote: 7.3.2
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ importFrom(dplyr,tibble)
importFrom(glue,glue)
importFrom(purrr,map_dfr)
importFrom(readr,read_csv)
importFrom(rlang,.data)
importFrom(vroom,problems)
6 changes: 5 additions & 1 deletion R/bundles.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ available_bundles <- function(version = "latest") {
#' @param domain The domain of the bundle.
#' @param id The ID of the bundle.
#' @param version The version of the bundle. Default is "latest".
#'
#' @return A data frame with the concept data.
#' @export
#'
#' @importFrom rlang .data
#'
#' @examples
#' # Usage with available_bundles, from a single row
#' smoking <- available_bundles() |> dplyr::filter(bundle_name == "Smoking")
Expand All @@ -42,6 +46,6 @@ available_bundles <- function(version = "latest") {
#' concept_by_bundle(domain = "observation", id = "smoking")
concept_by_bundle <- function(domain, id, version = "latest") {
get_raw_dir(version = version, domain, "bundles", glue::glue("{id}.csv")) |>
readr::read_csv(show_col_types = FALSE) |>
readr::read_csv(col_types = readr::cols(concept_id = readr::col_integer())) |>
dplyr::mutate(domain = domain)
}
1 change: 1 addition & 0 deletions tests/testthat/test-bundles.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ test_that("Concept by bundle works with character values", {
expect_true(nrow(smoking_concepts) > 1, info = "Smoking should have multiple concepts")
expect_false(any(is.na(smoking_concepts$concept_id)), info = "Concept ids should not be NA")
expect_true(all(smoking_concepts$domain == "observation"), info = "Domain should be set correctly")
expect_type(smoking_concepts$concept_id, "integer")
})

test_that("Available bundles and concept_by_bundle play nicely together", {
Expand Down