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-1994: Delete inactive investigations #116

Merged
merged 3 commits into from
Dec 18, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ BEGIN


SELECT @RowCount_no = @@ROWCOUNT;
INSERT INTO [dbo].[job_flow_log] (batch_id,[Dataflow_Name],[package_Name],[Status_Type] ,[step_number],[step_name],[row_count])
VALUES( @Batch_id,'STD_HIV_DATAMART','STD_HIV_DATAMART','START',@Proc_Step_no,@Proc_Step_Name,0);
INSERT INTO [dbo].[job_flow_log] (batch_id,[Dataflow_Name],[package_Name],[Status_Type] ,[step_number],[step_name],[row_count],[msg_description1])
VALUES( @Batch_id,'STD_HIV_DATAMART','STD_HIV_DATAMART','START',@Proc_Step_no,@Proc_Step_Name,0,LEFT(@phc_id, 500));
COMMIT TRANSACTION;

/*New logic for INV_HIV*/
Expand Down Expand Up @@ -1236,6 +1236,33 @@ BEGIN

BEGIN TRANSACTION;

SET @PROC_STEP_NO = @PROC_STEP_NO + 1;
SET @Proc_Step_Name = 'Remove INACTIVE Investigations';

DELETE FROM dbo.STD_HIV_DATAMART
WHERE INVESTIGATION_KEY IN (
SELECT DISTINCT PC.INVESTIGATION_KEY
FROM dbo.F_STD_PAGE_CASE PC
INNER JOIN dbo.INVESTIGATION INV ON PC.INVESTIGATION_KEY = INV.INVESTIGATION_KEY
INNER JOIN dbo.STD_HIV_DATAMART SHD ON SHD.INVESTIGATION_KEY = PC.INVESTIGATION_KEY
WHERE INV.RECORD_STATUS_CD <> 'ACTIVE');

DELETE FROM dbo.INV_HIV
WHERE INVESTIGATION_KEY IN (
SELECT DISTINCT PC.INVESTIGATION_KEY
FROM dbo.F_STD_PAGE_CASE PC
INNER JOIN dbo.INVESTIGATION INV ON PC.INVESTIGATION_KEY = INV.INVESTIGATION_KEY
INNER JOIN dbo.INV_HIV IH ON IH.INVESTIGATION_KEY = PC.INVESTIGATION_KEY
WHERE INV.RECORD_STATUS_CD <> 'ACTIVE');

SELECT @RowCount_no = @@ROWCOUNT;
INSERT INTO [dbo].[job_flow_log] (batch_id,[Dataflow_Name],[package_Name],[Status_Type],[step_number],[step_name],[row_count])
VALUES(@Batch_id,'STD_HIV_DATAMART','STD_HIV_DATAMART','START',@Proc_Step_no,@Proc_Step_name,@RowCount_no);

COMMIT TRANSACTION;

BEGIN TRANSACTION;

SET @PROC_STEP_NO = @PROC_STEP_NO + 1;
SET @Proc_Step_Name = 'SP_COMPLETE';
INSERT INTO [dbo].[job_flow_log]
Expand Down Expand Up @@ -1278,4 +1305,4 @@ BEGIN
RETURN -1;

END CATCH;
END;
END;
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ BEGIN


SELECT @RowCount_no = @@ROWCOUNT;
INSERT INTO [dbo].[job_flow_log] (batch_id,[Dataflow_Name],[package_Name],[Status_Type] ,[step_number],[step_name],[row_count])
VALUES( @Batch_id,'STD_HIV_DATAMART','STD_HIV_DATAMART','START',@Proc_Step_no,@Proc_Step_Name,0);
INSERT INTO [dbo].[job_flow_log] (batch_id,[Dataflow_Name],[package_Name],[Status_Type] ,[step_number],[step_name],[row_count],[msg_description1])
VALUES( @Batch_id,'STD_HIV_DATAMART','STD_HIV_DATAMART','START',@Proc_Step_no,@Proc_Step_Name,0,LEFT(@phc_id, 500));
COMMIT TRANSACTION;

/*New logic for INV_HIV*/
Expand Down Expand Up @@ -1236,6 +1236,33 @@ BEGIN

BEGIN TRANSACTION;

SET @PROC_STEP_NO = @PROC_STEP_NO + 1;
SET @Proc_Step_Name = 'Remove INACTIVE Investigations';

DELETE FROM dbo.STD_HIV_DATAMART
WHERE INVESTIGATION_KEY IN (
SELECT DISTINCT PC.INVESTIGATION_KEY
FROM dbo.F_STD_PAGE_CASE PC
INNER JOIN dbo.INVESTIGATION INV ON PC.INVESTIGATION_KEY = INV.INVESTIGATION_KEY
INNER JOIN dbo.STD_HIV_DATAMART SHD ON SHD.INVESTIGATION_KEY = PC.INVESTIGATION_KEY
WHERE INV.RECORD_STATUS_CD <> 'ACTIVE');

DELETE FROM dbo.INV_HIV
WHERE INVESTIGATION_KEY IN (
SELECT DISTINCT PC.INVESTIGATION_KEY
FROM dbo.F_STD_PAGE_CASE PC
INNER JOIN dbo.INVESTIGATION INV ON PC.INVESTIGATION_KEY = INV.INVESTIGATION_KEY
INNER JOIN dbo.INV_HIV IH ON IH.INVESTIGATION_KEY = PC.INVESTIGATION_KEY
WHERE INV.RECORD_STATUS_CD <> 'ACTIVE');

SELECT @RowCount_no = @@ROWCOUNT;
INSERT INTO [dbo].[job_flow_log] (batch_id,[Dataflow_Name],[package_Name],[Status_Type],[step_number],[step_name],[row_count])
VALUES(@Batch_id,'STD_HIV_DATAMART','STD_HIV_DATAMART','START',@Proc_Step_no,@Proc_Step_name,@RowCount_no);

COMMIT TRANSACTION;

BEGIN TRANSACTION;

SET @PROC_STEP_NO = @PROC_STEP_NO + 1;
SET @Proc_Step_Name = 'SP_COMPLETE';
INSERT INTO [dbo].[job_flow_log]
Expand Down Expand Up @@ -1278,4 +1305,4 @@ BEGIN
RETURN -1;

END CATCH;
END;
END;