Skip to content

Commit

Permalink
violating field should be non-null
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximMoinat committed Dec 28, 2023
1 parent 1d33ed5 commit 72b2f5b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions R/executeDqChecks.R
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,11 @@ executeDqChecks <- function(connectionDetails,
}

if ("plausibleDuringLife" %in% checkDescriptionsDf$checkName) {
ParallelLogger::logWarn("DEPRECATION WARNING - The plausibleDuringLife check has been reimplemented with the plausibleBeforeDeath check.")
warning("DEPRECATION WARNING - The plausibleDuringLife check has been reimplemented with the plausibleBeforeDeath check.")
}

if ("plausibleTemporalAfter" %in% checkDescriptionsDf$checkName) {
ParallelLogger::logWarn("DEPRECATION WARNING - The plausibleTemporalAfter check has been reimplemented with the plausibleAfterBirth and plausibleStartBeforeEnd checks.")
warning("DEPRECATION WARNING - The plausibleTemporalAfter check has been reimplemented with the plausibleAfterBirth and plausibleStartBeforeEnd checks.")
}

checkDescriptions <- split(checkDescriptionsDf, seq_len(nrow(checkDescriptionsDf)))
Expand Down
4 changes: 3 additions & 1 deletion inst/sql/sql_server/field_plausible_after_birth.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ FROM
AND c.COHORT_DEFINITION_ID = @cohortDefinitionId
}
JOIN @cdmDatabaseSchema.person p ON cdmTable.person_id = p.person_id
WHERE CAST(cdmTable.@cdmFieldName AS DATE) < COALESCE(
WHERE cdmTable.@cdmFieldName IS NOT NULL AND
CAST(cdmTable.@cdmFieldName AS DATE) < COALESCE(
p.birth_datetime,
CAST(CONCAT(
p.year_of_birth,
Expand All @@ -64,5 +65,6 @@ FROM
JOIN @cohortDatabaseSchema.@cohortTableName c ON cdmTable.person_id = c.subject_id
AND c.cohort_definition_id = @cohortDefinitionId
}
WHERE cdmTable.@cdmFieldName IS NOT NULL
) denominator
;
6 changes: 4 additions & 2 deletions inst/sql/sql_server/field_plausible_before_death.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/*********
PLAUSIBLE_BEFORE_DEATH
all events occur after death (PLAUSIBLE_BEFORE_DEATH == Yes)
Chedcks for events that occur more than 60 days after death (PLAUSIBLE_BEFORE_DEATH == Yes).
Denominator is number of events of persons who died.
Parameters used in this template:
Expand Down Expand Up @@ -39,7 +39,8 @@ FROM
AND c.COHORT_DEFINITION_ID = @cohortDefinitionId
}
JOIN @cdmDatabaseSchema.death de ON cdmTable.person_id = de.person_id
WHERE cast(cdmTable.@cdmFieldName AS DATE) > DATEADD(day, 60, cast(de.death_date AS DATE))
WHERE cdmTable.@cdmFieldName IS NOT NULL AND
CAST(cdmTable.@cdmFieldName AS DATE) > DATEADD(day, 60, de.death_date)
/*violatedRowsEnd*/
) violated_rows
) violated_row_count,
Expand All @@ -53,5 +54,6 @@ FROM
}
JOIN @cdmDatabaseSchema.death
ON death.person_id = cdmTable.person_id
WHERE cdmTable.@cdmFieldName IS NOT NULL
) denominator
;
11 changes: 9 additions & 2 deletions inst/sql/sql_server/field_plausible_start_before_end.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

/*********
PLAUSIBLE_START_BEFORE_END
all start dates are before their corresponding end dates (PLAUSIBLE_START_BEFORE_END == Yes)
all start dates are before their corresponding end dates (PLAUSIBLE_START_BEFORE_END == Yes).
@cdmFieldName is the start date and @plausibleStartBeforeEndFieldName is the end date.
Parameters used in this template:
schema = @schema
Expand Down Expand Up @@ -38,7 +39,10 @@ FROM
JOIN @cohortDatabaseSchema.@cohortTableName c ON cdmTable.person_id = c.subject_id
AND c.cohort_definition_id = @cohortDefinitionId
}
WHERE CAST(cdmTable.@cdmFieldName AS DATE) > CAST(cdmTable.@plausibleStartBeforeEndFieldName AS DATE)
WHERE
cdmTable.@cdmFieldName IS NOT NULL AND
cdmTable.@plausibleStartBeforeEndFieldName IS NOT NULL AND
CAST(cdmTable.@cdmFieldName AS DATE) > CAST(cdmTable.@plausibleStartBeforeEndFieldName AS DATE)
/*violatedRowsEnd*/
) violated_rows
) violated_row_count,
Expand All @@ -50,5 +54,8 @@ FROM
JOIN @cohortDatabaseSchema.@cohortTableName c ON cdmTable.person_id = c.subject_id
AND c.cohort_definition_id = @cohortDefinitionId
}
WHERE
cdmTable.@cdmFieldName IS NOT NULL AND
cdmTable.@plausibleStartBeforeEndFieldName IS NOT NULL
) denominator
;

0 comments on commit 72b2f5b

Please sign in to comment.