Skip to content

Commit 37e3444

Browse files
nullfluxclaude
andcommitted
Bug #5b: extend patient_id UPDATE to Tier 3 variants + apply pending-PR routines in orchestrator
Two changes: 1. Extend bug #5b's patient_id-NULL fix to the 10 multi-condition nrt_investigation variants (22000010-22000100) and the Tetanus variant (22000200). The original cherry-pick (bb7cec9) only set patient_id on the foundation Inv (20000100); the Tier 3 variants left it NULL, so the same DELETE-by-sentinel-PATIENT_UID cascade that blocks HEPATITIS_DATAMART would block any condition-datamart SP whose query path goes through F_PAGE_CASE -> D_PATIENT lookup. 2. New orchestrator step 2.5 apply_pending_pr_routines pulls each pending-PR routine (PRs #837, #839, #840) from its bug branch via `git show` and applies it to the freshly-reset DB before fixtures. Without this the orchestrator aborts at step 8 on ldf_answers_tetanus.sql (bug #7 early-RETURN guard fires on a SUB data_type ldf_uid, and bug #8 SUBSTRING fires on the tetanus datamart SP). Remove a branch from the list once its PR merges and the baseline image is refreshed. End-to-end coverage uplift vs. coverage_tier_3.md baseline: HEPATITIS_DATAMART 0 -> 1 (5b) COVID_CASE_DATAMART 0 -> 1 (5b on 22000070) BMIRD_STREP_PNEUMO_DATAMART 0 -> 1 (5b on 22000100) F_PAGE_CASE 1 -> 6 (multi-condition + 5b) LDF_DIMENSIONAL_DATA 0 -> 5 (PR #839 bug-7) MORB_RPT_USER_COMMENT 0 -> 1 (PR #837 bug-3) Still 0 (separate per-condition blockers, not 5b-related): HEPATITIS_CASE, HEP100, F_STD_PAGE_CASE, STD_HIV_DATAMART, TB_DATAMART, VAR_DATAMART, LDF_TETANUS, LDF_HEPATITIS — see coverage_hep_datamart_investigation.md for per-condition diagnoses. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent bb7cec9 commit 37e3444

3 files changed

Lines changed: 69 additions & 0 deletions

File tree

utilities/comparison-fixtures/fixtures/30_sp_coverage/ldf_answers_tetanus.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ VALUES
4040
'2026-04-01T00:00:00', '2026-04-01T00:00:00', N'ACTIVE',
4141
'2026-04-01T00:00:00', '2026-04-01T00:00:00', N'O');
4242

43+
-- RTR bug #5b: see multi_condition_investigations.sql for rationale.
44+
UPDATE dbo.nrt_investigation
45+
SET patient_id = 20000000
46+
WHERE public_health_case_uid = 22000200;
47+
4348
EXEC dbo.sp_nrt_investigation_postprocessing @id_list = N'22000200', @debug = 0;
4449

4550
-- Author nrt_ldf_data answer rows for the first 5 Tetanus LDFs.

utilities/comparison-fixtures/fixtures/30_sp_coverage/multi_condition_investigations.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ VALUES
120120
'2026-04-01T00:00:00', '2026-04-01T00:00:00', N'ACTIVE',
121121
'2026-04-01T00:00:00', '2026-04-01T00:00:00', N'O');
122122

123+
-- RTR bug #5b: point patient_id at the foundation nrt_patient.patient_uid
124+
-- so downstream Datamart SPs (sp_hepatitis_datamart_* etc. via F_PAGE_CASE)
125+
-- resolve to a real D_PATIENT row instead of falling back to the sentinel
126+
-- PATIENT_KEY=1 (PATIENT_UID=NULL) which the SPs then DELETE before INSERT.
127+
UPDATE dbo.nrt_investigation
128+
SET patient_id = 20000000
129+
WHERE public_health_case_uid IN
130+
(22000010, 22000020, 22000030, 22000040, 22000050,
131+
22000060, 22000070, 22000080, 22000090, 22000100);
132+
123133
-- Run sp_nrt_investigation_postprocessing to flow these into INVESTIGATION.
124134
EXEC dbo.sp_nrt_investigation_postprocessing
125135
@id_list = N'22000010,22000020,22000030,22000040,22000050,22000060,22000070,22000080,22000090,22000100',

utilities/comparison-fixtures/scripts/merge_and_verify.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,59 @@ run_infrastructure_sps() {
182182
log " RDB_DATE rows: $rdb_date_count, CONDITION rows: $cond_count"
183183
}
184184

185+
# --------------------------------------------------------------------
186+
# Step 2.5 — Apply pending-PR routine fixes
187+
# --------------------------------------------------------------------
188+
#
189+
# The baseline docker image (DATABASE_VERSION=6.0.18.1) ships SP versions
190+
# that pre-date several RTR fixes under review. Until those PRs merge to
191+
# main and a new image is cut, pull each pending routine from its bug
192+
# branch via `git show` and apply it to the freshly-restored DB so Tier 3
193+
# fixtures and the datamart chain can execute cleanly.
194+
#
195+
# Remove a branch from this list once its PR merges and the baseline
196+
# image is refreshed.
197+
198+
apply_pending_pr_routines() {
199+
log "Step 2.5: apply pending-PR routine fixes"
200+
local routines=(
201+
# PR #837 (bug-3): morbidity user-comment join via NRT staging CSV
202+
"aw/app-471/bug-3:liquibase-service/src/main/resources/db/005-rdb_modern/routines/016-sp_nrt_morbidity_report_postprocessing-001.sql"
203+
# PR #839 (bug-7): sp_nrt_ldf_dimensional_data_postprocessing
204+
"aw/app-471/bug-7:liquibase-service/src/main/resources/db/005-rdb_modern/routines/265-sp_nrt_ldf_dimensional_data_postprocessing-001.sql"
205+
# PR #840 (bug-8): SUBSTRING guards across 6 per-condition LDF datamart SPs
206+
"aw/app-471/bug-8:liquibase-service/src/main/resources/db/005-rdb_modern/routines/285-sp_ldf_bmird_datamart_postprocessing-001.sql"
207+
"aw/app-471/bug-8:liquibase-service/src/main/resources/db/005-rdb_modern/routines/290-sp_ldf_foodborne_datamart_postprocessing-001.sql"
208+
"aw/app-471/bug-8:liquibase-service/src/main/resources/db/005-rdb_modern/routines/295-sp_ldf_mumps_datamart_postprocessing-001.sql"
209+
"aw/app-471/bug-8:liquibase-service/src/main/resources/db/005-rdb_modern/routines/300-sp_ldf_tetanus_datamart_postprocessing-001.sql"
210+
"aw/app-471/bug-8:liquibase-service/src/main/resources/db/005-rdb_modern/routines/305-sp_ldf_vaccine_prevent_diseases_datamart_postprocessing-001.sql"
211+
"aw/app-471/bug-8:liquibase-service/src/main/resources/db/005-rdb_modern/routines/320-sp_ldf_hepatitis_datamart_postprocessing-001.sql"
212+
)
213+
214+
local tmp_dir
215+
tmp_dir=$(mktemp -d)
216+
trap "rm -rf '$tmp_dir'" RETURN
217+
218+
for spec in "${routines[@]}"; do
219+
local branch="${spec%%:*}"
220+
local path="${spec#*:}"
221+
local fname
222+
fname=$(basename "$path")
223+
local outfile="$tmp_dir/$fname"
224+
225+
if ! git -C "$NEDSS_DR_ROOT" show "$branch:$path" > "$outfile" 2>/dev/null; then
226+
log " skip (branch '$branch' not present): $fname"
227+
continue
228+
fi
229+
230+
log " apply: $branch -> $fname"
231+
if ! $SQLCMD_BASE -d RDB_MODERN -i "$outfile" -b >/dev/null 2>&1; then
232+
printf '\033[1;31m[merge ERROR]\033[0m failed to apply %s from %s\n' "$fname" "$branch" >&2
233+
return 1
234+
fi
235+
done
236+
}
237+
185238
# --------------------------------------------------------------------
186239
# Step 3 — Foundation
187240
# --------------------------------------------------------------------
@@ -579,6 +632,7 @@ main() {
579632
if [[ $SKIP_RESET -eq 0 ]]; then
580633
reset_baseline
581634
run_infrastructure_sps
635+
apply_pending_pr_routines
582636
else
583637
log "Skipping baseline reset (--skip-reset)"
584638
fi

0 commit comments

Comments
 (0)