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

Adding script for data exchange config #20

Merged
merged 15 commits into from
Oct 2, 2024
Merged
3 changes: 3 additions & 0 deletions liquibase-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ COPY liquibase-service/src/main/resources/db/master/routines /liquibase/changelo
COPY liquibase-service/src/main/resources/db/odse /liquibase/changelog
COPY liquibase-service/src/main/resources/db/odse/routines /liquibase/changelog
COPY liquibase-service/src/main/resources/db/odse/views /liquibase/changelog
COPY liquibase-service/src/main/resources/db/rdb_modern /liquibase/changelog
COPY liquibase-service/src/main/resources/db/rdb_modern/routines /liquibase/changelog
COPY liquibase-service/src/main/resources/db/rdb_modern/tables /liquibase/changelog
COPY liquibase-service/src/main/resources/db/rdb /liquibase/changelog
COPY liquibase-service/src/main/resources/db/rdb/routines /liquibase/changelog
COPY liquibase-service/src/main/resources/db/rdb/tables /liquibase/changelog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ databaseChangeLog:
author: liquibase
changes:
- sqlFile:
path: 001-create_nrt_organization-001.sql
path: 001-create_data_sync_config-001.sql
splitStatements: false
- changeSet:
id: 2
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
databaseChangeLog:
- changeSet:
id: 0
author: liquibase
changes:
- sqlFile:
path: 000-db-general-001.sql
splitStatements: false
- changeSet:
id: 1
author: liquibase
changes:
- sqlFile:
path: 001-create_nrt_organization-001.sql
splitStatements: false
- changeSet:
id: 2
author: liquibase
changes:
- sqlFile:
path: 002-create_nrt_organization_key-001.sql
splitStatements: false
- changeSet:
id: 3
author: liquibase
changes:
- sqlFile:
path: 003-create_nrt_provider-001.sql
splitStatements: false
- changeSet:
id: 4
author: liquibase
changes:
- sqlFile:
path: 004-create_nrt_provider_key.sql
splitStatements: false
- changeSet:
id: 5
author: liquibase
changes:
- sqlFile:
path: 005-create_nrt_patient-001.sql
splitStatements: false
- changeSet:
id: 6
author: liquibase
changes:
- sqlFile:
path: 006-create_nrt_patient_key-001.sql
splitStatements: false
- changeSet:
id: 7
author: liquibase
changes:
- sqlFile:
path: 007-create_nrt_investigation-001.sql
splitStatements: false
- changeSet:
id: 8
author: liquibase
changes:
- sqlFile:
path: 008-create_nrt_investigation_key-001.sql
splitStatements: false
- changeSet:
id: 9
author: liquibase
changes:
- sqlFile:
path: 009-create_nrt_investigation_confirmation-001.sql
splitStatements: false
- changeSet:
id: 10
author: liquibase
changes:
- sqlFile:
path: 010-create_nrt_confirmation_method_key-001.sql
splitStatements: false
- changeSet:
id: 11
author: liquibase
changes:
- sqlFile:
path: 011-create_nrt_investigation_observation-001.sql
splitStatements: false
- changeSet:
id: 12
author: liquibase
changes:
- sqlFile:
path: 012-create_nrt_investigation_notification-001.sql
splitStatements: false
- changeSet:
id: 13
author: liquibase
changes:
- sqlFile:
path: 012-create-nrt-investigation-notification-002.sql
splitStatements: false
- changeSet:
id: 14
author: liquibase
changes:
- sqlFile:
path: 013-create_nrt_notification_key-001.sql
splitStatements: false
- changeSet:
id: 15
author: liquibase
changes:
- sqlFile:
path: 014-create_nrt_page_case_answer-001.sql
splitStatements: false
- changeSet:
id: 16
author: liquibase
changes:
- sqlFile:
path: 015-create_nrt_ldf_data_key-001.sql
splitStatements: false
- changeSet:
id: 17
author: liquibase
changes:
- sqlFile:
path: 016-create_nrt_ldf_group_key-001.sql
splitStatements: false
- changeSet:
id: 18
author: liquibase
changes:
- sqlFile:
path: 017-create_nrt_observation-001.sql
splitStatements: false
- changeSet:
id: 19
author: liquibase
changes:
- sqlFile:
path: 017-create_nrt_observation-002.sql
splitStatements: false
- changeSet:
id: 20
author: liquibase
changes:
- sqlFile:
path: 001-fn_get_record_status-001.sql
splitStatements: false
- changeSet:
id: 21
author: liquibase
changes:
- sqlFile:
path: 002-sp_nrt_organization_postprocessing-001.sql
splitStatements: false
- changeSet:
id: 22
author: liquibase
changes:
- sqlFile:
path: 003-sp_nrt_provider_postprocessing-001.sql
splitStatements: false
- changeSet:
id: 23
author: liquibase
changes:
- sqlFile:
path: 004-sp_nrt_patient_postprocessing-001.sql
splitStatements: false
- changeSet:
id: 24
author: liquibase
changes:
- sqlFile:
path: 005-sp_nrt_investigation_postprocessing-001.sql
splitStatements: false
- changeSet:
id: 25
author: liquibase
changes:
- sqlFile:
path: 006-sp_nrt_notification_postprocessing-001.sql
splitStatements: false
- changeSet:
id: 26
author: liquibase
changes:
- sqlFile:
path: 007-sp_s_pagebuilder_postprocessing-001.sql
splitStatements: false
- changeSet:
id: 27
author: liquibase
changes:
- sqlFile:
path: 008-sp_l_pagebuilder_postprocessing-001.sql
splitStatements: false
- changeSet:
id: 28
author: liquibase
changes:
- sqlFile:
path: 009-sp_d_pagebuilder_postprocessing-001.sql
splitStatements: false
- changeSet:
id: 29
author: liquibase
changes:
- sqlFile:
path: 010-sp_sld_investigation_repeat_postprocessing-001.sql
splitStatements: false
- changeSet:
id: 30
author: liquibase
changes:
- sqlFile:
path: 011-sp_page_builder_postprocessing-001.sql
splitStatements: false
- changeSet:
id: 31
author: liquibase
changes:
- sqlFile:
path: 012-sp_f_page_case_postprocessing-001.sql
splitStatements: false
- changeSet:
id: 32
author: liquibase
changes:
- sqlFile:
path: 013-sp_hepatitis_datamart_postprocessing-001.sql
splitStatements: false
- changeSet:
id: 33
author: liquibase
changes:
- sqlFile:
path: 019-create_nrt_datamart_metadata-001.sql
splitStatements: false
- changeSet:
id: 34
author: liquibase
changes:
- sqlFile:
path: 014-sp_get_date_dim-001.sql
splitStatements: false
- changeSet:
id: 35
author: liquibase
changes:
- sqlFile:
path: 018-create-nrt_ldf_data-001.sql
splitStatements: false
- changeSet:
id: 36
author: liquibase
changes:
- sqlFile:
path: 015-sp_nrt_ldf_postprocessing-001.sql
splitStatements: false
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-- Upgrade compatibility level to allow inbuilt functions such as StringSplit
ALTER DATABASE RDB_MODERN SET COMPATIBILITY_LEVEL = 130;
ALTER DATABASE RDB SET COMPATIBILITY_LEVEL = 130;

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
INSERT INTO [RDB].[dbo].[data_sync_config]
(table_name, source_db, query, query_with_null_timestamp, query_count, query_with_pagination)
VALUES
('NRT_OBSERVATION', 'RDB_MODERN', 'SELECT * FROM nrt_observation WHERE last_chg_time :operator :timestamp OR refresh_datetime :operator :timestamp;', NULL, 'SELECT COUNT(*) FROM nrt_observation WHERE last_chg_time :operator :timestamp OR refresh_datetime :operator :timestamp;', 'WITH PaginatedResults AS (
SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS RowNum
FROM nrt_observation
WHERE last_chg_time :operator :timestamp OR refresh_datetime :operator :timestamp
)
SELECT * FROM PaginatedResults
WHERE RowNum BETWEEN :startRow AND :endRow;')
;


INSERT INTO [RDB].[dbo].[data_sync_config]
(table_name, source_db, query, query_with_null_timestamp, query_count, query_with_pagination)
VALUES
('NRT_OBSERVATION_CODED', 'RDB_MODERN', 'SELECT *
FROM rdb_modern.dbo.nrt_observation_coded
JOIN rdb_modern.dbo.nrt_observation
ON rdb_modern.dbo.nrt_observation_coded.observation_uid = rdb_modern.dbo.nrt_observation.observation_uid
WHERE rdb_modern.dbo.nrt_observation_coded.refresh_datetime :operator :timestamp
OR rdb_modern.dbo.nrt_observation.last_chg_time :operator :timestamp
OR rdb_modern.dbo.nrt_observation.refresh_datetime :operator :timestamp;', NULL, 'SELECT COUNT(*)
FROM rdb_modern.dbo.nrt_observation_coded
JOIN rdb_modern.dbo.nrt_observation
ON rdb_modern.dbo.nrt_observation_coded.observation_uid = rdb_modern.dbo.nrt_observation.observation_uid
WHERE rdb_modern.dbo.nrt_observation_coded.refresh_datetime :operator :timestamp
OR rdb_modern.dbo.nrt_observation.last_chg_time :operator :timestamp
OR rdb_modern.dbo.nrt_observation.refresh_datetime :operator :timestamp;', 'WITH PaginatedResults AS (
SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS RowNum
FROM rdb_modern.dbo.nrt_observation_coded
JOIN rdb_modern.dbo.nrt_observation
ON rdb_modern.dbo.nrt_observation_coded.observation_uid = rdb_modern.dbo.nrt_observation.observation_uid
WHERE rdb_modern.dbo.nrt_observation_coded.refresh_datetime :operator :timestamp
OR rdb_modern.dbo.nrt_observation.last_chg_time :operator :timestamp
OR rdb_modern.dbo.nrt_observation.refresh_datetime :operator :timestamp
)
SELECT * FROM PaginatedResults
WHERE RowNum BETWEEN :startRow AND :endRow;')
;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
INSERT INTO [RDB].[dbo].[data_sync_config] (table_name, source_db, query, query_with_null_timestamp, query_count,
query_with_pagination)
VALUES
('CONDITION_CODE', 'SRTE', 'SELECT * FROM CONDITION_CODE', NULL, 'SELECT COUNT(*) FROM CONDITION_CODE;', 'WITH PaginatedResults AS (SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS RowNum FROM CONDITION_CODE) SELECT * FROM PaginatedResults WHERE RowNum BETWEEN :startRow AND :endRow;'), ('CODE_TO_CONDITION', 'SRTE', 'SELECT * FROM CODE_TO_CONDITION', NULL, 'SELECT COUNT(*) FROM CODE_TO_CONDITION;', 'WITH PaginatedResults AS (SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS RowNum FROM CODE_TO_CONDITION) SELECT * FROM PaginatedResults WHERE RowNum BETWEEN :startRow AND :endRow;');


INSERT INTO [RDB].[dbo].[data_sync_config] (table_name, source_db, query, query_with_null_timestamp, query_count,
query_with_pagination)
VALUES
('Program_area_code', 'SRTE', 'SELECT * FROM Program_area_code;', NULL, 'SELECT COUNT(*) FROM Program_area_code;', 'WITH PaginatedResults AS (SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS RowNum FROM Program_area_code) SELECT * FROM PaginatedResults WHERE RowNum BETWEEN :startRow AND :endRow;')
;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
IF
NOT EXISTS(
SELECT 'X'
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'data_sync_config')
BEGIN
CREATE TABLE data_sync_config
(
table_name NVARCHAR(255) NOT NULL PRIMARY KEY,
source_db NVARCHAR(255) NOT NULL,
query NVARCHAR( MAX) NOT NULL,
query_count NVARCHAR( MAX) NOT NULL,
query_with_pagination NVARCHAR( MAX) NOT NULL,
query_with_null_timestamp NVARCHAR( MAX) NULL,
created_at DATETIME2 DEFAULT GETDATE(),
last_executed_timestamp DATETIME2 NULL DEFAULT NULL,
last_executed_run_time NVARCHAR(255) NULL DEFAULT NULL,
last_executed_result_count INTEGER NULL DEFAULT NULL,
log_start_row NVARCHAR(255) NULL,
log_end_row NVARCHAR(255) NULL
);
END
GO
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- Upgrade compatibility level to allow inbuilt functions such as StringSplit
ALTER DATABASE RDB_MODERN SET COMPATIBILITY_LEVEL = 130;