Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
katy-sadowski committed Nov 4, 2023
1 parent eb295b0 commit 5684275
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion R/writeJsonResultsTo.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ writeJsonResultsToTable <- function(connectionDetails,

ParallelLogger::logInfo(sprintf("Writing results to table %s", tableName))

if ("unitConceptId" %in% colnames(df)) {
if ("conceptId" %in% colnames(df)) {
ddl <- SqlRender::loadRenderTranslateSql(
sqlFilename = "result_table_ddl_concept.sql",
packageName = "DataQualityDashboard",
Expand Down
6 changes: 3 additions & 3 deletions inst/sql/sql_server/field_fk_class.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FK_CLASS
Drug era standard concepts, ingredients only
Parameters used in this template:
cdmDatabaseSchema = @cdmDatabaseSchema
schema = @schema
vocabDatabaseSchema = @vocabDatabaseSchema
cdmTableName = @cdmTableName
cdmFieldName = @cdmFieldName
Expand Down Expand Up @@ -32,7 +32,7 @@ FROM (
SELECT
'@cdmTableName.@cdmFieldName' AS violating_field,
cdmTable.*
FROM @cdmDatabaseSchema.@cdmTableName cdmTable
FROM @schema.@cdmTableName cdmTable
LEFT JOIN @vocabDatabaseSchema.concept co
ON cdmTable.@cdmFieldName = co.concept_id
{@cohort & '@runForCohort' == 'Yes'}?{
Expand All @@ -48,7 +48,7 @@ FROM (
(
SELECT
COUNT_BIG(*) AS num_rows
FROM @cdmDatabaseSchema.@cdmTableName cdmTable
FROM @schema.@cdmTableName cdmTable
{@cohort & '@runForCohort' == 'Yes'}?{
JOIN @cohortDatabaseSchema.@cohortTableName c
ON cdmTable.person_id = c.subject_id
Expand Down
6 changes: 3 additions & 3 deletions inst/sql/sql_server/field_fk_domain.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FIELD_FK_DOMAIN
all standard concept ids are part of specified domain
Parameters used in this template:
cdmDatabaseSchema = @cdmDatabaseSchema
schema = @schema
vocabDatabaseSchema = @vocabDatabaseSchema
cdmTableName = @cdmTableName
cdmFieldName = @cdmFieldName
Expand All @@ -32,7 +32,7 @@ FROM (
SELECT
'@cdmTableName.@cdmFieldName' AS violating_field,
cdmTable.*
FROM @cdmDatabaseSchema.@cdmTableName cdmTable
FROM @schema.@cdmTableName cdmTable
LEFT JOIN @vocabDatabaseSchema.concept co
ON cdmTable.@cdmFieldName = co.concept_id
{@cohort & '@runForCohort' == 'Yes'}?{
Expand All @@ -48,7 +48,7 @@ FROM (
(
SELECT
COUNT_BIG(*) AS num_rows
FROM @cdmDatabaseSchema.@cdmTableName cdmTable
FROM @schema.@cdmTableName cdmTable
{@cohort & '@runForCohort' == 'Yes'}?{
JOIN @cohortDatabaseSchema.@cohortTableName c
ON cdmTable.PERSON_ID = c.SUBJECT_ID
Expand Down
10 changes: 5 additions & 5 deletions inst/sql/sql_server/field_plausible_temporal_after.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PLAUSIBLE_TEMPORAL_AFTER
get number of records and the proportion to total number of eligible records with datetimes that do not occur on or after their corresponding datetimes
Parameters used in this template:
cdmDatabaseSchema = @cdmDatabaseSchema
schema = @schema
cdmTableName = @cdmTableName
cdmFieldName = @cdmFieldName
plausibleTemporalAfterTableName = @plausibleTemporalAfterTableName
Expand Down Expand Up @@ -33,9 +33,9 @@ FROM
SELECT
'@cdmTableName.@cdmFieldName' AS violating_field,
cdmTable.*
FROM @cdmDatabaseSchema.@cdmTableName cdmTable
{@cdmDatabaseSchema.@cdmTableName != @cdmDatabaseSchema.@plausibleTemporalAfterTableName}?{
JOIN @cdmDatabaseSchema.@plausibleTemporalAfterTableName plausibleTable ON cdmTable.person_id = plausibleTable.person_id}
FROM @schema.@cdmTableName cdmTable
{@schema.@cdmTableName != @schema.@plausibleTemporalAfterTableName}?{
JOIN @schema.@plausibleTemporalAfterTableName plausibleTable ON cdmTable.person_id = plausibleTable.person_id}
{@cohort & '@runForCohort' == 'Yes'}?{
JOIN @cohortDatabaseSchema.@cohortTableName c ON cdmTable.person_id = c.subject_id
AND c.cohort_definition_id = @cohortDefinitionId
Expand All @@ -55,7 +55,7 @@ FROM
(
SELECT
COUNT_BIG(*) AS num_rows
FROM @cdmDatabaseSchema.@cdmTableName cdmTable
FROM @schema.@cdmTableName cdmTable
{@cohort & '@runForCohort' == 'Yes'}?{
JOIN @cohortDatabaseSchema.@cohortTableName c ON cdmTable.person_id = c.subject_id
AND c.cohort_definition_id = @cohortDefinitionId
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-writeDBResultsTo.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test_that("Write DB results to json", {
connectionDetailsEunomia <- Eunomia::getEunomiaConnectionDetails()
cdmDatabaseSchemaEunomia <- "main"
resultsDatabaseSchemaEunomia <- "main"
writeTableName <- "dqdashboard_results"
writeTableName <- "dqd_db_results"

expect_warning(
results <- DataQualityDashboard::executeDqChecks(
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-writeJsonResultsTo.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ test_that("Write JSON results", {
connectionDetails = connectionDetailsEunomia,
resultsDatabaseSchema = resultsDatabaseSchemaEunomia,
jsonFilePath = jsonPath,
writeTableName = "dqd_results"
writeTableName = "dqd_json_results"
)
connection <- DatabaseConnector::connect(connectionDetailsEunomia)
on.exit(DatabaseConnector::disconnect(connection), add = TRUE)
tableNames <- DatabaseConnector::getTableNames(connection = connection, databaseSchema = resultsDatabaseSchemaEunomia)
expect_true("dqd_results" %in% tolower(tableNames))
DatabaseConnector::renderTranslateExecuteSql(connection, "DROP TABLE @database_schema.dqd_results;", database_schema = resultsDatabaseSchemaEunomia)
expect_true("dqd_json_results" %in% tolower(tableNames))
DatabaseConnector::renderTranslateExecuteSql(connection, "DROP TABLE @database_schema.dqd_json_results;", database_schema = resultsDatabaseSchemaEunomia)
})

0 comments on commit 5684275

Please sign in to comment.