INSERT IGNORE INTO permissions (name, display_name, description) VALUES
('treatment_plans.view','View Treatment Plans','View treatment plans and goals.'),
('treatment_plans.create','Create Treatment Plans','Create treatment plans for patients.'),
('treatment_plans.edit','Edit Treatment Plans','Edit treatment plans.'),
('treatment_plans.manage','Manage Treatment Plans','Change treatment plan status, including closing plans.');

INSERT IGNORE INTO role_permissions (role_id, permission_id)
SELECT r.id,p.id FROM roles r CROSS JOIN permissions p
WHERE r.name IN ('SUPER_ADMIN','ADMIN') AND p.name IN ('treatment_plans.view','treatment_plans.create','treatment_plans.edit','treatment_plans.manage');
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 ('treatment_plans.view','treatment_plans.create','treatment_plans.edit');
