Skip to content

Service encounter cleanup#904

Merged
bradmontierth merged 20 commits into
mainfrom
service_encounter_cleanup
Jun 11, 2025
Merged

Service encounter cleanup#904
bradmontierth merged 20 commits into
mainfrom
service_encounter_cleanup

Conversation

@bradmontierth

Copy link
Copy Markdown
Collaborator

Describe your changes

Please include a summary of any changes.
-adjusting priority of inpatient service categories so specialty categories like inpatient psych/rehab don't get overwritten by med/surg if DRG is present
-adding new long term care category and encounter
-adding concept of inpatient snf part b to differentiate between snf part a with different service category 3 and flag on the encounter
-some code cleanup and organization

How has this been tested?

Please describe the tests you ran to verify your changes. Provide instructions or code to reproduce output.
-client data with specific claim examples that were flagged as an issue. these were all resolved

Reviewer focus

Please summarize the specific items you’d like the reviewer(s) to look into.

Checklist before requesting a review

  • I have added at least one Github label to this PR (bug, enhancement, breaking change,...)
  • My code follows style guidelines
  • (New models) YAML files are categorized by sub folder and models listed in alphabetical order
  • (New models) I have added a config to each new model to enable it for claims and/or clinical data
  • (New models) I have added the variable tuva_last_run to the final output
  • (Optional) I have recorded a Loom to explain this PR

Package release checklist

  • I have updated dbt docs
  • I have updated the version number in the dbt_project.yml

(Optional) Gif of how this PR makes you feel

Loom link

@github-actions

Copy link
Copy Markdown

SQLFluff Linting Failed

Issues were found that require manual correction or are unfixable by sqlfluff fix.
Please review the output below (or the full logs), fix the issues locally, and commit the changes.

SQLFluff Run Log - Mode: ci, Fix: false, Time: Tue Jun 10 17:34:58 UTC 2025

===== SQLFLUFF LINT (Initial Check) OUTPUT (2025-06-10_17:39:47) (Filtered) =====

=== [dbt templater] Sorting Nodes...
=== [dbt templater] Compiling dbt project...
=== [dbt templater] Project Compiled.
== [models/claims_preprocessing/encounters/intermediate/acute_inpatient/acute_inpatient__prof_claims.sql] FAIL
L:  47 | P:  83 | LT12 | Files must end with a single trailing newline.
                       | [layout.end_of_file]
== [models/claims_preprocessing/encounters/intermediate/encounters__combined_claim_line_crosswalk.sql] FAIL
L: 194 | P:  23 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L: 206 | P:  23 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L: 218 | P:  23 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L: 341 | P:  72 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
== [models/claims_preprocessing/encounters/intermediate/inpatient_hospice/inpatient_hospice__prof_claims.sql] FAIL
L:  47 | P:  83 | LT12 | Files must end with a single trailing newline.
                       | [layout.end_of_file]
== [models/claims_preprocessing/encounters/intermediate/inpatient_psych/inpatient_psych__prof_claims.sql] FAIL
L:  47 | P:  83 | LT12 | Files must end with a single trailing newline.
                       | [layout.end_of_file]
== [models/claims_preprocessing/encounters/intermediate/inpatient_rehab/inpatient_rehab__prof_claims.sql] FAIL
L:  47 | P:  83 | LT12 | Files must end with a single trailing newline.
                       | [layout.end_of_file]
== [models/claims_preprocessing/encounters/intermediate/inpatient_snf/inpatient_snf__prof_claims.sql] FAIL
L:  47 | P:  83 | LT12 | Files must end with a single trailing newline.
                       | [layout.end_of_file]
== [models/claims_preprocessing/encounters/intermediate/inpatient_substance_use/inpatient_substance_use__prof_claims.sql] FAIL
L:  47 | P:  83 | LT12 | Files must end with a single trailing newline.
                       | [layout.end_of_file]
== [models/claims_preprocessing/encounters/staging/encounters__prof_and_lower_priority.sql] FAIL
L:   3 | P:  44 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L:  11 | P:   7 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L:  17 | P:   1 | AM02 | 'UNION [DISTINCT|ALL]' is preferred over just 'UNION'.
                       | [ambiguous.union]
L:  17 | P:   6 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L:  19 | P:   7 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L:  25 | P:  34 | LT01 | Expected single whitespace between comma ',' and quoted
                       | literal. [layout.spacing]
L:  25 | P:  62 | LT01 | Expected single whitespace between comma ',' and quoted
                       | literal. [layout.spacing]
L:  28 | P:  16 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L:  33 | P:   9 | LT12 | Files must end with a single trailing newline.
                       | [layout.end_of_file]
== [models/claims_preprocessing/service_category/final/service_category__service_category_grouper.sql] FAIL
L:  32 | P:  75 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L:  33 | P:   9 | LT01 | Expected only single space before naked identifier.
                       | Found '  '. [layout.spacing]
L:  65 | P:   9 | LT01 | Expected only single space before naked identifier.
                       | Found '  '. [layout.spacing]
L:  98 | P:   9 | LT01 | Expected only single space before naked identifier.
                       | Found '  '. [layout.spacing]
L: 122 | P:  89 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L: 123 | P:  73 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L: 125 | P:  72 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
== [models/claims_preprocessing/service_category/intermediate/service_category__inpatient_skilled_nursing_institutional.sql] FAIL
L:  18 | P:   1 | AM02 | 'UNION [DISTINCT|ALL]' is preferred over just 'UNION'.
                       | [ambiguous.union]
== [models/core/staging/core__stg_claims_encounter.sql] FAIL
L:  66 | P:  36 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  67 | P:  28 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  68 | P:  28 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  69 | P:  34 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  70 | P:  33 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  71 | P:  27 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  72 | P:  33 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  74 | P:  32 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  75 | P:  29 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  76 | P:  35 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
All Finished!

=========================================================================


===== SQLFLUFF FIX (Check, Informational) OUTPUT (2025-06-10_17:45:25) (Filtered) =====

==== finding fixable violations ====
=== [dbt templater] Sorting Nodes...
=== [dbt templater] Compiling dbt project...
=== [dbt templater] Project Compiled.
== [models/claims_preprocessing/encounters/intermediate/acute_inpatient/acute_inpatient__prof_claims.sql] FAIL
L:  47 | P:  83 | LT12 | Files must end with a single trailing newline.
                       | [layout.end_of_file]
== [models/claims_preprocessing/encounters/intermediate/acute_inpatient/acute_inpatient__prof_claims.sql] FIXED
== [models/claims_preprocessing/encounters/intermediate/encounters__combined_claim_line_crosswalk.sql] FAIL
L: 194 | P:  23 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L: 206 | P:  23 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L: 218 | P:  23 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L: 341 | P:  72 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
== [models/claims_preprocessing/encounters/intermediate/encounters__combined_claim_line_crosswalk.sql] FIXED
== [models/claims_preprocessing/encounters/intermediate/inpatient_hospice/inpatient_hospice__prof_claims.sql] FAIL
L:  47 | P:  83 | LT12 | Files must end with a single trailing newline.
                       | [layout.end_of_file]
== [models/claims_preprocessing/encounters/intermediate/inpatient_hospice/inpatient_hospice__prof_claims.sql] FIXED
== [models/claims_preprocessing/encounters/intermediate/inpatient_psych/inpatient_psych__prof_claims.sql] FAIL
L:  47 | P:  83 | LT12 | Files must end with a single trailing newline.
                       | [layout.end_of_file]
== [models/claims_preprocessing/encounters/intermediate/inpatient_psych/inpatient_psych__prof_claims.sql] FIXED
== [models/claims_preprocessing/encounters/intermediate/inpatient_rehab/inpatient_rehab__prof_claims.sql] FAIL
L:  47 | P:  83 | LT12 | Files must end with a single trailing newline.
                       | [layout.end_of_file]
== [models/claims_preprocessing/encounters/intermediate/inpatient_rehab/inpatient_rehab__prof_claims.sql] FIXED
== [models/claims_preprocessing/encounters/intermediate/inpatient_snf/inpatient_snf__prof_claims.sql] FAIL
L:  47 | P:  83 | LT12 | Files must end with a single trailing newline.
                       | [layout.end_of_file]
== [models/claims_preprocessing/encounters/intermediate/inpatient_snf/inpatient_snf__prof_claims.sql] FIXED
== [models/claims_preprocessing/encounters/intermediate/inpatient_substance_use/inpatient_substance_use__prof_claims.sql] FAIL
L:  47 | P:  83 | LT12 | Files must end with a single trailing newline.
                       | [layout.end_of_file]
== [models/claims_preprocessing/encounters/intermediate/inpatient_substance_use/inpatient_substance_use__prof_claims.sql] FIXED
== [models/claims_preprocessing/encounters/staging/encounters__prof_and_lower_priority.sql] FAIL
L:   3 | P:  44 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L:  11 | P:   7 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L:  17 | P:   1 | AM02 | 'UNION [DISTINCT|ALL]' is preferred over just 'UNION'.
                       | [ambiguous.union]
L:  17 | P:   6 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L:  19 | P:   7 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L:  25 | P:  34 | LT01 | Expected single whitespace between comma ',' and quoted
                       | literal. [layout.spacing]
L:  25 | P:  62 | LT01 | Expected single whitespace between comma ',' and quoted
                       | literal. [layout.spacing]
L:  28 | P:  16 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L:  33 | P:   9 | LT12 | Files must end with a single trailing newline.
                       | [layout.end_of_file]
== [models/claims_preprocessing/encounters/staging/encounters__prof_and_lower_priority.sql] FIXED
== [models/claims_preprocessing/service_category/final/service_category__service_category_grouper.sql] FAIL
L:  32 | P:  75 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L:  33 | P:   9 | LT01 | Expected only single space before naked identifier.
                       | Found '  '. [layout.spacing]
L:  65 | P:   9 | LT01 | Expected only single space before naked identifier.
                       | Found '  '. [layout.spacing]
L:  98 | P:   9 | LT01 | Expected only single space before naked identifier.
                       | Found '  '. [layout.spacing]
L: 122 | P:  89 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L: 123 | P:  73 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
L: 125 | P:  72 | LT01 | Unnecessary trailing whitespace. [layout.spacing]
== [models/claims_preprocessing/service_category/final/service_category__service_category_grouper.sql] FIXED
== [models/claims_preprocessing/service_category/intermediate/service_category__inpatient_skilled_nursing_institutional.sql] FAIL
L:  18 | P:   1 | AM02 | 'UNION [DISTINCT|ALL]' is preferred over just 'UNION'.
                       | [ambiguous.union]
== [models/claims_preprocessing/service_category/intermediate/service_category__inpatient_skilled_nursing_institutional.sql] FIXED
== [models/core/staging/core__stg_claims_encounter.sql] FAIL
L:  66 | P:  36 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  67 | P:  28 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  68 | P:  28 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  69 | P:  34 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  70 | P:  33 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  71 | P:  27 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  72 | P:  33 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  74 | P:  32 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  75 | P:  29 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
L:  76 | P:  35 | LT01 | Expected single whitespace between comma ',' and numeric
                       | literal. [layout.spacing]
== [models/core/staging/core__stg_claims_encounter.sql] FIXED
37 fixable linting violations found

=========================================================================

@github-actions

Copy link
Copy Markdown

SQLFluff Linting Failed

Issues were found that require manual correction or are unfixable by sqlfluff fix.
Please review the output below (or the full logs), fix the issues locally, and commit the changes.

SQLFluff Run Log - Mode: ci, Fix: false, Time: Wed Jun 11 14:49:25 UTC 2025

===== SQLFLUFF LINT (Initial Check) OUTPUT (2025-06-11_14:54:12) (Filtered) =====

=== [dbt templater] Sorting Nodes...
=== [dbt templater] Compiling dbt project...
=== [dbt templater] Project Compiled.
== [models/core/final/core__encounter.sql] FAIL
L:  28 | P:   1 | LT12 | Files must end with a single trailing newline.
                       | [layout.end_of_file]
All Finished!

=========================================================================


===== SQLFLUFF FIX (Check, Informational) OUTPUT (2025-06-11_14:59:02) (Filtered) =====

==== finding fixable violations ====
=== [dbt templater] Sorting Nodes...
=== [dbt templater] Compiling dbt project...
=== [dbt templater] Project Compiled.
==== no fixable linting violations found ====
All Finished!
  [1 unfixable linting violations found]

=========================================================================

@chase-jones chase-jones added v0.14.14 enhancement New feature or request labels Jun 11, 2025

@chase-jones chase-jones left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good, left a few comments

Understand it might be necessary in context, but in general would like to avoid distinct unless absolutely needed. Also would like to avoid select X.* and enumerate columns.

Comment thread models/core/final/core__encounter.sql Outdated
bradmontierth and others added 4 commits June 11, 2025 14:01
Co-authored-by: Chase Jones <60072797+chase-jones@users.noreply.github.com>
Co-authored-by: Chase Jones <60072797+chase-jones@users.noreply.github.com>
@chase-jones
chase-jones self-requested a review June 11, 2025 20:49

@chase-jones chase-jones left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@bradmontierth
bradmontierth merged commit dbadae5 into main Jun 11, 2025
9 checks passed
@bradmontierth
bradmontierth deleted the service_encounter_cleanup branch June 11, 2025 21:38
@github-project-automation github-project-automation Bot moved this from 👀 Ready for Review to 🚀 Ready to Release in The Tuva Project Jun 11, 2025
@sarahmcmorgan sarahmcmorgan moved this from 🚀 Ready to Release to ✅ Done in The Tuva Project Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants