IF ((SELECT COUNT(recId) FROM pal_SurfaceActionType WHERE actionType = 'Toggle View') = 0)
	INSERT INTO pal_SurfaceActionType (actionType, isActive) 
	VALUES ('Toggle View', 1)


IF ((SELECT COUNT(recId) FROM pal_SurfaceAction WHERE [action] = 'Visible') = 0)
	INSERT INTO pal_SurfaceAction (actionType, [action], isActive)
	VALUES (3, 'Visible', 1)


IF NOT EXISTS(
    SELECT *
    FROM sys.columns 
    WHERE Name      = N'actionValue'
      AND Object_ID = Object_ID(N'pal_SurfaceField'))
BEGIN
    ALTER TABLE pal_SurfaceField
	ADD actionValue VARCHAR(250); 
END




IF  NOT EXISTS (SELECT * FROM sys.objects 
WHERE object_id = OBJECT_ID(N'[dbo].[pal_MedicalDiagnosis]') AND type in (N'U'))
BEGIN
	CREATE TABLE [dbo].[pal_MedicalDiagnosis](
		[recId] [int] IDENTITY(1,1) NOT NULL,
		[diagnosis] [varchar](250) NULL,
		[categoryId] [int] NULL,
		[primaryICD10Id] [int] NULL,
		[sequence] [int] NULL,
		[isActive] [bit] NULL,
	 CONSTRAINT [PK_pal_MedicalDiagnosis] PRIMARY KEY CLUSTERED 
	(
		[recId] ASC
	)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
	) ON [PRIMARY]

END





IF  NOT EXISTS (SELECT * FROM sys.objects 
WHERE object_id = OBJECT_ID(N'[dbo].[pal_MedicalDiagnosisCategory]') AND type in (N'U'))
BEGIN
	CREATE TABLE [dbo].[pal_MedicalDiagnosisCategory](
		[recId] [int] IDENTITY(1,1) NOT NULL,
		[category] [varchar](50) NULL,
		[sequence] [int] NULL,
		[isActive] [bit] NULL,
	 CONSTRAINT [PK_pal_MedicalDiagnosisCategory] PRIMARY KEY CLUSTERED 
	(
		[recId] ASC
	)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
	) ON [PRIMARY]

END




IF EXISTS ( SELECT * 
            FROM   sysobjects 
            WHERE  id = object_id(N'[dbo].[sp_DebtorsAssistedReportResult]') 
                   and OBJECTPROPERTY(id, N'IsProcedure') = 1 )
BEGIN
    DROP PROCEDURE [dbo].[sp_DebtorsAssistedReportResult]
END

IF EXISTS ( SELECT * 
            FROM   sysobjects 
            WHERE  id = object_id(N'[dbo].[sp_DebtorsAssistedReportSummary]') 
                   and OBJECTPROPERTY(id, N'IsProcedure') = 1 )
BEGIN
    DROP PROCEDURE [dbo].[sp_DebtorsAssistedReportSummary]
END