|
@ -27,17 +27,23 @@ sqlBackUp<-function(dbfile=file,bu.dir){ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
sqlShowSamples<-function(conn=dta, nhcs=nhc.test, verb=F, dbtype){ |
|
|
sqlShowSamples<-function(conn=dta, nhcs=nhc.test, verb=F, dbtype){ |
|
|
|
|
|
if (dbtype == "OV"){ |
|
|
|
|
|
db<-c("dbtables"="SAMPLES", "dbcode"="OVID", "dbsamples"="samples") |
|
|
|
|
|
query<-paste0("SELECT O.NHC,S.* FROM ",db["dbtables"]," S INNER JOIN ",db["dbcode"]," O ON O.",db["dbcode"],"=S.",db["dbcode"]) |
|
|
|
|
|
} |
|
|
|
|
|
if (dbtype == "UM"){ |
|
|
|
|
|
db<-c("dbtables"="MUESTRAS", "dbcode"="UMID", "dbsamples"="CODIGO") |
|
|
|
|
|
query<-paste0("SELECT O.NHC,S.* FROM ",db["dbtables"]," S INNER JOIN ",db["dbcode"]," O ON O.",db["dbcode"],"=S.",db["dbcode"]) |
|
|
|
|
|
} |
|
|
|
|
|
if (nrow(sqlQuery(conn, query) %>% filter(NHC %in% nhcs)) == 0){ |
|
|
|
|
|
return("No hay muestras de ningún paciente.") |
|
|
|
|
|
} |
|
|
if (isFALSE(verb)){ |
|
|
if (isFALSE(verb)){ |
|
|
sqlQuery(conn, "SELECT O.NHC,S.* |
|
|
|
|
|
FROM SAMPLES S |
|
|
|
|
|
INNER JOIN OVID O |
|
|
|
|
|
ON O.OVID=S.OVID") %>% filter(NHC %in% nhcs) %>% |
|
|
|
|
|
group_by(NHC,OVID) %>% summarise(Samples=length(samples), Names=paste0(samples, collapse = ";")) %>% merge(data.frame(NHC=nhcs),all=T) |
|
|
|
|
|
|
|
|
sqlQuery(conn, query) %>% filter(NHC %in% nhcs) %>% |
|
|
|
|
|
group_by(NHC,db["dbcode"]) %>% summarise(Samples=length(UQ(rlang::sym(db["dbsamples"]))), Names=paste0(UQ(rlang::sym(db["dbsamples"])), collapse = ";")) %>% |
|
|
|
|
|
merge(data.frame(NHC=nhcs),all=T) %>% rename((!!db["dbcode"]):='db["dbcode"]') |
|
|
}else{ |
|
|
}else{ |
|
|
sqlQuery(conn, "SELECT O.NHC,S.* |
|
|
|
|
|
FROM SAMPLES S |
|
|
|
|
|
INNER JOIN OVID O |
|
|
|
|
|
ON O.OVID=S.OVID") %>% filter(NHC %in% nhcs) |
|
|
|
|
|
|
|
|
sqlQuery(conn, query) %>% filter(NHC %in% nhcs) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|