
declare @RoleAuthorizationGroupTypes table(
	[Name] [nvarchar](50) NOT NULL,
	[guid] [uniqueidentifier] NULL
)


insert into @RoleAuthorizationGroupTypes (name,guid) values('Read organization unit',			'572D45DE-1302-4940-AD3F-1F6556BC5F19')
insert into @RoleAuthorizationGroupTypes (name,guid) values('CUD organization unit',			'6E0A37F5-58FD-43D0-AC97-4FBC19FE664D')
insert into @RoleAuthorizationGroupTypes (name,guid) values('CRUD device (CP)',					'ED65F06B-4DE4-4B3B-9E7B-AA3849362A16')
insert into @RoleAuthorizationGroupTypes (name,guid) values('Read device',						'B47D02CF-F595-4652-80C4-8F8C34DE8C2E')
insert into @RoleAuthorizationGroupTypes (name,guid) values('Edit device configuration',		'BC6EAC6C-0C91-4169-A2C2-33AE54902E60')
insert into @RoleAuthorizationGroupTypes (name,guid) values('Send command',						'80F67FCE-680C-4FD5-BA74-C91A4EBFFAD8')
insert into @RoleAuthorizationGroupTypes (name,guid) values('Upload Template',					'80EA898F-4712-48BF-A7BA-82FFA2905AA1')
insert into @RoleAuthorizationGroupTypes (name,guid) values('Perform batch',					'1DB93246-E71B-4004-ACAA-F0DC4EF94690')
insert into @RoleAuthorizationGroupTypes (name,guid) values('CRUD staff',						'5A0FBC1D-C7DD-4C5B-801D-BCE7A0E276A1')
insert into @RoleAuthorizationGroupTypes (name,guid) values('Create user (resident)',			'44E26B50-C07B-4480-9CBD-7C3576D7D014')
insert into @RoleAuthorizationGroupTypes (name,guid) values('Read user (resident)',				'6ADC970A-7319-45DF-82C9-CF6AAAC5449C')
insert into @RoleAuthorizationGroupTypes (name,guid) values('Update user (resident)',			'C2E85DBA-D1EB-4FFE-89AF-01D07A4BD56D')
insert into @RoleAuthorizationGroupTypes (name,guid) values('Delete user (resident)',			'6BDC7B82-1142-4327-97F0-40FCCAF795F1')
insert into @RoleAuthorizationGroupTypes (name,guid) values('Export CV reports ',				'E4E43600-DA93-435F-8EE9-49DF3BEB89C7')
insert into @RoleAuthorizationGroupTypes (name,guid) values('Monitoring ',						'BEBDA7CF-A6BF-4621-9E7A-0BEDDE55526C')
insert into @RoleAuthorizationGroupTypes (name,guid) values('Clinical monitoring',				'519B59BD-5E6A-4688-8159-E80AC7932A36')
insert into @RoleAuthorizationGroupTypes (name,guid) values('Edit thresholds ',					'5323738B-E3AB-4F1B-8832-4DB062FDED08')
insert into @RoleAuthorizationGroupTypes (name,guid) values('FIT',								'F6CA26B0-BA14-4681-8B15-EC1CC9804386')
insert into @RoleAuthorizationGroupTypes (name,guid) values('Family/Pro Rules',					'FBF64DE8-BE89-40D4-9A3F-30567186AB36')
insert into @RoleAuthorizationGroupTypes (name,guid) values('SaveTemplate',						'2CAE9C2D-802A-42B9-9ADA-45A1C5433A36')



MERGE INTO [dbo].RoleAuthorizationGroupTypes AS TARGET
USING @RoleAuthorizationGroupTypes AS SOURCE
	ON TARGET.guid = SOURCE.guid
	WHEN MATCHED THEN    
			UPDATE SET name=source.name
	WHEN NOT MATCHED BY TARGET THEN   
			INSERT ( name,guid) VALUES (Source.name, SOURCE.guid)  
OUTPUT $action, SOURCE.*;


