Skip to content

Commit

Permalink
Rename to person_id_crosswalk and add data types
Browse files Browse the repository at this point in the history
  • Loading branch information
sarah-tuva committed Dec 11, 2024
1 parent 24039c1 commit a312b58
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 52 deletions.
6 changes: 3 additions & 3 deletions models/core/core_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -876,15 +876,15 @@ models:
- name: tuva_last_run
description: '{{ doc("tuva_last_run") }}'

- name: core__patient_crosswalk
- name: core__person_id_crosswalk
description: >
The patient crosswalk table contains all source patient identifiers from
The person id crosswalk table contains all source patient identifiers from
the input layer eligibility (claims) and patient (clinical).
config:
schema: |
{%- if var('tuva_schema_prefix',None) != None -%}{{var('tuva_schema_prefix')}}_core
{% else %}core{%- endif -%}
alias: patient_crosswalk
alias: person_id_crosswalk
tags: core
materialized: table
tests:
Expand Down
49 changes: 0 additions & 49 deletions models/core/final/core__patient_crosswalk.sql

This file was deleted.

49 changes: 49 additions & 0 deletions models/core/final/core__person_id_crosswalk.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{ config(
enabled = var('claims_enabled',var('clinical_enabled',var('tuva_marts_enabled',False)))
| as_bool
)
}}

{% if var('clinical_enabled', var('tuva_marts_enabled',False)) == true and var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}

select distinct
cast(person_id as {{ dbt.type_string() }}) as person_id
, cast(null as {{ dbt.type_string() }}) as patient_id
, cast(member_id as {{ dbt.type_string() }}) as member_id
, cast(payer as {{ dbt.type_string() }}) as payer
, cast({{ quote_column('plan') }} as {{ dbt.type_string() }}) as {{ quote_column('plan') }}
, cast(data_source as {{ dbt.type_string() }}) as data_source
from {{ ref('normalized_input__eligibility')}}
union all
select distinct
cast(person_id as {{ dbt.type_string() }}) as person_id
, cast(patient_id as {{ dbt.type_string() }}) as patient_id
, cast(null as {{ dbt.type_string() }}) as member_id
, cast(null as {{ dbt.type_string() }}) as payer
, cast(null as {{ dbt.type_string() }}) as {{ quote_column('plan') }}
, cast(data_source as {{ dbt.type_string() }}) as data_source
from {{ ref('patient') }}

{% elif var('clinical_enabled', var('tuva_marts_enabled',False)) == true -%}

select distinct
cast(person_id as {{ dbt.type_string() }}) as person_id
, cast(patient_id as {{ dbt.type_string() }}) as patient_id
, cast(null as {{ dbt.type_string() }}) as member_id
, cast(null as {{ dbt.type_string() }}) as payer
, cast(null as {{ dbt.type_string() }}) as {{ quote_column('plan') }}
, cast(data_source as {{ dbt.type_string() }}) as data_source
from {{ ref('patient') }}from {{ ref('patient') }}

{% elif var('claims_enabled', var('tuva_marts_enabled',False)) == true -%}

select distinct
cast(person_id as {{ dbt.type_string() }}) as person_id
, cast(null as {{ dbt.type_string() }}) as patient_id
, cast(member_id as {{ dbt.type_string() }}) as member_id
, cast(payer as {{ dbt.type_string() }}) as payer
, cast({{ quote_column('plan') }} as {{ dbt.type_string() }}) as {{ quote_column('plan') }}
, cast(data_source as {{ dbt.type_string() }}) as data_source
from {{ ref('normalized_input__eligibility') }}

{%- endif %}

0 comments on commit a312b58

Please sign in to comment.