Skip to content

Commit d6e0753

Browse files
committed
check if concept counts table exists
1 parent 2aaa96d commit d6e0753

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

R/executeDiagnostics.R

+25-28
Original file line numberDiff line numberDiff line change
@@ -671,30 +671,31 @@ executeDiagnostics <- function(cohortDefinitionSet,
671671
name = conceptCountsTable,
672672
databaseSchema = cdmDatabaseSchema)
673673

674-
675-
if (substr(conceptCountsTable, 1, 1) == "#") {
676-
conceptCountsTableIsTemp <- TRUE
677-
} else {
678-
conceptCountsTableIsTemp <- FALSE
679-
conceptCountsTable <- conceptCountsTable
680-
dataSourceInfo <- getCdmDataSourceInformation(connection = connection,
681-
cdmDatabaseSchema = cdmDatabaseSchema)
682-
vocabVersion <- dataSourceInfo$vocabularyVersion
683-
vocabVersionExternalConceptCountsTable <- renderTranslateQuerySql(
684-
connection = connection,
685-
sql = "SELECT DISTINCT vocabulary_version FROM @work_database_schema.@concept_counts_table;",
686-
work_database_schema = cohortDatabaseSchema,
687-
concept_counts_table = conceptCountsTable,
688-
snakeCaseToCamelCase = TRUE,
689-
tempEmulationSchema = getOption("sqlRenderTempEmulationSchena")
690-
)
691-
if (!identical(vocabVersion, vocabVersionExternalConceptCountsTable[1,1])) {
692-
stop(paste0("External concept counts table (",
693-
vocabVersionExternalConceptCountsTable,
694-
") does not match database (",
695-
vocabVersion,
696-
"). Update concept_counts with createConceptCountsTable()"))
697-
}
674+
if (checkConceptCountsTableExists) {
675+
if (substr(conceptCountsTable, 1, 1) == "#") {
676+
conceptCountsTableIsTemp <- TRUE
677+
} else {
678+
conceptCountsTableIsTemp <- FALSE
679+
conceptCountsTable <- conceptCountsTable
680+
dataSourceInfo <- getCdmDataSourceInformation(connection = connection,
681+
cdmDatabaseSchema = cdmDatabaseSchema)
682+
vocabVersion <- dataSourceInfo$vocabularyVersion
683+
vocabVersionExternalConceptCountsTable <- renderTranslateQuerySql(
684+
connection = connection,
685+
sql = "SELECT DISTINCT vocabulary_version FROM @work_database_schema.@concept_counts_table;",
686+
work_database_schema = cohortDatabaseSchema,
687+
concept_counts_table = conceptCountsTable,
688+
snakeCaseToCamelCase = TRUE,
689+
tempEmulationSchema = getOption("sqlRenderTempEmulationSchena")
690+
)
691+
if (!identical(vocabVersion, vocabVersionExternalConceptCountsTable[1,1])) {
692+
stop(paste0("External concept counts table (",
693+
vocabVersionExternalConceptCountsTable,
694+
") does not match database (",
695+
vocabVersion,
696+
"). Update concept_counts with createConceptCountsTable()"))
697+
}
698+
}
698699
}
699700

700701
# Always export concept sets to csv
@@ -720,9 +721,6 @@ executeDiagnostics <- function(cohortDefinitionSet,
720721
vocabularyDatabaseSchema = vocabularyDatabaseSchema,
721722
databaseId = databaseId,
722723
cohorts = cohortDefinitionSet,
723-
runIncludedSourceConcepts = runIncludedSourceConcepts,
724-
runOrphanConcepts = runOrphanConcepts,
725-
runBreakdownIndexEvents = runBreakdownIndexEvents,
726724
exportFolder = exportFolder,
727725
minCellCount = minCellCount,
728726
conceptCountsDatabaseSchema = NULL,
@@ -734,7 +732,6 @@ executeDiagnostics <- function(cohortDefinitionSet,
734732
incremental = incremental,
735733
conceptIdTable = "#concept_ids",
736734
recordKeepingFile = recordKeepingFile,
737-
useAchilles = useAchilles,
738735
resultsDatabaseSchema = resultsDatabaseSchema
739736
)
740737
}

0 commit comments

Comments
 (0)