Skip to content

Commit

Permalink
Merge pull request #197 from pharmaverse/181_nullcut
Browse files Browse the repository at this point in the history
Closes #181 Assertion added for cut date not to be NULL #181
  • Loading branch information
alanaharris22 authored Feb 9, 2024
2 parents 05e4ad1 + c34f508 commit 70f4f67
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
21 changes: 13 additions & 8 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@
- Added a "Report a bug" link to `{datacutr}` website (#182)

## Updates of Existing Functions
- Update to `impute_dcutdtc()`, `create_dcut()`, `date_cut()` and `special_dm_cut()` functions
to allow for datacut date to be null. In this case, all records for this patient will be
kept/left unchanged.
- Warning added to `process_cut` if expected dataset `dm` is missing
- Update to `impute_dcutdtc()`, `date_cut()` and `special_dm_cut()` functions to allow for
datacut date to be null. In this case, all records for this patient
will be kept/left unchanged. (#179, #188, #189, #190)
- Warning added to `process_cut` if expected dataset `dm` is missing (#172)
- Warning added to `create_dcut` if cut date being passed as `NULL`,
and not valid date or `NA`/`""` (#181)

## Breaking Changes
- N/A
- Added dependency on `admiraldev` >= 0.3.0 (#173)

## Documentation
- N/A
- Added notes on SDTM compatibility (#171)
- Cleaned install packages code format (#177)
- Fixed broken link to source (#184)
- Added report a bug link to site (#182)

## Various
- Minor documentation updates #171 #173 #177 #184
- Added CRAN badge to site (#174)
- Pull Request template updated (#192)

# datacutr 0.1.0

Expand All @@ -36,4 +42,3 @@ kept/left unchanged.
## Various
- N/A


5 changes: 5 additions & 0 deletions R/create_dcut.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ create_dcut <- function(dataset_ds,
must be stored in ISO 8601 format."
)

# Check that cut date is not NULL
assert_that(!is.null(cut_date),
msg = "Cut date is NULL, please populate as NA or valid ISO8601 date format"
)

# Check that cut_date is in ISO 8601 format
valid_dtc <- is_valid_dtc(cut_date)
assert_that(valid_dtc,
Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/test-create_dcut.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,17 @@ test_that("One observation in DCUT", {
expected_dcutna
)
})

# Test 3 - Cut date as NULL
test_that("Cut Date of NULL errors", {
expect_error(
create_dcut(
dataset_ds = input_ds,
ds_date_var = DSSTDTC,
filter = DSDECOD == "INFORMED CONSENT",
cut_date = NULL,
cut_description = "Patients with Informed Consent"
),
regexp = "Cut date is NULL, please populate as NA or valid ISO8601 date format"
)
})

0 comments on commit 70f4f67

Please sign in to comment.