From beb8efbebbf23e8e15d816624b17a29ddee905b7 Mon Sep 17 00:00:00 2001 From: John Eipe Date: Thu, 5 Dec 2024 08:11:05 -0600 Subject: [PATCH 1/5] CNDE-1913: Preprocess service and proc changes to capture additional ids related to investigation. --- .../repository/model/dto/Investigation.java | 52 +++++++++++++ .../reporting/InvestigationReporting.java | 17 +++++ .../010-sp_investigation_event-002.sql | 49 +++++++++++-- .../007-create_nrt_investigation-005.sql | 73 +++++++++++++++++++ 4 files changed, 184 insertions(+), 7 deletions(-) create mode 100644 liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-005.sql diff --git a/investigation-service/src/main/java/gov/cdc/etldatapipeline/investigation/repository/model/dto/Investigation.java b/investigation-service/src/main/java/gov/cdc/etldatapipeline/investigation/repository/model/dto/Investigation.java index 9e63c846..6afe43ce 100644 --- a/investigation-service/src/main/java/gov/cdc/etldatapipeline/investigation/repository/model/dto/Investigation.java +++ b/investigation-service/src/main/java/gov/cdc/etldatapipeline/investigation/repository/model/dto/Investigation.java @@ -324,4 +324,56 @@ public class Investigation { @Column(name = "investigation_form_cd") private String investigationFormCd; + + @Column(name = "ca_supervisor_of_phc_uid") + private Long caSupervisorOfPhcUid; + + @Column(name = "closure_investgr_of_phc_uid") + private Long closureInvestgrOfPhcUid; + + @Column(name = "dispo_fld_fupinvestgr_of_phc_uid") + private Long dispoFldFupinvestgrOfPhcUid; + + @Column(name = "fld_fup_investgr_of_phc_uid") + private Long fldFupInvestgrOfPhcUid; + + @Column(name = "fld_fup_prov_of_phc_uid") + private Long fldFupProvOfPhcUid; + + @Column(name = "fld_fup_supervisor_of_phc_uid") + private Long fldFupSupervisorOfPhcUid; + + @Column(name = "init_fld_fup_investgr_of_phc_uid") + private Long initFldFupInvestgrOfPhcUid; + + @Column(name = "init_fup_investgr_of_phc_uid") + private Long initFupInvestgrOfPhcUid; + + @Column(name ="init_interviewer_of_phc_uid") + private Long initInterviewerOfPhcUid; + + @Column(name = "interviewer_of_phc_uid") + private Long interviewerOfPhcUid; + + @Column(name = "surv_investgr_of_phc_uid") + private Long survInvestgrOfPhcUid; + + @Column(name = "fld_fup_facility_of_phc_uid") + private Long fldFupFacilityOfPhcUid; + + @Column(name = "org_as_hospital_of_delivery_uid") + private Long orgAsHospitalOfDeliveryUid; + + @Column(name = "per_as_provider_of_delivery_uid") + private Long perAsProviderOfDeliveryUid; + + @Column(name = "per_as_provider_of_obgyn_uid") + private Long perAsProviderOfObgynUid; + + @Column(name = "per_as_provider_of_pediatrics_uid") + private Long perAsProviderOfPediatricsUid; + + @Column(name = "org_as_reporter_uid") + private Long orgAsReporterUid; + } diff --git a/investigation-service/src/main/java/gov/cdc/etldatapipeline/investigation/repository/model/reporting/InvestigationReporting.java b/investigation-service/src/main/java/gov/cdc/etldatapipeline/investigation/repository/model/reporting/InvestigationReporting.java index 063da975..21105207 100644 --- a/investigation-service/src/main/java/gov/cdc/etldatapipeline/investigation/repository/model/reporting/InvestigationReporting.java +++ b/investigation-service/src/main/java/gov/cdc/etldatapipeline/investigation/repository/model/reporting/InvestigationReporting.java @@ -114,4 +114,21 @@ public class InvestigationReporting { private Long caseCount; private String investigatorAssignedDatetime; private String investigationFormCd; + private Long caSupervisorOfPhcUid; + private Long closureInvestgrOfPhcUid; + private Long dispoFldFupinvestgrOfPhcUid; + private Long fldFupInvestgrOfPhcUid; + private Long fldFupProvOfPhcUid; + private Long fldFupSupervisorOfPhcUid; + private Long initFldFupInvestgrOfPhcUid; + private Long initFupInvestgrOfPhcUid; + private Long initInterviewerOfPhcUid; + private Long interviewerOfPhcUid; + private Long survInvestgrOfPhcUid; + private Long fldFupFacilityOfPhcUid; + private Long orgAsHospitalOfDeliveryUid; + private Long perAsProviderOfDeliveryUid; + private Long perAsProviderOfObgynUid; + private Long perAsProviderOfPediatricsUid; + private Long orgAsReporterUid; } diff --git a/liquibase-service/src/main/resources/db/odse/routines/010-sp_investigation_event-002.sql b/liquibase-service/src/main/resources/db/odse/routines/010-sp_investigation_event-002.sql index c3c9331d..8f6fe90d 100644 --- a/liquibase-service/src/main/resources/db/odse/routines/010-sp_investigation_event-002.sql +++ b/liquibase-service/src/main/resources/db/odse/routines/010-sp_investigation_event-002.sql @@ -95,7 +95,7 @@ BEGIN results.hospitalized_ind, results.transmission_mode_cd, results.transmission_mode, - results.outcome_cd, + results.outcome_cd, results.die_frm_this_illness_ind, results.day_care_ind_cd, results.day_care_ind, @@ -130,6 +130,23 @@ BEGIN investigation_act_entity.person_as_reporter_uid, investigation_act_entity.hospital_uid, investigation_act_entity.ordering_facility_uid, + investigation_act_entity.ca_supervisor_of_phc_uid, + investigation_act_entity.closure_investgr_of_phc_uid, + investigation_act_entity.dispo_fld_fupinvestgr_of_phc_uid, + investigation_act_entity.fld_fup_investgr_of_phc_uid, + investigation_act_entity.fld_fup_prov_of_phc_uid, + investigation_act_entity.fld_fup_supervisor_of_phc_uid, + investigation_act_entity.init_fld_fup_investgr_of_phc_uid, + investigation_act_entity.init_fup_investgr_of_phc_uid, + investigation_act_entity.init_interviewer_of_phc_uid, + investigation_act_entity.interviewer_of_phc_uid, + investigation_act_entity.surv_investgr_of_phc_uid, + investigation_act_entity.fld_fup_facility_of_phc_uid, + investigation_act_entity.org_as_hospital_of_delivery_uid, + investigation_act_entity.per_as_provider_of_delivery_uid, + investigation_act_entity.per_as_provider_of_obgyn_uid, + investigation_act_entity.per_as_provider_of_pediatrics_uid, + investigation_act_entity.org_as_reporter_uid, results.act_ids, results.investigation_observation_ids, results.person_participations, @@ -767,12 +784,30 @@ BEGIN on results.contact_inv_status_cd = cvg2.code and cvg2.code_set_nm = 'PHC_IN_STS' LEFT OUTER JOIN nbs_odse.dbo.case_management cm WITH (NOLOCK) on results.public_health_case_uid = cm.public_health_case_uid LEFT JOIN - (SELECT DISTINCT act_uid AS nac_page_case_uid, - MAX(last_chg_time) AS nac_last_chg_time, - MIN(add_time) AS nac_add_time, - MAX(CASE WHEN type_cd = 'PerAsReporterOfPHC' THEN entity_uid END) person_as_reporter_uid, - MAX(CASE WHEN type_cd = 'HospOfADT' THEN entity_uid END) hospital_uid, - MAX(CASE WHEN type_cd = 'OrgAsClinicOfPHC' THEN entity_uid END) ordering_facility_uid + (SELECT DISTINCT + act_uid AS nac_page_case_uid, + MAX(last_chg_time) AS nac_last_chg_time, + MIN(add_time) AS nac_add_time, + MAX(CASE WHEN type_cd = 'PerAsReporterOfPHC' THEN entity_uid END) person_as_reporter_uid, + MAX(CASE WHEN type_cd = 'HospOfADT' THEN entity_uid END) hospital_uid, + MAX(CASE WHEN type_cd = 'OrgAsClinicOfPHC' THEN entity_uid END) ordering_facility_uid, + MAX(CASE WHEN type_cd = 'CASupervisorOfPHC' THEN entity_uid END) ca_supervisor_of_phc_uid, + MAX(CASE WHEN type_cd = 'ClosureInvestgrOfPHC' THEN entity_uid END) closure_investgr_of_phc_uid, + MAX(CASE WHEN type_cd = 'DispoFldFupInvestgrOfPHC' THEN entity_uid END) dispo_fld_fupinvestgr_of_phc_uid, + MAX(CASE WHEN type_cd = 'FldFupInvestgrOfPHC' THEN entity_uid END) fld_fup_investgr_of_phc_uid, + MAX(CASE WHEN type_cd = 'FldFupProvOfPHC' THEN entity_uid END) fld_fup_prov_of_phc_uid, + MAX(CASE WHEN type_cd = 'FldFupSupervisorOfPHC' THEN entity_uid END) fld_fup_supervisor_of_phc_uid, + MAX(CASE WHEN type_cd = 'InitFldFupInvestgrOfPHC' THEN entity_uid END) init_fld_fup_investgr_of_phc_uid, + MAX(CASE WHEN type_cd = 'InitFupInvestgrOfPHC' THEN entity_uid END) init_fup_investgr_of_phc_uid, + MAX(CASE WHEN type_cd = 'InitInterviewerOfPHC' THEN entity_uid END) init_interviewer_of_phc_uid, + MAX(CASE WHEN type_cd = 'InterviewerOfPHC' THEN entity_uid END) interviewer_of_phc_uid, + MAX(CASE WHEN type_cd = 'SurvInvestgrOfPHC' THEN entity_uid END) surv_investgr_of_phc_uid, + MAX(CASE WHEN type_cd = 'FldFupFacilityOfPHC' THEN entity_uid END) fld_fup_facility_of_phc_uid, + MAX(CASE WHEN type_cd = 'OrgAsHospitalOfDelivery' THEN entity_uid END) org_as_hospital_of_delivery_uid, + MAX(CASE WHEN type_cd = 'PerAsProviderOfDelivery' THEN entity_uid END) per_as_provider_of_delivery_uid, + MAX(CASE WHEN type_cd = 'PerAsProviderOfOBGYN' THEN entity_uid END) per_as_provider_of_obgyn_uid, + MAX(CASE WHEN type_cd = 'PerAsProvideroOfPediatrics' THEN entity_uid END) per_as_provider_of_pediatrics_uid, + MAX(CASE WHEN type_cd = 'OrgAsReporterOfPHC' THEN entity_uid END) org_as_reporter_uid FROM nbs_act_entity nac WITH (NOLOCK) GROUP BY act_uid) AS investigation_act_entity ON investigation_act_entity.nac_page_case_uid = results.public_health_case_uid diff --git a/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-005.sql b/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-005.sql new file mode 100644 index 00000000..ec611768 --- /dev/null +++ b/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-005.sql @@ -0,0 +1,73 @@ +IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U') +BEGIN + +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +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; +END; + +END; \ No newline at end of file From a9f5a8f4acc3b15a07c36b5bfd61dedd796c6ba5 Mon Sep 17 00:00:00 2001 From: John Eipe Date: Thu, 5 Dec 2024 08:27:29 -0600 Subject: [PATCH 2/5] CNDE-1913: Preprocess service and proc changes to capture additional ids related to investigation. --- .../db/changelog/db.rdb_modern.changelog-16.1.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/liquibase-service/src/main/resources/db/changelog/db.rdb_modern.changelog-16.1.yaml b/liquibase-service/src/main/resources/db/changelog/db.rdb_modern.changelog-16.1.yaml index c512dd13..f1c65f75 100644 --- a/liquibase-service/src/main/resources/db/changelog/db.rdb_modern.changelog-16.1.yaml +++ b/liquibase-service/src/main/resources/db/changelog/db.rdb_modern.changelog-16.1.yaml @@ -557,4 +557,11 @@ databaseChangeLog: changes: - sqlFile: path: 004-v_getobstxt-001.sql + splitStatements: false + - changeSet: + id: 75 + author: liquibase + changes: + - sqlFile: + path: 007-create_nrt_investigation-005.sql splitStatements: false \ No newline at end of file From d450c09d0e1d0c5754f9da2687876ebb26d810bf Mon Sep 17 00:00:00 2001 From: John Eipe Date: Thu, 5 Dec 2024 10:22:56 -0600 Subject: [PATCH 3/5] CNDE-1913: Preprocess service and proc changes to capture additional ids related to investigation. --- .../db.rdb_modern.changelog-16.1.yaml | 7 -- .../007-create_nrt_investigation-001.sql | 73 +++++++++++++++++++ .../007-create_nrt_investigation-005.sql | 73 ------------------- 3 files changed, 73 insertions(+), 80 deletions(-) delete mode 100644 liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-005.sql diff --git a/liquibase-service/src/main/resources/db/changelog/db.rdb_modern.changelog-16.1.yaml b/liquibase-service/src/main/resources/db/changelog/db.rdb_modern.changelog-16.1.yaml index e577a161..d6023078 100644 --- a/liquibase-service/src/main/resources/db/changelog/db.rdb_modern.changelog-16.1.yaml +++ b/liquibase-service/src/main/resources/db/changelog/db.rdb_modern.changelog-16.1.yaml @@ -597,11 +597,4 @@ databaseChangeLog: changes: - sqlFile: path: 024-sp_f_interview_case_postprocessing-001.sql - splitStatements: false - - changeSet: - id: 80 - author: liquibase - changes: - - sqlFile: - path: 007-create_nrt_investigation-005.sql splitStatements: false \ No newline at end of file diff --git a/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-001.sql b/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-001.sql index a23b5dfb..67e78b59 100644 --- a/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-001.sql +++ b/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-001.sql @@ -128,3 +128,76 @@ IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = END; END; + +IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U') + BEGIN + + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + END; + END; \ No newline at end of file diff --git a/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-005.sql b/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-005.sql deleted file mode 100644 index ec611768..00000000 --- a/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-005.sql +++ /dev/null @@ -1,73 +0,0 @@ -IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U') -BEGIN - -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; -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; -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; -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; -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; -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; -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; -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; -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; -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; -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; -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; -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; -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; -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; -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; -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; -END; - -END; \ No newline at end of file From 2300212b09047b0a29ae584924b6bd6d33e3e4f7 Mon Sep 17 00:00:00 2001 From: John Eipe Date: Thu, 5 Dec 2024 11:05:02 -0600 Subject: [PATCH 4/5] CNDE-1913: Collate nrt_investigation changes sets into the first file --- .../db.rdb_modern.changelog-16.1.yaml | 21 ------- .../007-create_nrt_investigation-001.sql | 58 +++++++++++++++++++ .../007-create_nrt_investigation-002.sql | 24 -------- .../007-create_nrt_investigation-003.sql | 18 ------ .../007-create_nrt_investigation-004.sql | 9 --- 5 files changed, 58 insertions(+), 72 deletions(-) delete mode 100644 liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-002.sql delete mode 100644 liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-003.sql delete mode 100644 liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-004.sql diff --git a/liquibase-service/src/main/resources/db/changelog/db.rdb_modern.changelog-16.1.yaml b/liquibase-service/src/main/resources/db/changelog/db.rdb_modern.changelog-16.1.yaml index d6023078..778ec3e7 100644 --- a/liquibase-service/src/main/resources/db/changelog/db.rdb_modern.changelog-16.1.yaml +++ b/liquibase-service/src/main/resources/db/changelog/db.rdb_modern.changelog-16.1.yaml @@ -443,20 +443,6 @@ databaseChangeLog: - sqlFile: path: 020-sp_lab101_datamart_postprocessing-001.sql splitStatements: false - - changeSet: - id: 59 - author: liquibase - changes: - - sqlFile: - path: 007-create_nrt_investigation-002.sql - splitStatements: false - - changeSet: - id: 60 - author: liquibase - changes: - - sqlFile: - path: 007-create_nrt_investigation-003.sql - splitStatements: false - changeSet: id: 61 author: liquibase @@ -487,13 +473,6 @@ databaseChangeLog: - sqlFile: path: 022-sp_nrt_case_management_postprocessing-001.sql splitStatements: false - - changeSet: - id: 65 - author: liquibase - changes: - - sqlFile: - path: 007-create_nrt_investigation-004.sql - splitStatements: false - changeSet: id: 66 author: liquibase diff --git a/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-001.sql b/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-001.sql index 67e78b59..2c878189 100644 --- a/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-001.sql +++ b/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-001.sql @@ -114,6 +114,7 @@ CREATE TABLE dbo.nrt_investigation ( PERIOD FOR SYSTEM_TIME (refresh_datetime, max_datetime) ); +--CNDE-1916 IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U') BEGIN @@ -129,6 +130,63 @@ IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = END; +--CNDE-1802 +IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U') + BEGIN + + 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; + 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; + 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; + 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; + END; + + END; + +--CNDE-1602 +IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U') + BEGIN + + 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; + 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; + 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; + END; + END; + +--CNDE-1902 +IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U') + BEGIN + + 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); + END; + END; + +--CNDE-1913 IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U') BEGIN diff --git a/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-002.sql b/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-002.sql deleted file mode 100644 index 2b5d7816..00000000 --- a/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-002.sql +++ /dev/null @@ -1,24 +0,0 @@ -IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U') - BEGIN - - 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; - 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; - 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; - 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; - END; - - END; diff --git a/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-003.sql b/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-003.sql deleted file mode 100644 index 17462324..00000000 --- a/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-003.sql +++ /dev/null @@ -1,18 +0,0 @@ -IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U') - BEGIN - - 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; - 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; - 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; - END; - END; diff --git a/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-004.sql b/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-004.sql deleted file mode 100644 index 55f9d4e3..00000000 --- a/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-004.sql +++ /dev/null @@ -1,9 +0,0 @@ -IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U') -BEGIN - - 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); - END; - -END; From 27201dc2f6f5c0d9a5919115fbf54c9a5600f2cc Mon Sep 17 00:00:00 2001 From: John Eipe Date: Thu, 5 Dec 2024 11:25:06 -0600 Subject: [PATCH 5/5] CNDE-1913: Collate nrt_investigation changes sets into the first file --- .../007-create_nrt_investigation-001.sql | 27 ++++--------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-001.sql b/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-001.sql index 2c878189..df545e5e 100644 --- a/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-001.sql +++ b/liquibase-service/src/main/resources/db/rdb_modern/tables/007-create_nrt_investigation-001.sql @@ -114,10 +114,11 @@ CREATE TABLE dbo.nrt_investigation ( PERIOD FOR SYSTEM_TIME (refresh_datetime, max_datetime) ); ---CNDE-1916 + IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U') BEGIN +--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); @@ -128,12 +129,7 @@ IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = ALTER TABLE dbo.nrt_investigation ADD outbreak_name_desc VARCHAR(100); END; - END; - --CNDE-1802 -IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U') - BEGIN - 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; @@ -154,12 +150,7 @@ IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = ALTER TABLE dbo.nrt_investigation DROP COLUMN notification_last_chg_time; END; - END; - --CNDE-1602 -IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U') - BEGIN - 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; @@ -171,25 +162,17 @@ IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 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; - END; - END; + BEGIN + ALTER TABLE dbo.nrt_investigation ADD investigator_assigned_datetime datetime; + END; --CNDE-1902 -IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U') - BEGIN - 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); END; - END; --CNDE-1913 -IF EXISTS (SELECT 1 FROM sysobjects WHERE name = 'nrt_investigation' and xtype = 'U') - BEGIN - 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;