update notebook to use staging steps instead of SQL hack
Remove the inline core.medical_claim → core.condition SQL JOIN from load() — the pipeline's _stg_medical_claim and _stg_medical_claim_condition steps handle diagnosis code enrichment now. Add staging steps to the UAMCC pipeline execution and walkthrough sections.
This commit is contained in:
@@ -138,6 +138,8 @@ def _(ex, inspect, mo):
|
||||
@app.cell(hide_code=True)
|
||||
def _(ex, fn_doc, mo):
|
||||
_uamcc_steps = [
|
||||
("0a. Stage Medical Claims", ex.stg_medical_claim),
|
||||
("0b. Stage Claim–Condition Pairs", ex.stg_medical_claim_condition),
|
||||
("1. Performance Period", ex.uamcc_performance_period),
|
||||
("2. MCC Cohort Identification", ex.uamcc_int_mcc_cohort),
|
||||
("3. Denominator", ex.uamcc_int_denominator),
|
||||
@@ -657,18 +659,6 @@ def _(con, inspect, mo, pl):
|
||||
|
||||
def load(table_ref):
|
||||
"""Load a table from DuckDB, with fallbacks for missing tables."""
|
||||
# Enrich core.medical_claim with diagnosis codes from core.condition
|
||||
if table_ref == "core.medical_claim":
|
||||
return con.execute("""
|
||||
SELECT m.*,
|
||||
c.normalized_code,
|
||||
c.normalized_code AS principal_diagnosis_code
|
||||
FROM core.medical_claim m
|
||||
LEFT JOIN core.condition c
|
||||
ON m.claim_id = c.claim_id
|
||||
AND c.condition_rank = 1
|
||||
""").pl()
|
||||
|
||||
_schema, _tbl = table_ref.split(".", 1)
|
||||
try:
|
||||
_df = con.execute(f'SELECT * FROM "{_schema}"."{_tbl}"').pl()
|
||||
@@ -724,6 +714,8 @@ Running all three measure pipelines against **Synthea/Tuva claims data**
|
||||
@app.cell(hide_code=True)
|
||||
def _(ex, mo, pl, run_step, uamcc_pp):
|
||||
_uamcc_pipeline = [
|
||||
("cms_quality_measures._stg_medical_claim", ex.stg_medical_claim),
|
||||
("cms_quality_measures._stg_medical_claim_condition", ex.stg_medical_claim_condition),
|
||||
("cms_quality_measures._uamcc_performance_period", ex.uamcc_performance_period),
|
||||
("cms_quality_measures._uamcc_int_mcc_cohort", ex.uamcc_int_mcc_cohort),
|
||||
("cms_quality_measures._uamcc_int_denominator", ex.uamcc_int_denominator),
|
||||
|
||||
Reference in New Issue
Block a user