Skip to content

Commit

Permalink
Merge pull request #79 from OHDSI/lawrenceadams-use-datediff-over-ext…
Browse files Browse the repository at this point in the history
…ract
  • Loading branch information
lawrenceadams authored Oct 7, 2024
2 parents 692c670 + 2536f28 commit 415130d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions models/omop/drug_era.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ WITH ctePreDrugTarget AS (
, COALESCE(
NULLIF(drug_exposure_end_date, NULL)
, NULLIF(
drug_exposure_start_date + days_supply * INTERVAL '1 day'
{{ dbt.dateadd("day", "days_supply", "drug_exposure_start_date") }}
, drug_exposure_start_date
)
, drug_exposure_start_date + INTERVAL '1 day'
, {{ dbt.dateadd("day", 1, "drug_exposure_start_date") }}
) AS drug_exposure_end_date
FROM {{ ref ('drug_exposure') }} AS d
INNER JOIN {{ ref ('stg_vocabulary__concept_ancestor') }} AS ca
Expand Down Expand Up @@ -122,9 +122,7 @@ WITH ctePreDrugTarget AS (
, drug_sub_exposure_start_date
, drug_sub_exposure_end_date
, drug_exposure_count
, EXTRACT(
DAY FROM drug_sub_exposure_end_date - drug_sub_exposure_start_date
) AS days_exposed
, {{ dbt.datediff("drug_sub_exposure_start_date", "drug_sub_exposure_end_date", "day") }} AS days_exposed
FROM cteSubExposures
)

Expand Down

0 comments on commit 415130d

Please sign in to comment.