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-2070 #131

Merged
merged 5 commits into from
Jan 16, 2025
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
1,093 changes: 529 additions & 564 deletions db/upgrade/odse/routines/006-sp_investigation_event.sql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ BEGIN
[INV_PRIORITY_CD] = inv.INV_PRIORITY_CD,
[COINFECTION_ID] = inv.COINFECTION_ID,
[LEGACY_CASE_ID] = inv.LEGACY_CASE_ID,
[OUTBREAK_NAME_DESC] = inv.OUTBREAK_NAME_DESC
[OUTBREAK_NAME_DESC] = inv.OUTBREAK_NAME_DESC,
[INV_CLOSE_DT] = inv.INV_CLOSE_DT
from #temp_inv_table inv
inner join dbo.investigation i with (nolock) on inv.case_uid = i.case_uid
and inv.investigation_key = i.investigation_key
Expand Down Expand Up @@ -545,7 +546,8 @@ BEGIN
[INV_PRIORITY_CD],
[COINFECTION_ID],
[LEGACY_CASE_ID],
[OUTBREAK_NAME_DESC])
[OUTBREAK_NAME_DESC],
[INV_CLOSE_DT])
select k.[d_INVESTIGATION_KEY] as INVESTIGATION_KEY,
inv.CASE_OID,
inv.CASE_UID,
Expand Down Expand Up @@ -615,7 +617,8 @@ BEGIN
inv.INV_PRIORITY_CD,
inv.COINFECTION_ID,
inv.LEGACY_CASE_ID,
inv.OUTBREAK_NAME_DESC
inv.OUTBREAK_NAME_DESC,
inv.INV_CLOSE_DT
FROM #temp_inv_table inv
join dbo.nrt_investigation_key k with (nolock) on inv.case_uid = k.case_uid
where inv.investigation_key is null;
Expand Down
265 changes: 135 additions & 130 deletions db/upgrade/rdb_modern/tables/007-create_nrt_investigation.sql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,5 @@ public class InvestigationReporting {
private Long perAsProviderOfObgynUid;
private Long perAsProviderOfPediatricsUid;
private Long orgAsReporterUid;
private String detectionMethodCd;
}
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ private Investigation constructInvestigation(Long investigationUid) {
investigation.setOutbreakInd("Yes");
investigation.setOutbreakName("MDK");
investigation.setOutbreakNameDesc("Ketchup - McDonalds");
investigation.setDetectionMethodCd("20");
investigation.setDetectionMethodDescTxt("Screening procedure (procedure)");

investigation.setActIds(readFileData(FILE_PATH_PREFIX + "ActIds.json"));
investigation.setInvestigationConfirmationMethod(readFileData(FILE_PATH_PREFIX + "ConfirmationMethod.json"));
Expand Down Expand Up @@ -289,6 +291,8 @@ private InvestigationReporting constructInvestigationReporting(Long investigatio
reporting.setOutbreakInd("Yes");
reporting.setOutbreakName("MDK");
reporting.setOutbreakNameDesc("Ketchup - McDonalds");
reporting.setDetectionMethodCd("20");
reporting.setDetectionMethodDescTxt("Screening procedure (procedure)");

reporting.setInvestigatorId(32143250L); // PersonParticipations.json, entity_id for type_cd=InvestgrOfPHC
reporting.setPhysicianId(14253651L); // PersonParticipations.json, entity_id for type_cd=PhysicianOfPHC
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ BEGIN
[INV_PRIORITY_CD] = inv.INV_PRIORITY_CD,
[COINFECTION_ID] = inv.COINFECTION_ID,
[LEGACY_CASE_ID] = inv.LEGACY_CASE_ID,
[OUTBREAK_NAME_DESC] = inv.OUTBREAK_NAME_DESC
[OUTBREAK_NAME_DESC] = inv.OUTBREAK_NAME_DESC,
[INV_CLOSE_DT] = inv.INV_CLOSE_DT
from #temp_inv_table inv
inner join dbo.investigation i with (nolock) on inv.case_uid = i.case_uid
and inv.investigation_key = i.investigation_key
Expand Down Expand Up @@ -545,7 +546,8 @@ BEGIN
[INV_PRIORITY_CD],
[COINFECTION_ID],
[LEGACY_CASE_ID],
[OUTBREAK_NAME_DESC])
[OUTBREAK_NAME_DESC],
[INV_CLOSE_DT])
select k.[d_INVESTIGATION_KEY] as INVESTIGATION_KEY,
inv.CASE_OID,
inv.CASE_UID,
Expand Down Expand Up @@ -615,7 +617,8 @@ BEGIN
inv.INV_PRIORITY_CD,
inv.COINFECTION_ID,
inv.LEGACY_CASE_ID,
inv.OUTBREAK_NAME_DESC
inv.OUTBREAK_NAME_DESC,
inv.INV_CLOSE_DT
FROM #temp_inv_table inv
join dbo.nrt_investigation_key k with (nolock) on inv.case_uid = k.case_uid
where inv.investigation_key is null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
IF NOT EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U')
CREATE TABLE dbo.nrt_investigation (
CREATE TABLE dbo.nrt_investigation
(
public_health_case_uid bigint NOT NULL PRIMARY KEY,
program_jurisdiction_oid bigint NULL,
local_id varchar(50) NULL,
Expand Down Expand Up @@ -118,10 +119,10 @@ CREATE TABLE dbo.nrt_investigation (
IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U')
BEGIN

--CNDE-1916
--CNDE-1916
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'investigation_form_cd' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD investigation_form_cd VARCHAR(50);
ALTER TABLE dbo.nrt_investigation ADD investigation_form_cd VARCHAR(50);
END;

IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'outbreak_name_desc' AND Object_ID = Object_ID(N'nrt_investigation'))
Expand All @@ -132,123 +133,129 @@ IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype =
--CNDE-1802
IF EXISTS(SELECT 1 FROM sys.columns WHERE name = N'notification_local_id' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation DROP COLUMN notification_local_id;
ALTER TABLE dbo.nrt_investigation DROP COLUMN notification_local_id;
END;

IF EXISTS(SELECT 1 FROM sys.columns WHERE name = N'notification_add_time' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation DROP COLUMN notification_add_time;
ALTER TABLE dbo.nrt_investigation DROP COLUMN notification_add_time;
END;

IF EXISTS(SELECT 1 FROM sys.columns WHERE name = N'notification_record_status_cd' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation DROP COLUMN notification_record_status_cd;
ALTER TABLE dbo.nrt_investigation DROP COLUMN notification_record_status_cd;
END;

IF EXISTS(SELECT 1 FROM sys.columns WHERE Name = N'notification_last_chg_time' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation DROP COLUMN notification_last_chg_time;
ALTER TABLE dbo.nrt_investigation DROP COLUMN notification_last_chg_time;
END;

--CNDE-1602
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'investigation_count' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD investigation_count bigint;
ALTER TABLE dbo.nrt_investigation ADD investigation_count bigint;
END;

IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'case_count' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD case_count bigint;
ALTER TABLE dbo.nrt_investigation ADD case_count bigint;
END;

IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'investigator_assigned_datetime' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD investigator_assigned_datetime datetime;
ALTER TABLE dbo.nrt_investigation ADD investigator_assigned_datetime datetime;
END;

--CNDE-1902
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'investigation_form_cd' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD investigation_form_cd VARCHAR(50);
ALTER TABLE dbo.nrt_investigation ADD investigation_form_cd VARCHAR(50);
END;

--CNDE-1913
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'ca_supervisor_of_phc_uid' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD ca_supervisor_of_phc_uid bigint;
ALTER TABLE dbo.nrt_investigation ADD ca_supervisor_of_phc_uid bigint;
END;
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'closure_investgr_of_phc_uid' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD closure_investgr_of_phc_uid bigint;
ALTER TABLE dbo.nrt_investigation ADD closure_investgr_of_phc_uid bigint;
END;
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'dispo_fld_fupinvestgr_of_phc_uid' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD dispo_fld_fupinvestgr_of_phc_uid bigint;
ALTER TABLE dbo.nrt_investigation ADD dispo_fld_fupinvestgr_of_phc_uid bigint;
END;
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'fld_fup_investgr_of_phc_uid' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD fld_fup_investgr_of_phc_uid bigint;
ALTER TABLE dbo.nrt_investigation ADD fld_fup_investgr_of_phc_uid bigint;
END;
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'fld_fup_prov_of_phc_uid' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD fld_fup_prov_of_phc_uid bigint;
ALTER TABLE dbo.nrt_investigation ADD fld_fup_prov_of_phc_uid bigint;
END;
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'fld_fup_supervisor_of_phc_uid' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD fld_fup_supervisor_of_phc_uid bigint;
ALTER TABLE dbo.nrt_investigation ADD fld_fup_supervisor_of_phc_uid bigint;
END;
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'init_fld_fup_investgr_of_phc_uid' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD init_fld_fup_investgr_of_phc_uid bigint;
ALTER TABLE dbo.nrt_investigation ADD init_fld_fup_investgr_of_phc_uid bigint;
END;
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'init_fup_investgr_of_phc_uid' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD init_fup_investgr_of_phc_uid bigint;
ALTER TABLE dbo.nrt_investigation ADD init_fup_investgr_of_phc_uid bigint;
END;
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'init_interviewer_of_phc_uid' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD init_interviewer_of_phc_uid bigint;
ALTER TABLE dbo.nrt_investigation ADD init_interviewer_of_phc_uid bigint;
END;
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'interviewer_of_phc_uid' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD interviewer_of_phc_uid bigint;
ALTER TABLE dbo.nrt_investigation ADD interviewer_of_phc_uid bigint;
END;
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'surv_investgr_of_phc_uid' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD surv_investgr_of_phc_uid bigint;
ALTER TABLE dbo.nrt_investigation ADD surv_investgr_of_phc_uid bigint;
END;
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'fld_fup_facility_of_phc_uid' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD fld_fup_facility_of_phc_uid bigint;
ALTER TABLE dbo.nrt_investigation ADD fld_fup_facility_of_phc_uid bigint;
END;
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'org_as_hospital_of_delivery_uid' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD org_as_hospital_of_delivery_uid bigint;
ALTER TABLE dbo.nrt_investigation ADD org_as_hospital_of_delivery_uid bigint;
END;
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'per_as_provider_of_delivery_uid' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD per_as_provider_of_delivery_uid bigint;
ALTER TABLE dbo.nrt_investigation ADD per_as_provider_of_delivery_uid bigint;
END;
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'per_as_provider_of_obgyn_uid' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD per_as_provider_of_obgyn_uid bigint;
ALTER TABLE dbo.nrt_investigation ADD per_as_provider_of_obgyn_uid bigint;
END;
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'per_as_provider_of_pediatrics_uid' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD per_as_provider_of_pediatrics_uid bigint;
ALTER TABLE dbo.nrt_investigation ADD per_as_provider_of_pediatrics_uid bigint;
END;
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'org_as_reporter_uid' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD org_as_reporter_uid bigint;
ALTER TABLE dbo.nrt_investigation ADD org_as_reporter_uid bigint;
END;

--CNDE-1968
IF EXISTS(SELECT 1 FROM sys.columns WHERE name = N'jurisdiction_code' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation DROP COLUMN jurisdiction_code;
ALTER TABLE dbo.nrt_investigation DROP COLUMN jurisdiction_code;
END;
IF EXISTS(SELECT 1 FROM sys.columns WHERE name = N'jurisdiction_code_desc_txt' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation DROP COLUMN jurisdiction_code_desc_txt;
ALTER TABLE dbo.nrt_investigation DROP COLUMN jurisdiction_code_desc_txt;
END;

--CNDE-2070
IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'detection_method_cd' AND Object_ID = Object_ID(N'nrt_investigation'))
BEGIN
ALTER TABLE dbo.nrt_investigation ADD detection_method_cd varchar(20);
END;
END;
Loading