CREATE TABLE [AKUZ].[T_BIRTH_CERTIFICATE_NEW]
(
    [MedicalRecordID] uniqueidentifier NOT NULL,
    [MotherAddress] uniqueidentifier NULL,
    [DocSeries] varchar(255) NOT NULL,
    [DocumentNumber] varchar(255) NOT NULL,
    [ExecuteDate] datetime NULL,
    [PresenceElectDoc] bit NULL,
    [EhrRus6cm4779hld] uniqueidentifier NOT NULL,
    [MotherFirstName] varchar(255) NULL,
    [MotherLastName] varchar(255) NULL,
    [MotherFathName] varchar(255) NULL,
    [MotherBirthday] datetime NULL,
    [DepartmentCode] varchar(255) NULL,
    [EhrRusJjd6fhfvqc] uniqueidentifier NOT NULL,
    [EhrRusSrml41u2ge] uniqueidentifier NOT NULL,
    [EhrRusNn5meatu5t] uniqueidentifier NOT NULL,
    [OMSPolicy] varchar(255) NULL,
    [BirthCount] int NULL,
    [IssuedBy] varchar(255) NOT NULL,
    [IssueDate] datetime NULL,
    [EhrRusPrk438] uniqueidentifier NULL,
    [FirstContactDate] int NOT NULL,
    [EhrRusAnhco4hvbo] uniqueidentifier NOT NULL,
    [ChildbirthPost] uniqueidentifier NULL,
    [EhrRusNoterddv83] uniqueidentifier NOT NULL,
    [ChildCount] int NOT NULL,
    [EhrRus2pgin0j8k4] uniqueidentifier NOT NULL,
    [TermOfDelivery] int NULL,
    [ChildBirthday] datetime NOT NULL,
    [ChildTimeBirthday] varchar(255) NOT NULL,
    [ChildName] varchar(255) NULL,
    [ChildFamilyname] varchar(255) NOT NULL,
    [ChildSecondName] varchar(255) NULL,
    [ChildCountInFamily] int NOT NULL,
    [ChildCountInDelivery] int NOT NULL,
    [EhrRusPrk438Child] uniqueidentifier NOT NULL,
    [BirthMass] int NOT NULL,
    [Sex] int NOT NULL,
    [BirthHeight] int NOT NULL,
    [PatientAddress] uniqueidentifier NULL,
    [SNILS] varchar(255) NULL,
    [EhrRus7c1skgluah] uniqueidentifier NOT NULL,
    [ReceivingDate] datetime NOT NULL,
    [LicenseDate] datetime NOT NULL,
    [LicenseNumber] varchar(255) NULL,
    [RepublicRegion] varchar(255) NULL,
    [Rajon] varchar(255) NULL,
    [City] varchar(255) NULL,
    [IsMother] bit NULL,
    [NameRec] varchar(255) NULL,
    [SurnameRec] varchar(255) NULL,
    [PatronymicRec] varchar(255) NULL,
    [EhrRusNn5meatu5tRec] uniqueidentifier NULL,
    [RecDocSeries] varchar(255) NOT NULL,
    [RecDocNumber] varchar(255) NOT NULL,
    [RecIssue] varchar(255) NULL,
    [RecIssueDate] datetime NULL,
    [MotherSeries] varchar(255) NOT NULL,
    [MotherNumber] varchar(255) NOT NULL,
    [RecDepartmentCode] varchar(255) NULL
)
ON [PRIMARY]
GO

-- Alters

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

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

ALTER TABLE [AKUZ].[T_BIRTH_CERTIFICATE_NEW] ADD CONSTRAINT [FK_T_PATIENT_ADDRESS_T_BIRTH_CERTIFICATE_NEW_MotherAddress]
FOREIGN KEY([MotherAddress]) REFERENCES [AKUZ].[T_PATIENT_ADDRESS] ([AddressID])
GO

ALTER TABLE [AKUZ].[T_BIRTH_CERTIFICATE_NEW] ADD CONSTRAINT [FK_T_EHR_RUS_T_BIRTH_CERTIFICATE_NEW_EhrRus6cm4779hld]
FOREIGN KEY([EhrRus6cm4779hld]) REFERENCES [EHR].[T_EHR_RUS] ([EhrRusID])
GO

ALTER TABLE [AKUZ].[T_BIRTH_CERTIFICATE_NEW] ADD CONSTRAINT [FK_T_EHR_RUS_T_BIRTH_CERTIFICATE_NEW_EhrRusJjd6fhfvqc]
FOREIGN KEY([EhrRusJjd6fhfvqc]) REFERENCES [EHR].[T_EHR_RUS] ([EhrRusID])
GO

ALTER TABLE [AKUZ].[T_BIRTH_CERTIFICATE_NEW] ADD CONSTRAINT [FK_T_EHR_RUS_SRML41U2GE_T_BIRTH_CERTIFICATE_NEW_EhrRusSrml41u2ge]
FOREIGN KEY([EhrRusSrml41u2ge]) REFERENCES [EHR].[T_EHR_RUS_SRML41U2GE] ([EhrRusID])
GO

ALTER TABLE [AKUZ].[T_BIRTH_CERTIFICATE_NEW] ADD CONSTRAINT [FK_T_EHR_RUS_NN5MEATU5T_T_BIRTH_CERTIFICATE_NEW_EhrRusNn5meatu5t]
FOREIGN KEY([EhrRusNn5meatu5t]) REFERENCES [EHR].[T_EHR_RUS_NN5MEATU5T] ([EhrRusID])
GO

ALTER TABLE [AKUZ].[T_BIRTH_CERTIFICATE_NEW] ADD CONSTRAINT [FK_T_EHR_RUS_T_BIRTH_CERTIFICATE_NEW_EhrRusPrk438]
FOREIGN KEY([EhrRusPrk438]) REFERENCES [EHR].[T_EHR_RUS] ([EhrRusID])
GO

ALTER TABLE [AKUZ].[T_BIRTH_CERTIFICATE_NEW] ADD CONSTRAINT [FK_T_EHR_RUS_ANHCO4HVBO_T_BIRTH_CERTIFICATE_NEW_EhrRusAnhco4hvbo]
FOREIGN KEY([EhrRusAnhco4hvbo]) REFERENCES [EHR].[T_EHR_RUS_ANHCO4HVBO] ([EhrRusID])
GO

ALTER TABLE [AKUZ].[T_BIRTH_CERTIFICATE_NEW] ADD CONSTRAINT [FK_T_POST_T_BIRTH_CERTIFICATE_NEW_ChildbirthPost]
FOREIGN KEY([ChildbirthPost]) REFERENCES [AKUZ].[T_POST] ([ResourceID])
GO

ALTER TABLE [AKUZ].[T_BIRTH_CERTIFICATE_NEW] ADD CONSTRAINT [FK_T_EHR_RUS_T_BIRTH_CERTIFICATE_NEW_EhrRusNoterddv83]
FOREIGN KEY([EhrRusNoterddv83]) REFERENCES [EHR].[T_EHR_RUS] ([EhrRusID])
GO

ALTER TABLE [AKUZ].[T_BIRTH_CERTIFICATE_NEW] ADD CONSTRAINT [FK_T_EHR_RUS_T_BIRTH_CERTIFICATE_NEW_EhrRus2pgin0j8k4]
FOREIGN KEY([EhrRus2pgin0j8k4]) REFERENCES [EHR].[T_EHR_RUS] ([EhrRusID])
GO

ALTER TABLE [AKUZ].[T_BIRTH_CERTIFICATE_NEW] ADD CONSTRAINT [FK_T_EHR_RUS_T_BIRTH_CERTIFICATE_NEW_EhrRusPrk438Child]
FOREIGN KEY([EhrRusPrk438Child]) REFERENCES [EHR].[T_EHR_RUS] ([EhrRusID])
GO

ALTER TABLE [AKUZ].[T_BIRTH_CERTIFICATE_NEW] ADD CONSTRAINT [FK_T_ENUMS_T_BIRTH_CERTIFICATE_NEW_Sex]
FOREIGN KEY([Sex]) REFERENCES [VCLib].[T_ENUMS] ([EnumID])
GO

ALTER TABLE [AKUZ].[T_BIRTH_CERTIFICATE_NEW] ADD CONSTRAINT [FK_T_PATIENT_ADDRESS_T_BIRTH_CERTIFICATE_NEW_PatientAddress]
FOREIGN KEY([PatientAddress]) REFERENCES [AKUZ].[T_PATIENT_ADDRESS] ([AddressID])
GO

ALTER TABLE [AKUZ].[T_BIRTH_CERTIFICATE_NEW] ADD CONSTRAINT [FK_T_EHR_RUS_T_BIRTH_CERTIFICATE_NEW_EhrRus7c1skgluah]
FOREIGN KEY([EhrRus7c1skgluah]) REFERENCES [EHR].[T_EHR_RUS] ([EhrRusID])
GO

ALTER TABLE [AKUZ].[T_BIRTH_CERTIFICATE_NEW] ADD CONSTRAINT [FK_T_EHR_RUS_NN5MEATU5T_T_BIRTH_CERTIFICATE_NEW_EhrRusNn5meatu5tRec]
FOREIGN KEY([EhrRusNn5meatu5tRec]) REFERENCES [EHR].[T_EHR_RUS_NN5MEATU5T] ([EhrRusID])
GO