Skip to content
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

chore: added more hba1c NPU codes to the fake dataset #102

Merged
merged 3 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions data-raw/simulate-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,20 @@ insert_false_drug_names <- function(data, proportion = 0.05) {
)
}

insert_analysiscode <- function(x) {
# TODO: Is this necessary?
# ANALYSISCODE: npu code of analysis type (chr)
# 50% is either NPU27300 or NPU03835
# other 50% is NPU10000 to NPU99999
x
insert_analysiscode <- function(data, proportion = 0.3) {
# NPU27300: New units for HbA1c
# NPU03835: Old units for HbA1c
data |>
dplyr::mutate(
dplyr::across(
dplyr::matches("^analysiscode$"),
\(column) dplyr::if_else(
runif(dplyr::n()) < proportion,
sample(c("NPU27300", "NPU03835"), 1),
lwjohnst86 marked this conversation as resolved.
Show resolved Hide resolved
column
)
)
)
}

# TODO: Need a function to reuse recnum and dw_ek_kontakt in LPR data
Expand Down Expand Up @@ -238,6 +246,7 @@ register_data <- simulation_definitions_list |>
map(add_fake_drug_name) |>
map(insert_false_drug_names) |>
map(insert_false_metformin) |>
map(insert_analysiscode) |>
# add the register abbreviations as a name to the list
set_names(
map_chr(
Expand Down
Binary file modified data/register_data.rda
Binary file not shown.