-- Tables

/***** Object:  Table [AKUZ].[T_EPIDEMIOLOGICAL_INVESTIGATION_CARD] *****/
CREATE TABLE [AKUZ].[T_EPIDEMIOLOGICAL_INVESTIGATION_CARD]
(
    [MedicalRecordID] uniqueidentifier NOT NULL,
    [MKBCode] varchar(255) NOT NULL,
    [Diagnosis] varchar(255) NULL,
    [Patient] uniqueidentifier NULL,
    [EmergencyNotificationNumber] int NULL,
    [EmergencyNotificationDate] datetime NULL,
    [EmergencySenderPost] int NULL,
    [EmergencyRecipientPost] varchar(255) NULL,
    [DetectionDate] datetime NULL,
    [DetectionPlace] varchar(255) NULL,
    [Foreigner] bit NOT NULL,
    [ComeFrom] varchar(255) NULL,
    [PreviousInfectiousDisease] int NULL,
    [OtherVaccinations] varchar(512) NULL,
    [Rash] bit NOT NULL,
    [RashCharacteristic] int NULL,
    [RashAppearanceDate] datetime NULL,
    [RashDateDoesntRemember] bit NOT NULL,
    [RashDuration] int NULL,
    [RashFirstPlace] int NULL,
    [OtherRashFirstPlace] varchar(255) NULL,
    [RashStageAppearance] bit NOT NULL,
    [SusContact] int NULL,
    [SusContactPlace] int NULL,
    [SusContactOtherPlace] varchar(255) NULL,
    [SusContactAround] int NULL,
    [TravelAnywhereBeforeRash] int NULL,
    [TravelWhere] varchar(255) NULL,
    [ImportedCase] int NULL,
    [Country] uniqueidentifier NULL,
    [Region] uniqueidentifier NULL,
    [Lymphadenopathy] bit NOT NULL,
    [Arthralgia] bit NOT NULL,
    [LymphNodesEnlargement] bit NOT NULL,
    [LymphNodesPlace] int NULL,
    [TempRise] int NULL,
    [TempRiseDate] datetime NULL,
    [MaxTempRise] int NULL,
    [MaxTempRiseLast] int NULL,
    [Cough] int NULL,
    [Rhinitis] int NULL,
    [Conjunctivitis] int NULL,
    [KopliksSpots] int NULL,
    [Enantheme] int NULL,
    [Pigmentation] int NULL,
    [PostoperativeWound] bit NOT NULL,
    [PostoperativeWoundInfo] varchar(255) NULL,
    [Catheters] bit NOT NULL,
    [CathetersInfo] varchar(255) NULL,
    [AntimicrobialTherapy] bit NOT NULL,
    [AdditionalInfo] varchar(4096) NULL
)
ON [PRIMARY]
GO

-- Alters

ALTER TABLE [AKUZ].[T_EPIDEMIOLOGICAL_INVESTIGATION_CARD] ADD CONSTRAINT [PK_T_EPIDEMIOLOGICAL_INVESTIGATION_CARD]
PRIMARY KEY CLUSTERED ([MedicalRecordID]) ON [PRIMARY]
GO

ALTER TABLE [AKUZ].[T_EPIDEMIOLOGICAL_INVESTIGATION_CARD] ADD CONSTRAINT [FK_T_AMBULANCE_CARD_RECORD_T_EPIDEMIOLOGICAL_INVESTIGATION_CARD_MedicalRecordID]
FOREIGN KEY([MedicalRecordID]) REFERENCES [AKUZ].[T_AMBULANCE_CARD_RECORD] ([MedicalRecordID])
GO

ALTER TABLE [AKUZ].[T_EPIDEMIOLOGICAL_INVESTIGATION_CARD] ADD CONSTRAINT [FK_T_PATIENT_T_EPIDEMIOLOGICAL_INVESTIGATION_CARD_Patient]
FOREIGN KEY([Patient]) REFERENCES [AKUZ].[T_PATIENT] ([PatientID])
GO

ALTER TABLE [AKUZ].[T_EPIDEMIOLOGICAL_INVESTIGATION_CARD] ADD CONSTRAINT [FK_T_POST_T_EPIDEMIOLOGICAL_INVESTIGATION_CARD_EmergencySenderPost]
FOREIGN KEY([EmergencySenderPost]) REFERENCES [AKUZ].[T_POST] ([ResourceID])
GO

ALTER TABLE [AKUZ].[T_EPIDEMIOLOGICAL_INVESTIGATION_CARD] ADD CONSTRAINT [FK_T_COUNTRY_T_EPIDEMIOLOGICAL_INVESTIGATION_CARD_Country]
FOREIGN KEY([Country]) REFERENCES [AKUZ].[T_COUNTRY] ([CountryID])
GO

ALTER TABLE [AKUZ].[T_EPIDEMIOLOGICAL_INVESTIGATION_CARD] ADD CONSTRAINT [FK_T_REGION_T_EPIDEMIOLOGICAL_INVESTIGATION_CARD_Region]
FOREIGN KEY([Region]) REFERENCES [AKUZ].[T_REGION] ([RegionID])
GO

-- Tables

/***** Object:  Table [AKUZ].[T_ANTIMICROBIAL_THERAPY] *****/
CREATE TABLE [AKUZ].[T_ANTIMICROBIAL_THERAPY]
(
    [AntimicrobialTherapyID] uniqueidentifier NOT NULL,
    [AppointmentDate] datetime NOT NULL,
    [EpidemiologicalInvestigationCard] uniqueidentifier NOT NULL,
    [Dose] varchar(255) NULL,
    [Frequency] varchar(255) NULL,
    [BillOfGoods] uniqueidentifier NOT NULL
)
ON [PRIMARY]
GO

-- Alters

ALTER TABLE [AKUZ].[T_ANTIMICROBIAL_THERAPY] ADD CONSTRAINT [PK_T_ANTIMICROBIAL_THERAPY]
PRIMARY KEY CLUSTERED ([AntimicrobialTherapyID]) ON [PRIMARY]
GO

ALTER TABLE [AKUZ].[T_ANTIMICROBIAL_THERAPY] ADD CONSTRAINT [FK_T_EPIDEMIOLOGICAL_INVESTIGATION_CARD_T_ANTIMICROBIAL_THERAPY_EpidemiologicalInvestigationCard]
FOREIGN KEY([EpidemiologicalInvestigationCard]) REFERENCES [AKUZ].[T_EPIDEMIOLOGICAL_INVESTIGATION_CARD] ([MedicalRecordID])
GO

ALTER TABLE [AKUZ].[T_ANTIMICROBIAL_THERAPY] ADD CONSTRAINT [FK_T_BILL_OF_GOODS_T_ANTIMICROBIAL_THERAPY_BillOfGoods]
FOREIGN KEY([BillOfGoods]) REFERENCES [PHARM].[T_BILL_OF_GOODS] ([BillOfGoodsID])
GO

-- Tables

/***** Object:  Table [AKUZ].[T_EPIDEMIOLOGICAL_VACCINATION_INFO] *****/
CREATE TABLE [AKUZ].[T_EPIDEMIOLOGICAL_VACCINATION_INFO]
(
    [EpidemiologicalVaccinationInfoHistoryID] uniqueidentifier NOT NULL,
    [VaccinationDate] datetime NOT NULL,
    [VaccineLibrary] uniqueidentifier NOT NULL,
    [RecordDate] datetime NULL,
    [EpidemiologicalInvestigationCard] uniqueidentifier NOT NULL
)
ON [PRIMARY]
GO

-- Alters

ALTER TABLE [AKUZ].[T_EPIDEMIOLOGICAL_VACCINATION_INFO] ADD CONSTRAINT [PK_T_EPIDEMIOLOGICAL_VACCINATION_INFO]
PRIMARY KEY CLUSTERED ([EpidemiologicalVaccinationInfoHistoryID]) ON [PRIMARY]
GO

ALTER TABLE [AKUZ].[T_EPIDEMIOLOGICAL_VACCINATION_INFO] ADD CONSTRAINT [FK_T_VACCINE_LIBRARY_T_EPIDEMIOLOGICAL_VACCINATION_INFO_VaccineLibrary]
FOREIGN KEY([VaccineLibrary]) REFERENCES [AKUZ].[T_VACCINE_LIBRARY] ([VaccineLibraryID])
GO

ALTER TABLE [AKUZ].[T_EPIDEMIOLOGICAL_VACCINATION_INFO] ADD CONSTRAINT [FK_T_EPIDEMIOLOGICAL_INVESTIGATION_CARD_T_EPIDEMIOLOGICAL_VACCINATION_INFO_EpidemiologicalInvestigationCard]
FOREIGN KEY([EpidemiologicalInvestigationCard]) REFERENCES [AKUZ].[T_EPIDEMIOLOGICAL_INVESTIGATION_CARD] ([MedicalRecordID])
GO

-- Tables

/***** Object:  Table [AKUZ].[T_MICROBIOLOGICAL_RESEARCH] *****/
CREATE TABLE [AKUZ].[T_MICROBIOLOGICAL_RESEARCH]
(
    [MicrobiologicalResearchID] uniqueidentifier NOT NULL,
    [BiomaterialTakingDate] datetime NOT NULL,
    [EhrRusNbpeonsbp4] int NOT NULL,
    [Result] int NOT NULL,
    [ResultInfo] varchar(255) NULL,
    [CGiEDate] datetime NULL,
    [RCDate] datetime NULL,
    [EpidemiologicalInvestigationCard] uniqueidentifier NOT NULL
)
ON [PRIMARY]
GO

-- Alters

ALTER TABLE [AKUZ].[T_MICROBIOLOGICAL_RESEARCH] ADD CONSTRAINT [PK_T_MICROBIOLOGICAL_RESEARCH]
PRIMARY KEY CLUSTERED ([MicrobiologicalResearchID]) ON [PRIMARY]
GO

ALTER TABLE [AKUZ].[T_MICROBIOLOGICAL_RESEARCH] ADD CONSTRAINT [FK_T_EHR_RUS_NBPEONSBP4_T_MICROBIOLOGICAL_RESEARCH_EhrRusNbpeonsbp4]
FOREIGN KEY([EhrRusNbpeonsbp4]) REFERENCES [EHR].[T_EHR_RUS_NBPEONSBP4] ([EhrRusID])
GO

ALTER TABLE [AKUZ].[T_MICROBIOLOGICAL_RESEARCH] ADD CONSTRAINT [FK_T_EPIDEMIOLOGICAL_INVESTIGATION_CARD_T_MICROBIOLOGICAL_RESEARCH_EpidemiologicalInvestigationCard]
FOREIGN KEY([EpidemiologicalInvestigationCard]) REFERENCES [AKUZ].[T_EPIDEMIOLOGICAL_INVESTIGATION_CARD] ([MedicalRecordID])
GO

-- Tables

/***** Object:  Table [AKUZ].[T_PAST_INFECTIOUS_DISEASE] *****/
CREATE TABLE [AKUZ].[T_PAST_INFECTIOUS_DISEASE]
(
    [PastInfectiousDiseaseID] uniqueidentifier NOT NULL,
    [MkbCode] varchar(255) NULL,
    [Diagnosis] varchar(255) NULL,
    [DiseaseDate] datetime NULL,
    [DoesntRemember] bit NOT NULL,
    [Comment] varchar(255) NULL,
    [EpidemiologicalInvestigationCard] uniqueidentifier NOT NULL
)
ON [PRIMARY]
GO

-- Alters

ALTER TABLE [AKUZ].[T_PAST_INFECTIOUS_DISEASE] ADD CONSTRAINT [PK_T_PAST_INFECTIOUS_DISEASE]
PRIMARY KEY CLUSTERED ([PastInfectiousDiseaseID]) ON [PRIMARY]
GO

ALTER TABLE [AKUZ].[T_PAST_INFECTIOUS_DISEASE] ADD CONSTRAINT [FK_T_EPIDEMIOLOGICAL_INVESTIGATION_CARD_T_PAST_INFECTIOUS_DISEASE_EpidemiologicalInvestigationCard]
FOREIGN KEY([EpidemiologicalInvestigationCard]) REFERENCES [AKUZ].[T_EPIDEMIOLOGICAL_INVESTIGATION_CARD] ([MedicalRecordID])
GO

-- Tables

-- Alters

ALTER TABLE [AKUZ].[T_PREPARE_DATA_HOSPITALISATION] ADD [EmergencyNotificationNumber] int NULL
GO

ALTER TABLE [AKUZ].[T_PREPARE_DATA_HOSPITALISATION] ADD [EmergencyNotificationDate] datetime NULL
GO

ALTER TABLE [AKUZ].[T_PREPARE_DATA_HOSPITALISATION] ADD [EmergencySenderPost] int NULL
GO

ALTER TABLE [AKUZ].[T_PREPARE_DATA_HOSPITALISATION] ADD [EmergencyRecipientPost] varchar(255) NULL
GO

ALTER TABLE [AKUZ].[T_PREPARE_DATA_HOSPITALISATION] ADD [EmergencyDiseaseDate] datetime NULL
GO

ALTER TABLE [AKUZ].[T_PREPARE_DATA_HOSPITALISATION] ADD [EmergencyOutcome] int NULL
GO

ALTER TABLE [AKUZ].[T_PREPARE_DATA_HOSPITALISATION] ADD [EmergencyAdditionalInfo] varchar(255) NULL
GO

ALTER TABLE [AKUZ].[T_PREPARE_DATA_HOSPITALISATION] ADD [SchoolLastVisit] varchar(255) NULL
GO

ALTER TABLE [AKUZ].[T_PREPARE_DATA_HOSPITALISATION] ADD [EpidNumber] varchar(255) NULL
GO

ALTER TABLE [AKUZ].[T_PREPARE_DATA_HOSPITALISATION] ADD [RegNumber] int NULL
GO

ALTER TABLE [AKUZ].[T_PREPARE_DATA_HOSPITALISATION] ADD [UZRN] varchar(255) NULL
GO

ALTER TABLE [AKUZ].[T_PREPARE_DATA_HOSPITALISATION] ADD CONSTRAINT [FK_T_POST_T_PREPARE_DATA_HOSPITALISATION_EmergencySenderPost]
FOREIGN KEY([EmergencySenderPost]) REFERENCES [AKUZ].[T_POST] ([ResourceID])
GO

ALTER TABLE [AKUZ].[T_PREPARE_DATA_HOSPITALISATION] ADD CONSTRAINT [FK_T_EHR_RUS_C43006_T_PREPARE_DATA_HOSPITALISATION_EmergencyOutcome]
FOREIGN KEY([EmergencyOutcome]) REFERENCES [EHR].[T_EHR_RUS_C43006] ([EhrRusID])
GO

