|
|
@ -1,9 +1,13 @@ |
|
|
|
library(shiny) |
|
|
|
library(rhandsontable) |
|
|
|
<<<<<<< HEAD |
|
|
|
library(tidyverse) |
|
|
|
library(reshape2) |
|
|
|
library(Matrix) |
|
|
|
library(CitFuns) |
|
|
|
======= |
|
|
|
library(BDCIT) |
|
|
|
>>>>>>> main |
|
|
|
|
|
|
|
print(getwd()) |
|
|
|
source("../sqlFunctions.R", encoding = "UTF-8") |
|
|
@ -57,6 +61,7 @@ ui <- fluidPage( |
|
|
|
choices = list("NHC" = 1, "UMID/OVID" = 2, "UM/OV"=3), |
|
|
|
selected = 2), |
|
|
|
textInput("id", label = "ID", value = ""), |
|
|
|
actionButton("nitrosync", "Actualiza Nitrógeno") |
|
|
|
), |
|
|
|
mainPanel( |
|
|
|
htmlOutput("report"), |
|
|
@ -696,6 +701,92 @@ server <- function(input, output) { |
|
|
|
nitro |
|
|
|
}) |
|
|
|
|
|
|
|
observeEvent(input$nitrosync, { |
|
|
|
|
|
|
|
if (input$dbtype == "UM"){ |
|
|
|
## Copia de backup |
|
|
|
|
|
|
|
if (!dir.exists(NitroRoute)){ |
|
|
|
dir.create(NitroRoute) |
|
|
|
print(paste0("Back Up directory ", NitroRoute, " created")) |
|
|
|
} |
|
|
|
|
|
|
|
write.xlsx( |
|
|
|
sqlFetch(dta, "NITROGEN"), |
|
|
|
file=paste0(NitroRoute, format(Sys.time(), format="%Y%m%d"),"-","UM-Nitrogen.xlsx") |
|
|
|
) |
|
|
|
|
|
|
|
table<-read.xlsx(paste0(gsub("/BU_NITRO/", "", NitroRoute),"/Nitrogen_ICO.xlsx")) |
|
|
|
|
|
|
|
table.um<-table %>% filter( grepl("UM|MU", Nombre) | grepl("Met|Prim|hep|Enn",Nombre, ignore.case = T) | |
|
|
|
Nombre == "TILs f. 21/09/20" | Nombre == "TILS DISG f. 03/07/20") |
|
|
|
|
|
|
|
table.um<-add_column(table.um,.before=1, "CODIGO"=str_extract(table.um$Nombre, "UM[0-9]{4}")) |
|
|
|
|
|
|
|
table.samp<-sqlQuery(dta, "SELECT U.NHC,M.* FROM MUESTRAS M INNER JOIN UMID U ON M.UMID=U.UMID") |
|
|
|
table.samp$FECHA_RECEPCION<-table.samp$FECHA_RECEPCION+24*60*60 |
|
|
|
|
|
|
|
|
|
|
|
table.um<-add_column(table.um, .after=1, |
|
|
|
"FECHA"=str_extract(table.um$Nombre, "[0-9]{2}[\\./][0-9]{2}[\\./][0-9]{2}") %>% gsub("\\.","/",.)) |
|
|
|
table.um$FECHA<-as.POSIXct(table.um$FECHA, format="%d/%m/%y") |
|
|
|
|
|
|
|
table.um<-merge(table.um, table.samp %>% select(CODIGO,FECHA_RECEPCION), by.x="FECHA", by.y="FECHA_RECEPCION", all.x=T) |
|
|
|
table.um<-table.um %>% mutate(CODIGO=case_when(is.na(CODIGO.x)~CODIGO.y, TRUE~CODIGO.x), .before=1) %>% select(-CODIGO.x,-CODIGO.y) |
|
|
|
|
|
|
|
table.um[table.um$Nombre == "MU Met f. 10/02/20","CODIGO"]<-"UM0009" |
|
|
|
table.um[table.um$Nombre == "TILs Diss Met","CODIGO"]<-"UM0020" |
|
|
|
table.um[table.um$Nombre == "UM Met","CODIGO"]<-"UM0020" |
|
|
|
table.um[table.um$Nombre == "UM MET NHC 11489341","CODIGO"]<-"UM0044" |
|
|
|
table.um[table.um$Nombre == "UM Primary 20278822","CODIGO"]<-"UM0029" |
|
|
|
table.um[table.um$Nombre == "Hip Nod Hep NHC11489341","CODIGO"]<-"UM0044" |
|
|
|
|
|
|
|
## Actualización |
|
|
|
|
|
|
|
sqlDrop(dta, "NITROGEN") |
|
|
|
sqlSave(dta, table.um %>% select(-FECHA) %>% filter(!is.na(CODIGO)), tablename="NITROGEN", rownames=F) |
|
|
|
} |
|
|
|
if (input$dbtype == "OV"){ |
|
|
|
## Copia de backup |
|
|
|
|
|
|
|
if (!dir.exists(NitroRoute)){ |
|
|
|
dir.create(NitroRoute) |
|
|
|
print(paste0("Back Up directory ", NitroRoute, " created")) |
|
|
|
} |
|
|
|
|
|
|
|
write.xlsx( |
|
|
|
sqlFetch(dta, "NITROGEN"), |
|
|
|
file=paste0(NitroRoute, format(Sys.time(), format="%Y%m%d"),"-","OV-Nitrogen.xlsx") |
|
|
|
) |
|
|
|
|
|
|
|
## Lectura del excel |
|
|
|
table<-read.xlsx(paste0(gsub("/BU_NITRO/", "", NitroRoute),"/Nitrogen_ICO.xlsx")) |
|
|
|
|
|
|
|
table.ov<-table %>% filter(grepl("OV",Nombre)) |
|
|
|
table.ov<-filter(table.ov, !grepl("OVA",Nombre)) |
|
|
|
|
|
|
|
table.ov<-add_column(table.ov,.before=1, "CODIGO"=str_extract(table.ov$Nombre, "OV[0-9]{4}")) |
|
|
|
table.ov[table.ov$Nombre == "Ascitis OV","CODIGO"]<-"OV2105" |
|
|
|
|
|
|
|
table.ov<-table.ov %>% add_column(SampType=NA, .after=1) |
|
|
|
table.ov[grepl("TIL",table.ov$Nombre, ignore.case = T),"SampType"]<-"TILs" |
|
|
|
table.ov[grepl("frag",table.ov$Nombre, ignore.case = T)|grepl("frag",table.ov$Observaciones, ignore.case = T),"SampType"]<-"FRAG" |
|
|
|
table.ov[grepl("slide",table.ov$Nombre, ignore.case = T)|grepl("slide",table.ov$Observaciones, ignore.case = T),"SampType"]<-"SLIDE" |
|
|
|
table.ov[(is.na(table.ov$SampType) | !(table.ov$SampType == "TILs")) & |
|
|
|
(grepl("disg|diss",table.ov$Nombre, ignore.case = T)| |
|
|
|
grepl("disg|diss",table.ov$Observaciones, ignore.case = T)),"SampType"]<-"DISG" |
|
|
|
table.ov[table.ov$Nombre == "Ascitis OV", "SampType"]<-"ASC" |
|
|
|
table.ov[20:25,"SampType"]<-"DISG" |
|
|
|
table.ov[63:68,"SampType"]<-"DISG" |
|
|
|
|
|
|
|
## Actualización |
|
|
|
|
|
|
|
sqlDrop(dta, "NITROGEN") |
|
|
|
sqlSave(dta, table.ov, tablename="NITROGEN", rownames=F) |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
## scRNAseq |
|
|
|
|
|
|
|
output$PATID = renderUI({ |
|
|
|