IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'pal_SurfaceField' AND COLUMN_NAME = 'isHiddenFromView')
BEGIN
	ALTER TABLE [dbo].[pal_SurfaceField]
		ADD isHiddenFromView       BIT CONSTRAINT [DF_pal_SurfaceField_isHiddenFromView] DEFAULT ((0)) NULL
END

IF  NOT EXISTS (SELECT * FROM sys.objects 
WHERE object_id = OBJECT_ID(N'[dbo].[pal_MedicalPatientSubjectivesLog]') AND type in (N'U'))
BEGIN
	CREATE TABLE [dbo].[pal_MedicalPatientSubjectivesLog] (
		[recId]      INT IDENTITY (1, 1) NOT NULL,
		[visitLogId] INT NULL,
		[compaintId] INT NULL,
		[score]      INT NULL,
		CONSTRAINT [PK_pal_MedicalPatientSubjectivesLog] PRIMARY KEY CLUSTERED ([recId] ASC)
	);
END

IF  NOT EXISTS (SELECT * FROM sys.objects 
WHERE object_id = OBJECT_ID(N'[dbo].[pal_MedicalPatientVisitLog]') AND type in (N'U'))
BEGIN
	CREATE TABLE [dbo].[pal_MedicalPatientVisitLog] (
		[recId]       INT      IDENTITY (1, 1) NOT NULL,
		[userId]      INT      NULL,
		[signInDate]  DATETIME NULL,
		[signOutDate] DATETIME NULL,
		CONSTRAINT [PK_pal_MedicalPatientVisitLog] PRIMARY KEY CLUSTERED ([recId] ASC)
	);
END

IF  NOT EXISTS (SELECT * FROM sys.objects 
WHERE object_id = OBJECT_ID(N'[dbo].[pal_MedicalPatientComplaints]') AND type in (N'U'))
BEGIN
	CREATE TABLE [dbo].[pal_MedicalPatientComplaints] (
		[recId]                        INT            IDENTITY (1, 1) NOT NULL,
		[surfaceItemId]                INT            NULL,
		[complaint]                    VARCHAR (200)  NULL,
		[complaintAge]                 VARCHAR (200)  NULL,
		[worstTime]                    VARCHAR (200)  NULL,
		[painLevel]                    INT            NULL,
		[discomfortTypes]              VARCHAR (200)  NULL,
		[discomfortFrequency]          VARCHAR (200)  NULL,
		[discomfortIncrease]           VARCHAR (200)  NULL,
		[discomfortDecrease]           VARCHAR (200)  NULL,
		[isInjuryRelated]              BIT            NULL,
		[injuryDetails]                VARCHAR (500)  NULL,
		[isAccidentRelated]            BIT            NULL,
		[spinalInjuryDetails]          VARCHAR (500)  NULL,
		[otherDrVisited]               BIT            NULL,
		[otherDrDetails]               VARCHAR (200)  NULL,
		[isPastProblem]                BIT            NULL,
		[pastProblemDetails]           VARCHAR (200)  NULL,
		[pastProblemTreated]           BIT            NULL,
		[pastProblemTreatment]         VARCHAR (200)  NULL,
		[pastProblemTreatmentAge]      VARCHAR (200)  NULL,
		[pastProblemTreatmentProvider] VARCHAR (200)  NULL,
		[pastProblemTreatmentResults]  VARCHAR (200)  NULL,
		[isActive]                     BIT            NULL,
		[complaintNotes]               VARCHAR (2000) NULL,
		[dateCreated]                  DATETIME       NULL,
		[createdBy]                    INT            NULL,
		[dateUpdated]                  DATETIME       NULL,
		[updatedBy]                    INT            NULL,
		[bodyMap]                      VARCHAR (500)  NULL,
		CONSTRAINT [PK_pal_MedicalPatientComplaints] PRIMARY KEY CLUSTERED ([recId] ASC)
	);
END