Browse Source

Use database names from the beginning (inout_cd)

master
Maxime Wack 6 years ago
parent
commit
3395b1d479
2 changed files with 2 additions and 10 deletions
  1. +1
    -2
      R/demodata.R
  2. +1
    -8
      R/import.R

+ 1
- 2
R/demodata.R View File

@@ -294,7 +294,7 @@ add_patients_demodata <- function(patients, project, host = "", admin = "", pass
#' - patient_ide: the original patient ID
#' - start_date: the start date of the encounter, as Date object
#' - end_date: the end date of the encounter, as Date object
#' - inout: I or O if inpatient or outpatient
#' - inout_cd: I or O if inpatient or outpatient
#'
#' @param encounters A dataframe of patients
#' @param project The project to add the patients to
@@ -340,7 +340,6 @@ add_encounters <- function(encounters, project, host = "", admin = "", pass = ""
start_date = ifelse(is.na(start_date), NA, format(start_date, format = "%m/%d/%Y %H:%M:%S")),
end_date = ifelse(is.na(end_date), NA, format(end_date, format = "%m/%d/%Y %H:%M:%S")),
active_status_cd = ifelse(is.na(end_date), "O", "S"),
inout_cd = inout,
patient_num = patient_ide,
update_date = format(Sys.Date(), "%m/%d/%Y")) %>%
dplyr::select(encounter_num, patient_num, active_status_cd, start_date, end_date, inout_cd, length_of_stay, update_date) %>%


+ 1
- 8
R/import.R View File

@@ -32,7 +32,7 @@ import_patients_visits <- function(patients, project)
patients %>%
dplyr::select(patient_ide, encounter_ide, start_date, end_date) %>%
dplyr::distinct() %>%
dplyr::mutate(inout = "I") %>%
dplyr::mutate(inout_cd = "I") %>%
add_encounters(project)

# Observations : Age à l'hospitalisation
@@ -53,13 +53,6 @@ import_mensurations <- function(mensurations, patients, project)
patients %>%
dplyr::left_join(mensurations) %>%
dplyr::select(patient_ide, encounter_ide, provider_id, start_date = rum_start, end_date = rum_end, poids, taille, IMC) %>%
tidyr::gather(concept_cd, nval_num, poids, taille, IMC) %>%
dplyr::filter(!is.na(nval_num)) %>%
dplyr::mutate(concept_cd = stringr::str_c("HOS:", concept_cd),
modifier_cd = "@",
valtype_cd = "N",
tval_char = "E",
nval_num = nval_num %>% str_replace(",", ".")) %>%
add_observations(project)
}



Loading…
Cancel
Save