# patient <- read_excel("./inst/app/www/data/LAMPA_PATIENT.xlsx", skip = 1)
patient <- read_excel("./www/data/LAMPA_PATIENT.xlsx", skip = 1)
patient <- janitor::clean_names(patient) %>%
rename(specialty = activity)
# add patient identifier and complete data
patient <- patient %>%
arrange(label, form_cycle) %>%
mutate(patient_id = 1:nrow(patient) - (form_cycle - 1))
patient <- patient %>%
group_by(patient_id) %>%
fill(form_cycle:specialty) %>%
ungroup()
# transform columns
patient <- patient %>%
mutate(surdate = dmy(surdate),
antistdate = dmy(antistdate),
antienddate = dmy(antienddate),
age_year = case_when(
!is.na(ageyr) ~ ageyr,
!is.na(agemo) ~ agemo / 12,
!is.na(ageday) ~ ageday / 365.25)) %>%
mutate(age_category = case_when(
age_year < 1 ~ "< 1 y.o.",
age_year < 5 ~ "1 to 5 y.o.",
age_year < 15 ~ "5 to 15 y.o.",
age_year < 120 ~ "> 15 y.o.",
TRUE ~ "Unknown")) %>%
mutate(age_category = factor(age_category, levels = c("< 1 y.o.", "1 to 5 y.o.", "5 to 15 y.o.",
"> 15 y.o.", "Unknown")))
patient$weight[patient$weight == 999] <- NA
if(! all(patient$typeind %in% c("Treat infection", "Completely unknown", "More than one day surgical prophylaxis",
"Medical prophylaxis", "completely unknown", "Single dose surgical prophylaxis",
"One day (multiple dose) surgical prophylaxix"))) error("Unexpected Type Indication")
patient$typeind_cat <- "Unknown"
patient$typeind_cat[patient$typeind == "Treat infection"] <- "Treatment"
patient$typeind_cat[patient$typeind %in%
c("More than one day surgical prophylaxis", "Medical prophylaxis",
"Single dose surgical prophylaxis", "One day (multiple dose) surgical prophylaxix")] <- "Prophylaxis"
# ward <- read_excel("./inst/app/www/data/LAMPA_WARD.xlsx", skip = 1)
ward <- read_excel("./www/data/LAMPA_WARD.xlsx", skip = 1)
ward <- janitor::clean_names(ward)
ward$surdate <- dmy(ward$surdate)
ward$specialty <- "Unknown"
ward[ward$ipdopd == "Inpatient", "specialty"] <- ward[ward$ipdopd == "Inpatient", "deptype"]
ward[ward$ipdopd == "Outpatient", "specialty"] <- ward[ward$ipdopd == "Outpatient", "opdtype"]
# Recode ward specialty so that it matches with patient specialty
ward$specialty <- recode(ward$specialty,
"Intensive Care Unit" = "Intensive Care",
"Obstetrics and Gynaecology" = "General practice",
"Paediatrics" = "General practice")
test_data_odk(patient, ward)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.