@@ -26,12 +26,12 @@ testthat::test_that("get_hipaa_disclosure_log_from_ehr_fhir_logs works", {
26
26
head(n = 30 ) | >
27
27
dplyr :: collect() | >
28
28
dplyr :: mutate(
29
- ehr_id = sample(1 : 3 , n(), replace = TRUE ),
30
- created_at = seq.Date(from = Sys.Date() - 10 , to = Sys.Date(), length.out = n())
29
+ ehr_id = sample(1 : 3 , dplyr :: n(), replace = TRUE ),
30
+ created_at = seq.Date(from = Sys.Date() - 10 , to = Sys.Date(), length.out = dplyr :: n())
31
31
)
32
32
33
33
# Write the mutated data back to the database
34
- duckdb_register(conn , " redcap_ehr_fhir_logs" , redcap_ehr_fhir_logs )
34
+ duckdb :: duckdb_register(conn , " redcap_ehr_fhir_logs" , redcap_ehr_fhir_logs )
35
35
36
36
# Required column names
37
37
required_names <- c(
@@ -44,15 +44,25 @@ testthat::test_that("get_hipaa_disclosure_log_from_ehr_fhir_logs works", {
44
44
testthat :: expect_gt(nrow(result ), 0 )
45
45
testthat :: expect_equal(
46
46
nrow(result ),
47
- result | > distinct(disclosure_date , fhir_id , mrn , project_irb_number , username ) | > nrow()
47
+ result | > dplyr :: distinct(disclosure_date , fhir_id , mrn , project_irb_number , username ) | > nrow()
48
48
)
49
49
50
50
result_filtered_ehr_id <- get_hipaa_disclosure_log_from_ehr_fhir_logs(conn , ehr_id = 1 )
51
51
testthat :: expect_true(all(result_filtered_ehr_id $ ehr_id == 1 ))
52
52
53
53
start_date <- Sys.Date() - 5
54
- result_filtered_date <- get_hipaa_disclosure_log_from_ehr_fhir_logs(conn , start_date = start_date )
55
- testthat :: expect_true(all(result_filtered_date $ disclosure_date > = start_date ))
54
+ result_filtered_start_date <- get_hipaa_disclosure_log_from_ehr_fhir_logs(conn , start_date = start_date )
55
+ testthat :: expect_true(all(result_filtered_start_date $ disclosure_date > = start_date ))
56
+
57
+ end_date <- Sys.Date() - 5
58
+ result_filtered_end_date <- get_hipaa_disclosure_log_from_ehr_fhir_logs(conn , end_date = end_date )
59
+ testthat :: expect_true(all(result_filtered_end_date $ disclosure_date < end_date ))
60
+
61
+ start_date <- Sys.Date() - 7
62
+ end_date <- Sys.Date() - 5
63
+ result_filtered_start_and_end_date <- get_hipaa_disclosure_log_from_ehr_fhir_logs(conn , start_date = start_date , end_date = end_date )
64
+ testthat :: expect_true(all(result_filtered_start_and_end_date $ disclosure_date > = start_date ))
65
+ testthat :: expect_true(all(result_filtered_start_and_end_date $ disclosure_date < end_date ))
56
66
57
67
result_combined_filters <- get_hipaa_disclosure_log_from_ehr_fhir_logs(conn , ehr_id = 2 , start_date = start_date )
58
68
testthat :: expect_true(all(result_combined_filters $ ehr_id == 2 ))
0 commit comments