
PRINT N'Dropping Default Constraint unnamed constraint on [sFeedback].[tFeedbackTemplate]...';


GO
ALTER TABLE [sFeedback].[tFeedbackTemplate] DROP CONSTRAINT [DF__tFeedback__IsAno__6753C011];


GO
PRINT N'Dropping Default Constraint unnamed constraint on [sFeedback].[tFeedbackTemplate]...';


GO
ALTER TABLE [sFeedback].[tFeedbackTemplate] DROP CONSTRAINT [DF__tFeedback__IsObs__6847E44A];


GO
PRINT N'Dropping Default Constraint unnamed constraint on [sFeedback].[tFeedbackTemplateDetail]...';


GO
ALTER TABLE [sFeedback].[tFeedbackTemplateDetail] DROP CONSTRAINT [DF__tFeedback__IsReq__693C0883];


GO
PRINT N'Dropping Default Constraint unnamed constraint on [sFeedback].[tFeedbackTemplateDetail]...';


GO
ALTER TABLE [sFeedback].[tFeedbackTemplateDetail] DROP CONSTRAINT [DF__tFeedback__IsObs__6A302CBC];


GO
PRINT N'Dropping Default Constraint unnamed constraint on [sWellness].[tAssignedActivity]...';


GO
ALTER TABLE [sWellness].[tAssignedActivity] DROP CONSTRAINT [DF__tAssigned__Statu__6E00BDA0];


GO
PRINT N'Dropping Default Constraint unnamed constraint on [sWellness].[tAssignedActivity]...';


GO
ALTER TABLE [sWellness].[tAssignedActivity] DROP CONSTRAINT [DF__tAssigned__Remin__6D0C9967];


GO
PRINT N'Dropping Default Constraint unnamed constraint on [sWellness].[tMHIScore_History]...';


GO
ALTER TABLE [sWellness].[tMHIScore_History] DROP CONSTRAINT [DF__tMHIScore__Actio__6EF4E1D9];


GO
PRINT N'Dropping Default Constraint unnamed constraint on [sWellness].[tWellnessActivityCategoryMaster]...';


GO
ALTER TABLE [sWellness].[tWellnessActivityCategoryMaster] DROP CONSTRAINT [DF__tWellness__IsObs__6FE90612];


GO
PRINT N'Dropping Default Constraint unnamed constraint on [sWellness].[tWellnessVisitPurposeMaster]...';


GO
ALTER TABLE [sWellness].[tWellnessVisitPurposeMaster] DROP CONSTRAINT [DF__tWellness__IsObs__70DD2A4B];

GO

PRINT N'Creating User-Defined Table Type [sFeedback].[udt_FeedbackTemplateQuestions]...';

GO
CREATE TYPE [sFeedback].[udt_FeedbackTemplateQuestions] AS TABLE (
    [Id]           INT             NULL,
    [QuestionText] NVARCHAR (2000) NULL,
    [AnswerType]   SMALLINT        NULL,
    [IsRequired]   BIT             NULL,
    [OrderIndex]   SMALLINT        NULL,
    [IsObsolete]   BIT             NULL);


GO
PRINT N'Creating User-Defined Table Type [sWellness].[udt_MHIBulkCategoryImport]...';


GO
CREATE TYPE [sWellness].[udt_MHIBulkCategoryImport] AS TABLE (
    [EmployeeCode]      NVARCHAR (50) NOT NULL,
    [HBA1CCategory]     SMALLINT      NULL,
    [LDLCategory]       SMALLINT      NULL,
    [BMICategory]       SMALLINT      NULL,
    [BPCategory]        SMALLINT      NULL,
    [StressCategory]    SMALLINT      NULL,
    [LifestyleCategory] SMALLINT      NULL);


GO
PRINT N'Creating User-Defined Table Type [sWellness].[udt_MHIScoreUpdateThroughtSurveyBulk]...';


GO
CREATE TYPE [sWellness].[udt_MHIScoreUpdateThroughtSurveyBulk] AS TABLE (
    [EmployeeCode] NVARCHAR (50)   NOT NULL,
    [Stress]       NUMERIC (10, 2) NULL,
    [LifeStyle]    NUMERIC (10, 2) NULL);


GO
PRINT N'Altering Table [sExamination].[tArchieveExamination]...';


GO
ALTER TABLE [sExamination].[tArchieveExamination]
    ADD [ContractorId] INT NULL;


GO
PRINT N'Altering Table [sExamination].[tEmployeePrescription]...';


GO
ALTER TABLE [sExamination].[tEmployeePrescription]
    ADD [DrugFrequencyPattern] NVARCHAR (200) NULL;


GO
PRINT N'Altering Table [sExamination].[tExamination]...';


GO
ALTER TABLE [sExamination].[tExamination]
    ADD [ContractorId] INT NULL;


GO
PRINT N'Starting rebuilding table [sFeedback].[tFeedbackTemplate]...';


GO
BEGIN TRANSACTION;

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

SET XACT_ABORT ON;

CREATE TABLE [sFeedback].[tmp_ms_xx_tFeedbackTemplate] (
    [Id]                  INT            NOT NULL,
    [OrgId]               SMALLINT       NULL,
    [Name]                NVARCHAR (250) NOT NULL,
    [FeedbackCategoryId]  INT            NULL,
    [FeedbackTypeId]      INT            NULL,
    [FeedbackDescription] NVARCHAR (250) NULL,
    [IsAnonymus]          BIT            CONSTRAINT [DF__tFeedback__IsAno__0C43E8BA] DEFAULT ((0)) NULL,
    [ExpireDuration]      DATETIME       NULL,
    [TrigerDuration]      DATETIME       NULL,
    [Priority]            TINYINT        NULL,
    [CanAssign]           BIT            CONSTRAINT [DF_tFeedbackTemplate_CanAssign] DEFAULT ((0)) NULL,
    [IsObsolete]          BIT            CONSTRAINT [DF__tFeedback__IsObs__0D380CF3] DEFAULT ((0)) NULL,
    [CreatedUserId]       BIGINT         NULL,
    [CreatedDatetime]     DATETIME       NULL,
    [UpdatedUserId]       BIGINT         NULL,
    [UpdatedDatetime]     DATETIME       NULL,
    CONSTRAINT [tmp_ms_xx_constraint_PK__tFeedbac__3214EC0742C057EC1] PRIMARY KEY CLUSTERED ([Id] ASC)
);

IF EXISTS (SELECT TOP 1 1 
           FROM   [sFeedback].[tFeedbackTemplate])
    BEGIN
        INSERT INTO [sFeedback].[tmp_ms_xx_tFeedbackTemplate] ([Id], [OrgId], [Name], [FeedbackCategoryId], [FeedbackTypeId], [FeedbackDescription], [IsAnonymus], [IsObsolete], [CreatedUserId], [CreatedDatetime], [UpdatedUserId], [UpdatedDatetime], [ExpireDuration], [TrigerDuration], [Priority])
        SELECT   [Id],
                 [OrgId],
                 [Name],
                 [FeedbackCategoryId],
                 [FeedbackTypeId],
                 [FeedbackDescription],
                 [IsAnonymus],
                 [IsObsolete],
                 [CreatedUserId],
                 [CreatedDatetime],
                 [UpdatedUserId],
                 [UpdatedDatetime],
                 [ExpireDuration],
                 [TrigerDuration],
                 [Priority]
        FROM     [sFeedback].[tFeedbackTemplate]
        ORDER BY [Id] ASC;
    END

DROP TABLE [sFeedback].[tFeedbackTemplate];

EXECUTE sp_rename N'[sFeedback].[tmp_ms_xx_tFeedbackTemplate]', N'tFeedbackTemplate';

EXECUTE sp_rename N'[sFeedback].[tmp_ms_xx_constraint_PK__tFeedbac__3214EC0742C057EC1]', N'PK__tFeedbac__3214EC0742C057EC', N'OBJECT';

COMMIT TRANSACTION;

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;


GO
PRINT N'Starting rebuilding table [sFeedback].[tFeedbackTemplateDetail]...';


GO
BEGIN TRANSACTION;

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

SET XACT_ABORT ON;

CREATE TABLE [sFeedback].[tmp_ms_xx_tFeedbackTemplateDetail] (
    [Id]                 INT             IDENTITY (1, 1) NOT NULL,
    [FeedbackTemplateId] INT             NULL,
    [QuestionText]       NVARCHAR (4000) NULL,
    [AnswerType]         TINYINT         NULL,
    [AnswerValues]       NVARCHAR (MAX)  CONSTRAINT [DF__tFeedback__Answe__7F5EEEE8] DEFAULT ('') NULL,
    [IsRequired]         BIT             CONSTRAINT [DF__tFeedback__IsReq__1014799E] DEFAULT ((0)) NULL,
    [OrderIndex]         SMALLINT        NULL,
    [IsObsolete]         BIT             CONSTRAINT [DF__tFeedback__IsObs__11089DD7] DEFAULT ((0)) NULL,
    [CreatedUserId]      BIGINT          NULL,
    [CreatedDatetime]    DATETIME        NULL,
    [UpdatedUserId]      BIGINT          NULL,
    [UpdatedDatetime]    DATETIME        NULL,
    CONSTRAINT [tmp_ms_xx_constraint_PK__tFeedbac__3214EC074B87B5EC1] PRIMARY KEY CLUSTERED ([Id] ASC)
);

IF EXISTS (SELECT TOP 1 1 
           FROM   [sFeedback].[tFeedbackTemplateDetail])
    BEGIN
        SET IDENTITY_INSERT [sFeedback].[tmp_ms_xx_tFeedbackTemplateDetail] ON;
        INSERT INTO [sFeedback].[tmp_ms_xx_tFeedbackTemplateDetail] ([Id], [FeedbackTemplateId], [QuestionText], [AnswerType], [IsRequired], [OrderIndex], [IsObsolete], [CreatedUserId], [CreatedDatetime], [UpdatedUserId], [UpdatedDatetime])
        SELECT   [Id],
                 [FeedbackTemplateId],
                 [QuestionText],
                 [AnswerType],
                 [IsRequired],
                 [OrderIndex],
                 [IsObsolete],
                 [CreatedUserId],
                 [CreatedDatetime],
                 [UpdatedUserId],
                 [UpdatedDatetime]
        FROM     [sFeedback].[tFeedbackTemplateDetail]
        ORDER BY [Id] ASC;
        SET IDENTITY_INSERT [sFeedback].[tmp_ms_xx_tFeedbackTemplateDetail] OFF;
    END

DROP TABLE [sFeedback].[tFeedbackTemplateDetail];

EXECUTE sp_rename N'[sFeedback].[tmp_ms_xx_tFeedbackTemplateDetail]', N'tFeedbackTemplateDetail';

EXECUTE sp_rename N'[sFeedback].[tmp_ms_xx_constraint_PK__tFeedbac__3214EC074B87B5EC1]', N'PK__tFeedbac__3214EC074B87B5EC', N'OBJECT';

COMMIT TRANSACTION;

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;


GO
PRINT N'Starting rebuilding table [sHrm].[tWebApiImportMissingEmployee]...';


GO
BEGIN TRANSACTION;

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

SET XACT_ABORT ON;

CREATE TABLE [sHrm].[tmp_ms_xx_tWebApiImportMissingEmployee] (
    [Id]                     INT                                                            IDENTITY (1, 1) NOT NULL,
    [PersonalNumber]         NVARCHAR (20) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)')  NULL,
    [EmployementStatus]      NVARCHAR (10)                                                  NULL,
    [FirstName]              NVARCHAR (100) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)') NULL,
    [MiddleName]             NVARCHAR (100) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)') NULL,
    [LastName]               NVARCHAR (100) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)') NULL,
    [Business]               NVARCHAR (100) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)') NULL,
    [SubBusiness]            NVARCHAR (100)                                                 NULL,
    [CompanyName]            NVARCHAR (100) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)') NULL,
    [DateOfBirth]            NVARCHAR (30) MASKED WITH (FUNCTION = 'default()')             NULL,
    [DateOfJoining]          NVARCHAR (30) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)')  NULL,
    [Designation]            NVARCHAR (100) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)') NULL,
    [Grade]                  NVARCHAR (100) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)') NULL,
    [Location]               NVARCHAR (100)                                                 NULL,
    [Department]             NVARCHAR (100) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)') NULL,
    [BloodGroup]             NVARCHAR (10) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)')  NULL,
    [ReportingManager]       NVARCHAR (300)                                                 NULL,
    [MaritalStatus]          NVARCHAR (20)                                                  NULL,
    [Gender]                 NVARCHAR (20) MASKED WITH (FUNCTION = 'default()')             NULL,
    [Address1]               NVARCHAR (500)                                                 NULL,
    [Address2]               NVARCHAR (500)                                                 NULL,
    [Address3]               NVARCHAR (500)                                                 NULL,
    [City]                   NVARCHAR (200)                                                 NULL,
    [State]                  NVARCHAR (50)                                                  NULL,
    [Country]                NVARCHAR (50)                                                  NULL,
    [CorporateMobileNumber]  NVARCHAR (40) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)')  NULL,
    [CorporateEmailId]       NVARCHAR (100) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)') NULL,
    [DateOfLeaving]          NVARCHAR (20) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)')  NULL,
    [WebApiImportEmployeeId] INT                                                            NULL,
    [IsSuccess]              BIT                                                            NULL,
    [Aadharno]               NVARCHAR (500) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)') NULL,
    [DateofMarriage]         NVARCHAR (500) MASKED WITH (FUNCTION = 'default()')            NULL,
    [GroupDateOfJoining]     NVARCHAR (500) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)') NULL,
    [LocationCode]           NVARCHAR (500)                                                 NULL,
    [PanNo]                  NVARCHAR (500) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)') NULL,
    [PFUANNo]                NVARCHAR (500) MASKED WITH (FUNCTION = 'partial(1, "xxx", 1)') NULL,
    [EmployeeGroup]          NVARCHAR (50)                                                  NULL,
    [CompanyGroup]           NVARCHAR (100)                                                 NULL,
    [WorkerType]             NVARCHAR (20)                                                  NULL,
    [ProcessType]            NVARCHAR (100)                                                 NULL,
    [EmployeeType]           NVARCHAR (200)                                                 NULL,
    [EmployeeSubType]        NVARCHAR (200)                                                 NULL,
    [Company]                NVARCHAR (200)                                                 NULL,
    [Function_]              NVARCHAR (200)                                                 NULL,
    [DepartmentGroup]        NVARCHAR (200)                                                 NULL,
    [SubLocation]            NVARCHAR (500)                                                 NULL,
    [ReportingManagerCode]   NVARCHAR (50)                                                  NULL,
    CONSTRAINT [tmp_ms_xx_constraint_PK_tWebApiImportMissingEmployee1] PRIMARY KEY CLUSTERED ([Id] ASC) WITH (FILLFACTOR = 85)
);

IF EXISTS (SELECT TOP 1 1 
           FROM   [sHrm].[tWebApiImportMissingEmployee])
    BEGIN
        SET IDENTITY_INSERT [sHrm].[tmp_ms_xx_tWebApiImportMissingEmployee] ON;
        INSERT INTO [sHrm].[tmp_ms_xx_tWebApiImportMissingEmployee] ([Id], [PersonalNumber], [EmployementStatus], [FirstName], [MiddleName], [LastName], [Business], [SubBusiness], [CompanyName], [DateOfBirth], [DateOfJoining], [Designation], [Grade], [Location], [Department], [BloodGroup], [ReportingManager], [MaritalStatus], [Gender], [Address1], [Address2], [Address3], [City], [State], [Country], [CorporateMobileNumber], [CorporateEmailId], [DateOfLeaving], [WebApiImportEmployeeId], [IsSuccess], [Aadharno], [DateofMarriage], [GroupDateOfJoining], [LocationCode], [PanNo], [PFUANNo], [EmployeeGroup], [CompanyGroup], [ProcessType], [EmployeeType], [EmployeeSubType], [Company], [Function_], [DepartmentGroup], [SubLocation], [ReportingManagerCode])
        SELECT   [Id],
                 [PersonalNumber],
                 [EmployementStatus],
                 [FirstName],
                 [MiddleName],
                 [LastName],
                 [Business],
                 [SubBusiness],
                 [CompanyName],
                 [DateOfBirth],
                 [DateOfJoining],
                 [Designation],
                 [Grade],
                 [Location],
                 [Department],
                 [BloodGroup],
                 [ReportingManager],
                 [MaritalStatus],
                 [Gender],
                 [Address1],
                 [Address2],
                 [Address3],
                 [City],
                 [State],
                 [Country],
                 [CorporateMobileNumber],
                 [CorporateEmailId],
                 [DateOfLeaving],
                 [WebApiImportEmployeeId],
                 [IsSuccess],
                 [Aadharno],
                 [DateofMarriage],
                 [GroupDateOfJoining],
                 [LocationCode],
                 [PanNo],
                 [PFUANNo],
                 [EmployeeGroup],
                 [CompanyGroup],
                 [ProcessType],
                 [EmployeeType],
                 [EmployeeSubType],
                 [Company],
                 [Function_],
                 [DepartmentGroup],
                 [SubLocation],
                 [ReportingManagerCode]
        FROM     [sHrm].[tWebApiImportMissingEmployee]
        ORDER BY [Id] ASC;
        SET IDENTITY_INSERT [sHrm].[tmp_ms_xx_tWebApiImportMissingEmployee] OFF;
    END

DROP TABLE [sHrm].[tWebApiImportMissingEmployee];

EXECUTE sp_rename N'[sHrm].[tmp_ms_xx_tWebApiImportMissingEmployee]', N'tWebApiImportMissingEmployee';

EXECUTE sp_rename N'[sHrm].[tmp_ms_xx_constraint_PK_tWebApiImportMissingEmployee1]', N'PK_tWebApiImportMissingEmployee', N'OBJECT';

COMMIT TRANSACTION;

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;


GO
PRINT N'Altering Table [sWellness].[tAppointment]...';


GO
ALTER TABLE [sWellness].[tAppointment]
    ADD [MobileNumber] NVARCHAR (100) NULL;


GO
PRINT N'Altering Table [sWellness].[tMHIScore]...';


GO
ALTER TABLE [sWellness].[tMHIScore]
    ADD [LocationId] INT NULL;


GO
PRINT N'Altering Table [sWellness].[tMHIScore_History]...';


GO
ALTER TABLE [sWellness].[tMHIScore_History]
    ADD [LocationId] INT NULL;


GO
PRINT N'Starting rebuilding table [sWellness].[tMHIScoreUpdation]...';


GO
BEGIN TRANSACTION;

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;

SET XACT_ABORT ON;

CREATE TABLE [sWellness].[tmp_ms_xx_tMHIScoreUpdation] (
    [Id]                      INT             IDENTITY (1, 1) NOT NULL,
    [ParticipantSourceTypeId] SMALLINT        NOT NULL,
    [ParticipantSourceId]     BIGINT          NOT NULL,
    [BMI]                     NUMERIC (10, 2) NULL,
    [BMICategory]             NVARCHAR (20)   CONSTRAINT [DF__tMHIScore__BMICa__3EEF6418] DEFAULT (NULL) NULL,
    [HBA1C]                   NUMERIC (10, 2) NULL,
    [HBA1CCategory]           NVARCHAR (20)   CONSTRAINT [DF__tMHIScore__HBA1C__3D071BA6] DEFAULT (NULL) NULL,
    [LDL]                     NUMERIC (10, 2) NULL,
    [LDLCategory]             NVARCHAR (20)   CONSTRAINT [DF__tMHIScore__LDLCa__3DFB3FDF] DEFAULT (NULL) NULL,
    [BPSystolic]              NUMERIC (10, 2) NULL,
    [BPDiastolic]             NUMERIC (10, 2) NULL,
    [BPCategory]              NVARCHAR (20)   CONSTRAINT [DF__tMHIScore__BPCat__3FE38851] DEFAULT (NULL) NULL,
    [Stress]                  NUMERIC (10, 2) NULL,
    [StressCategory]          NVARCHAR (20)   CONSTRAINT [DF__tMHIScore__Stres__40D7AC8A] DEFAULT (NULL) NULL,
    [LifeStyle]               NUMERIC (10, 2) NULL,
    [LifestyleCategory]       NVARCHAR (20)   CONSTRAINT [DF__tMHIScore__Lifes__41CBD0C3] DEFAULT (NULL) NULL,
    [InsertType]              SMALLINT        CONSTRAINT [DF__tMHIScore__Inser__42BFF4FC] DEFAULT ((1)) NULL,
    [CreatedUserId]           BIGINT          NOT NULL,
    [CreatedDateTime]         DATETIME        NOT NULL,
    [UpdatedUserId]           BIGINT          NULL,
    [UpdatedDateTime]         DATETIME        NULL,
    [LocationId]              INT             NULL,
    [LastUpdateType]          SMALLINT        NULL,
    CONSTRAINT [tmp_ms_xx_constraint_PK__tMHIScoreUpdation_Id1] PRIMARY KEY CLUSTERED ([Id] ASC)
);

IF EXISTS (SELECT TOP 1 1 
           FROM   [sWellness].[tMHIScoreUpdation])
    BEGIN
        SET IDENTITY_INSERT [sWellness].[tmp_ms_xx_tMHIScoreUpdation] ON;
        INSERT INTO [sWellness].[tmp_ms_xx_tMHIScoreUpdation] ([Id], [ParticipantSourceTypeId], [ParticipantSourceId], [BMI], [HBA1C], [LDL], [BPSystolic], [BPDiastolic], [Stress], [LifeStyle], [CreatedUserId], [CreatedDateTime], [UpdatedUserId], [UpdatedDateTime])
        SELECT   [Id],
                 [ParticipantSourceTypeId],
                 [ParticipantSourceId],
                 [BMI],
                 [HBA1C],
                 [LDL],
                 [BPSystolic],
                 [BPDiastolic],
                 [Stress],
                 [LifeStyle],
                 [CreatedUserId],
                 [CreatedDateTime],
                 [UpdatedUserId],
                 [UpdatedDateTime]
        FROM     [sWellness].[tMHIScoreUpdation]
        ORDER BY [Id] ASC;
        SET IDENTITY_INSERT [sWellness].[tmp_ms_xx_tMHIScoreUpdation] OFF;
    END

DROP TABLE [sWellness].[tMHIScoreUpdation];

EXECUTE sp_rename N'[sWellness].[tmp_ms_xx_tMHIScoreUpdation]', N'tMHIScoreUpdation';

EXECUTE sp_rename N'[sWellness].[tmp_ms_xx_constraint_PK__tMHIScoreUpdation_Id1]', N'PK__tMHIScoreUpdation_Id', N'OBJECT';

COMMIT TRANSACTION;

SET TRANSACTION ISOLATION LEVEL READ COMMITTED;


GO
PRINT N'Altering Table [sWellness].[tWellnessConsultation]...';


GO
ALTER TABLE [sWellness].[tWellnessConsultation]
    ADD [MobileNumber] NVARCHAR (100) NULL;


GO
PRINT N'Creating Table [sCommon].[tManageDashletSetting]...';


GO
CREATE TABLE [sCommon].[tManageDashletSetting] (
    [Id]            INT            IDENTITY (1, 1) NOT NULL,
    [OrgId]         SMALLINT       NULL,
    [ScreenId]      INT            NULL,
    [UserId]        BIGINT         NULL,
    [DashboardJson] NVARCHAR (MAX) NULL
);


GO
PRINT N'Creating Table [sExamination].[tSetupEmployeeLog]...';


GO
CREATE TABLE [sExamination].[tSetupEmployeeLog] (
    [LogId]                  BIGINT         IDENTITY (1, 1) NOT NULL,
    [SetupEmployeeId]        BIGINT         NULL,
    [SetupId]                INT            NULL,
    [SetupGroupId]           INT            NULL,
    [EmployeeId]             BIGINT         NULL,
    [OrgId]                  INT            NULL,
    [CriteriaGroupId]        INT            NULL,
    [NotDoneRemark]          NVARCHAR (400) NULL,
    [PlannedExaminationDate] DATE           NULL,
    [TargetGroupId]          INT            NULL,
    [CentralDoctorId]        BIGINT         NULL,
    [SiteDoctorId]           BIGINT         NULL,
    [CentralSpocId]          BIGINT         NULL,
    [SiteSpocId]             BIGINT         NULL,
    [ActionDate]             DATETIME       NULL,
    [ActionBy]               BIGINT         NULL,
    PRIMARY KEY CLUSTERED ([LogId] ASC)
);

GO
PRINT N'Creating Default Constraint unnamed constraint on [sExamination].[tSetupEmployeeLog]...';


GO
ALTER TABLE [sExamination].[tSetupEmployeeLog]
    ADD DEFAULT (getdate()) FOR [ActionDate];


GO
PRINT N'Creating Default Constraint [sWellness].[DF__tAssigned__Remin__30614D9F]...';


GO
ALTER TABLE [sWellness].[tAssignedActivity]
    ADD CONSTRAINT [DF__tAssigned__Remin__30614D9F] DEFAULT ((0)) FOR [ReminderEnabled];


GO
PRINT N'Creating Default Constraint [sWellness].[DF__tAssigned__Statu__315571D8]...';


GO
ALTER TABLE [sWellness].[tAssignedActivity]
    ADD CONSTRAINT [DF__tAssigned__Statu__315571D8] DEFAULT ((1)) FOR [Status];


GO
PRINT N'Creating Default Constraint [sWellness].[DF__tMHIScore__Actio__1AAA123C]...';


GO
ALTER TABLE [sWellness].[tMHIScore_History]
    ADD CONSTRAINT [DF__tMHIScore__Actio__1AAA123C] DEFAULT ([scommon].[fgetdate]()) FOR [ActionDateTime];


GO
PRINT N'Creating Default Constraint [sWellness].[DF__tWellness__IsObs__3C080A75]...';


GO
ALTER TABLE [sWellness].[tWellnessActivityCategoryMaster]
    ADD CONSTRAINT [DF__tWellness__IsObs__3C080A75] DEFAULT ((0)) FOR [IsObsolete];


GO
PRINT N'Creating Default Constraint [sWellness].[DF_tWellnessVisitPurposeMaster_IsObsolete]...';


GO
ALTER TABLE [sWellness].[tWellnessVisitPurposeMaster]
    ADD CONSTRAINT [DF_tWellnessVisitPurposeMaster_IsObsolete] DEFAULT ((0)) FOR [IsObsolete];