|
@ -61,7 +61,7 @@ samples.exp[is.na(samples.exp)]<-"" |
|
|
## Importar los datos clínicos de pacientes existentes y generar nueva entrada par los nuevos |
|
|
## Importar los datos clínicos de pacientes existentes y generar nueva entrada par los nuevos |
|
|
upd.clinics<-sqlFetch(dta, "CLINICS") |
|
|
upd.clinics<-sqlFetch(dta, "CLINICS") |
|
|
ovid.new<-sqlFetch(dta, "OVID") %>% filter(NHC %in% nhc.test) |
|
|
ovid.new<-sqlFetch(dta, "OVID") %>% filter(NHC %in% nhc.test) |
|
|
upd.clinics<-merge(ovid.new,upd.clinics, all.x=T) |
|
|
|
|
|
|
|
|
upd.clinics<-merge(ovid.new,upd.clinics, all.x=T, by="OVID") |
|
|
upd.clinics$NHC<-as.character(upd.clinics$NHC) |
|
|
upd.clinics$NHC<-as.character(upd.clinics$NHC) |
|
|
for (i in colnames(upd.clinics)[sapply(upd.clinics, lubridate::is.POSIXct)]){upd.clinics[,i]<-as.Date(upd.clinics[,i])} |
|
|
for (i in colnames(upd.clinics)[sapply(upd.clinics, lubridate::is.POSIXct)]){upd.clinics[,i]<-as.Date(upd.clinics[,i])} |
|
|
|
|
|
|
|
@ -79,3 +79,22 @@ rownames(upd.samples)<-(nsamples+1):(nsamples+nrow(upd.samples)) %>% as.characte |
|
|
|
|
|
|
|
|
### !! Atención, esto cambia la base de datos: |
|
|
### !! Atención, esto cambia la base de datos: |
|
|
sqlSave(dta, upd.samples, tablename="SAMPLES", append = T) |
|
|
sqlSave(dta, upd.samples, tablename="SAMPLES", append = T) |
|
|
|
|
|
|
|
|
|
|
|
## Añadir datos clínicos modificados a la base de datos |
|
|
|
|
|
upd.samples<-read.xlsx("QuerySamplesOV.xlsx", sheet = "CLINICS",detectDates = T) |
|
|
|
|
|
ovid.mod<-upd.clinics$OVID[upd.clinics$OVID %in% (sqlFetch(dta, "CLINICS") %>% pull(OVID))] |
|
|
|
|
|
rnames<-sqlFetch(dta, "CLINICS") %>% filter(OVID %in% ovid.mod) %>% rownames |
|
|
|
|
|
clinics.mod<-upd.clinics %>% filter(OVID %in% ovid.mod) %>% select(-NHC) |
|
|
|
|
|
rownames(clinics.mod)<-rnames |
|
|
|
|
|
|
|
|
|
|
|
### !! Atención, esto cambia la base de datos: |
|
|
|
|
|
sqlUpdate(dta, clinics.mod,"CLINICS") |
|
|
|
|
|
|
|
|
|
|
|
## Añadir datos clínicos nuevos a la base de datos |
|
|
|
|
|
nsamples.clin<-sqlFetch(dta, "CLINICS") %>% nrow |
|
|
|
|
|
ovid.new<-upd.clinics$OVID[!upd.clinics$OVID %in% (sqlFetch(dta, "CLINICS") %>% pull(OVID))] |
|
|
|
|
|
clinics.new<-upd.clinics %>% filter(OVID %in% ovid.new) %>% select(-NHC) |
|
|
|
|
|
rownames(clinics.new)<-(nsamples.clin+1):(nsamples.clin+nrow(clinics.new)) %>% as.character |
|
|
|
|
|
|
|
|
|
|
|
### !! Atención, esto cambia la base de datos: |
|
|
|
|
|
sqlSave(dta, clinics.new, tablename="CLINICS", append = T) |