The test dataset has episode_start and episode_end in it and incorrectly letting the .therapy_timeline_get_diagnoses() function pass tests even though validate_inpatient_diagnoses() does not mandate start/end dates.
.therapy_timeline_get_diagnoses() should be changed
> therapy_timeline(TherapyEpisode(ramses_db, xxx))
Error in `dplyr::mutate()`:
! Problem while computing `diagnosis_episode_end = dplyr::lag(.data$episode_end, n = 1, order_by =
.data$episode_start)`.
Caused by error in `.data$episode_start`:
! Column `episode_start` not found in `.data`.
Run `rlang::last_error()` to see where the error occurred.
Backtrace:
x
1. +-Ramses::therapy_timeline(TherapyEpisode(ramses_db, xxx))
2. +-Ramses::therapy_timeline(TherapyEpisode(ramses_db, xxx))
3. | \-Ramses .local(x, ...)
4. | \-Ramses:::.therapy_timeline_create(...)
5. | \-Ramses:::.therapy_timeline_get_diagnoses(input_patient)
6. | \-... %>% ...
7. +-dplyr::summarise(...)
8. +-dplyr::group_by(...)
9. +-dplyr::select(., -.data$diagnosis_episode_end)
10. +-dplyr::mutate(., grp = max(.data$grp))
11. +-dplyr::group_by(., .data$patient_id, .data$icd_code, .data$prim_diag)
12. +-dplyr::mutate(...)
13. +-dplyr::ungroup(.)
14. +-dplyr::mutate(...)
15. +-dplyr:::mutate.data.frame(...)
16. | \-dplyr:::mutate_cols(.data, dplyr_quosures(...), caller_env = caller_env())
17. | +-base::withCallingHandlers(...)
18. | \-mask$eval_all_mutate(quo)
19. +-dplyr::lag(.data$episode_end, n = 1, order_by = .data$episode_start)
20. +-episode_start
21. +-rlang:::`$.rlang_data_pronoun`(.data, episode_start)
22. | \-rlang:::data_pronoun_get(...)
23. \-rlang:::abort_data_pronoun(x, call = y)
24. \-rlang::abort(msg, "rlang_error_data_pronoun_not_found", call = call)
25. ```
The test dataset has episode_start and episode_end in it and incorrectly letting the .therapy_timeline_get_diagnoses() function pass tests even though validate_inpatient_diagnoses() does not mandate start/end dates.
.therapy_timeline_get_diagnoses() should be changed