-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19546 from department-of-veterans-affairs/nkirby/…
…APPEALS-30908 nkirby/APPEALS-30908
- Loading branch information
Showing
22 changed files
with
381 additions
and
369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
db/scripts/add_pepsq_populate_trigger_to_vbms_ext_claim.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# frozen_string_literal: true | ||
|
||
require "pg" | ||
|
||
conn = CaseflowRecord.connection | ||
conn.execute(" | ||
drop trigger if exists update_claim_status_trigger on vbms_ext_claim; | ||
create or replace function public.update_claim_status_trigger_function() | ||
returns trigger as $$ | ||
declare | ||
string_claim_id varchar(25); | ||
epe_id integer; | ||
begin | ||
if (NEW.\"EP_CODE\" LIKE '04%' | ||
OR NEW.\"EP_CODE\" LIKE '03%' | ||
OR NEW.\"EP_CODE\" LIKE '93%' | ||
OR NEW.\"EP_CODE\" LIKE '68%') | ||
and (NEW.\"LEVEL_STATUS_CODE\" = 'CLR' OR NEW.\"LEVEL_STATUS_CODE\" = 'CAN') then | ||
string_claim_id := cast(NEW.\"CLAIM_ID\" as varchar); | ||
select id into epe_id | ||
from end_product_establishments | ||
where (reference_id = string_claim_id | ||
and (synced_status is null or synced_status <> NEW.\"LEVEL_STATUS_CODE\")); | ||
if epe_id > 0 | ||
then | ||
if not exists ( | ||
select 1 | ||
from priority_end_product_sync_queue | ||
where end_product_establishment_id = epe_id | ||
) then | ||
insert into priority_end_product_sync_queue (created_at, end_product_establishment_id, updated_at) | ||
values (now(), epe_id, now()); | ||
end if; | ||
end if; | ||
end if; | ||
return null; | ||
end; | ||
$$ | ||
language plpgsql; | ||
create trigger update_claim_status_trigger | ||
after update or insert on vbms_ext_claim | ||
for each row | ||
execute procedure public.update_claim_status_trigger_function(); | ||
") | ||
|
||
conn.close |
42 changes: 42 additions & 0 deletions
42
db/scripts/add_pepsq_populate_trigger_to_vbms_ext_claim.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
drop trigger if exists update_claim_status_trigger on vbms_ext_claim; | ||
|
||
create or replace function public.update_claim_status_trigger_function() | ||
returns trigger as $$ | ||
declare | ||
string_claim_id varchar(25); | ||
epe_id integer; | ||
begin | ||
if (NEW."EP_CODE" LIKE '04%' | ||
OR NEW."EP_CODE" LIKE '03%' | ||
OR NEW."EP_CODE" LIKE '93%' | ||
OR NEW."EP_CODE" LIKE '68%') | ||
and (NEW."LEVEL_STATUS_CODE" = 'CLR' OR NEW."LEVEL_STATUS_CODE" = 'CAN') then | ||
|
||
string_claim_id := cast(NEW."CLAIM_ID" as varchar); | ||
|
||
select id into epe_id | ||
from end_product_establishments | ||
where (reference_id = string_claim_id | ||
and (synced_status is null or synced_status <> NEW."LEVEL_STATUS_CODE")); | ||
|
||
if epe_id > 0 | ||
then | ||
if not exists ( | ||
select 1 | ||
from priority_end_product_sync_queue | ||
where end_product_establishment_id = epe_id | ||
) then | ||
insert into priority_end_product_sync_queue (created_at, end_product_establishment_id, updated_at) | ||
values (now(), epe_id, now()); | ||
end if; | ||
end if; | ||
end if; | ||
return null; | ||
end; | ||
$$ | ||
language plpgsql; | ||
|
||
create trigger update_claim_status_trigger | ||
after update or insert on vbms_ext_claim | ||
for each row | ||
execute procedure public.update_claim_status_trigger_function(); |
11 changes: 11 additions & 0 deletions
11
db/scripts/drop_pepsq_populate_trigger_from_vbms_ext_claim.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
require "pg" | ||
|
||
conn = CaseflowRecord.connection | ||
conn.execute(" | ||
drop trigger if exists update_claim_status_trigger on vbms_ext_claim; | ||
drop function if exists public.update_claim_status_trigger_function(); | ||
") | ||
|
||
conn.close |
2 changes: 2 additions & 0 deletions
2
db/scripts/drop_pepsq_populate_trigger_from_vbms_ext_claim.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
drop trigger if exists update_claim_status_trigger on vbms_ext_claim; | ||
drop function if exists public.update_claim_status_trigger_function(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.