Skip to content

Commit

Permalink
Allow duplicated tracks when running emr_track.attr.set in batch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
aviezerl committed Mar 7, 2022
1 parent c449f46 commit 229ea7b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: naryn
Title: Toolkit for analysis of medical records
Version: 2.6.5
Version: 2.6.6
Authors@R: c(
person("Misha", "Hoichman", , "[email protected]", role = "aut"),
person("Aviezer", "Lifshitz", , "[email protected]", role = c("aut", "cre")),
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# naryn 2.6.6

* Allow duplicated tracks when running `emr_track.attr.set` in batch mode.

# naryn 2.6.5

* Added batch mode for `emr_track.attr.set` and `emr_track.attr.rm`
* Added batch mode for `emr_track.attr.set` and `emr_track.attr.rm`.
* Added `include_missing` parameter `emr_track.attr.export` allowing missing tracks and attributes.

# naryn 2.6.4
Expand Down
6 changes: 1 addition & 5 deletions R/track-attributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ emr_track.attr.rm <- function(track, attr) {
#' This function creates a track attribute and assigns 'value' to it. If the
#' attribute already exists its value is overwritten.
#'
#'
#' Note that both attributes and values sould be in ASCII encoding.
#'
#' @param track one or more track names
Expand All @@ -200,11 +201,6 @@ emr_track.attr.set <- function(track, attr, value) {
}
.emr_checkroot()

dups <- duplicated(track)
if (any(dups)) {
stop("The following tracks appear more than once: ", paste(unique(track[dups]), collapse = ", "))
}

if (length(track) != length(attr)) {
stop("Number of tracks is not equal to the number of attributes", call. = FALSE)
}
Expand Down
1 change: 1 addition & 0 deletions man/emr_track.attr.set.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions tests/testthat/test-track.attr.R
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,18 @@ test_that("emr_track.attr.set in batch mode works", {
expect_error(emr_track.attr.set(c("track1", "track2", "track3"), rep("var4", 3), "val2"))
})

test_that("emr_track.attr.set in batch mode works with repeated tracks", {
withr::defer(clean_attributes())
emr_track.attr.set(c("track1", "track2", "track3", "track1"), c("var1", "var1", "var2", "var3"), c("val1", "val1", "val2", "val3"))
expect_equal(
emr_track.attr.export(),
structure(list(track = c("track1", "track1", "track2", "track3"), attr = c("var1", "var3", "var1", "var2"), value = c(
"val1",
"val3", "val1", "val2"
)), row.names = c(NA, 4L), class = "data.frame")
)
})

test_that("emr_track.attr.set in batch mode works with an empty value", {
withr::defer(clean_attributes())
emr_track.attr.set(c("track1", "track2", "track3"), rep("var1", 3), value = rep("", 3))
Expand Down

0 comments on commit 229ea7b

Please sign in to comment.