-- Tables

/***** Object:  Table [AKUZ].[T_CHILDBIRTH_LINK_COMPLICATION] *****/
CREATE TABLE [AKUZ].[T_CHILDBIRTH_LINK_COMPLICATION]
(
    [ChildbirthLinkComplicationID] uniqueidentifier NOT NULL,
    [ObstetricHospitalStage] uniqueidentifier NULL,
    [EhrRusAjc73fcbn6] uniqueidentifier NOT NULL
)
ON [PRIMARY]
GO

-- Alters

ALTER TABLE [AKUZ].[T_CHILDBIRTH_LINK_COMPLICATION] ADD CONSTRAINT [PK_T_CHILDBIRTH_LINK_COMPLICATION]
PRIMARY KEY CLUSTERED ([ChildbirthLinkComplicationID]) ON [PRIMARY]
GO

ALTER TABLE [AKUZ].[T_CHILDBIRTH_LINK_COMPLICATION] ADD CONSTRAINT [FK_T_OBSTETRIC_HOSPITAL_STAGE_T_CHILDBIRTH_LINK_COMPLICATION_ObstetricHospitalStage]
FOREIGN KEY([ObstetricHospitalStage]) REFERENCES [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ([ObstetricHospitalStageID])
GO

ALTER TABLE [AKUZ].[T_CHILDBIRTH_LINK_COMPLICATION] ADD CONSTRAINT [FK_T_EHR_RUS_AJC73FCBN6_T_CHILDBIRTH_LINK_COMPLICATION_EhrRusAjc73fcbn6]
FOREIGN KEY([EhrRusAjc73fcbn6]) REFERENCES [EHR].[T_EHR_RUS_AJC73FCBN6] ([EhrRusID])
GO



ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [Address]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [RegistrationAddress]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [RegistrationAddressEquals]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [PainkillerType]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [MultiplePregnancy]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [MotherDischargedOnDaysAfterBirth]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [Peculiarities]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [PartnerChildbirth]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [PregnancyNumber]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [PainkillerApplied]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [MotherConditionAtDischarging]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [GestationalAge]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [MotherPostpartumStage]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [PregnancyType]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [FIO]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [PainkillerEffect]
GO


ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [Birthday]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [ChildbirthDate]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] DROP COLUMN [ConditionScale]
GO


ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] DROP COLUMN [ChildbirthDate]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] DROP CONSTRAINT [FK_T_EHR_RUS_MDR308_T_OBSTETRIC_HOSPITAL_STAGE_EhrRusMdr308]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] DROP COLUMN [EhrRusMdr308]
GO



ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [ChildbirthNumber] int NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [PregnancyType] int NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [LaborActivityStart] datetime NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [AnhydrousGapStart] datetime NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [FullOpening] datetime NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [PushingPeriodStart] datetime NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [AfterbirthTime] datetime NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [TotalBloodLoss] int NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [LaborDurationTotal] datetime NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [LaborDuration1] datetime NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [LaborDuration2] datetime NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [LaborDuration3] datetime NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [AnhydrousPeriod] datetime NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [AfterbirthExaminedPost] varbinary(max) NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [FinalMkb] varchar(255) NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [FinalDiagnosis] varchar(255) NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [RecordDate] datetime NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [Users] uniqueidentifier NULL
GO

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

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [Post] varbinary(max) NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_HOSPITAL_STAGE] ADD [WaterDescription] varchar(255) NULL
GO


ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] ADD [LpuMain] uniqueidentifier NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] ADD [ChildNumber] int NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] ADD CONSTRAINT [FK_T_LPU_MAIN_T_OBSTETRIC_NEWBORN_INFORMATION_LpuMain]
FOREIGN KEY([LpuMain]) REFERENCES [AKUZ].[T_LPU_MAIN] ([LpuID])
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] ADD [ExtraConditionAtBirth] varchar(255) NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] ADD [ConditionAtDischarging] varchar(255) NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] ADD [Patient] uniqueidentifier NULL
GO

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

DELETE FROM [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION]
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] ADD [ChildRegistration] uniqueidentifier NULL
GO
UPDATE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] SET [ChildRegistration] = '00000000-0000-0000-0000-000000000000'
GO
ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] ALTER COLUMN [ChildRegistration] uniqueidentifier NOT NULL
GO

ALTER TABLE [AKUZ].[T_OBSTETRIC_NEWBORN_INFORMATION] ADD CONSTRAINT [FK_T_CHILD_REGISTRATION_T_OBSTETRIC_NEWBORN_INFORMATION_ChildRegistration]
FOREIGN KEY([ChildRegistration]) REFERENCES [AKUZ].[T_CHILD_REGISTRATION] ([MovementID])
GO


ALTER TABLE [AKUZ].[T_CHILD_REGISTRATION] ADD [MBCNumber] varchar(255) NULL
GO

