Skip to content

Commit afebc88

Browse files
committed
Add vioscreen_registry queries
1 parent abb8e17 commit afebc88

File tree

1 file changed

+28
-0
lines changed
  • microsetta_private_api/db/patches

1 file changed

+28
-0
lines changed

microsetta_private_api/db/patches/0139.sql

+28
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ INSERT INTO barcodes.barcode_scans (barcode, scan_timestamp, sample_status, tech
3131
SELECT '0364352596', scan_timestamp, sample_status, technician_notes
3232
FROM barcodes.barcode_scans
3333
WHERE barcode = 'X00236845';
34+
35+
INSERT INTO ag.vioscreen_registry (account_id, source_id, sample_id, vio_id, deleted, registration_code)
36+
WITH temp_1 AS (
37+
SELECT vr.account_id, vr.source_id, vr.vio_id, vr.deleted, vr.registration_code
38+
FROM ag.vioscreen_registry vr
39+
INNER JOIN ag.ag_kit_barcodes akb ON vr.sample_id = akb.ag_kit_barcode_id
40+
WHERE akb.barcode = 'X00236845'
41+
),
42+
temp_2 AS (
43+
SELECT ag_kit_barcode_id
44+
FROM ag.ag_kit_barcodes
45+
WHERE barcode = '0364352596'
46+
)
47+
SELECT temp_1.account_id, temp_1.source_id, temp_2.ag_kit_barcode_id, temp_1.vio_id, temp_1.deleted, temp_1.registration_code FROM temp_1, temp_2;
3448
-- End copying X00236845 to 0364352596
3549

3650
-- Begin copying 000031307 to 0364406520
@@ -61,4 +75,18 @@ INSERT INTO barcodes.barcode_scans (barcode, scan_timestamp, sample_status, tech
6175
SELECT '0364406520', scan_timestamp, sample_status, technician_notes
6276
FROM barcodes.barcode_scans
6377
WHERE barcode = '000031307';
78+
79+
INSERT INTO ag.vioscreen_registry (account_id, source_id, sample_id, vio_id, deleted, registration_code)
80+
WITH temp_1 AS (
81+
SELECT vr.account_id, vr.source_id, vr.vio_id, vr.deleted, vr.registration_code
82+
FROM ag.vioscreen_registry vr
83+
INNER JOIN ag.ag_kit_barcodes akb ON vr.sample_id = akb.ag_kit_barcode_id
84+
WHERE akb.barcode = '000031307'
85+
),
86+
temp_2 AS (
87+
SELECT ag_kit_barcode_id
88+
FROM ag.ag_kit_barcodes
89+
WHERE barcode = '0364406520'
90+
)
91+
SELECT temp_1.account_id, temp_1.source_id, temp_2.ag_kit_barcode_id, temp_1.vio_id, temp_1.deleted, temp_1.registration_code FROM temp_1, temp_2;
6492
-- End copying 000031307 to 0364406520

0 commit comments

Comments
 (0)