Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CNDE 2345 - Post processing changes for D_ADDL_RISK #255

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions db/upgrade/rdb_modern/tables/081-create_d_addl_risk_group.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--CNDE-2345
IF NOT EXISTS (SELECT 1
FROM sysobjects
WHERE name = 'D_ADDL_RISK_GROUP'
and xtype = 'U')

BEGIN
CREATE TABLE DBO.D_ADDL_RISK_GROUP (
D_ADDL_RISK_GROUP_KEY BIGINT NOT NULL ,
PRIMARY KEY
(
D_ADDL_RISK_GROUP_KEY
)
);
END;
21 changes: 21 additions & 0 deletions db/upgrade/rdb_modern/tables/082-create_d_addl_risk.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--CNDE-2345 Foreign key constraints will be added after the completion of TB Datamart migration.*/
IF NOT EXISTS (SELECT 1
FROM sysobjects
WHERE name = 'D_ADDL_RISK'
and xtype = 'U')

BEGIN
CREATE TABLE DBO.D_ADDL_RISK (
TB_PAM_UID BIGINT NOT NULL ,
D_ADDL_RISK_KEY BIGINT NOT NULL ,
SEQ_NBR INT NULL ,
D_ADDL_RISK_GROUP_KEY BIGINT NOT NULL ,
LAST_CHG_TIME DATETIME NULL ,
VALUE VARCHAR (250) NULL ,
PRIMARY KEY
(
D_ADDL_RISK_KEY,
TB_PAM_UID
)
);
END;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
IF NOT EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_addl_risk_group_key' and xtype = 'U')
BEGIN
CREATE TABLE dbo.nrt_addl_risk_group_key (
D_ADDL_RISK_GROUP_KEY bigint IDENTITY (2,1) NOT NULL,
TB_PAM_UID bigint NOT NULL

);

declare @max bigint;
select @max=max(D_ADDL_RISK_GROUP_KEY)+1 from dbo.d_addl_risk_group ;
select @max;
if @max IS NULL --check when max is returned as null
SET @max = 2; -- default to 2
DBCC CHECKIDENT ('dbo.nrt_addl_risk_group_key', RESEED, @max);
END
16 changes: 16 additions & 0 deletions db/upgrade/rdb_modern/tables/084-create_nrt_addl_risk_key.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
IF NOT EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_addl_risk_key' and xtype = 'U')
BEGIN
CREATE TABLE dbo.nrt_addl_risk_key (
D_ADDL_RISK_KEY bigint IDENTITY (2,1) NOT NULL,
TB_PAM_UID bigint NOT NULL,
NBS_Case_Answer_UID bigint NOT NULL

);

declare @max bigint;
select @max=max(D_ADDL_RISK_KEY)+1 from dbo.d_addl_risk ;
select @max;
if @max IS NULL --check when max is returned as null
SET @max = 2; -- default to 2
DBCC CHECKIDENT ('dbo.nrt_addl_risk_key', RESEED, @max);
END
Original file line number Diff line number Diff line change
Expand Up @@ -1231,4 +1231,44 @@ databaseChangeLog:
changes:
- sqlFile:
path: 048-sp_morbidity_report_datamart_postprocessing-001.sql
splitStatements: false
- changeSet:
id: 230
author: liquibase
runOnChange: true
changes:
- sqlFile:
path: 081-create_d_addl_risk_group-001.sql
splitStatements: false
- changeSet:
id: 235
author: liquibase
runOnChange: true
changes:
- sqlFile:
path: 082-create_d_addl_risk-001.sql
splitStatements: false
- changeSet:
id: 240
author: liquibase
runOnChange: true
changes:
- sqlFile:
path: 083-create_nrt_addl_risk_group_key-001.sql
splitStatements: false
- changeSet:
id: 245
author: liquibase
runOnChange: true
changes:
- sqlFile:
path: 084-create_nrt_addl_risk_key-001.sql
splitStatements: false
- changeSet:
id: 250
author: liquibase
runOnChange: true
changes:
- sqlFile:
path: 146-sp_nrt_d_addl_risk_postprocessing-001.sql
splitStatements: false
Loading