Skip to content

Commit

Permalink
notes for the top of the report
Browse files Browse the repository at this point in the history
ref #5
  • Loading branch information
wibeasley committed Dec 31, 2021
1 parent c9b97c8 commit e3e85cb
Show file tree
Hide file tree
Showing 9 changed files with 199 additions and 76 deletions.
11 changes: 8 additions & 3 deletions R/execute-checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ execute_checks <- function (ds, checks) {
baseline_date_name = checks$baseline_date_name,
record_id_link = checks$record_id_link,
github_file_prefix = checks$github_file_prefix,
redcap_codebook = checks$redcap_codebook,

smells = smells$ds_smell_result,
smell_status = smells$smell_status,
smells_inactive = smells$smells_inactive,

rules = rules$rules,
rule_status = rules$rule_status
rule_status = rules$rule_status,
rules_inactive= rules$rules_inactive
),
class = "trawler_checks"
)
Expand Down Expand Up @@ -94,7 +97,8 @@ execute_smells <- function (ds, checks) {

list(
ds_smell_result = ds_smell_result,
smell_status = smell_status
smell_status = smell_status,
smells_inactive = checks$smells_inactive
)
}

Expand Down Expand Up @@ -194,6 +198,7 @@ execute_rules <- function (ds, checks) {

list(
rules = checks$rules,
rule_status = rule_status
rule_status = rule_status,
rules_inactive = checks$rules_inactive
)
}
5 changes: 4 additions & 1 deletion R/load-checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ new_trawler_checks <- function (checks) {
baseline_date_name = misc$baseline_date_name,
record_id_link = misc$record_id_link,
github_file_prefix = misc$github_file_prefix,
redcap_codebook = misc$redcap_codebook,

smells = smells_all$smells,
smells_inactive = smells_all$smells_inactive,
Expand All @@ -50,12 +51,14 @@ load_misc <- function (checks) {
checkmate::assert_character(checks$baseline_date_name, min.chars = 1, len = 1, any.missing = FALSE)
checkmate::assert_character(checks$record_id_link , min.chars = 10, len = 1, any.missing = FALSE)
checkmate::assert_character(checks$github_file_prefix, min.chars = 10, len = 1, any.missing = FALSE)
checkmate::assert_character(checks$redcap_codebook , min.chars = 10, len = 1, any.missing = FALSE)

list(
record_id_name = checks$record_id_name,
baseline_date_name = checks$baseline_date_name,
record_id_link = checks$record_id_link,
github_file_prefix = checks$github_file_prefix
github_file_prefix = checks$github_file_prefix,
redcap_codebook = checks$redcap_codebook
)
}

Expand Down
Binary file modified inst/derived/biochemical.rds
Binary file not shown.
43 changes: 43 additions & 0 deletions inst/report-templates/rmarkdown-1/report-1.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,49 @@ checks <- base::readRDS(path_checks)
```


Set Up {.tabset .tabset-fade}
=============================

Instructions
-----------------------------

1. Work through each line in the table to discover & correct entry mistakes in the database. Be aware that a single mistake may manifest in multiple rows/checks; fixing one value may clear several rows.
1. Click the `record id` value in a row to be taken to the participant's Event Grid in REDCap (*i.e.*, the 'stop light page').
1. Double-check that your manual corrections in REDCap are reflected in `r checks$path_output_rule`. Be careful not to move this file to somewhere unsafe.
1. To help discover the dataflow and problematic location, use the
* project's [codebook](`r checks$redcap_codebook`) in REDCap,
* the data pipeline files, and
* the report code.
1. If you create a new rule or smell check, make sure the error message won't reveal any PHI.

Execute Rules
-----------------------------
```{r execute-rules, echo = echo_chunks, results = 'asis'}
```

Execute Smells
-----------------------------
```{r execute-smells, echo = echo_chunks, results = 'asis'}
```

Inactive Rules
-----------------------------

`r nrow(checks$rules_inactive)` rules(s) are disabled for this report:

```{r rules-inactive, echo = echo_chunks, results = 'asis'}
cat(sprintf("1. %s;", checks$rules_inactive$check_name), sep = "\n")
```

Inactive Smells
-----------------------------

`r nrow(checks$smells_inactive)` smell(s) are disabled for this report:

```{r smells-inactive, echo = echo_chunks, results = 'asis'}
cat(sprintf("1. %s;", checks$smells_inactive$check_name), sep = "\n")
```

Rules {.tabset .tabset-fade}
=============================

Expand Down
61 changes: 48 additions & 13 deletions inst/report-templates/rmarkdown-1/report-1.html

Large diffs are not rendered by default.

43 changes: 40 additions & 3 deletions inst/report-templates/rmarkdown-1/report-1.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion man/render_rmarkdown.Rd

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

54 changes: 27 additions & 27 deletions tests/testthat/_snaps/execute-checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
1 proportion_fe~ TRUE Proportion femal~ 2 FALSE 0.25 0.75
2 proportion_ma~ TRUE Proportion male ~ 2 FALSE 0.25 0.75
3 mean_age TRUE Mean age of part~ 2 FALSE 20 80
4 mean_serum_pr~ FALSE Mean serum pre-a~ 1 FALSE 32 39
5 mean_serum_cr~ FALSE Mean serum creat~ 1 FALSE 3 15
4 mean_serum_pr~ FALSE Mean serum pre-a~ 2 FALSE 32 39
5 mean_serum_cr~ FALSE Mean serum creat~ 2 FALSE 3 15
6 average_bmi_a~ FALSE Average BMI is b~ 2 FALSE 18 24
7 mean_serum_ch~ TRUE Average Choleste~ 1 FALSE 100 140
8 dialysis_adeq~ TRUE Normal range for~ 1 FALSE 1.2 5
Expand Down Expand Up @@ -56,8 +56,8 @@
1 2 FALSE 0.25 0.75 [%.2f, %.2f] %.3f
2 2 FALSE 0.25 0.75 [%.2f, %.2f] %.3f
3 2 FALSE 20.00 80.00 [%.0f, %.0f] %.1f
4 1 FALSE 32.00 39.00 [%.0f, %.0f] %.1f
5 1 FALSE 3.00 15.00 [%.0f, %.0f] %.1f
4 2 FALSE 32.00 39.00 [%.0f, %.0f] %.1f
5 2 FALSE 3.00 15.00 [%.0f, %.0f] %.1f
6 2 FALSE 18.00 24.00 [%.0f, %.0f] %.1f
7 1 FALSE 100.00 140.00 [%.0f, %.0f] %.1f
8 1 FALSE 1.20 5.00 [%.1f, %.1f] %.2f
Expand Down Expand Up @@ -109,18 +109,18 @@
<chr> <int> <chr> <int> <lgl> <chr>
1 baseline_pre~ 10 Serum pre-albumi~ 1 FALSE baseline_data
2 missing_seru~ 3 Relevant nutriti~ 1 FALSE baseline_data
3 serum_prealb~ 15 Baseline prealbu~ 1 FALSE baseline_data~
4 serum_prealb~ 0 Baseline prealbu~ 1 FALSE baseline_data~
5 serum_prealb~ 0 Baseline prealbu~ 1 FALSE baseline_data~
6 serum_prealb~ 0 serum prealbumin~ 1 FALSE baseline_data~
7 baseline_fir~ 0 Serum prealbumin~ 1 FALSE baseline_data~
8 daily_first_~ 0 In-addition to b~ 1 FALSE baseline_data~
9 daily_protei~ 0 npcr levels in s~ 1 FALSE baseline_data~
3 serum_prealb~ 15 Baseline prealbu~ 2 FALSE baseline_data~
4 serum_prealb~ 0 Baseline prealbu~ 2 FALSE baseline_data~
5 serum_prealb~ 0 Baseline prealbu~ 2 FALSE baseline_data~
6 serum_prealb~ 0 serum prealbumin~ 3 FALSE baseline_data~
7 baseline_fir~ 0 Serum prealbumin~ 3 FALSE baseline_data~
8 daily_first_~ 0 In-addition to b~ 3 FALSE baseline_data~
9 daily_protei~ 0 npcr levels in s~ 3 FALSE baseline_data~
10 hospitalizat~ 2 Patient was hosp~ 1 FALSE completion_pr~
11 optimal_dail~ 7 Daily protein in~ 1 FALSE completion_pr~
12 recommended_~ 10 NPCR values are ~ 1 FALSE completion_da~
13 npcr 1 NPCR at completi~ 1 FALSE completion_da~
14 npcr_compari~ 2 NPCR at completi~ 1 FALSE completion_da~
11 optimal_dail~ 7 Daily protein in~ 2 FALSE completion_pr~
12 recommended_~ 10 NPCR values are ~ 2 FALSE completion_da~
13 npcr 1 NPCR at completi~ 2 FALSE completion_da~
14 npcr_compari~ 2 NPCR at completi~ 3 FALSE completion_da~
# ... with 2 more variables: passing_test <chr>, results <list>

---
Expand Down Expand Up @@ -161,18 +161,18 @@
priority debug
1 1 FALSE
2 1 FALSE
3 1 FALSE
4 1 FALSE
5 1 FALSE
6 1 FALSE
7 1 FALSE
8 1 FALSE
9 1 FALSE
3 2 FALSE
4 2 FALSE
5 2 FALSE
6 3 FALSE
7 3 FALSE
8 3 FALSE
9 3 FALSE
10 1 FALSE
11 1 FALSE
12 1 FALSE
13 1 FALSE
14 1 FALSE
11 2 FALSE
12 2 FALSE
13 2 FALSE
14 3 FALSE
instrument
1 baseline_data
2 baseline_data
Expand All @@ -198,7 +198,7 @@
7 function (d) {\n events_to_check <- c("enrollment_arm_1", "visit_1_arm_1")\n dplyr::if_else(\n (\n d$redcap_event_name %in% events_to_check &\n (d$baseline_prealbumin_level < 30) &\n (d$baseline_normalized_protein_catabolic_rate < 1.2)\n ),\n (d$baseline_normalized_protein_catabolic_rate <= d$visit_lab_npcr),\n TRUE\n )\n}\n
8 function (d) {\n events_to_check <- c("enrollment_arm_1", "visit_1_arm_1")\n dplyr::if_else(\n (\n (d$redcap_event_name %in% events_to_check) &\n (d$baseline_prealbumin_level < 30) &\n (d$baseline_normalized_protein_catabolic_rate < 1.2) &\n (d$baseline_normalized_protein_catabolic_rate <= d$visit_lab_npcr)\n ),\n d$visit_lab_npcr <= d$visit_blood_workup_npcr,\n TRUE\n )\n}\n
9 function (d) {\n events_to_check <- c("enrollment_arm_1", "visit_1_arm_1", "visit_2_arm_1", "final_visit_arm_1")\n dplyr::if_else(\n (\n (d$redcap_event_name %in% events_to_check) &\n (d$baseline_prealbumin_level < 30) &\n (d$baseline_normalized_protein_catabolic_rate < 1.2) &\n (d$baseline_normalized_protein_catabolic_rate <= d$visit_lab_npcr) &\n (d$visit_lab_npcr <= d$visit_blood_workup_npcr)\n ),\n d$visit_blood_workup_npcr < d$completion_data_npcr,\n TRUE\n )\n}\n
10 function (d) {\n dplyr::if_else(\n d$completion_project_questionnaire_hospitalization %in% 1,\n !is.na(d$completion_project_questionnaire_hospitalization_cause) & !is.na(d$completion_project_questionnaire_hospitalization_date),\n TRUE\n )\n}\n
10 function (d) {\n dplyr::if_else(\n d$completion_project_questionnaire_hospitalization == 1L,\n !is.na(d$completion_project_questionnaire_hospitalization_cause) & !is.na(d$completion_project_questionnaire_hospitalization_date),\n TRUE\n )\n}\n
11 function (d) {\n dplyr::if_else(\n d$completion_data_npcr >= 1.2,\n dplyr::between(d$completion_data_prealbumin_level, 30, 40),\n TRUE\n )\n}\n
12 function (d) {\n dplyr::between(d$completion_data_npcr, 1.2, 1.4)\n}\n
13 function (d) {\n events_to_check <- c("final_visit_arm_1")\n dplyr::if_else(\n d$redcap_event_name %in% events_to_check,\n !is.na(d$completion_data_npcr), # If this row exists in the desired event, then check for nonmissingness.\n TRUE # Otherwise, the test passes for rows associated with all other events.\n )\n}\n
Expand Down
Loading

0 comments on commit e3e85cb

Please sign in to comment.