Skip to content

Commit bb7cec9

Browse files
committed
Fix RTR bug #5b: populate nrt_investigation.patient_id before datamart chain
The Hepatitis datamart SP reads nrt_investigation.patient_id directly to resolve PATIENT_KEY via F_PAGE_CASE. When NULL, F_PAGE_CASE's COALESCE(PATIENT.PATIENT_KEY, 1) falls back to sentinel PATIENT_KEY=1 (PATIENT_UID=NULL), and the SP's `DELETE WHERE PATIENT_UID IS NULL` then removes the row before INSERT. Setting patient_id to a real nrt_patient.patient_uid in the orchestrator unblocks HEPATITIS_DATAMART population. Verified by re-running the merged-fixture chain.
1 parent efd71aa commit bb7cec9

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

utilities/comparison-fixtures/scripts/merge_and_verify.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,15 @@ run_place_chain() {
265265
run_investigation_chain() {
266266
log " investigation (foundation 20000100 + v2 20050010)"
267267
sql_q RDB_MODERN "EXEC dbo.sp_investigation_event @phc_id_list = N'20000100,20050010'" >/dev/null
268+
# RTR bug #5b: Tier 1 fixture left nrt_investigation.patient_id NULL on the
269+
# foundation Investigation by design (cross-subject UIDs were intentionally
270+
# NULL on Tier 1). The downstream Datamart chain (sp_hepatitis_datamart_*
271+
# via F_PAGE_CASE) reads nrt_investigation.patient_id directly, and a NULL
272+
# there cascades through COALESCE(PATIENT.PATIENT_KEY, 1) to the sentinel
273+
# PATIENT_KEY=1 (PATIENT_UID=NULL), which the SP then DELETEs before INSERT.
274+
# Point patient_id at the foundation nrt_patient.patient_uid so D_PATIENT
275+
# joins resolve to a real row.
276+
sql_q RDB_MODERN "UPDATE dbo.nrt_investigation SET patient_id = 20000000 WHERE public_health_case_uid = 20000100" >/dev/null
268277
sql_q RDB_MODERN "EXEC dbo.sp_nrt_investigation_postprocessing @id_list = N'20000100,20050010', @debug = 0" >/dev/null
269278
}
270279

0 commit comments

Comments
 (0)