-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: 🚧 skeleton of the core diabetes classification #142
base: main
Are you sure you want to change the base?
Changes from all commits
cbabee3
d0604aa
af34be8
ba8126f
f956fbd
95f6481
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,105 @@ | ||||||
#' Classify diabetes status using Danish registers. | ||||||
#' | ||||||
#' @return The same object type as the input data, which would be a | ||||||
#' [tibble::tibble()] type object. | ||||||
#' @export | ||||||
#' @seealso See the [vignette("function-flow", package = "osdc")] for a detailed | ||||||
#' description of the internal implementation of this classification function. | ||||||
#' | ||||||
#' @examples | ||||||
#' classify_diabetes( | ||||||
#' kontakter = register_data$kontakter, | ||||||
#' diagnoser = register_data$diagnoser, | ||||||
#' lpr_diag = register_data$lpr_diag, | ||||||
#' lpr_adm = register_data$lpr_adm, | ||||||
#' sysi = register_data$sysi, | ||||||
#' sssy = register_data$sssy, | ||||||
#' lab_forsker = register_data$lab_forsker, | ||||||
#' bef = register_data$bef, | ||||||
#' lmdb = register_data$lmdb | ||||||
#' ) | ||||||
classify_diabetes <- function(kontakter, diagnoser, lpr_diag, lpr_adm, sysi, sssy, lab_forsker, bef, lmdb) { | ||||||
# Verification step ----- | ||||||
verify_required_variables(kontakter, "kontakter") | ||||||
verify_required_variables(diagnoser, "diagnoser") | ||||||
verify_required_variables(lpr_diag, "lpr_diag") | ||||||
verify_required_variables(lpr_adm, "lpr_adm") | ||||||
verify_required_variables(sysi, "sysi") | ||||||
verify_required_variables(sssy, "sssy") | ||||||
verify_required_variables(lab_forsker, "lab_forsker") | ||||||
verify_required_variables(bef, "bef") | ||||||
verify_required_variables(lmdb, "lmdb") | ||||||
|
||||||
# Initially processing ----- | ||||||
lpr2 <- join_lpr2( | ||||||
lpr_diag = lpr_diag, | ||||||
lpr_adm = lpr_adm | ||||||
) | ||||||
|
||||||
lpr3 <- join_lpr3( | ||||||
kontakter = kontakter, | ||||||
diagnoser = diagnoser | ||||||
) | ||||||
|
||||||
# pregnancy_dates <- get_pregrancy_dates( | ||||||
# lpr2 = lpr2, | ||||||
# lpr3 = lpr3 | ||||||
# ) | ||||||
|
||||||
# Inclusion steps ----- | ||||||
# diabetes_diagnosis <- include_diabetes_diagnosis( | ||||||
# lpr2 = lpr2, | ||||||
# lpr3 = lpr3 | ||||||
# ) | ||||||
|
||||||
# podiatrist_services <- include_podiatrist_services( | ||||||
# sysi = sysi, | ||||||
# sssy = sssy | ||||||
# ) | ||||||
|
||||||
# gld_purchases <- include_gld_purchases( | ||||||
# lmdb = lmdb | ||||||
# ) | ||||||
|
||||||
included_hba1c <- include_hba1c( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Or something to be more like the other inclusion step variable names (i.e., not start with an "included"). |
||||||
lab_forsker = lab_forsker | ||||||
) | ||||||
|
||||||
# Exclusion steps ----- | ||||||
exclusions <- gld_purchases |> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe name the output |
||||||
exclude_potential_pcos(bef = bef) |> | ||||||
exclude_wld_purchases(lmdb = lmdb) |> | ||||||
exclude_pregnancy( | ||||||
# TODO: Need to think about arg naming here.. | ||||||
hba1c = included_hba1c, | ||||||
pregnancy_dates = pregnancy_dates | ||||||
) | ||||||
|
||||||
# Joining into an initial dataset ----- | ||||||
# inclusions <- join_inclusions( | ||||||
# included_diabetes_diagnosis, | ||||||
# included_podiatrist_services, | ||||||
# exclusions | ||||||
# ) | ||||||
|
||||||
# inclusions |> | ||||||
# get_diagnosis_dates() |> | ||||||
# classify_t1d() | ||||||
} | ||||||
|
||||||
#' After inclusion and exclusion, classify those with type 1 diabetes. | ||||||
#' | ||||||
#' @param data Joined data output from the inclusion and exclusion steps. | ||||||
#' | ||||||
#' @return The same object type as the input data, which would be a | ||||||
#' [tibble::tibble()] type object. | ||||||
#' @keywords internal | ||||||
#' | ||||||
classify_t1d <- function(data) { | ||||||
# data |> | ||||||
# get_has_t1d_primary_diagnosis() |> | ||||||
# get_only_insulin_purchases() |> | ||||||
# get_majority_of_t1d_primary_diagnosis() |> | ||||||
# get_insulin_purchases_within_180_days() |> | ||||||
# get_insulin_is_two_thirds_of_gld_purchases() | ||||||
} | ||||||
Comment on lines
+98
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it is still present in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function outputs and helper functions currently described in #133 need a bit of aligning to match what ends up being implemented in this script (right now I've added another helper function, get_type_diagnosis_majority(), but that one only relates to hospital diagnoses, not GLD, so it should be fine for this PR). There will probably be some back-and-forth between the function flow docs and this script as we go along. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I've included this in
include_podiatrist_services()
too. Should it only be here?