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

Closes #181 Assertion added for cut date not to be NULL #181 #197

Merged
merged 6 commits into from
Feb 9, 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
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"
)
})
Loading