Skip to content
Open
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
1 change: 1 addition & 0 deletions integration_tests/models/encounter.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ select {% if target.type == 'fabric' %} top 0 {% else %}{% endif %}
, cast(null as {{ dbt.type_string() }}) as person_id
, cast(null as {{ dbt.type_string() }}) as patient_id
, cast(null as {{ dbt.type_string() }}) as encounter_type
, cast(null as {{ dbt.type_string() }}) as encounter_status
, {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as encounter_start_date
, {{ try_to_cast_date('null', 'YYYY-MM-DD') }} as encounter_end_date
, cast(null as {{ dbt.type_string() }}) as admit_source_code
Expand Down
11 changes: 11 additions & 0 deletions models/core/core_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,17 @@ models:
config:
meta:
data_type: varchar
- name: encounter_status
description: Lifecycle status of the encounter for clinical (EHR-sourced)
encounters, aligned with the FHIR Encounter.status value set, such as
planned, arrived, in-progress, onleave, finished, cancelled, or
entered-in-error. Populated from input_layer__encounter when clinical
data is enabled so downstream analytics can distinguish completed
encounters from in-progress or unsigned documentation. Null for
claims-derived encounters, which have no clinical lifecycle status.
config:
meta:
data_type: varchar
- name: encounter_start_date
description: Date the encounter started. For inpatient and multi-day encounters,
this is the admission or first service date.
Expand Down
1 change: 1 addition & 0 deletions models/core/final/core__encounter.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
, person_id
, encounter_type
, encounter_group
, encounter_status
, encounter_start_date
, encounter_end_date
, length_of_stay
Expand Down
1 change: 1 addition & 0 deletions models/core/staging/core__stg_claims_encounter.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ select
, cast(p.person_id as {{ dbt.type_string() }}) as person_id
, cast(encounter_type as {{ dbt.type_string() }}) as encounter_type
, cast(encounter_group as {{ dbt.type_string() }}) as encounter_group
, cast(null as {{ dbt.type_string() }}) as encounter_status
, {{ try_to_cast_date('encounter_start_date', 'YYYY-MM-DD') }} as encounter_start_date
, coalesce({{ try_to_cast_date('encounter_end_date', 'YYYY-MM-DD') }}, {{ try_to_cast_date('encounter_start_date', 'YYYY-MM-DD') }}) as encounter_end_date
, cast(length_of_stay as {{ dbt.type_int() }}) as length_of_stay
Expand Down
1 change: 1 addition & 0 deletions models/core/staging/core__stg_clinical_encounter.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
, cast(enc.person_id as {{ dbt.type_string() }}) as person_id
, cast(enc.encounter_type as {{ dbt.type_string() }}) as encounter_type
, cast('clinical' as {{ dbt.type_string() }}) as encounter_group
, cast(enc.encounter_status as {{ dbt.type_string() }}) as encounter_status
, enc.normalized_encounter_start_date as encounter_start_date
, enc.normalized_encounter_end_date as encounter_end_date
, cast(
Expand Down
23 changes: 23 additions & 0 deletions models/input_layer/input_layer__encounter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,29 @@ models:
config:
meta:
data_type: varchar
- name: encounter_status
description: >-
Lifecycle status of the encounter as reported by the clinical source system, aligned with the FHIR Encounter.status value set, such as planned, arrived, in-progress, onleave, finished, cancelled, or entered-in-error. Populate this to distinguish completed encounters (for example finished) from encounters that are still in-progress or that represent unsigned or not-yet-completed documentation. Preserve the source status value when available. This lets downstream analytics filter incomplete encounters instead of relying on the connector to drop them from the input layer.
required_for_data_marts: []
tests:
- the_tuva_project.expect_column_to_exist:
config:
severity: warn
enabled: '{{ (var(''enable_input_layer_testing'', true)) | as_bool }}'
tags:
- tuva_dqi_sev_1
- dqi
- the_tuva_project.warn_if_null_percentage_is_100:
description: Percentage of values that are null.
config:
severity: warn
enabled: '{{ var(''enable_input_layer_testing'', true) | as_bool }}'
tags:
- tuva_dqi_sev_5
- dqi
config:
meta:
data_type: varchar
- name: encounter_start_date
description: >-
Date the encounter started, formatted as YYYY-MM-DD. For inpatient and multi-day encounters, this is the admission or first service date.
Expand Down