INSERT IGNORE INTO permissions (name, display_name, created_at, updated_at) VALUES
('reports.view','View clinical reports',NOW(),NOW()),
('reports.create','Create clinical reports',NOW(),NOW()),
('reports.edit','Edit clinical reports',NOW(),NOW()),
('reports.submit','Submit clinical reports',NOW(),NOW()),
('reports.review','Review and return clinical reports',NOW(),NOW()),
('reports.approve','Approve clinical reports',NOW(),NOW()),
('reports.generate','Generate official report',NOW(),NOW());

INSERT IGNORE INTO role_permissions (role_id, permission_id)
SELECT r.id,p.id FROM roles r CROSS JOIN permissions p
WHERE r.name='SUPER_ADMIN' AND p.name IN ('reports.view','reports.create','reports.edit','reports.submit','reports.review','reports.approve','reports.generate');

INSERT IGNORE INTO role_permissions (role_id, permission_id)
SELECT r.id,p.id FROM roles r CROSS JOIN permissions p
WHERE r.name='ADMIN' AND p.name IN ('reports.view','reports.create','reports.edit','reports.submit','reports.review','reports.approve','reports.generate');

INSERT IGNORE INTO role_permissions (role_id, permission_id)
SELECT r.id,p.id FROM roles r CROSS JOIN permissions p
WHERE r.name='THERAPIST' AND p.name IN ('reports.view','reports.create','reports.edit','reports.submit');
