You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: vignettes/checks/plausibleAfterBirth.Rmd
+1-1
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ output:
20
20
The number and percent of records with a date value in the **cdmFieldName** field of the **cdmTableName** table that occurs prior to birth.
21
21
22
22
## Definition
23
-
This check verifies that events happen after birth. This check is only run on fields where the **PLAUSIBLE_AFTER_BIRTH** parameter is set to **Yes**. The birthdate is taken from the `person` table, either the `birth_datetime` or composed from `year_of_birth`, `month_of_birth`, `day_of_birth` (taking 1st month/1st day if missing).
23
+
This check verifies that events happen after birth. The birthdate is taken from the `person` table, either the `birth_datetime` or composed from `year_of_birth`, `month_of_birth`, `day_of_birth` (taking 1st month/1st day if missing).
24
24
25
25
-*Numerator*: The number of records with a non-null date value that happen prior to birth
26
26
-*Denominator*: The total number of records in the table with a non-null date value
Copy file name to clipboardexpand all lines: vignettes/checks/plausibleStartBeforeEnd.Rmd
+26-11
Original file line number
Diff line number
Diff line change
@@ -14,33 +14,48 @@ output:
14
14
**Context**: Verification\
15
15
**Category**: Plausibility\
16
16
**Subcategory**: Temporal\
17
-
**Severity**:
17
+
**Severity**: CDM convention ⚠\
18
18
19
19
20
20
## Description
21
-
The number and percent of records with a value in the @cdmFieldName field of the @cdmTableName that occurs after the date in the @plausibleStartBeforeEndFieldName.
21
+
The number and percent of records with a value in the **cdmFieldName** field of the **cdmTableName** that occurs after the date in the **plausibleStartBeforeEndFieldName**.
22
22
23
23
24
24
## Definition
25
+
Most tables have a field for the start and a field for the end date for the event. This check verifies that the start date is not after the end date. The start date can be before the end date or equal to the end date. It is applied to the start date field and takes the end date field as a parameter. Both date and datetime fields are checked.
25
26
26
-
-*Numerator*:
27
-
-*Denominator*:
28
-
-*Related CDM Convention(s)*:
29
-
-*CDM Fields/Tables*:
30
-
-*Default Threshold Value*:
27
+
-*Numerator*: The number of records where date in **cdmFieldName** is after the date in **plausibleStartBeforeEndFieldName**.
28
+
-*Denominator*: The total number of records with a non-null start and non-null end date value
29
+
-*Related CDM Convention(s)*: -Not linked to a convention-
30
+
-*CDM Fields/Tables*: This check runs on all date and datetime fields that have a start and end date in the same table. It also runs on the `cdm_source` table, comparing `source_release_date` is before `cdm_release_date`.
31
+
-*Default Threshold Value*: 1% (except for vocabulary and cdm_source tables, where it is 0%)
31
32
32
33
33
34
## User Guidance
34
-
35
+
If the start date is after the end date, it is likely that the data is incorrect or the dates are unreliable.
35
36
36
37
### Violated rows query
37
38
```sql
38
-
39
+
SELECT
40
+
'@cdmTableName.@cdmFieldName'AS violating_field,
41
+
cdmTable.*
42
+
FROM @schema.@cdmTableName cdmTable
43
+
WHERE cdmTable.@cdmFieldName IS NOT NULL
44
+
AND cdmTable.@plausibleStartBeforeEndFieldName IS NOT NULL
45
+
AND cdmTable.@cdmFieldName > cdmTable.@plausibleStartBeforeEndFieldName
39
46
```
40
47
41
-
42
48
### ETL Developers
49
+
There main reason for this check to fail is often that the source data is incorrect. If the end date is derived from other data, the calculation might not take into account some edge cases.
43
50
51
+
Any violating checks should either be removed or corrected. In most cases this can be done by adjusting the end date:
52
+
- With a few exceptions, the end date is not mandatory and can be left empty.
53
+
- If the end date is mandatory (visit_occurrence and drug_exposure), the end date can be set to the start date if the event. Note tha
54
+
- If this check fails for the observation_period, it might signify a bigger underlying issue. Please investigate all records for this person in the CDM and source.
55
+
- If neither the start or end date can be trusted, pleaes remove the record from the CDM.
44
56
45
-
### Data Users
57
+
Make sure to clearly document the choices in your ETL specification.
46
58
59
+
### Data Users
60
+
An start date after the end date gives negative event durations, which might break analyses.
61
+
Especially take note if this check fails for the `observation_period` table. This means that there are persons with negative observation time. If these persons are included in a cohort, it will potentially skew e.g. survival analyses.
0 commit comments