Browse Source

NHC as a character.

main
marcelcosta 1 year ago
parent
commit
4c27e84cbd
2 changed files with 55 additions and 53 deletions
  1. +49
    -49
      BDAccess/app.R
  2. +6
    -4
      sqlFunctions.R

+ 49
- 49
BDAccess/app.R

@ -299,13 +299,13 @@ server <- function(input, output) {
}
if (input$dbtype == "UM"){
values[["DF"]]<-merge(values[["DF"]], sqlFetch(dta, "UMID"))
values[["DF"]]<-merge(values[["DF"]], sqlFetch(dta, "UMID", as.is=T))
}
if (input$dbtype == "OV"){
values[["DF"]]<-merge(values[["DF"]], sqlFetch(dta, "OVID"))
values[["DF"]]<-merge(values[["DF"]], sqlFetch(dta, "OVID", as.is=T))
}
if (input$dbtype == "CC"){
values[["DF"]]<-merge(values[["DF"]], sqlFetch(dta, "PATID"))
values[["DF"]]<-merge(values[["DF"]], sqlFetch(dta, "PATID", as.is=T))
}
print(values[["DF"]])
})
@ -313,9 +313,9 @@ server <- function(input, output) {
observeEvent(input$filltemplate,{
today=T
if (input$dbtype == "UM"){
upd.umid<-sqlFetch(dta, "UMID") %>% filter(NHC %in% values[["DF"]]$NHC)
upd.umid<-sqlFetch(dta, "UMID", as.is=T) %>% filter(NHC %in% values[["DF"]]$NHC)
## Generar código para las nuevas muestras
samples<-sqlFetch(dta, "MUESTRAS")
samples<-sqlFetch(dta, "MUESTRAS", as.is=T)
if(sum(grepl(paste0("UM",Sys.time() %>% format("%y")), samples$CODIGO)) > 0){
next.samp<-gsub(paste0("UM",Sys.time() %>% format("%y")),"", samples$CODIGO) %>% as.numeric %>% max(na.rm=T)+1
}else{
@ -323,7 +323,7 @@ server <- function(input, output) {
}
last.samp<-next.samp+(length(values[["DF"]]$NHC)-1)
new.samp<-sprintf("UM%s%02d",Sys.time() %>% format("%y"),next.samp:last.samp)
new.samp.df<-data.frame("NHC"=values[["DF"]]$NHC, "CODIGO"=new.samp) %>% merge(sqlFetch(dta,"UMID"), all.x=T) %>% arrange(CODIGO)
new.samp.df<-data.frame("NHC"=values[["DF"]]$NHC, "CODIGO"=new.samp) %>% merge(sqlFetch(dta,"UMID", as.is=T), all.x=T) %>% arrange(CODIGO)
samples.exp<-merge(samples %>% slice(0), new.samp.df %>% select(-NHC), all=T) %>% select(colnames(samples)) %>% arrange(CODIGO)
if (today==TRUE){
samples.exp$FECHA_RECEPCION<-format(Sys.Date(), "%d/%m/%y")
@ -333,30 +333,30 @@ server <- function(input, output) {
if (any(sapply(nhc.table$Samples, function(x) "cnag" %in% strsplit(x,",")[[1]]) == T)){
nhcs.cnag<-nhc.table[sapply(nhc.table$Samples, function(x) "cnag" %in% strsplit(x,",")[[1]]),"NHC"]
umid.cnag<-sqlFetch(dta, "UMID") %>% filter(NHC %in% nhcs.cnag) %>% pull(UMID)
umid.cnag<-sqlFetch(dta, "UMID", as.is=T) %>% filter(NHC %in% nhcs.cnag) %>% pull(UMID)
sample.cnag<-samples.exp %>% filter(UMID %in% umid.cnag) %>% pull(CODIGO)
cnag.exp<-merge(data.frame("UMID"=umid.cnag, "CODIGO"=sample.cnag), sqlFetch(dta, "CNAG") %>% slice(0), all=T)
cnag.exp<-merge(data.frame("UMID"=umid.cnag, "CODIGO"=sample.cnag), sqlFetch(dta, "CNAG", as.is=T) %>% slice(0), all=T)
if (today==TRUE){
cnag.exp$FECHA_ENVIO<-format(Sys.Date(), "%d/%m/%y")
}
}else{
cnag.exp<-sqlFetch(dta, "CNAG") %>% slice(0) %>%
cnag.exp<-sqlFetch(dta, "CNAG", as.is=T) %>% slice(0) %>%
mutate(across(lubridate::is.POSIXct, as.character))
}
if (any(sapply(nhc.table$Samples, function(x) "rna" %in% strsplit(x,",")[[1]]) == T)){
nhcs.rna<-nhc.table[sapply(nhc.table$Samples, function(x) "rna" %in% strsplit(x,",")[[1]]),"NHC"]
umid.rna<-sqlFetch(dta, "UMID") %>% filter(NHC %in% nhcs.rna) %>% pull(UMID)
umid.rna<-sqlFetch(dta, "UMID", as.is=T) %>% filter(NHC %in% nhcs.rna) %>% pull(UMID)
sample.rna<-samples.exp %>% filter(UMID %in% umid.rna) %>% pull(CODIGO)
rna.exp<-merge(data.frame("UMID"=umid.rna, "CODIGO"=sample.rna), sqlFetch(dta, "RNADNA") %>% slice(0)%>%
rna.exp<-merge(data.frame("UMID"=umid.rna, "CODIGO"=sample.rna), sqlFetch(dta, "RNADNA", as.is=T) %>% slice(0)%>%
mutate(across(lubridate::is.POSIXct, as.character)), all=T)
}else{
rna.exp<-sqlFetch(dta, "RNADNA") %>% slice(0) %>%
rna.exp<-sqlFetch(dta, "RNADNA", as.is=T) %>% slice(0) %>%
mutate(across(lubridate::is.POSIXct, as.character))
}
## Importar los datos clínicos de pacientes existentes y generar nueva entrada par los nuevos
upd.clinics<-sqlFetch(dta, "CLINICOS")
umid.new<-sqlFetch(dta, "UMID") %>% filter(NHC %in% values[["DF"]]$NHC)
upd.clinics<-sqlFetch(dta, "CLINICOS", as.is=T)
umid.new<-sqlFetch(dta, "UMID", as.is=T) %>% filter(NHC %in% values[["DF"]]$NHC)
upd.clinics<-merge(umid.new,upd.clinics, all.x=T, by="UMID")
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])}
@ -367,9 +367,9 @@ server <- function(input, output) {
values[["rna"]]<-rna.exp
}
if (input$dbtype == "OV"){
upd.umid<-sqlFetch(dta, "OVID") %>% filter(NHC %in% values[["DF"]]$NHC)
upd.umid<-sqlFetch(dta, "OVID", as.is=T) %>% filter(NHC %in% values[["DF"]]$NHC)
## Generar código para las nuevas muestras
samples<-sqlFetch(dta, "SAMPLES")
samples<-sqlFetch(dta, "SAMPLES", as.is=T)
if(sum(grepl(paste0("OV",Sys.time() %>% format("%y")), samples$samples)) > 0){
next.samp<-gsub(paste0("OV",Sys.time() %>% format("%y")),"", samples$samples) %>% as.numeric %>% max(na.rm=T)+1
}else{
@ -377,7 +377,7 @@ server <- function(input, output) {
}
last.samp<-next.samp+(length(values[["DF"]]$NHC)-1)
new.samp<-sprintf("OV%s%02d",Sys.time() %>% format("%y"),next.samp:last.samp)
new.samp.df<-data.frame("NHC"=values[["DF"]]$NHC, "samples"=new.samp) %>% merge(sqlFetch(dta,"OVID"), all.x=T) %>% arrange(samples)
new.samp.df<-data.frame("NHC"=values[["DF"]]$NHC, "samples"=new.samp) %>% merge(sqlFetch(dta,"OVID", as.is=T), all.x=T) %>% arrange(samples)
samples.exp<-merge(samples %>% slice(0), new.samp.df %>% select(-NHC), all=T) %>% select(colnames(samples)) %>% arrange(samples)
if (today==TRUE){
samples.exp$IQ_date<-format(Sys.Date(), "%d/%m/%y")
@ -386,8 +386,8 @@ server <- function(input, output) {
nhc.table<-values[["DF"]]
## Importar los datos clínicos de pacientes existentes y generar nueva entrada par los nuevos
upd.clinics<-sqlFetch(dta, "CLINICS")
umid.new<-sqlFetch(dta, "OVID") %>% filter(NHC %in% values[["DF"]]$NHC)
upd.clinics<-sqlFetch(dta, "CLINICS", as.is=T)
umid.new<-sqlFetch(dta, "OVID", as.is=T) %>% filter(NHC %in% values[["DF"]]$NHC)
upd.clinics<-merge(umid.new,upd.clinics, all.x=T, by="OVID")
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])}
@ -397,9 +397,9 @@ server <- function(input, output) {
}
if (input$dbtype %in% c("CC")){
upd.umid<-sqlFetch(dta, "PATID") %>% filter(NHC %in% values[["DF"]]$NHC)
upd.umid<-sqlFetch(dta, "PATID", as.is=T) %>% filter(NHC %in% values[["DF"]]$NHC)
## Generar código para las nuevas muestras
samples<-sqlFetch(dta, "MUESTRAS")
samples<-sqlFetch(dta, "MUESTRAS", as.is=T)
if(sum(grepl(paste0(input$dbtype,Sys.time() %>% format("%y")), samples$CODIGO)) > 0){
next.samp<-gsub(paste0(input$dbtype,Sys.time() %>% format("%y")),"", samples$CODIGO) %>% as.numeric %>% max(na.rm=T)+1
}else{
@ -407,7 +407,7 @@ server <- function(input, output) {
}
last.samp<-next.samp+(length(values[["DF"]]$NHC)-1)
new.samp<-sprintf("%s%s%02d",input$dbtype,Sys.time() %>% format("%y"),next.samp:last.samp)
new.samp.df<-data.frame("NHC"=values[["DF"]]$NHC, "CODIGO"=new.samp) %>% merge(sqlFetch(dta,"PATID"), all.x=T) %>% arrange(CODIGO)
new.samp.df<-data.frame("NHC"=values[["DF"]]$NHC, "CODIGO"=new.samp) %>% merge(sqlFetch(dta,"PATID", as.is=T), all.x=T) %>% arrange(CODIGO)
samples.exp<-merge(samples %>% slice(0), new.samp.df %>% select(-NHC), all=T) %>% select(colnames(samples)) %>% arrange(CODIGO)
if (today==TRUE){
samples.exp$FECHA_RECEPCION<-format(Sys.Date(), "%d/%m/%y")
@ -417,30 +417,30 @@ server <- function(input, output) {
if (any(sapply(nhc.table$Samples, function(x) "cnag" %in% strsplit(x,",")[[1]]) == T)){
nhcs.cnag<-nhc.table[sapply(nhc.table$Samples, function(x) "cnag" %in% strsplit(x,",")[[1]]),"NHC"]
umid.cnag<-sqlFetch(dta, "PATID") %>% filter(NHC %in% nhcs.cnag) %>% pull(PATID)
umid.cnag<-sqlFetch(dta, "PATID", as.is=T) %>% filter(NHC %in% nhcs.cnag) %>% pull(PATID)
sample.cnag<-samples.exp %>% filter(PATID %in% umid.cnag) %>% pull(CODIGO)
cnag.exp<-merge(data.frame("PATID"=umid.cnag, "CODIGO"=sample.cnag), sqlFetch(dta, "CNAG") %>% slice(0), all=T)
cnag.exp<-merge(data.frame("PATID"=umid.cnag, "CODIGO"=sample.cnag), sqlFetch(dta, "CNAG", as.is=T) %>% slice(0), all=T)
if (today==TRUE){
cnag.exp$FECHA_ENVIO<-format(Sys.Date(), "%d/%m/%y")
}
}else{
cnag.exp<-sqlFetch(dta, "CNAG") %>% slice(0) %>%
cnag.exp<-sqlFetch(dta, "CNAG", as.is=T) %>% slice(0) %>%
mutate(across(lubridate::is.POSIXct, as.character))
}
if (any(sapply(nhc.table$Samples, function(x) "rna" %in% strsplit(x,",")[[1]]) == T)){
nhcs.rna<-nhc.table[sapply(nhc.table$Samples, function(x) "rna" %in% strsplit(x,",")[[1]]),"NHC"]
umid.rna<-sqlFetch(dta, "PATID") %>% filter(NHC %in% nhcs.rna) %>% pull(PATID)
umid.rna<-sqlFetch(dta, "PATID", as.is=T) %>% filter(NHC %in% nhcs.rna) %>% pull(PATID)
sample.rna<-samples.exp %>% filter(PATID %in% umid.rna) %>% pull(CODIGO)
rna.exp<-merge(data.frame("PATID"=umid.rna, "CODIGO"=sample.rna), sqlFetch(dta, "RNADNA") %>% slice(0)%>%
rna.exp<-merge(data.frame("PATID"=umid.rna, "CODIGO"=sample.rna), sqlFetch(dta, "RNADNA", as.is=T) %>% slice(0)%>%
mutate(across(lubridate::is.POSIXct, as.character)), all=T)
}else{
rna.exp<-sqlFetch(dta, "RNADNA") %>% slice(0) %>%
rna.exp<-sqlFetch(dta, "RNADNA", as.is=T) %>% slice(0) %>%
mutate(across(lubridate::is.POSIXct, as.character))
}
## Importar los datos clínicos de pacientes existentes y generar nueva entrada par los nuevos
upd.clinics<-sqlFetch(dta, "CLINICOS")
umid.new<-sqlFetch(dta, "PATID") %>% filter(NHC %in% values[["DF"]]$NHC)
upd.clinics<-sqlFetch(dta, "CLINICOS", as.is=T)
umid.new<-sqlFetch(dta, "PATID", as.is=T) %>% filter(NHC %in% values[["DF"]]$NHC)
upd.clinics<-merge(umid.new,upd.clinics, all.x=T, by="PATID")
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])}
@ -473,8 +473,8 @@ server <- function(input, output) {
## Entradas modificadas en CLINICOS
upd.clinics<-values[["CLINICS"]]
umid.mod<-upd.clinics$UMID[upd.clinics$UMID %in% (sqlFetch(dta, "CLINICOS") %>% pull(UMID))]
rnames<-sqlFetch(dta, "CLINICOS") %>% filter(UMID %in% umid.mod) %>% rownames
umid.mod<-upd.clinics$UMID[upd.clinics$UMID %in% (sqlFetch(dta, "CLINICOS", as.is=T) %>% pull(UMID))]
rnames<-sqlFetch(dta, "CLINICOS", as.is=T) %>% filter(UMID %in% umid.mod) %>% rownames
clinics.mod<-upd.clinics %>% filter(UMID %in% umid.mod) %>% select(-NHC)
rownames(clinics.mod)<-rnames
@ -487,8 +487,8 @@ server <- function(input, output) {
print("Tabla CLINICOS modificada.")
## Nuevas entradas en CLINICOS
nsamples.clin<-sqlFetch(dta, "CLINICOS") %>% nrow
umid.new<-upd.clinics$UMID[!upd.clinics$UMID %in% (sqlFetch(dta, "CLINICOS") %>% pull(UMID))]
nsamples.clin<-sqlFetch(dta, "CLINICOS", as.is=T) %>% nrow
umid.new<-upd.clinics$UMID[!upd.clinics$UMID %in% (sqlFetch(dta, "CLINICOS", as.is=T) %>% pull(UMID))]
clinics.new<-upd.clinics %>% filter(UMID %in% umid.new) %>% select(-NHC)
if (length(umid.new) > 0){rownames(clinics.new)<-(nsamples.clin+1):(nsamples.clin+nrow(clinics.new)) %>% as.character}
@ -505,7 +505,7 @@ server <- function(input, output) {
## Nuevas entradas en CNAG
if (nrow(values[["cnag"]]) > 0){
cnag.sync<-values[["cnag"]]
fechas<-colnames(cnag.sync)[sqlFetch(dta, "CNAG") %>% sapply(lubridate::is.POSIXct)]
fechas<-colnames(cnag.sync)[sqlFetch(dta, "CNAG", as.is=T) %>% sapply(lubridate::is.POSIXct)]
varTypes<-rep("Date",length(fechas))
names(varTypes)<-fechas
print(fechas)
@ -518,7 +518,7 @@ server <- function(input, output) {
## Nuevas entradas en RNADNA
if (nrow(values[["rna"]]) > 0){
rna.sync<-values[["rna"]]
fechas<-colnames(rna.sync)[sqlFetch(dta, "RNADNA") %>% sapply(lubridate::is.POSIXct)]
fechas<-colnames(rna.sync)[sqlFetch(dta, "RNADNA", as.is=T) %>% sapply(lubridate::is.POSIXct)]
varTypes<-rep("Date",length(fechas))
names(varTypes)<-fechas
for (i in fechas){
@ -534,7 +534,7 @@ server <- function(input, output) {
if (nrow(upd.samples) > 0){rownames(upd.samples)<-(nsamples+1):(nsamples+nrow(upd.samples)) %>% as.character}
if (nrow(upd.samples) > 0){
fechas<-colnames(upd.samples)[sqlFetch(dta, "SAMPLES") %>% sapply(lubridate::is.POSIXct)]
fechas<-colnames(upd.samples)[sqlFetch(dta, "SAMPLES", as.is=T) %>% sapply(lubridate::is.POSIXct)]
for (i in fechas){
upd.samples[,i]<-lubridate::parse_date_time(upd.samples[,i], c("d/m/Y","d/m/y","Y-m-d")) %>% as.Date()
}
@ -549,14 +549,14 @@ server <- function(input, output) {
## Entradas modificadas en CLINICOS
upd.clinics<-values[["CLINICS"]]
umid.mod<-upd.clinics$OVID[upd.clinics$OVID %in% (sqlFetch(dta, "CLINICS") %>% pull(OVID))]
rnames<-sqlFetch(dta, "CLINICS") %>% filter(OVID %in% umid.mod) %>% rownames
umid.mod<-upd.clinics$OVID[upd.clinics$OVID %in% (sqlFetch(dta, "CLINICS", as.is=T) %>% pull(OVID))]
rnames<-sqlFetch(dta, "CLINICS", as.is=T) %>% filter(OVID %in% umid.mod) %>% rownames
clinics.mod<-upd.clinics %>% filter(OVID %in% umid.mod) %>% select(-NHC)
rownames(clinics.mod)<-rnames
### !! Atención, esto cambia la base de datos:
print(clinics.mod)
fechas<-colnames(clinics.mod)[sqlFetch(dta, "CLINICS") %>% sapply(lubridate::is.POSIXct)]
fechas<-colnames(clinics.mod)[sqlFetch(dta, "CLINICS", as.is=T) %>% sapply(lubridate::is.POSIXct)]
for (i in fechas){
clinics.mod[,i]<-lubridate::parse_date_time(clinics.mod[,i], c("d/m/Y","d/m/y","Y-m-d")) %>% as.Date()
}
@ -567,13 +567,13 @@ server <- function(input, output) {
print("Tabla CLINICS modificada.")
## Nuevas entradas en CLINICOS
nsamples.clin<-sqlFetch(dta, "CLINICS") %>% nrow
umid.new<-upd.clinics$OVID[!upd.clinics$OVID %in% (sqlFetch(dta, "CLINICS") %>% pull(OVID))]
nsamples.clin<-sqlFetch(dta, "CLINICS", as.is=T) %>% nrow
umid.new<-upd.clinics$OVID[!upd.clinics$OVID %in% (sqlFetch(dta, "CLINICS", as.is=T) %>% pull(OVID))]
clinics.new<-upd.clinics %>% filter(OVID %in% umid.new) %>% select(-NHC)
if (length(umid.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)[sqlFetch(dta, "CLINICS") %>% sapply(lubridate::is.POSIXct)]
fechas<-colnames(clinics.new)[sqlFetch(dta, "CLINICS", as.is=T) %>% sapply(lubridate::is.POSIXct)]
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()
}
@ -601,8 +601,8 @@ server <- function(input, output) {
## 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
PATID.mod<-upd.clinics$PATID[upd.clinics$PATID %in% (sqlFetch(dta, "CLINICOS", as.is=T) %>% pull(PATID))]
rnames<-sqlFetch(dta, "CLINICOS", as.is=T) %>% filter(PATID %in% PATID.mod) %>% rownames
clinics.mod<-upd.clinics %>% filter(PATID %in% PATID.mod) %>% select(-NHC)
rownames(clinics.mod)<-rnames
@ -615,8 +615,8 @@ server <- function(input, output) {
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))]
nsamples.clin<-sqlFetch(dta, "CLINICOS", as.is=T) %>% nrow
PATID.new<-upd.clinics$PATID[!upd.clinics$PATID %in% (sqlFetch(dta, "CLINICOS", as.is=T) %>% 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}
@ -633,7 +633,7 @@ server <- function(input, output) {
## Nuevas entradas en CNAG
if (nrow(values[["cnag"]]) > 0){
cnag.sync<-values[["cnag"]]
fechas<-colnames(cnag.sync)[sqlFetch(dta, "CNAG") %>% sapply(lubridate::is.POSIXct)]
fechas<-colnames(cnag.sync)[sqlFetch(dta, "CNAG", as.is=T) %>% sapply(lubridate::is.POSIXct)]
varTypes<-rep("Date",length(fechas))
names(varTypes)<-fechas
print(fechas)
@ -646,7 +646,7 @@ server <- function(input, output) {
## Nuevas entradas en RNADNA
if (nrow(values[["rna"]]) > 0){
rna.sync<-values[["rna"]]
fechas<-colnames(rna.sync)[sqlFetch(dta, "RNADNA") %>% sapply(lubridate::is.POSIXct)]
fechas<-colnames(rna.sync)[sqlFetch(dta, "RNADNA", as.is=T) %>% sapply(lubridate::is.POSIXct)]
varTypes<-rep("Date",length(fechas))
names(varTypes)<-fechas
for (i in fechas){

+ 6
- 4
sqlFunctions.R

@ -15,7 +15,7 @@ sqlLastDrop<-function(conn, tablename, droplast=1,dbtype=NULL){
sqlInitialize<-function(ruta="ruta_database.R"){
library(tidyverse)
# library(tidyverse)
library(RODBC)
library(openxlsx)
@ -24,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)
@ -75,7 +77,7 @@ sqlGenOVID<-function(conn=dta, nhcs=nhc.test, verb=T, sinc=F, dbtype=NULL){
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){
@ -91,7 +93,7 @@ sqlGenOVID<-function(conn=dta, nhcs=nhc.test, verb=T, sinc=F, dbtype=NULL){
if(dbtype=="UM"){
dbid<-merge(dbid, newtab, all=T) %>% select(NHC,UMID) %>% arrange(UMID)
# dbid$Id<-as.numeric(rownames(dbid))
dbid$NHC<-as.numeric(dbid$NHC)
# dbid$NHC<-dbid$NHC
}
if (dbtype=="CC"){
dbid<-merge(dbid, newtab, all=T) %>% select(NHC,PATID) %>% arrange(PATID)

Loading…
Cancel
Save