IF NOT EXISTS
(
    SELECT TABLE_NAME
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_NAME = 'EPMPrescriptionTransaction'
)
BEGIN
    CREATE TABLE [dbo].[EPMPrescriptionTransaction]
    (
        [Id] [UNIQUEIDENTIFIER] NOT NULL,
        [PrescriptionTypeCode] [TINYINT] NULL,
        [PrescriptionId] [UNIQUEIDENTIFIER] NULL,
        [IncurableTotalAmount] [MONEY] NULL,
        [SupplementaryInsuranceTotalAmount] [MONEY] NULL,
        [SupportiveInsuranceTotalAmount] [MONEY] NULL,
        [ExcessTotalAmount] [MONEY] NULL,
        [RASAClaimNumber] [VARCHAR](15) NULL,
        [CreatedBy] [SMALLINT] NULL,
        [CreatedOn] [DATETIME] NULL,
        CONSTRAINT [PK_EPMPrescriptionTransaction]
            PRIMARY KEY CLUSTERED ([Id] ASC)
    ) ON [PRIMARY];
    ALTER TABLE [dbo].[EPMPrescriptionTransaction]
    ADD CONSTRAINT [DF_EPMPrescriptionTransaction_Id]
        DEFAULT (NEWID()) FOR [Id];

    ALTER TABLE [dbo].[EPMPrescriptionTransaction]
    ADD CONSTRAINT [DF_EPMDecreasingTransaction_CreatedOn]
        DEFAULT (GETDATE()) FOR [CreatedOn];
END;
ELSE IF NOT EXISTS
     (
         SELECT 1
         FROM INFORMATION_SCHEMA.COLUMNS
         WHERE TABLE_NAME = 'EPMPrescriptionTransaction'
               AND COLUMN_NAME = 'RASAClaimNumber'
     )
BEGIN
    
    ALTER TABLE dbo.EPMPrescriptionTransaction
    ADD [RASAClaimNumber] [VARCHAR](15) NULL;

END;