Repository navigation
Make plausibleValueHigh checks deterministic via a futureDate parameter - #695
developer-rpai wants to merge 10 commits into
Conversation
|
Thanks @developer-rpai. Coincidentally I was working on a new check for future dates. The current (mis)use of the That said, I agree we need to have a futureDate parameter, the current definition using the current date is not great. The best date to use for me would be the For the default futureDate, I would suggest to keep it the same (current date) as not to change behaviour too much. Also, setting default to |
|
@MaximMoinat I agree with you re: breaking this out into a new future date check. cdm_source.source_release_date was also my first thought for the default value. Obviously if someone didn't fill this out (another DQD failure), or filled it out wrong, this will cause issues. @developer-rpai thanks so much for the contribution! |
|
Agree, we just need a fallback date if release date is missing. Either we use current date, or don't execute the check and mark as 'NA'. |
|
@MaximMoinat Went with the NA-skip option. Rationale: the entire purpose of #277 is determinism. A current-date fallback would reintroduce exactly the run-to-run variance this PR removes, and without a release date there is no honest definition of "future" — executing the check against an invented date is worse than not running it. What changed in this push:
Caveat: no R toolchain in this environment, so this is a careful manual syntax review only — testthat and R CMD check will need to run on repo CI. |
|
Thanks again @developer-rpai. Overall, I think this is the right logic. Two review notes:
A few notes before merging @katy-sadowski:
|
|
@MaximMoinat Good questions — clarifying both: The
On the pre-merge notes (separate check, NA consolidation, comment cleanup) — those are maintainer-side restructuring calls; I will defer to you and @katy-sadowski on how far to take them before v3. |
|
This makes it clear we need a dedicated check for future dates. Thanks for your analysis. |
…h thresholds (v5.2)
…h thresholds (v5.3)
…h thresholds (v5.4)
…sing (OHDSI#277) Per maintainer feedback: default futureDate is now cdm_source.source_release_date instead of MAX(observation_period_end_date). When the release date is missing/NULL the affected checks are not executed and are marked not-applicable -- never the current date, which would reintroduce the run-to-run variance this PR removes. - R/executeDqChecks.R: .getSourceReleaseDate() replaces .getMaxObservationPeriodEndDate(); NULL release date stays NULL - R/runCheck.R: skip @futureDate checks when futureDate is unavailable; new .recordFutureDateSkipped() flags the row via futureDateSkipped - R/recordResult.R: futureDateSkipped marker column (default FALSE) - R/calculateNotApplicableStatus.R: special NA rule + reason text for skipped future-date checks - tests, NEWS.md, man page updated
…t coverage Upstream added OMOP_CDMv5.5_Field_Level.csv after this branch was created; it still referenced GETDATE() in 56 plausibleValueHigh thresholds. Apply the same GETDATE() -> @futureDate substitution used for v5.2/v5.4 (DATEADD(dd,1,GETDATE()) and YEAR(GETDATE())+1) so v5.5 runs are deterministic too, and include 5.5 in the no-GETDATE() test.
7a7c8ed to
cbba098
Compare
|
Rebased onto latest main, merge conflicts resolved (upstream's CRAN threshold refresh touched the same CSV rows; kept their row content with the @futureDate substitution). Also applied the same substitution to the new OMOP_CDMv5.5 field-level file so v5.5 runs are deterministic as well, and extended the no-GETDATE() test to cover 5.5. |
Fixes #277
Problem
The
plausibleValueHighfield-level checks ("no dates in the future") hard-codeGETDATE()in the control-file thresholds (DATEADD(dd,1,GETDATE()),YEAR(GETDATE())+1). Running the same checks over the same data on different days produces different results, violating the basic expectation that analysis X on data Y is reproducible regardless of run date.What this PR does
futureDateparameter toexecuteDqChecks():YYYY-MM-DD).MAX(observation_period_end_date)queried once from the CDM, so the reference date is inherent in the data and stable across runs.sqlOnlymode with nofutureDate, the legacyGETDATE()behavior is kept (sqlOnly only generates SQL; it never produces results).GETDATE()expressions in the v5.2/v5.3/v5.4 field-level control files (138 thresholds) with an@futureDateplaceholder, resolved in.runCheckbefore SQL rendering.futureDateinman/executeDqChecks.Rd, adds a NEWS.md entry, and adds testthat coverage: placeholder-resolution unit tests plus a guard asserting noplausibleValueHighthreshold referencesGETDATE()anymore.Design notes
future_dateparameter defaulting to a data-inherent date;observation_period_end_dateovercdm_source.source_release_datesince it is the more conservative "future" bound and always present in the CDM).DATEADD(dd,1,CAST(GETDATE() AS DATE))(date-truncated, vs the old datetimeGETDATE()); the check template casts to date for date/datetime fields anyway.Testing
tests/testthat/test-futureDate.R(placeholder resolution + control-file guard).R CMD check.