CREATE TABLE [AKUZ].[T_CDA_SECTION_SPECIMENS_CYT_EXAM_ELEMENT]
(
    [CdaSectionSpecimensCytExamElementID] uniqueidentifier NOT NULL,
    [MaterialCount] decimal(31, 10) NULL,
    [EhrRusS0JLHGTLBJ] int NULL,
    [MaterialDesc] varchar(1000) NOT NULL,
    [EhrRus72QGP117QF] int NULL,
    [EhrRusNbpeonsbp4] int NULL,
    [CdaSectionSpecimensCytExam] uniqueidentifier NOT NULL
)
ON [PRIMARY]
GO

ALTER TABLE [AKUZ].[T_CDA_SECTION_SPECIMENS_CYT_EXAM_ELEMENT] ADD CONSTRAINT [PK_T_CDA_SECTION_SPECIMENS_CYT_EXAM_ELEMENT]
PRIMARY KEY CLUSTERED ([CdaSectionSpecimensCytExamElementID]) ON [PRIMARY]
GO
ALTER TABLE [AKUZ].[T_CDA_SECTION_SPECIMENS_CYT_EXAM_ELEMENT] ADD CONSTRAINT [FK_T_EHR_RUS_S0JLHGTLBJ_T_CDA_SECTION_SPECIMENS_CYT_EXAM_ELEMENT_EhrRusS0JLHGTLBJ]
FOREIGN KEY([EhrRusS0JLHGTLBJ]) REFERENCES [EHR].[T_EHR_RUS_S0JLHGTLBJ] ([EhrRusID])
GO
ALTER TABLE [AKUZ].[T_CDA_SECTION_SPECIMENS_CYT_EXAM_ELEMENT] ADD CONSTRAINT [FK_T_EHR_RUS_72QGP117QF_T_CDA_SECTION_SPECIMENS_CYT_EXAM_ELEMENT_EhrRus72QGP117QF]
FOREIGN KEY([EhrRus72QGP117QF]) REFERENCES [EHR].[T_EHR_RUS_72QGP117QF] ([EhrRusID])
GO
ALTER TABLE [AKUZ].[T_CDA_SECTION_SPECIMENS_CYT_EXAM_ELEMENT] ADD CONSTRAINT [FK_T_EHR_RUS_NBPEONSBP4_T_CDA_SECTION_SPECIMENS_CYT_EXAM_ELEMENT_EhrRusNbpeonsbp4]
FOREIGN KEY([EhrRusNbpeonsbp4]) REFERENCES [EHR].[T_EHR_RUS_NBPEONSBP4] ([EhrRusID])
GO
ALTER TABLE [AKUZ].[T_CDA_SECTION_SPECIMENS_CYT_EXAM_ELEMENT] ADD CONSTRAINT [FK_T_CDA_SECTION_SPECIMENS_CYT_EXAM_T_CDA_SECTION_SPECIMENS_CYT_EXAM_ELEMENT_CdaSectionSpecimensCytExam]
FOREIGN KEY([CdaSectionSpecimensCytExam]) REFERENCES [AKUZ].[T_CDA_SECTION_SPECIMENS_CYT_EXAM] ([CdaSectionSpecimensCytExamID])
GO

insert into akuz.T_CDA_SECTION_SPECIMENS_CYT_EXAM_ELEMENT
(
	CdaSectionSpecimensCytExamElementID,
	MaterialCount,
	EhrRusS0JLHGTLBJ, 
	MaterialDesc, 
	EhrRusNbpeonsbp4, 
	CdaSectionSpecimensCytExam
)
select
	newid(), 
	cert.MaterialCount, 
	cert.EhrRusS0JLHGTLBJ, 
	cert.MaterialDesc, 
	cert.EhrRusNbpeonsbp4, 
	cert.CdaSectionSpecimensCytExamID
from akuz.t_CDA_SECTION_SPECIMENS_CYT_EXAM cert
GO

ALTER TABLE [AKUZ].[T_CDA_SECTION_SPECIMENS_CYT_EXAM] DROP CONSTRAINT [FK_T_EHR_RUS_S0JLHGTLBJ_T_CDA_SECTION_SPECIMENS_CYT_EXAM_EhrRusS0JLHGTLBJ]
GO
ALTER TABLE [AKUZ].[T_CDA_SECTION_SPECIMENS_CYT_EXAM] DROP CONSTRAINT [FK_T_EHR_RUS_NBPEONSBP4_T_CDA_SECTION_SPECIMENS_CYT_EXAM_EhrRusNbpeonsbp4]
GO
exec dbo.sp_AlterDropColumn '[AKUZ].[T_CDA_SECTION_SPECIMENS_CYT_EXAM]' , 'MaterialCount', 0
GO
exec dbo.sp_AlterDropColumn '[AKUZ].[T_CDA_SECTION_SPECIMENS_CYT_EXAM]' , 'EhrRusS0JLHGTLBJ', 0
GO
exec dbo.sp_AlterDropColumn '[AKUZ].[T_CDA_SECTION_SPECIMENS_CYT_EXAM]' , 'MaterialDesc', 0
GO
exec dbo.sp_AlterDropColumn '[AKUZ].[T_CDA_SECTION_SPECIMENS_CYT_EXAM]' , 'EhrRusNbpeonsbp4', 0
GO

ALTER TABLE [AKUZ].[T_CDA_SECTION_DOCINFO_HEIGHTWORK] DROP CONSTRAINT [FK_T_EHR_RUS_PRP365_T_CDA_SECTION_DOCINFO_HEIGHTWORK_EhrRusPrp365]
GO
exec dbo.sp_AlterDropColumn '[AKUZ].[T_CDA_SECTION_DOCINFO_HEIGHTWORK]' , 'EhrRusPrp365', 1, 'int NULL'
GO
ALTER TABLE [AKUZ].[T_CDA_SECTION_DOCINFO_HEIGHTWORK] ADD CONSTRAINT [FK_T_EHR_RUS_PRP365_T_CDA_SECTION_DOCINFO_HEIGHTWORK_EhrRusPrp365]
FOREIGN KEY([EhrRusPrp365]) REFERENCES [EHR].[T_EHR_RUS_PRP365] ([EhrRusID])
GO