--{5.8.1.12}  
----------------------  
-- $Change: xxxxx $  
-- $DateTime: 2013/01/30 23:42:00 $  
-- $Author: bdowling $  
----------------------  
-- Rename encounter_id column to cqm_provider_id on event_interoperability
----------------------


IF EXISTS(SELECT 1 FROM sys.columns WHERE Name = N'encounter_id' AND Object_ID = Object_ID(N'[dbo].[event_interoperability]'))
	BEGIN
		EXEC SP_RENAME 'dbo.event_interoperability.encounter_id', 'cqm_provider_id', 'COLUMN'
	END
ELSE IF NOT EXISTS(SELECT 1 FROM sys.columns WHERE Name = N'cqm_provider_id' AND Object_ID = Object_ID(N'[dbo].[event_interoperability]'))
	BEGIN
		ALTER TABLE [dbo].[event_interoperability]
		ADD cqm_provider_id uniqueidentifier NULL
	END
GO