diff --git a/NEWS.md b/NEWS.md index 84d4bd2..e147e9a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 @@ -36,4 +42,3 @@ kept/left unchanged. ## Various - N/A - diff --git a/R/create_dcut.R b/R/create_dcut.R index 3733d61..22c0622 100644 --- a/R/create_dcut.R +++ b/R/create_dcut.R @@ -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, diff --git a/tests/testthat/test-create_dcut.R b/tests/testthat/test-create_dcut.R index ad6407d..1e776f2 100644 --- a/tests/testthat/test-create_dcut.R +++ b/tests/testthat/test-create_dcut.R @@ -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" + ) +})