Skip to content

Commit

Permalink
Merge pull request #361 from coderxio/jrlegrand/atcprod-update
Browse files Browse the repository at this point in the history
  • Loading branch information
jrlegrand authored Feb 4, 2025
2 parents 7d0b93c + 8fee5c3 commit c525c10
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- atc_codes_to_rxnorm_products

with atc_codes_to_rxnorm_product_rxcuis as (
with rxclass_atcprod as (

select * from {{ ref('stg_rxclass__atc_codes_to_rxnorm_product_rxcuis') }}
select * from {{ ref('stg_rxclass__atcprod') }}

)

Expand All @@ -19,7 +19,7 @@ with atc_codes_to_rxnorm_product_rxcuis as (
)

select distinct
atc_codes_to_rxnorm_product_rxcuis.rxcui
rxclass_atcprod.rxcui
, rxnorm_product_rxcuis.str as rxnorm_description
, atc_codes.atc_1_code
, atc_codes.atc_2_code
Expand All @@ -29,9 +29,9 @@ select distinct
, atc_codes.atc_2_name
, atc_codes.atc_3_name
, atc_codes.atc_4_name
from atc_codes_to_rxnorm_product_rxcuis
from rxclass_atcprod
left join atc_codes
on atc_codes.atc_4_code = atc_codes_to_rxnorm_product_rxcuis.class_id
on atc_codes.atc_4_code = rxclass_atcprod.class_id
left join rxnorm_product_rxcuis
on rxnorm_product_rxcuis.rxcui = atc_codes_to_rxnorm_product_rxcuis.rxcui
on rxnorm_product_rxcuis.rxcui = rxclass_atcprod.rxcui
order by rxcui
10 changes: 8 additions & 2 deletions dbt/sagerx/models/staging/rxclass/_rxclass__sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ version: 2
sources:
- name: rxclass
description: |
A product-level mapping of RxNorm to ATC1-4 classes.
This data source represents all of RxClass.
Below are descriptions of a select few of the RxClass sources.
## ATCPROD
> A product-level mapping of RxNorm to ATC1-4 classes.
RxClass has added RxNorm product-level mapping for ATC. The product-level mapping is now the default source mapping for the ATC classes in the RxClass browser.
Expand All @@ -17,4 +23,4 @@ sources:
The original ingredient-level mapping to ATC from the WHO Collaborating Centre for Drug Statistics Methodology remains available in RxClass (select ATC under Edit Drug Sources) and through the RxClass API (relaSource=ATC).
schema: sagerx_lake
tables:
- name: rxclass_atc_to_product
- name: rxclass

This file was deleted.

14 changes: 14 additions & 0 deletions dbt/sagerx/models/staging/rxclass/stg_rxclass__atcprod.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- stg_rxclass__atcprod.sql

with atcprod as (

select
*
from {{ source('rxclass', 'rxclass') }}
where rela_source = 'ATCPROD'

)

select
*
from atcprod

0 comments on commit c525c10

Please sign in to comment.