Skip to content

Commit

Permalink
creation of data viz tables
Browse files Browse the repository at this point in the history
  • Loading branch information
J'aime Tue committed Dec 20, 2024
1 parent d701616 commit 5b26814
Show file tree
Hide file tree
Showing 12 changed files with 550 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
with apr_drg as (

select
apr_drg_code
, apr_drg_description
from {{ ref('terminology__apr_drg') }}

)

select *
from apr_drg
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
with calendar as (

select
full_date
, year
, month
, day
, month_name
, day_of_week_number
, day_of_week_name
, week_of_year
, day_of_year
, year_month
, first_day_of_month
, last_day_of_month
, year_month_int
from {{ ref('reference_data__calendar') }}

)

select *
from calendar
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
with condition_group_distinct as (

select distinct
condition_group_1
, condition_group_2
, condition_group_3
from {{ ref('medical_economics__specialty_condition_grouper_medical_claim') }}

),

condition_group_final as (

select
condition_group_1
, condition_group_2
, condition_group_3
, row_number() over (
order by
condition_group_1
, condition_group_2
, condition_group_3
) as condition_group_id
from condition_group_distinct

)

select *
from condition_group_final
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
with hcpcs as (

select
hcpcs_cd as hcpcs_code
, rbcs_family_desc as hcpcs_description
from {{ ref('terminology__hcpcs_to_rbcs') }}

)

select *
from hcpcs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
with ms_drg as (

select
ms_drg_code
, ms_drg_description
from {{ ref('terminology__ms_drg') }}

)

select *
from ms_drg
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
with patient as (

select
person_id
, first_name
, last_name
, sex
, race
, birth_date
, death_date
, address
, city
, state
, zip_code
, county
, latitude
, longitude
, phone
, age
, age_group
, data_source
from {{ ref('core__patient') }}

)

select *
from patient
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
with provider as (

select
npi
, entity_type_description
, primary_specialty_description
, provider_first_name
, provider_last_name
, provider_organization_name
, parent_organization_name
, practice_address_line_1
, practice_address_line_2
, practice_city
, practice_zip_code
, mailing_telephone_number
, location_telephone_number
, official_telephone_number
, last_updated
from {{ ref('terminology__provider') }}

)

select *
from provider
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
with service_category_distinct as (

select distinct
service_category_1
, service_category_2
, service_category_3
from {{ ref('medical_economics__specialty_condition_grouper_medical_claim') }}

),

service_category_final as (

select
service_category_1
, service_category_2
, service_category_3
, row_number() over (
order by
service_category_1
, service_category_2
, service_category_3
) as service_category_id
from service_category_distinct

)

select *
from service_category_final
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
with provider_distinct as (

select distinct
primary_specialty_description as specialty_provider
from {{ ref('terminology__provider') }}

),

provider as (

select
specialty_provider
, row_number() over (
order by specialty_provider
) as specialty_provider_id
from provider_distinct

)

select *
from provider
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
select
aa.person_id
, aa.claim_id
, aa.payer
, aa.claim_start_date
, aa.claim_end_date
, aa.claim_line_number
, cc.service_category_id
, aa.ms_drg_code
, aa.apr_drg_code
, aa.hcpcs_code
, aa.rendering_id
, aa.paid_amount
, aa.allowed_amount
, bb.condition_group_id
, dd.specialty_provider_id
from {{ ref('medical_economics__specialty_condition_grouper_medical_claim') }} aa
left join {{ ref('medical_economics__dim_condition_group') }} bb
on aa.condition_group_1 = bb.condition_group_1
on aa.condition_group_2 = bb.condition_group_2
on aa.condition_group_3 = bb.condition_group_3
left join {{ ref('medical_economics__dim_service_category') }} cc
on aa.service_category_1 = cc.service_category_1
on aa.service_category_2 = cc.service_category_2
on aa.service_category_3 = cc.service_category_3
left join {{ ref('medical_economics__dim_service_category') }} dd
on aa.specialty_provider = dd.specialty_provider
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
select
person_id
, payer
, year_month
, member_month
, payment_risk_score
, risk_adjusted_member_months
from {{ ref('medical_economics__risk_adjusted_member_months') }}
Loading

0 comments on commit 5b26814

Please sign in to comment.