	
	--VendorSettingsTypes
	DECLARE @VendorSettingsTypes TABLE (RowId uniqueidentifier NOT NULL,[Name] [nvarchar](500) NOT NULL,SettingsType int NOT NULL);

	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('DA3442F0-97A4-4F27-8761-BCEF7B4C62E1', N'PasswordChangeNotificationEnabled',3);
	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('EA93ACAD-96BF-440A-83C1-11D7940519BE', N'TeleHealthEnabled',1);
	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('3ebf07a7-94a7-4adc-8ef7-6b6741190b61', N'EventSchedulingEnabled',1);
	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('adaf2d5d-7cd2-469f-aeab-3dc84844b68d', N'EventSchedulingEnabledAlertTypesWhiteList',2);
	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('d7e1cd43-c687-439f-a586-2491ee065b2d', N'TimeZoneId',2);
	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('61ac9515-ac8e-4d72-ad0e-0d8c241f079e', N'DefaultInternationalDialingCode',2);

	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('613CCA1C-D1D4-461D-8753-3A7F0136FE55', N'ShouldRemoveDeletedPatientMeasurements',1);
	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('A985A782-8405-4732-A38B-D8170E1DFB2B', N'DayIntervalToRemoveDeletedPatientMeasurements',3);
	INSERT into @VendorSettingsTypes (RowId, [Name], SettingsType) VALUES ('DDF3DE6B-421A-4052-95D5-1C287C7516AD', N'SmartCallEnabled',1);


	MERGE INTO dbo.[VendorSettingsTypes] AS TARGET  
		USING @VendorSettingsTypes AS SOURCE  
		ON TARGET.RowId = SOURCE.RowId	
		WHEN MATCHED THEN    
			UPDATE SET	[Name] = SOURCE.[Name],
						[SettingsType] = SOURCE.[SettingsType]
		WHEN NOT MATCHED BY TARGET THEN   
			INSERT (RowId, [Name], SettingsType) VALUES (SOURCE.RowId, SOURCE.[Name], SOURCE.SettingsType)  
	OUTPUT $action, SOURCE.*;



	--VendorSettings
	DECLARE @VendorSettings TABLE (VendorId int NOT NULL, SettingTypeId int NOT NULL, Value nvarchar(1024) NULL);

	--Get the settings DB Id
	declare @PasswordChangeNotificationEnabledId int
	declare @EventSchedulingEnabledId int
	declare @EventSchedulingEnabledAlertTypesWhiteListId int
	declare @vendorTimeZoneId int
	declare @defaultInternationalDialingCodeId int
	declare @ShouldRemoveDeletedPatientMeasurementsId int
	declare @DayIntervalToRemoveDeletedPatientMeasurementsId int
	declare @VirtualCallEnabledId int

	select @PasswordChangeNotificationEnabledId = Id from VendorSettingsTypes where RowId='DA3442F0-97A4-4F27-8761-BCEF7B4C62E1'
	select @EventSchedulingEnabledId = Id from VendorSettingsTypes where RowId='3ebf07a7-94a7-4adc-8ef7-6b6741190b61'
	select @EventSchedulingEnabledAlertTypesWhiteListId = Id from VendorSettingsTypes where RowId='adaf2d5d-7cd2-469f-aeab-3dc84844b68d'
	select @vendorTimeZoneId = Id from VendorSettingsTypes where RowId='d7e1cd43-c687-439f-a586-2491ee065b2d'
	select @defaultInternationalDialingCodeId = Id from VendorSettingsTypes where RowId='61ac9515-ac8e-4d72-ad0e-0d8c241f079e'
	select @ShouldRemoveDeletedPatientMeasurementsId = Id from VendorSettingsTypes where RowId='613CCA1C-D1D4-461D-8753-3A7F0136FE55'
	select @DayIntervalToRemoveDeletedPatientMeasurementsId = Id from VendorSettingsTypes where RowId='A985A782-8405-4732-A38B-D8170E1DFB2B'
	select @VirtualCallEnabledId = Id from VendorSettingsTypes where RowId='DDF3DE6B-421A-4052-95D5-1C287C7516AD'


	--Add to ALL vendors
	INSERT into @VendorSettings select VendorTbl.VendorId,@PasswordChangeNotificationEnabledId,'true' from VendorTbl order by VendorId
	INSERT into @VendorSettings select VendorTbl.VendorId,@EventSchedulingEnabledId,'false' from VendorTbl order by VendorId
	INSERT into @VendorSettings select VendorTbl.VendorId,@EventSchedulingEnabledAlertTypesWhiteListId,'' from VendorTbl order by VendorId
	INSERT into @VendorSettings select VendorTbl.VendorId,@vendorTimeZoneId,'Etc/UTC' from VendorTbl order by VendorId
	INSERT into @VendorSettings select VendorTbl.VendorId,@defaultInternationalDialingCodeId,'+1' from VendorTbl order by VendorId
	INSERT into @VendorSettings select VendorTbl.VendorId,@ShouldRemoveDeletedPatientMeasurementsId,'0' from VendorTbl order by VendorId
	INSERT into @VendorSettings select VendorTbl.VendorId,@DayIntervalToRemoveDeletedPatientMeasurementsId,'0' from VendorTbl order by VendorId
	INSERT into @VendorSettings select VendorTbl.VendorId,@VirtualCallEnabledId,'false' from VendorTbl order by VendorId

	MERGE INTO dbo.[VendorSettings] AS TARGET  
		USING @VendorSettings AS SOURCE  
		ON TARGET.VendorId = SOURCE.VendorId and TARGET.SettingTypeId = SOURCE.SettingTypeId	
		WHEN MATCHED THEN    
			UPDATE SET	[Value] = SOURCE.[Value],
						[UpdatedUtc] = GetUtcDate()
		WHEN NOT MATCHED BY TARGET THEN   
			INSERT (VendorId, SettingTypeId, [Value],CreatedUtc,UpdatedUtc) VALUES (SOURCE.VendorId, SOURCE.SettingTypeId, SOURCE.[Value],GetUtcDate(),GetUtcDate())  
	OUTPUT $action, SOURCE.*;
		
