Skip to content

Commit 0c8e4d8

Browse files
Merge pull request #543 from OHDSI/issue-541-docs
Documentation for plausibleBeforeDeath and plausibleStartBeforeEnd
2 parents 540718e + 8efebd4 commit 0c8e4d8

4 files changed

+62
-27
lines changed

vignettes/checkIndex.Rmd

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ above to navigate to the check's documentation page.\
4747
- plausibleDuringLife (PAGE UNDER CONSTRUCTION)
4848
- withinVisitDates (PAGE UNDER CONSTRUCTION)
4949
- [plausibleAfterBirth](checks/plausibleAfterBirth.html)
50-
- plausibleBeforeDeath (PAGE UNDER CONSTRUCTION)
51-
- plausibleStartBeforeEnd (PAGE UNDER CONSTRUCTION)
50+
- [plausibleBeforeDeath](checks/plausibleBeforeDeath.html)
51+
- [plausibleStartBeforeEnd](checks/plausibleStartBeforeEnd.html)
5252
- plausibleGender (PAGE UNDER CONSTRUCTION)
5353
- plausibleUnitConceptIds (PAGE UNDER CONSTRUCTION)

vignettes/checks/plausibleAfterBirth.Rmd

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ output:
1818

1919
## Description
2020
The number and percent of records with a date value in the **cdmFieldName** field of the **cdmTableName** table that occurs prior to birth.
21+
Note that this check replaces the previous `plausibleTemporalAfter` check.
2122

2223
## 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).
24+
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).
2425

2526
- *Numerator*: The number of records with a non-null date value that happen prior to birth
2627
- *Denominator*: The total number of records in the table with a non-null date value
+27-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "plausibleBeforeDeath"
3-
author: ""
3+
author: "Maxim Moinat"
44
date: "`r Sys.Date()`"
55
output:
66
html_document:
@@ -14,33 +14,48 @@ output:
1414
**Context**: Verification\
1515
**Category**: Plausibility\
1616
**Subcategory**: Temporal\
17-
**Severity**:
17+
**Severity**: Characterization ✔
1818

1919

2020
## Description
21-
The number and percent of records with a date value in the @cdmFieldName field of the @cdmTableName table that occurs after death.
21+
The number and percent of records with a date value in the **cdmFieldName** field of the **cdmTableName** table that occurs more than 60 days after death.
22+
Note that this check replaces the previous `plausibleDuringLife` check.
2223

2324

2425
## Definition
26+
A record violates this check if the date is more than 60 days after the death date of the person, allowing administrative records directly after death.
2527

26-
- *Numerator*:
27-
- *Denominator*:
28-
- *Related CDM Convention(s)*:
29-
- *CDM Fields/Tables*:
30-
- *Default Threshold Value*:
28+
- *Numerator*: The number of records where date in **cdmFieldName** is more than 60 days after the persons' death date.
29+
- *Denominator*: Total number of records of persons with a death date, in the **cdmTableName**.
30+
- *Related CDM Convention(s)*: -Not linked to a convention-
31+
- *CDM Fields/Tables*: This check runs on all date and datetime fields.
32+
- *Default Threshold Value*: 1%
3133

3234

3335
## User Guidance
34-
36+
Events are expected to occur between birth and death. The check `plausibleAfterbirth` checks for the former, this check for the latter.
37+
The 60-day period is a conservative estimate of the time it takes for administrative records to be updated after a person's death.
38+
By default, both start and end dates are checked.
3539

3640
### Violated rows query
3741
```sql
38-
42+
SELECT
43+
'@cdmTableName.@cdmFieldName' AS violating_field,
44+
cdmTable.*
45+
FROM @cdmDatabaseSchema.@cdmTableName cdmTable
46+
JOIN @cdmDatabaseSchema.death de
47+
ON cdmTable.person_id = de.person_id
48+
WHERE cdmTable.@cdmFieldName IS NOT NULL
49+
AND CAST(cdmTable.@cdmFieldName AS DATE) > DATEADD(day, 60, de.death_date)
3950
```
4051

41-
4252
### ETL Developers
53+
Start dates after death are likely to be source data issues, and failing this check should trigger investigation of the source data quality.
54+
End dates after death can occur due to derivation logic. For example, a drug exposure can be prescribed as being continued long after death.
55+
In such cases, it is recommended to update the logic to end the prescription at death.
4356

4457

4558
### Data Users
46-
59+
For most studies, a low number of violating records will have limited impact on data use as it could be caused by lagging administrative records.
60+
However, it might signify a larger data quality issue.
61+
Note that the percentage violating records reported is among records from death persons and such might be slightly inflated if comparing to the overall population.
+31-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "plausibleStartBeforeEnd"
3-
author: ""
3+
author: "Maxim Moinat"
44
date: "`r Sys.Date()`"
55
output:
66
html_document:
@@ -14,33 +14,52 @@ output:
1414
**Context**: Verification\
1515
**Category**: Plausibility\
1616
**Subcategory**: Temporal\
17-
**Severity**:
17+
**Severity**: CDM convention ⚠\
1818

1919

2020
## 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+
Note that this check replaces the previous `plausibleTemporalAfter` check.
2223

2324

2425
## Definition
26+
This check is attempting to apply temporal rules within a table, specifically checking that all start dates are before the end dates. For example, in the VISIT_OCCURRENCE table it checks that the VISIT_OCCURRENCE_START_DATE is before VISIT_OCCURRENCE_END_DATE.
27+
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.
2528

26-
- *Numerator*:
27-
- *Denominator*:
28-
- *Related CDM Convention(s)*:
29-
- *CDM Fields/Tables*:
30-
- *Default Threshold Value*:
29+
- *Numerator*: The number of records where date in **cdmFieldName** is after the date in **plausibleStartBeforeEndFieldName**.
30+
- *Denominator*: The total number of records with a non-null start and non-null end date value
31+
- *Related CDM Convention(s)*: -Not linked to a convention-
32+
- *CDM Fields/Tables*: This check runs on all start date/datetime fields with an end date/datetime in the same table. It also runs on the cdm_source table, comparing `source_release_date` is before `cdm_release_date`.
33+
- *Default Threshold Value*:
34+
- 0% for the observation_period, vocabulary (valid_start/end_date) and cdm_source tables.
35+
- 1% for other tables with an end date.
3136

3237

3338
## User Guidance
34-
39+
If the start date is after the end date, it is likely that the data is incorrect or the dates are unreliable.
3540

3641
### Violated rows query
3742
```sql
38-
43+
SELECT
44+
'@cdmTableName.@cdmFieldName' AS violating_field,
45+
cdmTable.*
46+
FROM @schema.@cdmTableName cdmTable
47+
WHERE cdmTable.@cdmFieldName IS NOT NULL
48+
AND cdmTable.@plausibleStartBeforeEndFieldName IS NOT NULL
49+
AND cdmTable.@cdmFieldName > cdmTable.@plausibleStartBeforeEndFieldName
3950
```
4051

41-
4252
### ETL Developers
53+
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.
4354

55+
Any violating checks should either be removed or corrected. In most cases this can be done by adjusting the end date:
56+
- With a few exceptions, the end date is not mandatory and can be left empty.
57+
- If the end date is mandatory (notably visit_occurrence and drug_exposure), the end date can be set to the start date if the event. Make sure to document this as it leads to loss of duration information.
58+
- 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.
59+
- If neither the start or end date can be trusted, pleaes remove the record from the CDM.
4460

45-
### Data Users
61+
Make sure to clearly document the choices in your ETL specification.
4662

63+
### Data Users
64+
An start date after the end date gives negative event durations, which might break analyses.
65+
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

Comments
 (0)