-- Tables

/***** Object:  Table [EHR].[T_EHR_RUS_Professionalnie_zabolevanija] *****/
IF OBJECT_ID('EHR.T_EHR_RUS_Professionalnie_zabolevanija', 'U') IS NULL
CREATE TABLE [EHR].[T_EHR_RUS_Professionalnie_zabolevanija]
(
    [EhrRusID] int NOT NULL,
    [IdEHR] int NOT NULL,
    [NameEHR] varchar(512) NULL,
    [EhrRusRefBooks] int NOT NULL,
    [PidEHR] int NULL,
    [EhrRusTree] int NULL,
    [NUMBER] varchar(15) NULL,
    [DISEASES] varchar(1024) NULL,
    [ICD10_NAME] varchar(256) NULL,
    [ICD10] varchar(10) NULL,
    [EXTERNAL_CAUSE] varchar(5) NULL
)
ON [PRIMARY]
GO

-- Alters
IF OBJECT_ID('EHR.T_EHR_RUS_Professionalnie_zabolevanija', 'U') IS NULL
ALTER TABLE [EHR].[T_EHR_RUS_Professionalnie_zabolevanija] ADD CONSTRAINT [PK_T_EHR_RUS_PROFESSIONALNIE_ZABOLEVANIJA]
PRIMARY KEY CLUSTERED ([EhrRusID]) ON [PRIMARY]
GO

IF OBJECT_ID('EHR.T_EHR_RUS_Professionalnie_zabolevanija', 'U') IS NULL
ALTER TABLE [EHR].[T_EHR_RUS_Professionalnie_zabolevanija] ADD CONSTRAINT [FK_T_EHR_RUS_REF_BOOKS_T_EHR_RUS_PROFESSIONALNIE_ZABOLEVANIJA_EhrRusRefBooks]
FOREIGN KEY([EhrRusRefBooks]) REFERENCES [EHR].[T_EHR_RUS_REF_BOOKS] ([EhrRusRefBooksID])
GO

IF OBJECT_ID('EHR.T_EHR_RUS_Professionalnie_zabolevanija', 'U') IS NULL
ALTER TABLE [EHR].[T_EHR_RUS_Professionalnie_zabolevanija] ADD CONSTRAINT [FK_T_EHR_RUS_PROFESSIONALNIE_ZABOLEVANIJA_T_EHR_RUS_PROFESSIONALNIE_ZABOLEVANIJA_EhrRusTree]
FOREIGN KEY([EhrRusTree]) REFERENCES [EHR].[T_EHR_RUS_Professionalnie_zabolevanija] ([EhrRusID])
GO
