-
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: ✨ add include_diabetes_diagnoses()
with tests
#192
base: main
Are you sure you want to change the base?
Conversation
Outlined diabetes inclusion function.
Finished include_diabetes_diagnoses function.
…-aarhus/osdc into include-diabetes-diagnoses
Minor edits to the function itself so handle missing values properly.
…-aarhus/osdc into include-diabetes-diagnoses
Slightly reworded some error messages.
Edits to include_diabetes_diagnoses to fix logic for counting diabetes diagnoses
include_diabetes_diagnoses()
with tests
lpr3_diabetes <- join_lpr3(kontakter = kontakter, diagnoser = lpr3_diabetes_diagnoses) | ||
|
||
# Define variables | ||
hovedspeciale_other_medical_pattern <- '[Mm]edicin|[Gg]eriatri|[Hh]epatologi|[Hh]æmatologi|[Ii]nfektion|[Kk]ardiologi|[Nn]efrologi|[Rr]eumatologi|[Dd]ermato|[Nn]eurologi|[Oo]nkologi|[Oo]ftalmologi|[Nn]eurofysiologi' |
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.
This is the regex I mentioned.
Maybe it should be moved to algorithm.csv now that lots of logic has been added there (including the string matching logic which the regex is intended to replace) as part of #190
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.
I'm thinking that it makes sense to move this to algorithm.csv
and maybe adding the potentially capitalised letters in #190 👍
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.
Nice work 🎉
Just a mini review with some initial comments :)
verify_required_variables(register_data$diagnoser, "diagnoser") | ||
verify_required_variables(register_data$kontakter, "kontakter") | ||
|
||
# Filter and join LPR2 data: |
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.
# Filter and join LPR2 data: | |
# Filter and join LPR2 data |
# To convert the string into an R expression. | ||
rlang::parse_expr() | ||
|
||
# Filter to diabetes diagnoses using expression filter. |
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.
# Filter to diabetes diagnoses using expression filter. | |
# Filter to diabetes diagnoses using expression filter |
lpr3_diabetes <- join_lpr3(kontakter = kontakter, diagnoser = lpr3_diabetes_diagnoses) | ||
|
||
# Define variables | ||
hovedspeciale_other_medical_pattern <- '[Mm]edicin|[Gg]eriatri|[Hh]epatologi|[Hh]æmatologi|[Ii]nfektion|[Kk]ardiologi|[Nn]efrologi|[Rr]eumatologi|[Dd]ermato|[Nn]eurologi|[Oo]nkologi|[Oo]ftalmologi|[Nn]eurofysiologi' |
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.
I'm thinking that it makes sense to move this to algorithm.csv
and maybe adding the potentially capitalised letters in #190 👍
n_t1d_endocrinology = sum( | ||
(is_t1d == TRUE) & | ||
(is_primary == TRUE) & (department == 'endocrinology'), | ||
na.rm = TRUE | ||
), | ||
n_t2d_endocrinology = sum( | ||
(is_t2d == TRUE) & | ||
(is_primary == TRUE) & (department == 'endocrinology'), | ||
na.rm = TRUE | ||
), | ||
n_t1d_medical = sum( | ||
(is_t1d == TRUE) & | ||
(is_primary == TRUE) & (department == 'other medical'), | ||
na.rm = TRUE | ||
), | ||
n_t2d_medical = sum( | ||
(is_t2d == TRUE) & | ||
(is_primary == TRUE) & (department == 'other medical'), | ||
na.rm = TRUE | ||
) |
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.
Could/should this be moved to some simple helper/filter functions?
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.
Hmm, yes... something like get_n_type_specific_diagnoses()
It could also be made more succinct by removing all the " == TRUE" parts, since they're not needed. I originally didn't write them out, but I ended up adding the for readability (but now I think they degrade it).
This PR adds:
Closes #91
Checklist
just run-all