-- turn admin to SysAdmin
update m
set m.roleid = r.id
from CmsUserTbl m, roles r 
where m.SecurityLevelId=1 and r.guid='0E9CB844-06B6-4AEA-A0DC-0FC17EE71BE2'

-- turn resident to Subscriber 
update m
set m.roleid = r.id
from CmsUserTbl m, roles r 
where m.SecurityLevelId=3 and r.guid='31EBDBC3-8596-4448-A063-1D462772118A'

-- caregiver withOUT telehealth enabled (or without the setting) to role.Caregiver
update m
set m.roleid = r.id
from CmsUserTbl m  left outer join UserSettings u on u.CmsUserId=m.CmsUserId and u.SettingTypeId=(select id from UserSettingsTypes where rowid='41288138-4780-4EAF-A850-284B8903B20E') and value='false', roles r 
where m.SecurityLevelId=2 and r.guid='D0275602-E7DF-420F-9E29-77AF67A7B844'


-- caregiver with telehealth enabled to role.Madical Admin
update m
set m.roleid = r.id
from CmsUserTbl m join UserSettings u on u.CmsUserId=m.CmsUserId and u.SettingTypeId=(select id from UserSettingsTypes where rowid='41288138-4780-4EAF-A850-284B8903B20E') and value='true', roles r 
where m.SecurityLevelId=2 and r.guid='A6B2BFC3-D2E0-4496-81D0-224F77085DA5'


