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


GO
CREATE TYPE [sWellness].[EmployeeTaskTrackTableType] AS TABLE (
    [ConsultationId]         INT NULL,
    [WellnessActivityTaskId] INT NULL,
    [AssignedActivityId]     INT NULL,
    [Status]                 BIT NULL);


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


GO
CREATE TYPE [sWellness].[ProgramParameterTrackTableType] AS TABLE (
    [ProgramParticipantId]  BIGINT         NULL,
    [ProgramParameterId]    INT            NULL,
    [InputId]               TINYINT        NULL,
    [InputDate]             DATE           NULL,
    [ProgramParameterValue] NVARCHAR (500) NULL,
    [CreatedUserId]         BIGINT         NULL);


DROP TABLE [sWellness].[tProgramMaster];

CREATE TABLE [sWellness].[tProgramMaster](
	[Id] [int] NOT NULL,
	[OrgId] [smallint] NOT NULL,
	[Title] [nvarchar](100) NOT NULL,
	[ModeId] [tinyint] NOT NULL,
	[Description] [nvarchar](500) NULL,
	[FromDate] [date] NOT NULL,
	[ToDate] [date] NOT NULL,
	[FromTime] [time](0) NULL,
	[ToTime] [time](0) NULL,
	[CategoryId] [smallint] NOT NULL,
	[MHIIndicatorId] [int] NULL,
	[IsSurveyRequired] [bit] NOT NULL,
	[AssignSurveyId] [int] NULL,
	[ProgramSubTypeId] [int] NOT NULL,
	[IsRegistrationRequired] [bit] NOT NULL,
	[RegisterUptoDatetime] [datetime] NULL,
	[IsObsolete] [bit] NOT NULL,
	[CreatedUserId] [bigint] NOT NULL,
	[CreatedDatetime] [datetime] NOT NULL,
	[UpdatedUserId] [bigint] NULL,
	[UpdatedDatetime] [datetime] NULL,
 CONSTRAINT [PK__tProgram__3214EC074CAFBA93] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO

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


GO
CREATE TYPE [sWellness].[udt_ProgramParameterTableType] AS TABLE (
    [AutoID]            INT     NULL,
    [ParameterTypeId]   TINYINT NULL,
    [ParameterSourceId] BIGINT  NULL,
    [OrderIndex]        INT     NULL);


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


GO
ALTER TABLE [sExamination].[tGeneralTemplateExaminationDetail] ALTER COLUMN [Diagnosis] NVARCHAR (1000) NULL;

ALTER TABLE [sExamination].[tGeneralTemplateExaminationDetail] ALTER COLUMN [Recommendation] NVARCHAR (1000) NULL;


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


GO
ALTER TABLE [sExamination].[tTestRequestDetail] ALTER COLUMN [Diagnosis] NVARCHAR (1000) NULL;

ALTER TABLE [sExamination].[tTestRequestDetail] ALTER COLUMN [Recommendation] NVARCHAR (1000) NULL;


GO
PRINT N'Altering Table [sHospitalization].[tIntimationDetails]...';


GO
ALTER TABLE [sHospitalization].[tIntimationDetails]
    ADD [AssignedDoctorDetails] NVARCHAR (1000) NULL;


GO
PRINT N'Altering Table [sOrderEntry].[tTestParameterDetail]...';


GO
ALTER TABLE [sOrderEntry].[tTestParameterDetail] ALTER COLUMN [Diagnosis] NVARCHAR (1000) NULL;

ALTER TABLE [sOrderEntry].[tTestParameterDetail] ALTER COLUMN [Recommendation] NVARCHAR (1000) NULL;

ALTER TABLE [sOrderEntry].[tTestParameterDetail] ALTER COLUMN [Remark] NVARCHAR (1000) NOT NULL;


GO
PRINT N'Altering Table [sOrderEntry].[tTestParameterMaster]...';


GO
ALTER TABLE [sOrderEntry].[tTestParameterMaster] ALTER COLUMN [Remark] NVARCHAR (1000) NULL;


GO
PRINT N'Altering Table [sSupport].[tHealthSetupIndicator]...';


GO
ALTER TABLE [sSupport].[tHealthSetupIndicator]
    ADD [ColorCode]            NVARCHAR (100) DEFAULT (NULL) NULL,
        [HealthIndicatorLabel] NVARCHAR (200) DEFAULT (NULL) NULL,
        [ProgramId]            INT            DEFAULT ((0)) NULL;


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


GO
ALTER TABLE [sWellness].[tProgramParameterTrack]
    ADD [InputDate] DATE NOT NULL;


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


GO
ALTER TABLE [sWellness].[tWellnessRegistration]
    ADD [LDL]   DECIMAL (5, 2) NULL,
        [HBA1C] DECIMAL (5, 2) NULL;


GO
PRINT N'Creating Table [sHospitalization].[tClaimIntimationAssignedDoctor]...';


GO
CREATE TABLE [sHospitalization].[tClaimIntimationAssignedDoctor] (
    [Id]                    INT            NOT NULL,
    [OrgId]                 SMALLINT       NOT NULL,
    [BusinessId]            BIGINT         NULL,
    [SubBusinessId]         BIGINT         NULL,
    [LocationId]            BIGINT         NULL,
    [SubLocationId]         BIGINT         NULL,
    [StateId]               BIGINT         NULL,
    [OrganizationId]        BIGINT         NULL,
    [DoctorEmployeeId]      BIGINT         NULL,
    [AssignDesignationId]   TINYINT        NULL,
    [AssignDoctorIndex]     INT            NULL,
    [IsObsolete]            BIT            NULL,
    [CreatedUserId]         BIGINT         NULL,
    [CreatedDateTime]       DATETIME       NULL,
    [UpdatedUserId]         BIGINT         NULL,
    [UpdatedDateTime]       DATETIME       NULL,
    [AssignDesignationName] NVARCHAR (200) NULL,
    PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
PRINT N'Creating Table [sSupport].[tCheckListApprovalLog]...';


GO
CREATE TABLE [sSupport].[tCheckListApprovalLog] (
    [Id]                  INT            IDENTITY (1, 1) NOT NULL,
    [CheckListApprovalId] INT            NOT NULL,
    [StatusId]            SMALLINT       NOT NULL,
    [RevisionNo]          SMALLINT       NOT NULL,
    [AuthorityLevel]      SMALLINT       NOT NULL,
    [EmployeeId]          BIGINT         NOT NULL,
    [Remark]              NVARCHAR (MAX) NOT NULL,
    [CreatedUserId]       BIGINT         NOT NULL,
    [CreatedDateTime]     DATETIME       NOT NULL,
    CONSTRAINT [PK_tCheckListApprovalLog] PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
PRINT N'Creating Table [sWellness].[tAssignedActivity]...';


GO
CREATE TABLE [sWellness].[tAssignedActivity] (
    [AssignedActivityId]         INT             IDENTITY (1, 1) NOT NULL,
    [ConsultationId]             INT             NULL,
    [EmployeeId]                 BIGINT          NOT NULL,
    [WellnessActivityCategoryId] INT             NULL,
    [WellnessActivityId]         INT             NULL,
    [WellnessActivityTaskId]     INT             NOT NULL,
    [IsCustomActivityTask]       BIT             NULL,
    [WellnessActivityCustom]     NVARCHAR (500)  NULL,
    [TargetValue]                NUMERIC (18, 2) NULL,
    [UnitId]                     SMALLINT        NULL,
    [FrequencyTypeId]            SMALLINT        NULL,
    [FrequencyCount]             INT             NULL,
    [StartDate]                  DATETIME        NULL,
    [EndDate]                    DATETIME        NULL,
    [ReminderEnabled]            BIT             NOT NULL,
    [ReminderTime]               TIME (0)        NULL,
    [Status]                     TINYINT         NOT NULL,
    [WeekStart]                  DATETIME        NULL,
    [WeekEnd]                    DATETIME        NULL,
    [WeekNo]                     TINYINT         NULL,
    [CreatedUserId]              BIGINT          NOT NULL,
    [CreatedDateTime]            DATETIME        NOT NULL,
    [UpdatedUserId]              BIGINT          NULL,
    [UpdatedDateTime]            DATETIME        NULL,
    CONSTRAINT [PK__tAssigne__7E251EEEBEE7A4D9] PRIMARY KEY CLUSTERED ([AssignedActivityId] ASC)
);


GO
PRINT N'Creating Table [sWellness].[tConsultationAdditionalFieldDetails]...';


GO
CREATE TABLE [sWellness].[tConsultationAdditionalFieldDetails] (
    [Id]                      INT             IDENTITY (1, 1) NOT NULL,
    [AdditionalFieldId]       BIGINT          NOT NULL,
    [AdditionalFieldSetupId]  INT             NOT NULL,
    [AdditionalFieldResponse] NVARCHAR (1000) NULL
);


GO
PRINT N'Creating Table [sWellness].[tConsultationAdditionalFieldMaster]...';


GO
CREATE TABLE [sWellness].[tConsultationAdditionalFieldMaster] (
    [Id]              BIGINT   NOT NULL,
    [ConsultationId]  BIGINT   NULL,
    [OrgId]           SMALLINT NOT NULL,
    [IsObsolete]      BIT      NULL,
    [CreatedUserId]   BIGINT   NOT NULL,
    [CreatedDateTime] DATETIME NOT NULL,
    [UpdatedUserId]   BIGINT   NOT NULL,
    [UpdatedDateTime] DATETIME NOT NULL,
    PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
PRINT N'Creating Table [sWellness].[tConsultationDocuments]...';


GO
CREATE TABLE [sWellness].[tConsultationDocuments] (
    [Id]              INT           IDENTITY (1, 1) NOT NULL,
    [ConsultationId]  BIGINT        NULL,
    [ConfigId]        TINYINT       NOT NULL,
    [FileName]        VARCHAR (300) NULL,
    [IsObsolete]      BIT           NOT NULL,
    [CreatedUserId]   BIGINT        NOT NULL,
    [CreatedDateTime] DATE          NOT NULL
);


GO
PRINT N'Creating Table [sWellness].[tConsultationTestRequest]...';


GO
CREATE TABLE [sWellness].[tConsultationTestRequest] (
    [OrgId]               SMALLINT       NOT NULL,
    [Id]                  BIGINT         NOT NULL,
    [SourceTypeId]        SMALLINT       NOT NULL,
    [SourceId]            BIGINT         NOT NULL,
    [Remark]              NVARCHAR (400) NULL,
    [IsObsolete]          BIT            NOT NULL,
    [TestId]              INT            NULL,
    [TestSpecificationId] INT            NULL,
    [IsPackage]           BIT            NULL,
    PRIMARY KEY CLUSTERED ([Id] ASC) WITH (FILLFACTOR = 85)
);


GO
PRINT N'Creating Table [sWellness].[tConsultationTestRequestDetail]...';


GO
CREATE TABLE [sWellness].[tConsultationTestRequestDetail] (
    [OrgId]          SMALLINT        NOT NULL,
    [Id]             BIGINT          IDENTITY (1, 1) NOT NULL,
    [TestRequestId]  BIGINT          NOT NULL,
    [TestDetailId]   INT             NOT NULL,
    [ServiceValue]   NVARCHAR (300)  NULL,
    [Remark]         NVARCHAR (4000) NULL,
    [Diagnosis]      NVARCHAR (100)  NULL,
    [Recommendation] NVARCHAR (100)  NULL,
    [IsAbnormal]     BIT             NULL,
    CONSTRAINT [PK_tTestRequestDetail] PRIMARY KEY CLUSTERED ([Id] ASC) WITH (FILLFACTOR = 85)
);


GO
PRINT N'Creating Table [sWellness].[tEmployeeTaskTrack]...';


GO
CREATE TABLE [sWellness].[tEmployeeTaskTrack] (
    [Id]                     INT      IDENTITY (1, 1) NOT NULL,
    [ConsultationId]         INT      NULL,
    [EmployeeId]             BIGINT   NOT NULL,
    [WellnessActivityTaskId] INT      NOT NULL,
    [TaskDate]               DATETIME NULL,
    [AssignedActivityId]     INT      NOT NULL,
    [Status]                 BIT      NOT NULL,
    [CreatedUserId]          BIGINT   NOT NULL,
    [CreatedDateTime]        DATETIME NOT NULL,
    [UpdatedUserId]          BIGINT   NULL,
    [UpdatedDateTime]        DATETIME NULL,
    CONSTRAINT [PK__tEmploye__3214EC07A4507530] PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
PRINT N'Creating Table [sWellness].[tGeneralTemplateConsultation]...';


GO
CREATE TABLE [sWellness].[tGeneralTemplateConsultation] (
    [OrgId]             SMALLINT       NOT NULL,
    [Id]                BIGINT         NOT NULL,
    [SourceTypeId]      SMALLINT       NOT NULL,
    [SourceId]          BIGINT         NOT NULL,
    [Remark]            NVARCHAR (200) NULL,
    [GeneralTemplateId] INT            NULL,
    CONSTRAINT [PK_tGeneralTemplateExamination] PRIMARY KEY CLUSTERED ([Id] ASC) WITH (FILLFACTOR = 85)
);


GO
PRINT N'Creating Table [sWellness].[tGeneralTemplateConsultationDetail]...';


GO
CREATE TABLE [sWellness].[tGeneralTemplateConsultationDetail] (
    [Id]                            BIGINT         IDENTITY (1, 1) NOT NULL,
    [GeneralTemplateConsultationId] BIGINT         NOT NULL,
    [GeneralTemplateParameterId]    INT            NOT NULL,
    [ParameterValue]                NVARCHAR (200) NULL,
    [Remark]                        NVARCHAR (200) NULL,
    [Diagnosis]                     NVARCHAR (100) NULL,
    [Recommendation]                NVARCHAR (100) NULL,
    [IsAbnormal]                    BIT            NULL,
    CONSTRAINT [PK_tGeneralTemplateExaminationDetail] PRIMARY KEY CLUSTERED ([Id] ASC) WITH (FILLFACTOR = 85),
    CONSTRAINT [UK_tGeneralTemplateExaminationDetail] UNIQUE NONCLUSTERED ([GeneralTemplateConsultationId] ASC, [GeneralTemplateParameterId] ASC) WITH (FILLFACTOR = 85)
);


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


GO
CREATE TABLE [sWellness].[tMHIScore] (
    [Id]                   INT             NOT NULL,
    [OrgId]                SMALLINT        NOT NULL,
    [ProgramId]            INT             NULL,
    [EmployeeId]           BIGINT          NOT NULL,
    [EmployeeSourceTypeId] INT             NULL,
    [LastUpdateType]       TINYINT         NULL,
    [HBA1C]                NUMERIC (10, 2) NULL,
    [HBA1CScore]           SMALLINT        NULL,
    [HBA1CCategory]        VARCHAR (30)    NULL,
    [LDL]                  NUMERIC (10, 2) NULL,
    [LDLScore]             SMALLINT        NULL,
    [LDLCategory]          VARCHAR (30)    NULL,
    [BMI]                  NUMERIC (10, 2) NULL,
    [BMIScore]             SMALLINT        NULL,
    [BMICategory]          VARCHAR (30)    NULL,
    [BP]                   NVARCHAR (30)   NULL,
    [BPScore]              SMALLINT        NULL,
    [BPCategory]           VARCHAR (30)    NULL,
    [Biometrics]           NUMERIC (10, 2) NULL,
    [BiometricsCategory]   VARCHAR (30)    NULL,
    [Stress]               NUMERIC (10, 2) NULL,
    [StressScore]          SMALLINT        NULL,
    [StressCategory]       VARCHAR (30)    NULL,
    [Lifestyle]            NUMERIC (10, 2) NULL,
    [LifestyleScore]       SMALLINT        NULL,
    [LifestyleCategory]    VARCHAR (30)    NULL,
    [SurveyCategory]       VARCHAR (30)    NULL,
    [MHICategoryId]        SMALLINT        NULL,
    [MHICategory]          VARCHAR (30)    NULL,
    [CreatedUserId]        BIGINT          NOT NULL,
    [CreatedDatetime]      DATETIME        NOT NULL,
    [UpdatedUserId]        BIGINT          NULL,
    [UpdatedDatetime]      DATETIME        NULL,
    CONSTRAINT [PK_tMHIScore] PRIMARY KEY CLUSTERED ([Id] ASC)
);


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


GO
CREATE TABLE [sWellness].[tMHIScore_History] (
    [HistoryId]            BIGINT          IDENTITY (1, 1) NOT NULL,
    [Id]                   INT             NOT NULL,
    [OrgId]                SMALLINT        NOT NULL,
    [ProgramId]            INT             NULL,
    [EmployeeId]           BIGINT          NOT NULL,
    [EmployeeSourceTypeId] INT             NULL,
    [LastUpdateType]       TINYINT         NULL,
    [HBA1C]                NUMERIC (10, 2) NULL,
    [HBA1CScore]           SMALLINT        NULL,
    [HBA1CCategory]        VARCHAR (30)    NULL,
    [LDL]                  NUMERIC (10, 2) NULL,
    [LDLScore]             SMALLINT        NULL,
    [LDLCategory]          VARCHAR (30)    NULL,
    [BMI]                  NUMERIC (10, 2) NULL,
    [BMIScore]             SMALLINT        NULL,
    [BMICategory]          VARCHAR (30)    NULL,
    [BP]                   NVARCHAR (30)   NULL,
    [BPScore]              SMALLINT        NULL,
    [BPCategory]           VARCHAR (30)    NULL,
    [Biometrics]           NUMERIC (10, 2) NULL,
    [BiometricsCategory]   VARCHAR (30)    NULL,
    [Stress]               NUMERIC (10, 2) NULL,
    [StressScore]          SMALLINT        NULL,
    [StressCategory]       VARCHAR (30)    NULL,
    [Lifestyle]            NUMERIC (10, 2) NULL,
    [LifestyleScore]       SMALLINT        NULL,
    [LifestyleCategory]    VARCHAR (30)    NULL,
    [SurveyCategory]       VARCHAR (30)    NULL,
    [MHICategoryId]        SMALLINT        NULL,
    [MHICategory]          VARCHAR (30)    NULL,
    [ActionType]           VARCHAR (10)    NOT NULL,
    [CreatedUserId]        BIGINT          NULL,
    [ActionDateTime]       DATETIME        NOT NULL,
    CONSTRAINT [PK__tMHIScor__4D7B4ABD2ACEE725] PRIMARY KEY CLUSTERED ([HistoryId] ASC)
);


GO
PRINT N'Creating Table [sWellness].[tMHIScoreUpdation]...';


GO
CREATE TABLE [sWellness].[tMHIScoreUpdation] (
    [Id]                      INT             IDENTITY (1, 1) NOT NULL,
    [ParticipantSourceTypeId] SMALLINT        NOT NULL,
    [ParticipantSourceId]     BIGINT          NOT NULL,
    [BMI]                     NUMERIC (10, 2) NULL,
    [HBA1C]                   NUMERIC (10, 2) NULL,
    [LDL]                     NUMERIC (10, 2) NULL,
    [BPSystolic]              NUMERIC (10, 2) NULL,
    [BPDiastolic]             NUMERIC (10, 2) NULL,
    [Stress]                  NUMERIC (10, 2) NULL,
    [LifeStyle]               NUMERIC (10, 2) NULL,
    [CreatedUserId]           BIGINT          NOT NULL,
    [CreatedDateTime]         DATETIME        NOT NULL,
    [UpdatedUserId]           BIGINT          NULL,
    [UpdatedDateTime]         DATETIME        NULL,
    CONSTRAINT [PK__tMHIScoreUpdation_Id] PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
PRINT N'Creating Table [sWellness].[tProgramSessionAttendance]...';


GO
CREATE TABLE [sWellness].[tProgramSessionAttendance] (
    [AutoId]           INT             IDENTITY (1, 1) NOT NULL,
    [StoreLocationId]  INT             NOT NULL,
    [ProgramId]        INT             NOT NULL,
    [AttendedEmployee] INT             NOT NULL,
    [AttendedDate]     DATE            NOT NULL,
    [Remark]           NVARCHAR (1000) NULL,
    [CreatedUserId]    BIGINT          NOT NULL,
    [CreatedDateTime]  DATETIME        NOT NULL,
    [UpdatedUserId]    BIGINT          NULL,
    [UpdatedDateTime]  DATETIME        NULL,
    CONSTRAINT [PK_tProgramSessionAttendance] PRIMARY KEY CLUSTERED ([AutoId] ASC)
);


GO
PRINT N'Creating Table [sWellness].[tStaticMHICategoryIndicator]...';


GO
CREATE TABLE [sWellness].[tStaticMHICategoryIndicator] (
    [Id]    INT            NOT NULL,
    [Title] NVARCHAR (100) NOT NULL
);


GO
PRINT N'Creating Table [sWellness].[tWellnessActivityCategoryMaster]...';


GO
CREATE TABLE [sWellness].[tWellnessActivityCategoryMaster] (
    [Id]              INT            NOT NULL,
    [Code]            NVARCHAR (100) NULL,
    [Title]           NVARCHAR (100) NULL,
    [IsObsolete]      BIT            NULL,
    [CreatedUserId]   BIGINT         NULL,
    [CreatedDatetime] DATETIME       NULL,
    [UpdatedUserId]   BIGINT         NULL,
    [UpdatedDatetime] DATETIME       NULL,
    CONSTRAINT [PK__tWellnes__3214EC07B2368F48] PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
PRINT N'Creating Table [sWellness].[tWellnessActivityMaster]...';


GO
CREATE TABLE [sWellness].[tWellnessActivityMaster] (
    [ActivityId]                 INT            NOT NULL,
    [ActivityName]               NVARCHAR (100) NULL,
    [WellnessActivityCategoryId] INT            NULL,
    [DefaultUnitId]              SMALLINT       NULL,
    [Description]                NVARCHAR (500) NULL,
    [IsObsolete]                 BIT            NULL,
    [CreatedUserId]              BIGINT         NULL,
    [CreatedDatetime]            DATETIME       NULL,
    [UpdatedUserId]              BIGINT         NULL,
    [UpdatedDatetime]            DATETIME       NULL
);


GO
PRINT N'Creating Table [sWellness].[tWellnessActivityTaskMaster]...';


GO
CREATE TABLE [sWellness].[tWellnessActivityTaskMaster] (
    [Id]              INT            NOT NULL,
    [Name]            NVARCHAR (500) NULL,
    [ActivityId]      INT            NOT NULL,
    [TargetValue]     INT            NULL,
    [UnitId]          SMALLINT       NULL,
    [FrequencyTypeId] SMALLINT       NULL,
    [FrequencyCount]  INT            NULL,
    [DurationDays]    INT            NULL,
    CONSTRAINT [PK__tWellnes__3214EC07D3DF22D9] PRIMARY KEY CLUSTERED ([Id] ASC)
);


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


GO
CREATE TABLE [sWellness].[tWellnessConsultation] (
    [Id]                      BIGINT          IDENTITY (1, 1) NOT NULL,
    [ConsultationNumber]      VARCHAR (200)   NULL,
    [ParticipantSourceTypeId] SMALLINT        NOT NULL,
    [ParticipantSourceId]     BIGINT          NOT NULL,
    [ConsultationDate]        DATE            NOT NULL,
    [DoctorEmployeeId]        BIGINT          NULL,
    [SetupId]                 INT             NOT NULL,
    [CauseId]                 INT             NULL,
    [OrgId]                   SMALLINT        NOT NULL,
    [StatusId]                INT             NULL,
    [WellnessAppointmentId]   INT             NULL,
    [StoreLocationId]         INT             NOT NULL,
    [IsCancel]                BIT             NULL,
    [ConsultationNotes]       NVARCHAR (1000) NULL,
    [ConsultationRemarks]     NVARCHAR (1000) NULL,
    [Age]                     INT             NULL,
    [Months]                  TINYINT         NULL,
    [GenderId]                TINYINT         NULL,
    [ConsultationTime]        VARCHAR (100)   NULL,
    [ConsultationOutTime]     VARCHAR (100)   NULL,
    [CreatedUserId]           BIGINT          NOT NULL,
    [CreatedDateTime]         DATETIME        NOT NULL,
    [UpdatedUserId]           BIGINT          NULL,
    [UpdatedDateTime]         DATETIME        NULL,
    CONSTRAINT [PK__tWellnes__3214EC075765A0B7] PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
PRINT N'Creating Table [sWellness].[tWellnessVisitPurposeMaster]...';


GO
CREATE TABLE [sWellness].[tWellnessVisitPurposeMaster] (
    [Id]              INT            NOT NULL,
    [Code]            NVARCHAR (100) NULL,
    [Title]           NVARCHAR (100) NULL,
    [IsObsolete]      BIT            NULL,
    [CreatedUserId]   BIGINT         NULL,
    [CreatedDatetime] DATETIME       NULL,
    [UpdatedUserId]   BIGINT         NULL,
    [UpdatedDatetime] DATETIME       NULL,
    [OrgId]           SMALLINT       NULL,
    CONSTRAINT [PK__tWellnessVisitPurposeMaster] PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
PRINT N'Creating Default Constraint unnamed constraint on [sHospitalization].[tClaimIntimationAssignedDoctor]...';


GO
ALTER TABLE [sHospitalization].[tClaimIntimationAssignedDoctor]
    ADD DEFAULT (getutcdate()) FOR [CreatedDateTime];


GO
PRINT N'Creating Default Constraint unnamed constraint on [sHospitalization].[tClaimIntimationAssignedDoctor]...';


GO
ALTER TABLE [sHospitalization].[tClaimIntimationAssignedDoctor]
    ADD DEFAULT ((0)) FOR [IsObsolete];


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


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


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


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


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


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


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


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


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


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