

--create permission
insert into usermanagement.permission (name, description) values (E'AdminModule.viewAdminTab',	E'User is allowed to view the Admin Stuff');
insert into usermanagement.permission (name, description) values (E'Core.changePhysician',		E'User is allowed to change to another physician');


--create roles
INSERT INTO usermanagement.role (name, description) values (E'PatientModule.admin',     E'Administrator allowed to do everything');
INSERT INTO usermanagement.role (name, description) values (E'PatientModule.physician', E'Physician Role');
INSERT INTO usermanagement.role (name, description) values (E'PatientModule.secretary', E'Secretary Role');
INSERT INTO usermanagement.role (name, description) values (E'Core.changePhysician', 	E'change Physician');

--create admin user
insert into usermanagement.gecamed_user (name, language, last_modification, modified_by, login, passwordhash, locale_id) values (E'System Administrator',E'en_US','2005-03-21','1',E'admin','ISMvKXpXpadDiUoOSoAfww==', 1);


--add rights to roles
insert into usermanagement.rel_role_permission (role_id,permission_id) values ((select id from usermanagement.role where name=E'PatientModule.admin'),(select id from usermanagement.permission where name=E'AdminModule.viewAdminTab'));
insert into usermanagement.rel_role_permission (role_id,permission_id) values ((select id from usermanagement.role where name=E'Core.changePhysician'),(select id from usermanagement.permission where name=E'Core.changePhysician'));
insert into usermanagement.rel_role_permission (role_id,permission_id) values ((select id from usermanagement.role where name=E'PatientModule.admin'),(select id from usermanagement.permission where name=E'Core.changePhysician'));


--add roles to users
insert into usermanagement.rel_user_role (user_id,role_id) values ((select id from usermanagement.gecamed_user where name=E'System Administrator'),(select id from usermanagement.role where name=E'PatientModule.admin'));

