<?php

/**
 * Specialty practice modules (Settings → Modules).
 * Pro-gated via plans.*.features specialty_modules.
 *
 * Primary specialty visibility is driven by CarePermissions::primaryAppsFor() /
 * referAppsFor() / viewAppsFor() (role → module keys). Config roles /
 * support_roles / view_roles / refer_roles remain for legacy doctor desk-specialist
 * keyword matching and as a secondary allowlist aligned with the matrix.
 *
 * @return array<string, array<string, mixed>>
 */
return [
    'emergency' => [
        'label' => 'Emergency',
        'description' => 'Emergency department triage, resus, and urgent care queues.',
        'department_type' => 'emergency',
        'department_name' => 'Emergency',
        'queue_name' => 'Emergency',
        'queue_prefix' => 'ER',
        'nav_label' => 'Emergency',
        'icon' => 'bolt',
        'queue_keywords' => ['emerg', 'casualty', 'trauma', 'er', 'a&e'],
        'access' => 'general',
        'roles' => [
            'emergency_physician', 'ed_nurse', 'general_physician', 'doctor',
            'ambulance_staff',
        ],
        'view_roles' => [
            'emergency_physician', 'ed_nurse', 'general_physician', 'doctor',
            'ambulance_staff', 'nurse', 'pharmacist', 'receptionist',
        ],
        'refer_roles' => [
            'general_physician', 'doctor', 'nurse', 'pharmacist', 'receptionist',
        ],
        'default_on_paid_plans' => true,
    ],
    'blood_bank' => [
        'label' => 'Blood Bank',
        'description' => 'Blood products, cross-match requests, and transfusion counters.',
        'department_type' => 'blood_bank',
        'department_name' => 'Blood Bank',
        'queue_name' => 'Blood Bank',
        'queue_prefix' => 'BB',
        'nav_label' => 'Blood Bank',
        'icon' => 'droplet',
        'queue_keywords' => ['blood', 'transfusion', 'crossmatch', 'donor'],
        'access' => 'general',
        'roles' => [
            'blood_bank_officer', 'blood_bank_manager', 'lab_technician', 'lab_manager',
            'emergency_physician', 'ed_nurse', 'surgeon', 'theatre_nurse',
        ],
        'view_roles' => [
            'blood_bank_officer', 'blood_bank_manager', 'lab_technician', 'lab_manager',
            'pathologist', 'emergency_physician', 'ed_nurse', 'surgeon', 'theatre_nurse',
            'general_physician', 'doctor', 'nurse',
        ],
        'refer_roles' => [
            'general_physician', 'doctor', 'nurse',
        ],
        'default_on_paid_plans' => true,
    ],
    'dentistry' => [
        'label' => 'Dentistry',
        'description' => 'Dental chairs, oral consults, and dentistry waiting lists.',
        'department_type' => 'dental',
        'department_name' => 'Dentistry',
        'queue_name' => 'Dentistry',
        'queue_prefix' => 'DEN',
        'nav_label' => 'Dentistry',
        'icon' => 'face-smile',
        'queue_keywords' => ['dent', 'dental', 'oral'],
        'access' => 'limited',
        'roles' => ['dentist'],
        'view_roles' => ['dentist', 'general_physician', 'doctor', 'receptionist'],
        'refer_roles' => ['general_physician', 'doctor', 'receptionist'],
        'specialist_keywords' => ['dent', 'dental', 'oral', 'odont'],
    ],
    'ophthalmology' => [
        'label' => 'Eye care',
        'description' => 'Ophthalmology and optometry clinics with dedicated queues.',
        'department_type' => 'ophthalmology',
        'department_name' => 'Eye care',
        'queue_name' => 'Eye care',
        'queue_prefix' => 'EYE',
        'nav_label' => 'Eye care',
        'icon' => 'eye',
        'queue_keywords' => ['eye', 'ophthal', 'optom'],
        'access' => 'limited',
        'roles' => ['ophthalmologist', 'general_physician', 'doctor'],
        'view_roles' => [
            'ophthalmologist', 'general_physician', 'doctor', 'receptionist',
        ],
        'refer_roles' => ['general_physician', 'doctor', 'receptionist'],
        'specialist_keywords' => ['eye', 'ophthal', 'optom'],
    ],
    'physiotherapy' => [
        'label' => 'Physiotherapy',
        'description' => 'Rehab sessions and physiotherapy treatment queues.',
        'department_type' => 'physiotherapy',
        'department_name' => 'Physiotherapy',
        'queue_name' => 'Physiotherapy',
        'queue_prefix' => 'PHY',
        'nav_label' => 'Physiotherapy',
        'icon' => 'arrow-path',
        'queue_keywords' => ['physio', 'rehab', 'therapy'],
        'access' => 'limited',
        'roles' => ['physiotherapist'],
        'view_roles' => [
            'physiotherapist', 'general_physician', 'doctor', 'receptionist',
        ],
        'refer_roles' => ['general_physician', 'doctor', 'receptionist'],
        'specialist_keywords' => ['physio', 'rehab', 'therapy'],
    ],
    'womens_health' => [
        'label' => "Women's Health (OB/GYN)",
        'description' => 'Gynecology, obstetrics, antenatal, labour & delivery, postnatal, and related women\'s health clinics.',
        'department_type' => 'womens_health',
        'department_name' => "Women's Health",
        'queue_name' => "Women's Health",
        'queue_prefix' => 'WH',
        'nav_label' => "Women's Health",
        'icon' => 'home',
        'queue_keywords' => ['women', 'obgyn', 'ob/gyn', 'gynae', 'gynec', 'matern', 'antenatal', 'obstetric', 'labour', 'labor'],
        'access' => 'limited',
        'roles' => [
            'obstetrician', 'gynecologist', 'obgyn', 'midwife', 'labour_ward_nurse', 'nurse',
        ],
        'view_roles' => [
            'obstetrician', 'gynecologist', 'obgyn', 'midwife', 'labour_ward_nurse', 'nurse',
            'general_physician', 'doctor', 'pharmacist', 'receptionist',
        ],
        'refer_roles' => [
            'general_physician', 'doctor', 'pharmacist', 'receptionist',
        ],
        'specialist_keywords' => [
            'women', 'obgyn', 'ob/gyn', 'gynae', 'gynecolog', 'obstetric', 'matern', 'antenatal', 'midwif',
        ],
        // Configurable service lines (Settings → Modules → Women's Health).
        // All default on so migrated maternity hospitals keep full surface.
        'service_lines' => [
            'gynecology' => ['label' => 'Gynecology', 'default_on' => true],
            'obstetrics' => ['label' => 'Obstetrics', 'default_on' => true],
            'antenatal' => ['label' => 'Antenatal Clinic', 'default_on' => true],
            'labour_delivery' => ['label' => 'Labour & Delivery (Maternity)', 'default_on' => true],
            'postnatal' => ['label' => 'Postnatal Care', 'default_on' => true],
            'family_planning' => ['label' => 'Family Planning', 'default_on' => true],
            'cervical_screening' => ['label' => 'Cervical Screening', 'default_on' => true],
            'menopause' => ['label' => 'Menopause Clinic', 'default_on' => true],
            'high_risk_pregnancy' => ['label' => 'High-Risk Pregnancy', 'default_on' => true],
            'early_pregnancy' => ['label' => 'Early Pregnancy Assessment', 'default_on' => true],
        ],
    ],
    'radiology' => [
        'label' => 'Radiology',
        'description' => 'Imaging requests and radiology service counters.',
        'department_type' => 'radiology',
        'department_name' => 'Radiology',
        'queue_name' => 'Radiology',
        'queue_prefix' => 'RAD',
        'nav_label' => 'Radiology',
        'icon' => 'camera',
        'queue_keywords' => ['radio', 'imaging', 'x-ray', 'xray', 'ultrasound', 'ct', 'mri'],
        'access' => 'general',
        'roles' => [
            'radiologist', 'radiographer', 'emergency_physician', 'ed_nurse', 'surgeon',
        ],
        'view_roles' => [
            'radiologist', 'radiographer', 'emergency_physician', 'ed_nurse', 'surgeon',
            'lab_technician', 'lab_manager', 'general_physician', 'doctor',
        ],
        'refer_roles' => [
            'general_physician', 'doctor',
        ],
        'specialist_keywords' => ['radio', 'radiolog', 'imaging'],
    ],
    'cardiology' => [
        'label' => 'Cardiology',
        'description' => 'Heart clinics, ECG follow-up, and cardiology waiting lists.',
        'department_type' => 'cardiology',
        'department_name' => 'Cardiology',
        'queue_name' => 'Cardiology',
        'queue_prefix' => 'CAR',
        'nav_label' => 'Cardiology',
        'icon' => 'heart',
        'queue_keywords' => ['cardio', 'heart', 'ecg', 'echo'],
        'access' => 'restricted',
        'roles' => ['cardiologist', 'emergency_physician', 'general_physician', 'doctor'],
        'support_roles' => ['ed_nurse'],
        'view_roles' => [
            'cardiologist', 'emergency_physician', 'general_physician', 'doctor',
            'ed_nurse',
        ],
        'refer_roles' => ['general_physician', 'doctor'],
        'specialist_keywords' => ['cardio', 'cardiology', 'heart', 'ecg'],
    ],
    'psychiatry' => [
        'label' => 'Psychiatry',
        'description' => 'Mental health consultations and psychiatry clinic queues.',
        'department_type' => 'psychiatry',
        'department_name' => 'Psychiatry',
        'queue_name' => 'Psychiatry',
        'queue_prefix' => 'PSY',
        'nav_label' => 'Psychiatry',
        'icon' => 'chat-bubble-left-right',
        'queue_keywords' => ['psych', 'mental', 'behaviour'],
        'access' => 'restricted',
        'roles' => ['psychiatrist'],
        'support_roles' => [],
        'view_roles' => [
            'psychiatrist', 'general_physician', 'doctor',
        ],
        'refer_roles' => ['general_physician', 'doctor'],
        'specialist_keywords' => ['psych', 'psychiatry', 'mental', 'behaviour'],
    ],
    'pediatrics' => [
        'label' => 'Pediatrics',
        'description' => 'Child health clinics and pediatric consultation queues.',
        'department_type' => 'pediatrics',
        'department_name' => 'Pediatrics',
        'queue_name' => 'Pediatrics',
        'queue_prefix' => 'PED',
        'nav_label' => 'Pediatrics',
        'icon' => 'user-group',
        'queue_keywords' => ['pedia', 'paedia', 'child', 'infant'],
        'access' => 'general',
        'roles' => ['pediatrician', 'general_physician', 'doctor'],
        'view_roles' => [
            'pediatrician', 'general_physician', 'doctor', 'nurse', 'receptionist',
        ],
        'refer_roles' => [
            'general_physician', 'doctor', 'nurse', 'receptionist',
        ],
        // Avoid bare "child" — collides with Child Welfare Clinic specialty labels.
        'specialist_keywords' => ['pedia', 'paedia', 'pediatric', 'paediatric', 'infant'],
    ],
    'orthopedics' => [
        'label' => 'Orthopedics',
        'description' => 'Bones, joints, fracture clinics, and orthopedic queues.',
        'department_type' => 'orthopedics',
        'department_name' => 'Orthopedics',
        'queue_name' => 'Orthopedics',
        'queue_prefix' => 'ORT',
        'nav_label' => 'Orthopedics',
        'icon' => 'cube',
        'queue_keywords' => ['ortho', 'fracture', 'bone', 'joint'],
        'access' => 'restricted',
        'roles' => ['orthopedist'],
        'support_roles' => [],
        'view_roles' => [
            'orthopedist', 'general_physician', 'doctor',
        ],
        'refer_roles' => ['general_physician', 'doctor'],
        'specialist_keywords' => ['ortho', 'orthopedic', 'orthopaedic', 'fracture'],
    ],
    'ent' => [
        'label' => 'ENT',
        'description' => 'Ear, nose, and throat clinics with dedicated queues.',
        'department_type' => 'ent',
        'department_name' => 'ENT',
        'queue_name' => 'ENT',
        'queue_prefix' => 'ENT',
        'nav_label' => 'ENT',
        'icon' => 'speaker-wave',
        'queue_keywords' => ['ent', 'ear', 'nose', 'throat', 'otolaryng'],
        'access' => 'restricted',
        'roles' => ['ent_specialist', 'general_physician', 'doctor'],
        'support_roles' => [],
        'view_roles' => [
            'ent_specialist', 'general_physician', 'doctor',
        ],
        'refer_roles' => ['general_physician', 'doctor'],
        'specialist_keywords' => ['ent', 'otolaryng', 'ear', 'nose', 'throat'],
    ],
    'oncology' => [
        'label' => 'Oncology',
        'description' => 'Cancer care clinics, chemo day-care, and oncology queues.',
        'department_type' => 'oncology',
        'department_name' => 'Oncology',
        'queue_name' => 'Oncology',
        'queue_prefix' => 'ONC',
        'nav_label' => 'Oncology',
        'icon' => 'shield-exclamation',
        'queue_keywords' => ['oncol', 'cancer', 'chemo'],
        'access' => 'restricted',
        'roles' => ['oncologist'],
        'support_roles' => ['nurse'],
        'view_roles' => [
            'oncologist', 'general_physician', 'doctor', 'pharmacist',
        ],
        'refer_roles' => [
            'general_physician', 'doctor', 'pharmacist',
        ],
        'specialist_keywords' => ['oncol', 'cancer', 'chemo'],
    ],
    'renal' => [
        'label' => 'Renal Care',
        'description' => 'Dialysis, nephrology clinics, and renal care queues.',
        'department_type' => 'renal',
        'department_name' => 'Renal Care',
        'queue_name' => 'Renal Care',
        'queue_prefix' => 'REN',
        'nav_label' => 'Renal Care',
        'icon' => 'circle-stack',
        'queue_keywords' => ['renal', 'dialysis', 'nephro', 'kidney'],
        'access' => 'restricted',
        'roles' => ['dialysis_nurse'],
        'support_roles' => [],
        'view_roles' => [
            'dialysis_nurse', 'general_physician', 'doctor',
        ],
        'refer_roles' => ['general_physician', 'doctor'],
        'specialist_keywords' => ['renal', 'nephro', 'dialysis', 'kidney'],
    ],
    'surgery' => [
        'label' => 'Surgery',
        'description' => 'Surgical OPD, pre-op assessment, and theatre-linked queues.',
        'department_type' => 'surgery',
        'department_name' => 'Surgery',
        'queue_name' => 'Surgery',
        'queue_prefix' => 'SUR',
        'nav_label' => 'Surgery',
        'icon' => 'wrench-screwdriver',
        'queue_keywords' => ['surg', 'theatre', 'operat', 'pre-op'],
        'access' => 'restricted',
        'roles' => ['surgeon', 'theatre_nurse'],
        'support_roles' => [],
        'view_roles' => [
            'surgeon', 'theatre_nurse', 'general_physician', 'doctor',
        ],
        'refer_roles' => ['general_physician', 'doctor'],
        'specialist_keywords' => ['surg', 'theatre', 'operat'],
    ],
    'vaccination' => [
        'label' => 'Vaccination & Immunization',
        'description' => 'Immunization clinics, EPI schedules, and vaccine queues.',
        'department_type' => 'vaccination',
        'department_name' => 'Vaccination',
        'queue_name' => 'Vaccination',
        'queue_prefix' => 'VAX',
        'nav_label' => 'Vaccination',
        'icon' => 'shield-check',
        'queue_keywords' => ['vaccin', 'immun', 'epi', 'injection'],
        'access' => 'general',
        'roles' => ['general_physician', 'doctor', 'nurse'],
        'view_roles' => [
            'general_physician', 'doctor', 'nurse', 'receptionist',
        ],
        'refer_roles' => ['general_physician', 'doctor', 'receptionist'],
        'specialist_keywords' => ['vaccin', 'immun', 'epi'],
    ],
    'pathology' => [
        'label' => 'Pathology',
        'description' => 'Clinic histopathology and cytology specialty flow (complementary to the Lab app queue).',
        'department_type' => 'pathology',
        'department_name' => 'Pathology',
        'queue_name' => 'Pathology',
        'queue_prefix' => 'PATH',
        'nav_label' => 'Pathology',
        'icon' => 'document-magnifying-glass',
        'queue_keywords' => ['pathol', 'histo', 'cytol', 'biopsy'],
        'access' => 'general',
        'roles' => [
            'lab_technician', 'lab_manager', 'pathologist',
            'emergency_physician', 'ed_nurse', 'surgeon',
        ],
        'view_roles' => [
            'lab_technician', 'lab_manager', 'pathologist',
            'emergency_physician', 'ed_nurse', 'surgeon',
            'general_physician', 'doctor',
        ],
        'refer_roles' => [
            'general_physician', 'doctor',
        ],
        'specialist_keywords' => ['pathol', 'histo', 'cytol'],
    ],
    'infusion' => [
        'label' => 'Infusion Centre',
        'description' => 'IV therapy, infusion chairs, and day-care infusion queues.',
        'department_type' => 'infusion',
        'department_name' => 'Infusion Centre',
        'queue_name' => 'Infusion',
        'queue_prefix' => 'INF',
        'nav_label' => 'Infusion',
        'icon' => 'beaker',
        'queue_keywords' => ['infusion', 'iv', 'drip', 'day care'],
        'access' => 'general',
        'roles' => ['oncologist', 'nurse'],
        'view_roles' => [
            'oncologist', 'nurse', 'general_physician', 'doctor', 'pharmacist',
        ],
        'refer_roles' => [
            'general_physician', 'doctor', 'pharmacist',
        ],
        'specialist_keywords' => ['infusion', 'iv therapy', 'day care'],
    ],
    'dermatology' => [
        'label' => 'Dermatology',
        'description' => 'Skin clinics, dermatology procedures, and specialty queues.',
        'department_type' => 'dermatology',
        'department_name' => 'Dermatology',
        'queue_name' => 'Dermatology',
        'queue_prefix' => 'DER',
        'nav_label' => 'Dermatology',
        'icon' => 'swatch',
        'queue_keywords' => ['derma', 'skin', 'rash'],
        'access' => 'restricted',
        'roles' => ['dermatologist', 'general_physician', 'doctor'],
        'support_roles' => [],
        'view_roles' => [
            'dermatologist', 'general_physician', 'doctor',
        ],
        'refer_roles' => ['general_physician', 'doctor'],
        'specialist_keywords' => ['derma', 'skin'],
    ],
    'podiatry' => [
        'label' => 'Podiatry',
        'description' => 'Foot clinics, diabetic foot care, and podiatry queues.',
        'department_type' => 'podiatry',
        'department_name' => 'Podiatry',
        'queue_name' => 'Podiatry',
        'queue_prefix' => 'POD',
        'nav_label' => 'Podiatry',
        'icon' => 'finger-print',
        'queue_keywords' => ['podiat', 'foot', 'diabetic foot'],
        'access' => 'restricted',
        'roles' => ['podiatrist'],
        'support_roles' => [],
        'view_roles' => [
            'podiatrist', 'general_physician', 'doctor',
        ],
        'refer_roles' => ['general_physician', 'doctor'],
        'specialist_keywords' => ['podiat', 'foot'],
    ],
    'fertility' => [
        'label' => 'Fertility & Reproductive Medicine',
        'description' => 'IVF / fertility clinics, embryology, and reproductive medicine queues. Integrates with Women\'s Health via referrals.',
        'department_type' => 'fertility',
        'department_name' => 'Fertility',
        'queue_name' => 'Fertility',
        'queue_prefix' => 'FER',
        'nav_label' => 'Fertility',
        'icon' => 'sparkles',
        'queue_keywords' => ['fertil', 'ivf', 'reproduct', 'embryol'],
        'access' => 'restricted',
        'roles' => ['fertility_specialist', 'embryologist', 'fertility_nurse'],
        'support_roles' => [],
        'view_roles' => [
            'fertility_specialist', 'embryologist', 'fertility_nurse',
            'general_physician', 'doctor', 'obstetrician', 'gynecologist', 'obgyn',
        ],
        'refer_roles' => [
            'general_physician', 'doctor', 'obstetrician', 'gynecologist', 'obgyn', 'midwife',
        ],
        'specialist_keywords' => ['fertil', 'ivf', 'reproduct', 'embryol'],
    ],
    'child_welfare' => [
        'label' => 'Child Welfare Clinic',
        'description' => 'Well-child / CWC clinics: intake, growth assessment, care plans, and follow-up.',
        'department_type' => 'child_welfare',
        'department_name' => 'Child Welfare Clinic',
        'queue_name' => 'Child Welfare',
        'queue_prefix' => 'CWC',
        'nav_label' => 'Child Welfare',
        'icon' => 'gift',
        'queue_keywords' => ['cwc', 'child welfare', 'well baby', 'well-child', 'welfare clinic'],
        'access' => 'general',
        'roles' => ['general_physician', 'doctor', 'nurse'],
        'view_roles' => [
            'general_physician', 'doctor', 'nurse', 'receptionist',
        ],
        'refer_roles' => ['general_physician', 'doctor', 'receptionist'],
        // Prefer multi-word / CWC stems — do not use bare "child" (steals pediatrics).
        'specialist_keywords' => ['child welfare', 'cwc', 'welfare clinic', 'well baby', 'well-child'],
    ],
    'ambulance' => [
        'label' => 'Ambulance',
        'description' => 'EMS / ambulance dispatch board: new calls, dispatch, scene, transport, and facility handover.',
        'department_type' => 'ambulance',
        'department_name' => 'Ambulance',
        'queue_name' => 'Ambulance',
        'queue_prefix' => 'AMB',
        'nav_label' => 'Ambulance',
        'icon' => 'truck',
        // Avoid ED stems (emergency, casualty, trauma, er, a&e) — those belong to emergency.
        'queue_keywords' => ['ambulance', 'ems', 'paramedic', 'prehospital', 'ambulance service'],
        'access' => 'general',
        'roles' => ['ambulance_staff'],
        'view_roles' => [
            'ambulance_staff', 'general_physician', 'doctor', 'receptionist',
        ],
        'refer_roles' => [
            'general_physician', 'doctor', 'receptionist',
        ],
        'specialist_keywords' => ['ambulance', 'ems', 'paramedic', 'prehospital'],
    ],
    'nursing_services' => [
        'label' => 'Nursing Services',
        'description' => 'Nursing administration hub: nurse registry, ward allocation, duty roster, and unit clinical shortcuts.',
        'department_type' => 'nursing',
        'department_name' => 'Nursing Services',
        'queue_name' => 'Nursing',
        'queue_prefix' => 'NUR',
        'nav_label' => 'Nursing',
        'icon' => 'user-group',
        'queue_keywords' => ['nursing', 'nurse', 'matron', 'ward'],
        'access' => 'general',
        'roles' => [
            'ed_nurse', 'theatre_nurse', 'labour_ward_nurse',
            'fertility_nurse', 'dialysis_nurse', 'midwife',
        ],
        'view_roles' => [
            'ed_nurse', 'theatre_nurse', 'labour_ward_nurse',
            'fertility_nurse', 'dialysis_nurse', 'midwife',
            'department_manager', 'general_physician', 'doctor',
        ],
        'refer_roles' => [],
        'specialist_keywords' => ['nursing services', 'nursing', 'matron'],
        'default_on_paid_plans' => true,
    ],
];
