DROP TABLE AKUZ.T_CDA_SECTION_LINKED_DOC_VMP
DROP TABLE AKUZ.T_CDA_DOC_RELATED_DETAIL


/***** Object:  Table [AKUZ].[T_CDA_DOC_RELATED_DETAIL] *****/
CREATE TABLE [AKUZ].[T_CDA_DOC_RELATED_DETAIL]
(
    [RefMisDoc] varchar(255) NOT NULL,
    [DocumentType] uniqueidentifier NOT NULL,
    [DocumentRemark] varchar(255) NULL,
    [DocIssueDate] datetime NOT NULL,
    [DocumentNumber] varchar(255) NOT NULL,
    [RefMisDocExt] varchar(255) NULL,
    [CdaSectionRelatedDoc] uniqueidentifier NULL,
    [CdaDocRelatedDetailID] uniqueidentifier NOT NULL
)
ON [PRIMARY]
GO

-- Alters

ALTER TABLE [AKUZ].[T_CDA_DOC_RELATED_DETAIL] ADD CONSTRAINT [PK_T_CDA_DOC_RELATED_DETAIL]
PRIMARY KEY CLUSTERED ([CdaDocRelatedDetailID]) ON [PRIMARY]
GO

ALTER TABLE [AKUZ].[T_CDA_DOC_RELATED_DETAIL] ADD CONSTRAINT [FK_T_EHR_RUS_SLM365_T_CDA_DOC_RELATED_DETAIL_DocumentType]
FOREIGN KEY([DocumentType]) REFERENCES [EHR].[T_EHR_RUS_SLM365] ([EhrRusID])
GO

ALTER TABLE [AKUZ].[T_CDA_DOC_RELATED_DETAIL] ADD CONSTRAINT [FK_T_CDA_SECTION_T_CDA_DOC_RELATED_DETAIL_CdaSectionRelatedDoc]
FOREIGN KEY([CdaSectionRelatedDoc]) REFERENCES [AKUZ].[T_CDA_SECTION] ([CdaSectionID])
GO

