
-- add permissions
INSERT INTO usermanagement.permission (name, description) 
VALUES 
('ReportModule.useReports','User is allowed to use reports'),
('ReportModule.createReports', 'User is allowed to create new reports');

-- add roles
INSERT INTO usermanagement.role (name, description) 
VALUES 
('ReportModule.admin', 'Use and create reports'),
('ReportModule.user', 'Use created reports');

-- add permissions to roles
INSERT INTO usermanagement.rel_role_permission (role_id,permission_id) 
VALUES 
-- assign permissions for admin 
((SELECT id FROM usermanagement.role WHERE name='PatientModule.admin'),
	(SELECT id FROM usermanagement.permission WHERE name='ReportModule.useReports')),
((SELECT id FROM usermanagement.role WHERE name='PatientModule.admin'),
	(SELECT id FROM usermanagement.permission WHERE name='ReportModule.createReports')),
-- assign permissions for report module admin
((SELECT id FROM usermanagement.role WHERE name='ReportModule.admin'),
	(SELECT id FROM usermanagement.permission WHERE name='ReportModule.useReports')),
((SELECT id FROM usermanagement.role WHERE name='ReportModule.admin'),
	(SELECT id FROM usermanagement.permission WHERE name='ReportModule.createReports')),
-- assign permissions for report module user
((SELECT id FROM usermanagement.role WHERE name='ReportModule.user'),
	(SELECT id FROM usermanagement.permission WHERE name='ReportModule.useReports'));