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

Local containers #248

Merged
merged 7 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ hl7-parser/.gradle/*
*.env

.vscode/*
application-local.yaml
2 changes: 1 addition & 1 deletion cdaschema/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Sep 19 13:01:35 MST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 1 addition & 0 deletions containers/db/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.backups
File renamed without changes.
81 changes: 81 additions & 0 deletions containers/db/initialize/restore.d/00-restore.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
use [master];
go

-- Following Script will restore the DATABASE FROM "/var/opt/database/restore" Backups folder
-- All database Data files/log files go to "/var/opt/mssql/data". User can Modify the folder where they need to....

---------------------------------------------------------------------------------------------------
-- NBS_ODSE
---------------------------------------------------------------------------------------------------

RESTORE DATABASE [NBS_ODSE] FROM
DISK = N'/var/opt/database/initialize/restore.d/NBS_ODSE.bak'
WITH FILE = 1,
MOVE N'ODS_PRIMARY_DATA01' TO N'/var/opt/mssql/data/Nbs_odse.mdf',
MOVE N'ODS_PRIMARY_DAT02' TO N'/var/opt/mssql/data/nbs_odse1.mdf',
MOVE N'ODS_ACTS01' TO N'/var/opt/mssql/data/nbs_odse2.mdf',
MOVE N'ODS_ACTS02' TO N'/var/opt/mssql/data/nbs_odse3.mdf',
MOVE N'ODS_ENTITIES01' TO N'/var/opt/mssql/data/nbs_odse4.mdf',
MOVE N'ODS_ENTITIES02' TO N'/var/opt/mssql/data/nbs_odse5.mdf',
MOVE N'ODS_ENTITIES_LOCATOR01' TO N'/var/opt/mssql/data/nbs_odse6.mdf',
MOVE N'ODS_ENTITIES_LOCATOR02' TO N'/var/opt/mssql/data/nbs_odse7.mdf',
MOVE N'ODS_HIST01' TO N'/var/opt/mssql/data/nbs_odse8.mdf',
MOVE N'ODS_HIST02' TO N'/var/opt/mssql/data/nbs_odse9.mdf',
MOVE N'ODS_INDEX01' TO N'/var/opt/mssql/data/nbs_odse10.mdf',
MOVE N'ODS_INDEX02' TO N'/var/opt/mssql/data/nbs_odse11.mdf',
MOVE N'ODS_REPORT01' TO N'/var/opt/mssql/data/nbs_odse12.mdf',
MOVE N'ODS_REPORT02' TO N'/var/opt/mssql/data/nbs_odse13.mdf',
MOVE N'ODS_TEXTFILE01' TO N'/var/opt/mssql/data/nbs_odse14.mdf',
MOVE N'ODS_TEXTFILE02' TO N'/var/opt/mssql/data/nbs_odse15.mdf',
MOVE N'ODS_PARTICIPATION01' TO N'/var/opt/mssql/data/nbs_odse16.mdf',
MOVE N'ODS_PARTICIPATION02' TO N'/var/opt/mssql/data/nbs_odse17.mdf',
MOVE N'PRIMARY_LOG1' TO N'/var/opt/mssql/data/nbs_odse_1.ldf', NOUNLOAD, STATS = 10
GO

EXEC dbo.sp_dbcmptlevel @dbname=N'NBS_ODSE', @new_cmptlevel=120
GO

---------------------------------------------------------------------------------------------------
-- NBS_SRTE
---------------------------------------------------------------------------------------------------

RESTORE DATABASE [NBS_SRTE] FROM
DISK = N'/var/opt/database/initialize/restore.d/NBS_SRTE.bak'
WITH FILE = 1,
MOVE N'nbs_srte_generic113_Data' TO N'/var/opt/mssql/data/nbs_srte.mdf',
MOVE N'nbs_srte_generic113_Log' TO N'/var/opt/mssql/data/nbs_srte.ldf', NOUNLOAD, STATS = 10
GO

EXEC dbo.sp_dbcmptlevel @dbname=N'NBS_SRTE', @new_cmptlevel=120
GO

---------------------------------------------------------------------------------------------------
-- NBS_MSGOUTE
---------------------------------------------------------------------------------------------------

RESTORE DATABASE [NBS_MSGOUTE] FROM DISK = N'/var/opt/database/initialize/restore.d/NBS_MSGOUTE.bak' WITH FILE = 1,
MOVE N'MSGOUT_PRIMARY_DATA01' TO N'/var/opt/mssql/data/nbs_msgoute.mdf',
MOVE N'MSGOUT_PRIMARY_DATA02' TO N'/var/opt/mssql/data/nbs_msgoute_1.mdf',
MOVE N'MSGOUT_TEXTFILE01' TO N'/var/opt/mssql/data/nbs_msgoute_2.mdf',
MOVE N'MSGOUT_TEXTFILE02' TO N'/var/opt/mssql/data/nbs_msgoute_3.mdf',
MOVE N'MSGOUT_APP01' TO N'/var/opt/mssql/data/nbs_msgoute_4.mdf',
MOVE N'MSGOUT_APP02' TO N'/var/opt/mssql/data/nbs_msgoute_5.mdf',
MOVE N'PRIMARY_LOG1' TO N'/var/opt/mssql/data/nbs_msgoute_log.ldf',
NOUNLOAD, STATS = 10
GO

EXEC dbo.sp_dbcmptlevel @dbname=N'NBS_MSGOUTE', @new_cmptlevel=120
GO

---------------------------------------------------------------------------------------------------
-- RDB
---------------------------------------------------------------------------------------------------

RESTORE DATABASE [RDB] FROM DISK = N'/var/opt/database/initialize/restore.d/RDB.bak' WITH FILE = 1,
MOVE N'RDB' TO N'/var/opt/mssql/data/rdb_data.mdf',
MOVE N'RDB_log' TO N'/var/opt/mssql/data/rdb_log.ldf', NOUNLOAD, STATS = 10
GO


EXEC dbo.sp_dbcmptlevel @dbname=N'RDB', @new_cmptlevel=120
GO
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
use [master];

IF EXISTS (SELECT * FROM sys.server_principals WHERE name = N'nbs_ods')
DROP LOGIN [nbs_ods];

create login nbs_ods with password = 'ods', default_database = [master], check_expiration=OFF, check_policy=OFF;

IF EXISTS (SELECT * FROM sys.server_principals WHERE name = N'SRTE_ADMIN')
DROP LOGIN [SRTE_ADMIN];

CREATE LOGIN srte_admin WITH PASSWORD = 'admin',DEFAULT_DATABASE = [master], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF;

IF EXISTS (SELECT * FROM sys.server_principals WHERE name = N'nbs_rdb')
DROP LOGIN [nbs_rdb];

CREATE LOGIN nbs_rdb WITH PASSWORD = 'rdb',DEFAULT_DATABASE = [master], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF;


GO

---------------------------------------------------------------------------------------------------
use NBS_MSGoute;

if exists (select * from sys.database_principals where name = N'nbs_ods')
drop user [nbs_ods];
go

create user nbs_ods for login nbs_ods;

exec sp_addrolemember 'db_owner', 'nbs_ods';

go

---------------------------------------------------------------------------------------------------
use NBS_ODSE;

if exists (select * from sys.database_principals where name = N'nbs_ods')
drop user [nbs_ods];
go

create user nbs_ods for login nbs_ods;

exec sp_addrolemember 'db_owner', 'nbs_ods';

go

---------------------------------------------------------------------------------------------------
use [NBS_SRTE];

if exists (select * from sys.database_principals where name = N'nbs_ods')
drop user [nbs_ods];
go

create user nbs_ods for login nbs_ods;

exec sp_addrolemember 'db_owner', 'nbs_ods';

go

if exists (select * from sys.database_principals where name = N'srte_admin')
drop user [srte_admin];
go

create user srte_admin for login srte_admin;

exec sp_addrolemember 'db_owner', 'srte_admin';

go

---------------------------------------------------------------------------------------------------
use [rdb];

if exists (select * from sys.database_principals where name = N'nbs_rdb')
drop user [nbs_rdb];
go

create user nbs_rdb for login nbs_rdb;

exec sp_addrolemember 'db_owner', 'nbs_rdb';

go
121 changes: 121 additions & 0 deletions containers/db/initialize/restore.d/02-create-application-users.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
use NBS_ODSE;

declare @user varchar (100) = 'superuser'
declare @first varchar(100) = 'Ariella'
declare @last varchar(100) = 'Kent'
declare @permissions varchar(100) = 'superuser'

---------------------------------------------------------------------------------------------------
declare @next_id bigint
declare @changedBy bigint = -1;
declare @changedOn datetime = getDate();
declare @guest char = 'F'
declare @read_only char = 'T'

-- find the NBS Class
declare @class varchar(20);
select
@class = config_value
from [nbs_configuration]
where config_key = 'NBS_CLASS_CODE'

IF NOT EXISTS (SELECT 1 FROM [dbo].[Auth_user] where [user_id] = @user)
begin

begin transaction

-- get the next NBS identifier
select
@next_id = seed_value_nbr
from local_uid_generator
where class_name_cd = @class

-- Add the user
insert into Auth_user (
nedss_entry_id,
user_id,
user_type,
user_first_nm,
user_last_nm,
master_sec_admin_ind,
prog_area_admin_ind,
user_comments,
add_user_id,
add_time,
last_chg_user_id,
last_chg_time,
record_status_cd,
record_status_time
) values (
@next_id,
@user,
'internalUser',
@first,
@last,
'F',
'F',
'Auto-generated user.',
@changedBy,
@changedOn,
@changedBy,
@changedOn,
'ACTIVE',
@changedOn
)

-- update NBS identifier
update local_uid_generator
set seed_value_nbr = @next_id + 1
where class_name_cd = @class;

commit transaction

---------------------------------------------------------------------------------------------------
-- Add permissions to all Jurisdictions

;with users (identifier) as (
select
auth_user_uid
from Auth_user
where user_id in (
@user
)
)
insert into Auth_user_role (
auth_user_uid,
auth_role_nm,
prog_area_cd,
jurisdiction_cd,
auth_perm_set_uid,
role_guest_ind,
read_only_ind,
disp_seq_nbr,
add_time,
add_user_id,
last_chg_time,
last_chg_user_id,
record_status_cd,
record_status_time
)
select
[user].[identifier] as [auth_user_uid],
[permission_set].perm_set_nm as [auth_role_nm],
[program_area].[prog_area_cd],
'ALL' as [jurisdiction_cd],
[permission_set].auth_perm_set_uid,
@guest as [role_guest_ind],
@read_only as [read_only_ind],
0 as [disp_seq_nbr],
@changedOn as [add_time],
@changedBy as [add_user_id],
@changedOn as [last_chg_time],
@changedBy as [last_chg_user_id],
'ACTIVE' as [record_status_cd],
@changedOn as [record_status_time]
from Auth_perm_set [permission_set],
users [user],
NBS_SRTE..Program_area_code [program_area]

where [permission_set].perm_set_nm = @permissions

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE DATABASE NBS_DATAINGEST;

GO
60 changes: 30 additions & 30 deletions ...on/db/initialize/restore.d/00-initial.sql → .../restore.d/04-create-deduplication-db.sql
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
USE [master];
GO
CREATE DATABASE deduplication;
GO
USE [deduplication];
GO
CREATE TABLE data_element_configuration (
id int IDENTITY (1,1) PRIMARY KEY,
configuration NVARCHAR(MAX) NOT NULL,
add_time datetime NOT NULL default(current_timestamp));
GO
CREATE TABLE match_configuration (
id int IDENTITY (1,1) PRIMARY KEY,
configuration NVARCHAR(MAX) NOT NULL,
add_time datetime NOT NULL default(current_timestamp));
GO
CREATE TABLE nbs_mpi_mapping (
id bigint,
person_uid bigint,
person_parent_uid bigint,
mpi_person uniqueidentifier,
mpi_patient uniqueidentifier,
status varchar,
PRIMARY KEY ([id])
USE [master];
GO

CREATE DATABASE deduplication;
GO

USE [deduplication];
GO


CREATE TABLE data_element_configuration (
id int IDENTITY (1,1) PRIMARY KEY,
configuration NVARCHAR(MAX) NOT NULL,
add_time datetime NOT NULL default(current_timestamp));
GO

CREATE TABLE match_configuration (
id int IDENTITY (1,1) PRIMARY KEY,
configuration NVARCHAR(MAX) NOT NULL,
add_time datetime NOT NULL default(current_timestamp));
GO

CREATE TABLE nbs_mpi_mapping (
id bigint,
person_uid bigint,
person_parent_uid bigint,
mpi_person uniqueidentifier,
mpi_patient uniqueidentifier,
status varchar,
PRIMARY KEY ([id])
);
Binary file not shown.
Binary file added containers/db/initialize/restore.d/NBS_ODSE.bak
Binary file not shown.
Binary file not shown.
Binary file added containers/db/initialize/restore.d/RDB.bak
Binary file not shown.
Loading
Loading