IF NOT EXISTS (SELECT * FROM sysobjects WHERE name = 'PISSenderPrescription')
BEGIN
CREATE TABLE [dbo].[PISSenderPrescription](
	[Id] [UNIQUEIDENTIFIER] NOT NULL,
	[PrescriptionId] [NUMERIC](18, 0) NULL,
	[Status] [TINYINT] NULL,
	[CreatedDate] [DATETIME] NULL,
	[SendDate] [DATETIME] NULL,
	[ResponseDate] [DATETIME] NULL,
	[MessageUId] [NVARCHAR](MAX) NULL,
	[CompositionUID] [NVARCHAR](MAX) NULL,
	[PatientUID] [NVARCHAR](MAX) NULL,
	[ErrorCategoryCritical] [NVARCHAR](MAX) NULL,
	[ErrorCategoryType] [VARCHAR](MAX) NULL,
	[ErrorDescription] [NVARCHAR](MAX) NULL,
	[ErrorMessage] [NVARCHAR](MAX) NULL,
	[ErrorSolution] [NVARCHAR](MAX) NULL,
	[NormalizedErrorMessage] [NVARCHAR](MAX) NULL,
 CONSTRAINT [PK_PISSenderPrescription] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)
) ON [PRIMARY] 

ALTER TABLE [dbo].[PISSenderPrescription] ADD  CONSTRAINT [DF_PISSenderPrescription_Id]  DEFAULT (NEWID()) FOR [Id]
ALTER TABLE [dbo].[PISSenderPrescription] ADD  CONSTRAINT [DF_PISSenderPrescription_Status]  DEFAULT ((0)) FOR [Status]
ALTER TABLE [dbo].[PISSenderPrescription] ADD  CONSTRAINT [DF_PISSenderPrescription_CreatedDate]  DEFAULT (GETDATE()) FOR [CreatedDate]

End

