IF NOT EXISTS (SELECT * FROM sysobjects WHERE name = 'PISReceivedPrescriptionDetailIngredients')
BEGIN
CREATE TABLE [dbo].[PISReceivedPrescriptionDetailIngredients](
	[Id] [UNIQUEIDENTIFIER] NOT NULL,
	[PrescriptionDetailId] [UNIQUEIDENTIFIER] NULL,
	[eRxCode] [VARCHAR](10) NULL,
	[GoodsCode] [VARCHAR](15) NULL,
	[Term] [NVARCHAR](MAX) NULL,
	[Amount] [MONEY] NULL,
	[AmountUnit] [NVARCHAR](30) NULL,
	[AmountMax] [MONEY] NULL,
	[AmountMaxUnit] [NVARCHAR](30) NULL,
	[RoleCode] [VARCHAR](15) NULL,
	[RoleTerm] [NVARCHAR](MAX) NULL,
 CONSTRAINT [PK_PISReceivedPrescriptionDetailIngredients] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)) ON [PRIMARY] 

ALTER TABLE [dbo].[PISReceivedPrescriptionDetailIngredients]  WITH CHECK ADD  CONSTRAINT [FK_PISReceivedPrescriptionDetailIngredients_PISReceivedPrescriptionDetail] FOREIGN KEY([PrescriptionDetailId])
REFERENCES [dbo].[PISReceivedPrescriptionDetail] ([Id])

ALTER TABLE [dbo].[PISReceivedPrescriptionDetailIngredients] CHECK CONSTRAINT [FK_PISReceivedPrescriptionDetailIngredients_PISReceivedPrescriptionDetail]
End

