From e892f49d98995c20bc7023fc3e1889786e126f11 Mon Sep 17 00:00:00 2001 From: Ivo Leist Date: Wed, 28 Feb 2024 17:16:22 +0100 Subject: [PATCH] added forgotten commit --- phenoRankeR/R/mod_patient_mode.R | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/phenoRankeR/R/mod_patient_mode.R b/phenoRankeR/R/mod_patient_mode.R index 478c32f..8bf78a7 100644 --- a/phenoRankeR/R/mod_patient_mode.R +++ b/phenoRankeR/R/mod_patient_mode.R @@ -493,16 +493,30 @@ mod_patient_mode_server <- function( ) for (i in 1:nrow(input$referenceFiles)) { - file <- input$referenceFiles[i, ] - # file_ext <- file_ext(file$name) + total_individual_counts <- 0 + uploaded_file <- input$referenceFiles[i, ] - if (!(get_file_ext(file$name) %in% allowed_types)) { + file_con <- file(uploaded_file$datapath, "r") + individual_counts <- as.numeric(jq(file_con, "length")) + close(file_con) + + total_individual_counts <- total_individual_counts + individual_counts + if (total_individual_counts > 1000) { + showNotification( + "The maximum number of individuals is 1000", + type = "error" + ) + reset("referenceFiles") + return() + } + + if (!(get_file_ext(uploaded_file$name) %in% allowed_types)) { showNotification("Invalid file type!", type = "error") reset("referenceFiles") return() } - json_data <- fromJSON(readLines(file$datapath)) + json_data <- fromJSON(readLines(uploaded_file$datapath)) rv_patient$inputFormat <- "bff" if ("subject" %in% names(json_data)) { rv_patient$inputFormat <- "pxf" @@ -520,7 +534,7 @@ mod_patient_mode_server <- function( str_references <- paste0( str_references, - file$name, + uploaded_file$name, ":C", i, "\n" @@ -543,7 +557,7 @@ mod_patient_mode_server <- function( ) file.copy( - file$datapath, + uploaded_file$datapath, file_path )