-- Tables

/***** Object:  Table [AKUZ].[T_PREGNANT_HOSPITALIZATION_INFO] *****/
CREATE TABLE [AKUZ].[T_PREGNANT_HOSPITALIZATION_INFO]
(
    [PregnantHospitalizationInfoID] uniqueidentifier NOT NULL,
    [DateBegin] datetime NOT NULL,
    [DateEnd] datetime NULL,
    [HospitalizationType] int NOT NULL,
    [EhrRusMdr308] uniqueidentifier NOT NULL,
    [Diagnosis] varchar(255) NULL,
    [PregnantDispanserisation] uniqueidentifier NOT NULL
)
ON [PRIMARY]
GO

/***** Object:  Table [AKUZ].[T_PREVIOUS_PREGNANCIES_LINK_COMPLICATION] *****/
CREATE TABLE [AKUZ].[T_PREVIOUS_PREGNANCIES_LINK_COMPLICATION]
(
    [PreviousPregnanciesLinkComplicationID] uniqueidentifier NOT NULL,
    [PreviousPregnanciesInformation] uniqueidentifier NOT NULL,
    [MKB] varchar(255) NOT NULL,
    [Diagnosis] varchar(255) NOT NULL,
    [Users] uniqueidentifier NULL,
    [RecordDate] datetime NULL
)
ON [PRIMARY]
GO

/***** Object:  Table [AKUZ].[T_PREVIOUS_PREGNANICES_NEWBORN_INFORMATION] *****/
CREATE TABLE [AKUZ].[T_PREVIOUS_PREGNANICES_NEWBORN_INFORMATION]
(
    [PreviousPregnanicesNewbornInformationID] uniqueidentifier NOT NULL,
    [BornAlive] bit NOT NULL,
    [Sex] int NOT NULL,
    [Height] int NOT NULL,
    [Weight] int NOT NULL,
    [PreviousPregnanciesInformation] uniqueidentifier NOT NULL,
    [Users] uniqueidentifier NULL,
    [RecordDate] datetime NULL
)
ON [PRIMARY]
GO

-- Alters

ALTER TABLE [AKUZ].[T_PREGNANT_HOSPITALIZATION_INFO] ADD CONSTRAINT [PK_T_PREGNANT_HOSPITALIZATION_INFO]
PRIMARY KEY CLUSTERED ([PregnantHospitalizationInfoID]) ON [PRIMARY]
GO

ALTER TABLE [AKUZ].[T_PREGNANT_HOSPITALIZATION_INFO] ADD CONSTRAINT [FK_T_EHR_RUS_MDR308_T_PREGNANT_HOSPITALIZATION_INFO_EhrRusMdr308]
FOREIGN KEY([EhrRusMdr308]) REFERENCES [EHR].[T_EHR_RUS_MDR308] ([EhrRusID])
GO

ALTER TABLE [AKUZ].[T_PREGNANT_HOSPITALIZATION_INFO] ADD CONSTRAINT [FK_T_PREGNANT_DISPANSERISATION_T_PREGNANT_HOSPITALIZATION_INFO_PregnantDispanserisation]
FOREIGN KEY([PregnantDispanserisation]) REFERENCES [AKUZ].[T_PREGNANT_DISPANSERISATION] ([MedicalRecordID])
GO

ALTER TABLE [AKUZ].[T_PREVIOUS_PREGNANCIES_LINK_COMPLICATION] ADD CONSTRAINT [PK_T_PREVIOUS_PREGNANCIES_LINK_COMPLICATION]
PRIMARY KEY CLUSTERED ([PreviousPregnanciesLinkComplicationID]) ON [PRIMARY]
GO

ALTER TABLE [AKUZ].[T_PREVIOUS_PREGNANCIES_LINK_COMPLICATION] ADD CONSTRAINT [FK_T_PREVIOUS_PREGNANCIES_INFORMATION_T_PREVIOUS_PREGNANCIES_LINK_COMPLICATION_PreviousPregnanciesInformation]
FOREIGN KEY([PreviousPregnanciesInformation]) REFERENCES [AKUZ].[T_PREVIOUS_PREGNANCIES_INFORMATION] ([PreviousPregnanciesInformationID])
GO

ALTER TABLE [AKUZ].[T_PREVIOUS_PREGNANCIES_LINK_COMPLICATION] ADD CONSTRAINT [FK_T_USERS_T_PREVIOUS_PREGNANCIES_LINK_COMPLICATION_Users]
FOREIGN KEY([Users]) REFERENCES [AKUZ].[T_USERS] ([UserID])
GO

ALTER TABLE [AKUZ].[T_PREVIOUS_PREGNANICES_NEWBORN_INFORMATION] ADD CONSTRAINT [PK_T_PREVIOUS_PREGNANICES_NEWBORN_INFORMATION]
PRIMARY KEY CLUSTERED ([PreviousPregnanicesNewbornInformationID]) ON [PRIMARY]
GO

ALTER TABLE [AKUZ].[T_PREVIOUS_PREGNANICES_NEWBORN_INFORMATION] ADD CONSTRAINT [FK_T_PREVIOUS_PREGNANCIES_INFORMATION_T_PREVIOUS_PREGNANICES_NEWBORN_INFORMATION_PreviousPregnanciesInformation]
FOREIGN KEY([PreviousPregnanciesInformation]) REFERENCES [AKUZ].[T_PREVIOUS_PREGNANCIES_INFORMATION] ([PreviousPregnanciesInformationID])
GO

ALTER TABLE [AKUZ].[T_PREVIOUS_PREGNANICES_NEWBORN_INFORMATION] ADD CONSTRAINT [FK_T_USERS_T_PREVIOUS_PREGNANICES_NEWBORN_INFORMATION_Users]
FOREIGN KEY([Users]) REFERENCES [AKUZ].[T_USERS] ([UserID])
GO


