Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add observation suspecting logic for HCC 48 - Morbid Obesity #429

Merged
merged 9 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'the_tuva_project'
version: '0.7.14'
version: '0.7.15'
config-version: 2
require-dbt-version: ">=1.3.0"

Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/manifest.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/run_results.json

Large diffs are not rendered by default.

36 changes: 34 additions & 2 deletions models/hcc_suspecting/final/hcc_suspecting__list.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ with hcc_history_suspects as (
end as contributing_factor
, coalesce(last_billed, last_recorded) as condition_date
from {{ ref('hcc_suspecting__int_patient_hcc_history') }}
where current_year_billed = false
where (current_year_billed = false
or current_year_billed is null)

)

Expand Down Expand Up @@ -47,7 +48,36 @@ with hcc_history_suspects as (
as contributing_factor
, condition_1_recorded_date as condition_date
from {{ ref('hcc_suspecting__int_comorbidity_suspects') }}
where current_year_billed = false
where (current_year_billed = false
or current_year_billed is null)

)

, observation_suspects as (

select distinct
patient_id
, data_source
, hcc_code
, hcc_description
, cast('Observation suspect' as {{ dbt.type_string() }}) as reason
, 'BMI result '
|| cast(observation_result as {{ dbt.type_string() }})
|| case
when condition_code is null then ''
else ' with '
|| condition_concept_name
|| ' ('
|| condition_code
|| ' on '
|| condition_date
|| ')'
end
as contributing_factor
, observation_date as condition_date
from {{ ref('hcc_suspecting__int_observation_suspects') }}
where (current_year_billed = false
or current_year_billed is null)

)

Expand All @@ -56,6 +86,8 @@ with hcc_history_suspects as (
select * from hcc_history_suspects
union all
select * from comorbidity_suspects
union all
select * from observation_suspects

)

Expand Down
74 changes: 67 additions & 7 deletions models/hcc_suspecting/hcc_suspecting_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ models:
alias: _int_comorbidity_suspects
tags: hcc_suspecting
materialized: table
description: Comorbidity suspecting conditions.
description: Suspecting comorbidities.
columns:
- name: patient_id
description: Unique ID for the patient.
Expand All @@ -148,16 +148,61 @@ models:
- name: hcc_description
description: >
HCC description from the latest CMS HCC model available in the mart.
- name: reason
description: Standardized reason for the suspecting condition.
- name: contributing_factor
- name: condition_1_concept_name
description: Clinical concept name for the first comorbid condition.
- name: condition_1_code
description: Condition code for the first comorbid condition.
- name: condition_1_recorded_date
description: Recorded date for the first comorbid condition.
- name: condition_2_concept_name
description: Clinical concept name for the second comorbid condition.
- name: condition_2_code
description: Condition code for the second comorbid condition.
- name: condition_2_recorded_date
description: Recorded date for the second comorbid condition.
- name: current_year_billed
description: >
Description of the contributing factor(s) for the suspecting condition.
Flag indicating that the HCC has been billed during the payment year.
- name: tuva_last_run
description: The date the model was run.

- name: hcc_suspecting__int_observation_suspects
config:
schema: |
{%- if var('tuva_schema_prefix',None) != None -%}{{var('tuva_schema_prefix')}}_hcc_suspecting{% else %}hcc_suspecting{%- endif -%}
alias: _int_observation_suspects
tags: hcc_suspecting
materialized: table
description: Suspecting observation conditions.
columns:
- name: patient_id
description: Unique ID for the patient.
- name: data_source
description: >
User-configured field that indicates the data source (e.g. typically
named after the payer and state "BCBS Tennessee").
- name: observation_date
description: Date the observation was recorded.
- name: observation_result
description: The result of the observation.
- name: condition_code
description: The code for the comorbid condition.
- name: condition_date
description: Date when the condition was recorded or billed.
description: Recorded date for the condition.
- name: condition_concept_name
description: Clinical concept name for the comorbid condition.
- name: hcc_code
description: >
HCC code from the latest CMS HCC model available in the mart.
meta:
terminology: https://github.com/tuva-health/tuva/blob/main/seeds/value_sets/hcc_suspecting/hcc_suspecting__hcc_descriptions.csv
- name: hcc_description
description: >
HCC description from the latest CMS HCC model available in the mart.
- name: current_year_billed
description: >
Flag indicating that the HCC has been billed during the payment year.
Flag indicating that the ICD-10-CM code mapped to the HCC has been
billed during the payment year.
- name: tuva_last_run
description: The date the model was run.

Expand Down Expand Up @@ -251,6 +296,21 @@ models:
- name: code_type
- name: code

- name: hcc_suspecting__stg_core__observation
config:
schema: |
{%- if var('tuva_schema_prefix',None) != None -%}{{var('tuva_schema_prefix')}}_hcc_suspecting{% else %}hcc_suspecting{%- endif -%}
alias: _stg_observation
tags: hcc_suspecting
materialized: ephemeral
description: Staging observations from core.
columns:
- name: patient_id
- name: observation_date
- name: result
- name: code_type
- name: code

- name: hcc_suspecting__stg_core__patient
config:
schema: |
Expand Down
Loading
Loading