|
@ -520,6 +520,77 @@ server <- function(input, output) { |
|
|
sqlSave(dta, clinics.new, tablename="CLINICS", append = T, varTypes = varTypes, rownames = F) |
|
|
sqlSave(dta, clinics.new, tablename="CLINICS", append = T, varTypes = varTypes, rownames = F) |
|
|
print("Tabla CLINICS sincronizada.") |
|
|
print("Tabla CLINICS sincronizada.") |
|
|
} |
|
|
} |
|
|
|
|
|
if (input$dbtype %in% c("CC")){ |
|
|
|
|
|
## Nuevas entradas en MUESTRAS |
|
|
|
|
|
nsamples<-values[["samples"]] %>% nrow |
|
|
|
|
|
upd.samples<-values[["samples"]] |
|
|
|
|
|
if (nrow(upd.samples) > 0){rownames(upd.samples)<-(nsamples+1):(nsamples+nrow(upd.samples)) %>% as.character} |
|
|
|
|
|
|
|
|
|
|
|
if (nrow(upd.samples) > 0){ |
|
|
|
|
|
upd.samples$FECHA_RECEPCION<-lubridate::parse_date_time(upd.samples$FECHA_RECEPCION, c("d/m/Y","d/m/y")) %>% as.Date() |
|
|
|
|
|
upd.samples$TIPO<-as.character(upd.samples$TIPO) |
|
|
|
|
|
upd.samples$OBS<-as.character(upd.samples$OBS) |
|
|
|
|
|
### !! Atención, esto cambia la base de datos: |
|
|
|
|
|
sqlSave(dta, upd.samples, tablename="MUESTRAS", append = T, varTypes = c("FECHA_RECEPCION"="Date"), rownames = F) |
|
|
|
|
|
print("Tabla MUESTRAS sincronizada.") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
## Entradas modificadas en CLINICOS |
|
|
|
|
|
upd.clinics<-values[["CLINICS"]] |
|
|
|
|
|
PATID.mod<-upd.clinics$PATID[upd.clinics$PATID %in% (sqlFetch(dta, "CLINICOS") %>% pull(PATID))] |
|
|
|
|
|
rnames<-sqlFetch(dta, "CLINICOS") %>% filter(PATID %in% PATID.mod) %>% rownames |
|
|
|
|
|
clinics.mod<-upd.clinics %>% filter(PATID %in% PATID.mod) %>% select(-NHC) |
|
|
|
|
|
rownames(clinics.mod)<-rnames |
|
|
|
|
|
|
|
|
|
|
|
### !! Atención, esto cambia la base de datos: |
|
|
|
|
|
fechas<-colnames(clinics.mod)[grepl("date|MET_DX|DoB", colnames(clinics.mod), ignore.case = T)] |
|
|
|
|
|
for (i in fechas){ |
|
|
|
|
|
clinics.mod[,i]<-lubridate::parse_date_time(clinics.mod[,i], c("d/m/Y","d/m/y")) %>% as.Date() |
|
|
|
|
|
} |
|
|
|
|
|
sqlUpdate(dta, clinics.mod,"CLINICOS", index="PATID") |
|
|
|
|
|
print("Tabla CLINICOS modificada.") |
|
|
|
|
|
|
|
|
|
|
|
## Nuevas entradas en CLINICOS |
|
|
|
|
|
nsamples.clin<-sqlFetch(dta, "CLINICOS") %>% nrow |
|
|
|
|
|
PATID.new<-upd.clinics$PATID[!upd.clinics$PATID %in% (sqlFetch(dta, "CLINICOS") %>% pull(PATID))] |
|
|
|
|
|
clinics.new<-upd.clinics %>% filter(PATID %in% PATID.new) %>% select(-NHC) |
|
|
|
|
|
if (length(PATID.new) > 0){rownames(clinics.new)<-(nsamples.clin+1):(nsamples.clin+nrow(clinics.new)) %>% as.character} |
|
|
|
|
|
|
|
|
|
|
|
### !! Atención, esto cambia la base de datos: |
|
|
|
|
|
fechas<-colnames(clinics.new)[grepl("date|MET_DX|DoB", colnames(clinics.new), ignore.case = T)] |
|
|
|
|
|
varTypes<-rep("Date",length(fechas)) |
|
|
|
|
|
names(varTypes)<-fechas |
|
|
|
|
|
for (i in fechas){ |
|
|
|
|
|
clinics.new[,i]<-lubridate::parse_date_time(clinics.new[,i], c("d/m/Y","d/m/y","Y-m-d")) %>% as.Date() |
|
|
|
|
|
} |
|
|
|
|
|
sqlSave(dta, clinics.new, tablename="CLINICOS", append = T, varTypes = varTypes, rownames = F) |
|
|
|
|
|
print("Tabla CLINICOS sincronizada.") |
|
|
|
|
|
|
|
|
|
|
|
## Nuevas entradas en CNAG |
|
|
|
|
|
if (nrow(values[["cnag"]]) > 0){ |
|
|
|
|
|
cnag.sync<-values[["cnag"]] |
|
|
|
|
|
fechas<-colnames(cnag.sync)[sqlFetch(dta, "CNAG") %>% sapply(lubridate::is.POSIXct)] |
|
|
|
|
|
varTypes<-rep("Date",length(fechas)) |
|
|
|
|
|
names(varTypes)<-fechas |
|
|
|
|
|
print(fechas) |
|
|
|
|
|
for (i in fechas){ |
|
|
|
|
|
cnag.sync[,i]<-lubridate::parse_date_time(cnag.sync[,i], c("d/m/Y","d/m/y","Y-m-d")) %>% as.Date() |
|
|
|
|
|
} |
|
|
|
|
|
sqlSave(dta, cnag.sync, tablename="CNAG", append = T, varTypes = varTypes, rownames = F) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
## Nuevas entradas en RNADNA |
|
|
|
|
|
if (nrow(values[["rna"]]) > 0){ |
|
|
|
|
|
rna.sync<-values[["rna"]] |
|
|
|
|
|
fechas<-colnames(rna.sync)[sqlFetch(dta, "RNADNA") %>% sapply(lubridate::is.POSIXct)] |
|
|
|
|
|
varTypes<-rep("Date",length(fechas)) |
|
|
|
|
|
names(varTypes)<-fechas |
|
|
|
|
|
for (i in fechas){ |
|
|
|
|
|
rna.sync[,i]<-lubridate::parse_date_time(rna.sync[,i], c("d/m/Y","d/m/y","Y-m-d")) %>% as.Date() |
|
|
|
|
|
} |
|
|
|
|
|
sqlSave(dta, rna.sync, tablename="RNADNA", append = T, varTypes = varTypes, rownames = F) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
## Visor |
|
|
## Visor |
|
|