Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ venv/
.Rproj.user/
released_output/*
reports/pharmacy_first_data_development.html
reports/resources/*
reports/resources/*
reports/pharmacy_first_data_development_files/*
pharmacy_first_data_development.*
publish
justfile
reports/_publish_ids.yml
lib/validation/data/df_bsa_validation.csv
15 changes: 8 additions & 7 deletions analysis/data_development_med_status_post_counts.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ library(arrow)
library(dplyr)

selected_variables_list <- list(
"post_anymed" <- paste0("post_anymed_", paste0("status", 0:28)),
"post_anypfid" <- paste0("post_anypfid_", paste0("status", 0:28)),
"post_anypfdate" <- paste0("post_anypfdate_", paste0("status", 0:28)),
"post_pfmed" <- paste0("post_pfmed_", paste0("status", 0:28)),
"post_pfmedid" <- paste0("post_pfmedid_", paste0("status", 0:28)),
"post_pfmedpfdate" <- paste0("post_pfmedpfdate_", paste0("status", 0:28))
post_anymed = paste0("post_anymed_", paste0("status", c(0:5, 7:28))),
post_anypfid = paste0("post_anypfid_", paste0("status", c(0:5, 7:28))),
post_anypfdate = paste0("post_anypfdate_", paste0("status", c(0:5, 7:28))),
post_pfmed = paste0("post_pfmed_", paste0("status", c(0:5, 7:28))),
post_pfmedid = paste0("post_pfmedid_", paste0("status", c(0:5, 7:28))),
post_pfmedpfdate = paste0("post_pfmedpfdate_", paste0("status", c(0:5, 7:28)))
)

# Load data
df_med_status <- arrow::read_feather(
here::here("output", "data_development", "med_status_data_development.arrow")
) %>% select(all_of(unlist(selected_variables_list)))
) %>%
dplyr::select(-dplyr::matches("status6$"))

print("Load data successfully")

Expand Down
19 changes: 11 additions & 8 deletions analysis/data_development_med_status_pre_counts.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@ library(arrow)
library(dplyr)

selected_variables_list <- list(
"pre_anymed" <- paste0("pre_anymed_", paste0("status", 0:28)),
"pre_anypfid" <- paste0("pre_anypfid_", paste0("status", 0:28)),
"pre_anypfdate" <- paste0("pre_anypfdate_", paste0("status", 0:28)),
"pre_pfmed" <- paste0("pre_pfmed_", paste0("status", 0:28)),
"pre_pfmedid" <- paste0("pre_pfmedid_", paste0("status", 0:28)),
"pre_pfmedpfdate" <- paste0("pre_pfmedpfdate_", paste0("status", 0:28))
pre_anymed = paste0("pre_anymed_", paste0("status", c(0:5, 7:28))),
pre_anypfid = paste0("pre_anypfid_", paste0("status", c(0:5, 7:28))),
pre_anypfdate = paste0("pre_anypfdate_", paste0("status", c(0:5, 7:28))),
pre_pfmed = paste0("pre_pfmed_", paste0("status", c(0:5, 7:28))),
pre_pfmedid = paste0("pre_pfmedid_", paste0("status", c(0:5, 7:28))),
pre_pfmedpfdate = paste0("pre_pfmedpfdate_", paste0("status", c(0:5, 7:28)))
)

# Load data
expected <- unlist(selected_variables_list)

df_med_status <- arrow::read_feather(
here::here("output", "data_development", "med_status_data_development.arrow")
) %>% select(all_of(unlist(selected_variables_list)))
) %>%
dplyr::select(-dplyr::matches("status6$"))

print("Load data successfully")

# Check that all names defined in data_extractions are in df df_med_status
# all(unlist(selected_variables_list) %in% names(df_med_status))
#all(unlist(selected_variables_list) %in% names(df_med_status))

print("Define variable names successfully")

Expand Down
2 changes: 2 additions & 0 deletions analysis/dataset_definition_med_status_data_development.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@
# This will add 6 x 28 = 168 new columns
for desc, selected_medications in selected_medications_dict.items():
for status in range(29):
if status == 6:
continue
count_med_status_query = selected_medications.where(
selected_medications.medication_status.is_in([status])
).count_for_patient()
Expand Down
Loading