Compare commits
49 Commits
b968de1fb1
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| d3dcbc3d51 | |||
| faffd13524 | |||
| 9f7430a4ae | |||
| 4c27e84cbd | |||
| 560540cf1a | |||
| bd52e8c452 | |||
| 43b807cc63 | |||
| cb38ea347d | |||
| 6671939939 | |||
| a6f0c97d47 | |||
| 56484a5903 | |||
| b5323436ec | |||
| a57fb3aac8 | |||
| dbb8e1ed0d | |||
| e6c2a32ddb | |||
| 51acdd0ece | |||
| dcbf4f8b9d | |||
| 001f64cc76 | |||
| e95caafe28 | |||
| f45ebfd106 | |||
| cb6c739d14 | |||
| 20bf1d2c20 | |||
| a5581182c2 | |||
| ab1684651e | |||
| 67ba4921ca | |||
| db6c07595c | |||
| 35e4d31495 | |||
| 38aa06c4ee | |||
| 38e902cef0 | |||
| 3492b7f7ef | |||
| 44901be490 | |||
| 3c8a69b21c | |||
| 9b8f24ddd8 | |||
| ea45d8c845 | |||
| 134133498b | |||
| c9d09c44a2 | |||
| b12ae3fd5f | |||
| 2909f49eec | |||
| b14fddf8fe | |||
| 5bbd25c64d | |||
| 5ea3b493f4 | |||
| ffdf64d736 | |||
| af5eee3a33 | |||
| 6cdde0282a | |||
| f4c6fae34a | |||
| a8ca15592e | |||
| 022a222ddf | |||
| 5762efa5e4 | |||
| df0e5d4985 |
+1131
-48
File diff suppressed because it is too large
Load Diff
+4
-1
@@ -1 +1,4 @@
|
||||
file<-"C:/Users/47926492N/OneDrive - IDIBELL - Institut d'Investigació Biomèdica de Bellvitge/RATG-PIULATS/OVARIO.accdb"
|
||||
# file<-"C:/Users/47926492N/OneDrive - IDIBELL - Institut d'Investigació Biomèdica de Bellvitge/RATG-PIULATS/MELANOMA UVEAL CIT.accdb"
|
||||
# file<-"C:/Users/47926492N/OneDrive - IDIBELL - Institut d'Investigació Biomèdica de Bellvitge/RATG-PIULATS/OVARIO.accdb"
|
||||
UMfile<-file<-"C:/Users/47926492N/Documents/Test/MELANOMA UVEAL CIT.accdb"
|
||||
OVfile<-file<-"C:/Users/47926492N/Documents/Test/OVARIO.accdb"
|
||||
+23
-10
@@ -13,8 +13,9 @@ sqlLastDrop<-function(conn, tablename, droplast=1,dbtype=NULL){
|
||||
sqlSave(conn, table, tablename = tablename, safer = F)}
|
||||
}
|
||||
|
||||
|
||||
sqlInitialize<-function(ruta="ruta_database.R"){
|
||||
library(tidyverse)
|
||||
# library(tidyverse)
|
||||
library(RODBC)
|
||||
library(openxlsx)
|
||||
|
||||
@@ -23,10 +24,12 @@ sqlInitialize<-function(ruta="ruta_database.R"){
|
||||
}
|
||||
|
||||
sqlBackUp<-function(dbfile=file,conn=dta,bu.dir=NULL){
|
||||
print(dbfile)
|
||||
if(sqlTables(conn) %>% filter(TABLE_NAME == "UMID") %>% nrow > 0){bu.dir<-"BU_UM"}
|
||||
if(sqlTables(conn) %>% filter(TABLE_NAME == "OVID") %>% nrow > 0){bu.dir<-"BU_OVARIO"}
|
||||
|
||||
db=strsplit(dbfile, "/")[[1]]%>% tail(n=1)
|
||||
db=tail(strsplit(dbfile, "/")[[1]], n=1)
|
||||
print(db)
|
||||
bu_path<-gsub(db,bu.dir,dbfile)
|
||||
if (!dir.exists(bu_path)){
|
||||
dir.create(bu_path)
|
||||
@@ -61,29 +64,39 @@ sqlShowSamples<-function(conn=dta, nhcs=nhc.test, verb=F, dbtype=NULL){
|
||||
}
|
||||
|
||||
sqlGenOVID<-function(conn=dta, nhcs=nhc.test, verb=T, sinc=F, dbtype=NULL){
|
||||
if(sqlTables(dta) %>% filter(TABLE_NAME == "UMID") %>% nrow > 0){dbtype<-"UM"}
|
||||
if(sqlTables(dta) %>% filter(TABLE_NAME == "OVID") %>% nrow > 0){dbtype<-"OV"}
|
||||
if(sqlTables(conn) %>% filter(TABLE_NAME == "UMID") %>% nrow > 0){dbtype<-"UM"}
|
||||
if(sqlTables(conn) %>% filter(TABLE_NAME == "OVID") %>% nrow > 0){dbtype<-"OV"}
|
||||
|
||||
if (dbtype == "OV"){
|
||||
db<-c("dbcode"="OVID")
|
||||
db<-c("dbcode"="OVID", "dbpref"="OVID")
|
||||
}
|
||||
if (dbtype == "UM"){
|
||||
db<-c("dbcode"="UMID")
|
||||
db<-c("dbcode"="UMID","dbpref"="UMID")
|
||||
}
|
||||
if (dbtype == "CC"){
|
||||
db<-c("dbcode"="PATID", "dbpref"="CCID")
|
||||
}
|
||||
|
||||
dbid<-sqlFetch(conn,db["dbcode"])
|
||||
|
||||
dbid<-sqlFetch(conn,db["dbcode"], as.is=T)
|
||||
new.nhc<-nhcs[!nhcs %in% dbid$NHC] %>% unique()
|
||||
|
||||
if(length(new.nhc) > 0){
|
||||
next.num<-gsub(db["dbcode"],"",dbid[,db["dbcode"]]) %>% as.numeric %>% max(na.rm=T)+1
|
||||
if (nrow(dbid) == 0){next.num<-1}else{
|
||||
next.num<-gsub(db["dbpref"],"",dbid[,db["dbcode"]]) %>% as.numeric %>% max(na.rm=T)+1
|
||||
}
|
||||
print(next.num)
|
||||
last.num<-next.num+(length(new.nhc)-1)
|
||||
newtab<-data.frame("NHC"=new.nhc, "ID"=sprintf("%s%04d",db["dbcode"],next.num:last.num)) %>% rename(!!db["dbcode"]:="ID")
|
||||
newtab<-data.frame("NHC"=new.nhc, "ID"=sprintf("%s%04d",db["dbpref"],next.num:last.num)) %>% rename(!!db["dbcode"]:="ID")
|
||||
if(dbtype=="OV"){
|
||||
dbid<-rbind(dbid,newtab)
|
||||
}
|
||||
if(dbtype=="UM"){
|
||||
dbid<-merge(dbid, newtab, all=T) %>% select(NHC,UMID) %>% arrange(UMID)
|
||||
# dbid$Id<-as.numeric(rownames(dbid))
|
||||
# dbid$NHC<-dbid$NHC
|
||||
}
|
||||
if (dbtype=="CC"){
|
||||
dbid<-merge(dbid, newtab, all=T) %>% select(NHC,PATID) %>% arrange(PATID)
|
||||
dbid$NHC<-as.numeric(dbid$NHC)
|
||||
}
|
||||
rownames(dbid)<-as.character(1:nrow(dbid))
|
||||
|
||||
Reference in New Issue
Block a user