<?php

namespace RxConnexionBundle\Service;

use Symfony\Component\DependencyInjection\ContainerInterface;
use Doctrine\ORM\EntityManager;
use Symfony\Component\HttpFoundation\RedirectResponse;

Class AuthService {

    private $em;
    private $container;

    public function __construct(EntityManager $em, ContainerInterface $container) {

        $this->em = $em;
        $this->container = $container;
    }

    // Original PHP code by Chirp Internet: www.chirp.com.au
    public function better_crypt($input, $rounds = 7)
    {
        $salt = "";
        $salt_chars = array_merge(range('A','Z'), range('a','z'), range(0,9));
        for($i=0; $i < 22; $i++) {
            $salt .= $salt_chars[array_rand($salt_chars)];
        }
        return crypt($input, sprintf('$2a$%02d$', $rounds) . $salt);
    }

    /**
     * Checks if the user is logged in or not
     */
    public function isLoggedIn($requestUri = true) {

        $session = $this->container->get('session');

        if($session->has('userData') && isset($_COOKIE['userId']) && '' !== $_COOKIE['userId'] && null !== $_COOKIE['userId']) {
            return true;
        } else {
            if($requestUri) {
                $req_uri = $_SERVER['REQUEST_URI'];
                if($req_uri !== $this->container->get('router')->generate('login') &&
                    $req_uri !== $this->container->get('router')->generate('logout') &&
                    strpos($req_uri, 'ajax') === false) $session->set('req_uri', $req_uri);
            }
            return false;
        }
    }

    /**
     * Checks if the general user is logged in or not
     */
    public function isLoggedInGeneralUser() {

        $session = $this->container->get('session');

        return $session->has('generalUserData');
    }

    /**
     * Checks if the user has the access
     */
    public function isUserHasAccesses($accessDescriptions, $hasErrorMsg=true, $matchCtr=false) {
        $session = $this->container->get('session');
        //$session->save(); // This will automatically call session_write_close() to prevent session lock timeout error
        $userData = $session->get('userData');
        if($userData['type'] === 'Super Admin') {
            return true;
        } else {
            if($matchCtr) {
                $accessCtr = 0;
                foreach($accessDescriptions as $accessDescription) if(in_array($accessDescription, $userData['accesses'])) $accessCtr++;
                $hasAccess = count($accessDescriptions) === $accessCtr;
                if(!$hasAccess) {
                    if($hasErrorMsg) {
                        $session->getFlashBag()->set('error_messages', "You don't have the right to access the page. Please contact the administrator.");
                    }
                    return false;
                } else {
                    return true;
                }
            } else {
                foreach($accessDescriptions as $accessDescription) if(in_array($accessDescription, $userData['accesses'])) return true;
                if($hasErrorMsg) $session->getFlashBag()->set('error_messages', "You don't have the right to access the page. Please contact the administrator.");
                return false;
            }
        }
    }

    /**
     * Redirects to login page
     */
    public function redirectToLogin() {

        $req_uri = $_SERVER['REQUEST_URI'];
        if($req_uri !== $this->container->get('router')->generate('login') &&
            $req_uri !== $this->container->get('router')->generate('logout') &&
            /*$req_uri !== $this->container->get('router')->generate('auth_forgot_password') &&*/
            strpos($req_uri, 'ajax') === false) {
            $url = $this->container->get('router')->generate('login', array('then' => $req_uri));
        } else {
            $url = $this->container->get('router')->generate('login');
        }

        return new RedirectResponse($url, 302);
    }

    /**
     * Redirects to home page
     */
    public function redirectToHome() {

        return new RedirectResponse($this->container->get('router')->generate('main'), 302);
    }

    /**
     * Get user
     */
    public function getUser() {

        $session = $this->container->get('session');
        //$session->save(); // This will automatically call session_write_close() to prevent session lock timeout error
        $userData = $session->get('userData');
        if($userData['userType'] != 'System'){
            return $accountUser = $this->em->getRepository('RxConnexionBundle:AccountUserEntity')->find($userData['id']);
        }else{
            return $this->em->getRepository('RxConnexionBundle:UserEntity')->find($userData['id']);
        }

    }

    /**
     * Get user types
     */
    public function getUserTypes() {

//        $accountUserType = $this->em->getRepository('RxConnexionBundle:AccountUserTypeEntity')->userTypeAccessList();
//
//        foreach ($accountUserType as $rows) {
//            return array (
//                $rows['description']
//            );
//        }
    }

    /**
     * Get user account Id
     */
    public function get_user_account_id() {
        $userData = $this->container->get('session')->get('userData');
        return $userData['accountId'];
    }

    public function getAccesses()
    {
        return array(
            array('label' => 'Admin', 'description' => 'Admin', 'children' => array(
                //Patient Access
                array('label' => 'Manage Patient', 'description' => 'Admin Patient', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Patient New'),
                    array('label' => 'Update', 'description' => 'Admin Patient Update'),
                    array('label' => 'Delete', 'description' => 'Admin Patient Delete'),
                    array('label' => 'Patient Details', 'description' => 'Admin Patient Detail', 'children' => array(
                        array('label' => 'Profile', 'description' => 'Admin Patient Detail Profile'),

                        //Patient Encounter
                        array('label' => 'Patient Encounter', 'description' => 'Admin Patient Detail Encounter', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Patient Chart New'),
                            array('label' => 'Update', 'description' => 'Admin Patient Chart Update'),
                            array('label' => 'Delete', 'description' => 'Admin Patient Chart Delete', 'children' => array(
                                array('label' => 'Encounter Medical', 'description' => 'Admin Patient Chart Medical', 'children' => array(
                                    array('label' => 'Encounter Diagnosis', 'description' => 'Admin Patient Chart Medical Diagnosis', 'children' => array(
                                        array('label' => 'New', 'description' => 'Admin Patient Chart Medical Diagnosis New'),
                                        array('label' => 'Update', 'description' => 'Admin Patient Chart Medical Diagnosis Update'),
                                        array('label' => 'Delete', 'description' => 'Admin Patient Chart Medical Diagnosis Delete')
                                    )),
                                    array('label' => 'Encounter Medication', 'description' => 'Admin Patient Chart Medical Medication', 'children' => array(
                                        array('label' => 'New', 'description' => 'Admin Patient Chart Medical Medication New'),
                                        array('label' => 'Update', 'description' => 'Admin Patient Chart Medical Medication Update'),
                                        array('label' => 'Delete', 'description' => 'Admin Patient Chart Medical Medication Delete')
                                    )),
                                )),
                                array('label' => 'Encounter Insurance', 'description' => 'Admin Patient Insurance', 'children' => array(
                                    array('label' => 'New', 'description' => 'Admin Patient Insurance New'),
                                    array('label' => 'Update', 'description' => 'Admin Patient Insurance Update'),
                                    array('label' => 'Delete', 'description' => 'Admin Patient Insurance Delete')
                                )),
                                array('label' => 'Encounter File', 'description' => 'Admin Patient Chart File', 'children' => array(
                                    array('label' => 'New', 'description' => 'Admin Patient Chart File New'),
                                    array('label' => 'Update', 'description' => 'Admin Patient Chart File Update'),
                                    array('label' => 'Delete', 'description' => 'Admin Patient Chart File Delete')
                                )),
                                array('label' => 'Encounter Billing', 'description' => 'Admin Patient Chart Billing', 'children' => array(
                                    array('label' => 'Billing', 'description' => 'Admin Patient Chart Billing Procedure', 'children' => array(
                                        array('label' => 'New', 'description' => 'Admin Patient Chart Billing Procedure New'),
                                        array('label' => 'Update', 'description' => 'Admin Patient Chart Billing Procedure Update'),
                                        array('label' => 'Delete', 'description' => 'Admin Patient Chart Billing Procedure Delete'),
                                    )),
                                    array('label' => 'Other Billing', 'description' => 'Admin Patient Chart Billing Other', 'children' => array(
                                        array('label' => 'New', 'description' => 'Admin Patient Chart Billing Other Procedure New'),
                                        array('label' => 'Update', 'description' => 'Admin Patient Chart Billing Other Procedure Update'),
                                        array('label' => 'Delete', 'description' => 'Admin Patient Chart Billing Other Procedure Delete'),
                                    )),
                                )),
                                array('label' => 'Payment', 'description' => 'Admin Patient Chart Payment', 'children' => array(
                                    array('label' => 'New', 'description' => 'Admin Patient Chart Payment New'),
                                    array('label' => 'Update', 'description' => 'Admin Patient Chart Payment Update'),
                                    array('label' => 'Delete', 'description' => 'Admin Patient Chart Payment Delete'),
                                )),
                                array('label' => 'Encounter Note', 'description' => 'Admin Patient Chart Note', 'children' => array(
                                    array('label' => 'New', 'description' => 'Admin Patient Chart Note New'),
                                    array('label' => 'Update', 'description' => 'Admin Patient Chart Note Update'),
                                    array('label' => 'Delete', 'description' => 'Admin Patient Chart Note Delete')
                                )),
                            )),
                        )),

                        //Patient Appointment
                        array('label' => 'Patient Appointment', 'description' => 'Admin Patient Appointment', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Patient Schedule New'),
                            array('label' => 'Appointment Notice', 'description' => 'Admin Appointment Notice'),
                            array('label' => 'Update', 'description' => 'Admin Patient Schedule Update'),
                            array('label' => 'Delete', 'description' => 'Admin Patient Schedule Delete', 'children' => array(
                                array('label' => 'Fax', 'description' => 'Admin Appointment Fax Pdf'),
                                array('label' => 'Fax Preview', 'description' => 'Admin Appointment Notice Pdf Preview'),
                            )),
                        )),

                        //Patient Branch
                        array('label' => 'Patient Branch', 'description' => 'Admin Patient Health Facility', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Patient Health Facility New'),
                            array('label' => 'Update', 'description' => 'Admin Patient Health Facility Update'),
                            array('label' => 'Delete', 'description' => 'Admin Patient Health Facility Delete')
                        )),

                        //Patient Affiliation
                        array('label' => 'Patient Affiliation', 'description' => 'Admin Patient Detail Affiliation', 'children' => array(
                            array('label' => 'Insurance', 'description' => 'Admin Patient Insurance', 'children' => array(
                                array('label' => 'New', 'description' => 'Admin Patient Insurance New'),
                                array('label' => 'Update', 'description' => 'Admin Patient Insurance Update'),
                                array('label' => 'Delete', 'description' => 'Admin Patient Insurance Delete')
                            )),
                            array('label' => 'Referring Affiliate', 'description' => 'Admin Patient Referring Health Facility', 'children' => array(
                                array('label' => 'New', 'description' => 'Admin Patient Referring Health Facility New'),
                                array('label' => 'Update', 'description' => 'Admin Patient Referring Health Facility Update'),
                                array('label' => 'Delete', 'description' => 'Admin Patient Referring Health Facility Delete')
                            )),
                            array('label' => 'Referring Physician', 'description' => 'Admin Patient Referring Provider', 'children' => array(
                                array('label' => 'New', 'description' => 'Admin Patient Referring Provider New'),
                                array('label' => 'Update', 'description' => 'Admin Patient Referring Provider Update'),
                                array('label' => 'Delete', 'description' => 'Admin Patient Referring Provider Delete')
                            )),
                            array('label' => 'Specialist', 'description' => 'Admin Patient Specialist', 'children' => array(
                                array('label' => 'New', 'description' => 'Admin Patient Specialist New'),
                                array('label' => 'Update', 'description' => 'Admin Patient Specialist Update'),
                                array('label' => 'Delete', 'description' => 'Admin Patient Specialist Delete')
                            )),
                        )),

                        //Patient File
                        array('label' => 'Patient File', 'description' => 'Admin Patient Detail File', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Patient File New'),
                            array('label' => 'Update', 'description' => 'Admin Patient File Update'),
                            array('label' => 'Delete', 'description' => 'Admin Patient File Delete')
                        )),

                        //Patient File From Import
                        array('label' => 'Patient File From Import', 'description' => 'Admin Patient Detail File From Import'),

                        //Patient Letters
                        array('label' => 'Patient Letter', 'description' => 'Admin Patient Detail Letter', 'children' => array(
                            array('label' => 'Preview', 'description' => 'Admin Patient Letter Preview'),
                            array('label' => 'Export to PDF', 'description' => 'Admin Patient Letter Pdf'),
                            array('label' => 'Approved', 'description' => 'Admin Patient Letter Approved'),
                            array('label' => 'Fax', 'description' => 'Admin Patient Letter Update'),
                            array('label' => 'New', 'description' => 'Admin Patient Letter New'),
                            array('label' => 'Update', 'description' => 'Admin Patient Letter Update'),
                            array('label' => 'Delete', 'description' => 'Admin Patient Letter Delete'),
                            array('label' => 'Note', 'description' => 'Admin Patient Letter Note')
                        )),

                        //Patient Billing and Payment
                        array('label' => 'Patient Billing', 'description' => 'Admin Patient Billing', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Patient Billing New'),
                            array('label' => 'Update', 'description' => 'Admin Patient Billing Update'),
                            array('label' => 'Delete', 'description' => 'Admin Patient Billing Delete'),
                            array('label' => 'Void', 'description' => 'Admin Patient Billing Void'),
                            array('label' => 'Return', 'description' => 'Admin Patient Billing Return'),
                            array('label' => 'Refund', 'description' => 'Admin Patient Refund', 'children' => array(
                                array('label' => 'New', 'description' => 'Admin Patient Billing Refund New'),
                                array('label' => 'Update', 'description' => 'Admin Patient Billing Refund Update'),
                                array('label' => 'Delete', 'description' => 'Admin Patient Billing Refund Delete'),
                            )),
                            array('label' => 'Preview Invoice', 'description' => 'Admin Patient Billing Invoice Preview'),
                            array('label' => 'Print Invoice', 'description' => 'Admin Patient Billing Invoice Print'),
                            array('label' => 'Insurance Package', 'description' => 'Admin Patient Billing Upload'),
                        )),
                        array('label' => 'Patient Payment', 'description' => 'Admin Patient Payment', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Patient Payment New'),
                            array('label' => 'Update', 'description' => 'Admin Patient Payment Update'),
                            array('label' => 'Delete', 'description' => 'Admin Patient Payment Delete'),
                            array('label' => 'Void', 'description' => 'Admin Patient Payment Void'),
                            array('label' => 'Post', 'description' => 'Admin Patient Payment Post'),
                            array('label' => 'Preview Receipt', 'description' => 'Admin Patient Payment Receipt Preview'),
                            array('label' => 'Print Receipt', 'description' => 'Admin Patient Payment Receipt Print'),
                        )),

                        //Patient Rental
                        array('label' => 'Patient Rental', 'description' => 'Admin Patient Rental', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Patient Rental New'),
                            array('label' => 'Update', 'description' => 'Admin Patient Rental Update'),
                            array('label' => 'Delete', 'description' => 'Admin Patient Rental Delete'),
                        )),

                        //Patient Ticket
                        array('label' => 'Patient Ticket', 'description' => 'Admin Patient Ticket', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Patient Ticket New'),
                            array('label' => 'Update', 'description' => 'Admin Patient Ticket Update'),
                            array('label' => 'Delete', 'description' => 'Admin Patient Ticket Delete'),
                        )),

                        //Patient Reminder
                        array('label' => 'Patient Reminder', 'description' => 'Admin Patient Reminder', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Patient Reminder New'),
                            array('label' => 'Update', 'description' => 'Admin Patient Reminder Update'),
                            array('label' => 'Delete', 'description' => 'Admin Patient Reminder Delete'),
                        )),

                        //Patient History
                        array('label' => 'Patient Audit Trail', 'description' => 'Admin Patient History'),

                        //Patient Notes
                        array('label' => 'Patient Note', 'description' => 'Admin Patient Detail Note', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Patient Note New'),
                            array('label' => 'Update', 'description' => 'Admin Patient Note Update'),
                            array('label' => 'Delete', 'description' => 'Admin Patient Note Delete', 'children' => array(
                                array('label' => 'Clinical Tab', 'description' => 'Admin Patient Clinical Note'),
                                array('label' => 'Billing Tab', 'description' => 'Admin Patient Billing Note'),
                                array('label' => 'Appointment Tab', 'description' => 'Admin Patient Appointment Note'),
                                array('label' => 'Specialist Tab', 'description' => 'Admin Patient Specialist Note'),
                                array('label' => 'All Tab', 'description' => 'Admin Patient All Note'),
                            )),
                        )),
                    )),

                    //Patient Medical
                    array('label' => 'Patient Medical', 'description' => 'Admin Patient Detail Medical', 'children' => array(
                        array('label' => 'Diagnosis', 'description' => 'Admin Patient Medical Diagnosis', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Patient Medical Diagnosis New'),
                            array('label' => 'Update', 'description' => 'Admin Patient Medical Diagnosis Update'),
                            array('label' => 'Delete', 'description' => 'Admin Patient Medical Diagnosis Delete'),
                        )),
                        array('label' => 'Treatment Consideration', 'description' => 'Admin Patient Treatment Consideration', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Patient Treatment Consideration New'),
                            array('label' => 'Update', 'description' => 'Admin Patient Treatment Consideration Update'),
                            array('label' => 'Delete', 'description' => 'Admin Patient Treatment Consideration Delete'),
                        )),
                        array('label' => 'Treatment Plan', 'description' => 'Admin Patient Treatment Plan', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Patient Treatment Plan New'),
                            array('label' => 'Update', 'description' => 'Admin Patient Treatment Plan Update'),
                            array('label' => 'Delete', 'description' => 'Admin Patient Treatment Plan Delete'),
                        )),
                        array('label' => 'Medication', 'description' => 'Admin Patient Medical Medication', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Patient Detail Medical Medication New'),
                            array('label' => 'Update', 'description' => 'Admin Patient Detail Medical Medication Update'),
                            array('label' => 'Delete', 'description' => 'Admin Patient Detail Medical Medication Delete'),
                        )),
                    )),

                    //Patient Red Flag
                    array('label' => 'Patient Red Flag', 'description' => 'Admin Patient Red Flag', 'children' => array(
                        array('label' => 'New', 'description' => 'Admin Patient Red Flag New'),
                        array('label' => 'Update', 'description' => 'Admin Patient Red Flag Update'),
                        array('label' => 'Delete', 'description' => 'Admin Patient Red Flag Delete'),
                    )),

                    //Patient Services
                    array('label' => 'Admin Patient Services', 'description' => 'Admin Patient Services', 'children' => array(
                        array('label' => 'New', 'description' => 'Admin Patient Services New'),
                        array('label' => 'Update', 'description' => 'Admin Patient Services Update'),
                        array('label' => 'Delete', 'description' => 'Admin Patient Services Delete'),
                    )),

                    //Patient Services
                    array('label' => 'Files (Imported)', 'description' => 'Admin Clinicmaster File'),
                )),

                //Clinician Menu
                array('label' => 'Manage Clinician', 'description' => 'Admin Provider', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Provider New'),
                    array('label' => 'Update', 'description' => 'Admin Provider Update'),
                    array('label' => 'Delete', 'description' => 'Admin Provider Delete'),
                    array('label' => 'Clinician Details', 'description' => 'Admin Provider Health Facility', 'children' => array(
                        array('label' => 'Branch', 'description' => 'Admin Provider Detail', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Provider Health Facility New'),
                            array('label' => 'Update', 'description' => 'Admin Provider Health Facility Update'),
                            array('label' => 'Delete', 'description' => 'Admin Provider Health Facility Delete')
                        )),
                        array('label' => 'Work Schedule', 'description' => 'Admin Provider Work Schedule', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Physician Work Schedule New'),
                            array('label' => 'Update', 'description' => 'Admin Physician Work Schedule Update'),
                            array('label' => 'Delete', 'description' => 'Admin Physician Work Schedule Delete'),
                            array('label' => 'History', 'description' => 'Admin Provider Work Schedule History'),
                        )),
                    )),
                )),

                //Appointment Menu
                array('label' => 'Manage Appointment', 'description' => 'Admin Calendar', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Schedule New'),
                    array('label' => 'Update', 'description' => 'Admin Schedule Update'),
                    array('label' => 'Delete', 'description' => 'Admin Schedule Delete'),
                )),

                //Referral Menu
                array('label' => 'Manage Referral', 'description' => 'Admin Referral', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Referral New'),
                    array('label' => 'Update', 'description' => 'Admin Referral Update'),
                    array('label' => 'Delete', 'description' => 'Admin Referral Delete'),
                )),

                //Ticket Menu
                array('label' => 'Manage Ticket', 'description' => 'Admin Ticket', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Ticket New'),
                    array('label' => 'Update', 'description' => 'Admin Ticket Update'),
                    array('label' => 'Delete', 'description' => 'Admin Ticket Delete'),
                )),

                //Letter Menu
                array('label' => 'Manage Ticket', 'description' => 'Admin Letter', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Letter New'),
                    array('label' => 'Update', 'description' => 'Admin Letter Update'),
                    array('label' => 'Delete', 'description' => 'Admin Letter Delete'),
                )),

                //Portal Menu
                array('label' => 'Manage Portal', 'description' => 'Admin Portal', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Portal New'),
                    array('label' => 'Update', 'description' => 'Admin Portal Update'),
                    array('label' => 'Delete', 'description' => 'Admin Portal Delete'),
                )),

                //Faxing Option Menu
                array('label' => 'Manage Faxing Option', 'description' => 'Admin Faxing Option'),

                //Fax Menu
                array('label' => 'Fax', 'description' => 'Admin Fax', 'children' => array(
                    array('label' => 'Send Fax', 'description' => 'Admin Send Fax'),
                    array('label' => 'Fax Details', 'description' => 'Admin Fax Update'),
                )),

                //Fax Menu
                array('label' => 'Map', 'description' => 'Admin Map'),
                array('label' => 'User', 'description' => 'Admin Account User', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Account User New'),
                    array('label' => 'Update', 'description' => 'Admin Account User Update'),
                    array('label' => 'Delete', 'description' => 'Admin Account User Delete'),
                    array('label' => 'Details', 'description' => 'Admin Account User Detail', 'children' => array(
                        array('label' => 'Account User Company', 'description' => 'Admin Account User Company', 'children' => array(
                            array('label' => 'Add Company', 'description' => 'Admin Account User Company New'),
                            array('label' => 'Update Company', 'description' => 'Admin Account User Company Update'),
                            array('label' => 'Delete Company', 'description' => 'Admin Account User Company Delete'),
                        )),
                        array('label' => 'Account User Branch', 'description' => 'Admin Account User Health Facility', 'children' => array(
                            array('label' => 'Add Branch', 'description' => 'Admin Account User Health Facility'),
                            array('label' => 'Update Branch', 'description' => 'Admin Account User Health Facility Update'),
                            array('label' => 'Delete Branch', 'description' => 'Admin Account User Health Facility Delete'),
                        )),
                    )),
                    array('label' => 'Account User Reminder', 'description' => 'Admin Account User Reminder', 'children' => array(
                        array('label' => 'Add Reminder', 'description' => 'Admin Account User Reminder New'),
                        array('label' => 'Update Reminder', 'description' => 'Admin Account User Reminder Update'),
                        array('label' => 'Delete Reminder', 'description' => 'Admin Account User Reminder Delete'),
                    )),
                )),
                array('label' => 'Specialist', 'description' => 'Admin Specialist', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Specialist New'),
                    array('label' => 'Update', 'description' => 'Admin Specialist Update'),
                    array('label' => 'Delete', 'description' => 'Admin Specialist Delete'),
                )),
                array('label' => 'Sales Agent', 'description' => 'Admin Sales Agent', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Sales Agent New'),
                    array('label' => 'Update', 'description' => 'Admin Sales Agent Update'),
                    array('label' => 'Delete', 'description' => 'Admin Sales Agent Delete'),
                    array('label' => 'Details', 'description' => 'Admin Sales Agent Detail', 'children' => array(
                        array('label' => 'Add Affiliate', 'description' => 'Admin Sales Agent New Referring Health Facility'),
                        array('label' => 'Update Affiliate', 'description' => 'Admin Sales Agent Referring Health Facility Update'),
                        array('label' => 'Delete Affiliate', 'description' => 'Admin Sales Agent Referring Health Facility Delete'),
                    )),
                )),
                array('label' => 'Account Staff', 'description' => 'Admin Account Staff', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Account Staff New'),
                    array('label' => 'Update', 'description' => 'Admin Account Staff Update'),
                    array('label' => 'Delete', 'description' => 'Admin Account Staff Delete'),
//                    array('label' => 'Details', 'description' => 'Admin Account Staff Detail'),
                )),
                array('label' => 'Chat', 'description' => 'Admin Chat', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Chat New'),
                    array('label' => 'Update', 'description' => 'Admin Chat Update'),
                    array('label' => 'Delete', 'description' => 'Admin Chat Delete'),
                    array('label' => 'Send', 'description' => 'Admin Chat Send Message'),
                )),

                //REPORTS
                array('label' => 'Access Reports', 'description' => 'Admin Report'),
                array('label' => 'Access Productivity Report', 'description' => 'Admin Report Productivity', 'children' => array(
                    array('label' => 'Productivity Report (Clinical)', 'description' => 'Admin Report Productivity Clinical', 'children' => array(
                        array('label' => 'Preview', 'description' => 'Admin Report Productivity Clinical Preview'),
                        array('label' => 'Export to PDF', 'description' => 'Admin Report Productivity Clinical Pdf'),
                        array('label' => 'Export to Excel', 'description' => 'Admin Report Productivity Clinical Excel'),
                    )),
                    array('label' => 'Productivity Report (Billing)', 'description' => 'Admin Report Productivity Billing', 'children' => array(
                        array('label' => 'Preview', 'description' => 'Admin Report Productivity Billing Preview'),
                        array('label' => 'Export to PDF', 'description' => 'Admin Report Productivity Billing Pdf'),
                        array('label' => 'Export to Excel', 'description' => 'Admin Report Productivity Billing Excel'),
                    )),
                )),
                array('label' => 'Access Billing Report', 'description' => 'Admin Report Billing', 'children' => array(
                    array('label' => 'Invoice', 'description' => 'Admin Report Invoice', 'children' => array(
                        array('label' => 'Preview', 'description' => 'Admin Report Invoice Preview'),
                        array('label' => 'Export to PDF', 'description' => 'Admin Report Invoice Pdf'),
                        array('label' => 'Export to Excel', 'description' => 'Admin Report Invoice Excel'),
                    )),
                    array('label' => 'Invoice Itemised', 'description' => 'Admin Report Invoice Itemised', 'children' => array(
                        array('label' => 'Preview', 'description' => 'Admin Report Invoice Itemised Preview'),
                        array('label' => 'Export to PDF', 'description' => 'Admin Report Invoice Itemised Pdf'),
                        array('label' => 'Export to Excel', 'description' => 'Admin Report Invoice Itemised Excel'),
                    )),
                    array('label' => 'Report Rent to Own and Long Term Rental', 'description' => 'Admin Report Rent to Own and Long Term Rental', 'children' => array(
                        array('label' => 'Preview', 'description' => 'Admin Report Rent to Own and Long Term Rental Preview'),
                        array('label' => 'Export to PDF', 'description' => 'Admin Report Rent to Own and Long Term Rental Pdf'),
                        array('label' => 'Export to Excel', 'description' => 'Admin Report Rent to Own and Long Term Rental Excel'),
                    )),
                    array('label' => 'Accounts Receivable', 'description' => 'Admin Report Accounts Receivable', 'children' => array(
                        array('label' => 'Preview', 'description' => 'Admin Report Accounts Receivable Preview'),
                        array('label' => 'Export to PDF', 'description' => 'Admin Report Accounts Receivable Pdf'),
                        array('label' => 'Export to Excel', 'description' => 'Admin Report Accounts Receivable Excel'),
                    )),
                    array('label' => 'AR Summary', 'description' => 'Admin Report AR Summary', 'children' => array(
                        array('label' => 'Preview', 'description' => 'Admin Report AR Summary Preview'),
                        array('label' => 'Export to PDF', 'description' => 'Admin Report AR Summary Pdf'),
                        array('label' => 'Export to Excel', 'description' => 'Admin Report AR Summary Excel'),
                    )),
                    array('label' => 'Payment', 'description' => 'Admin Report Payment', 'children' => array(
                        array('label' => 'Preview', 'description' => 'Admin Report Payment Preview'),
                        array('label' => 'Export to PDF', 'description' => 'Admin Report Payment Pdf'),
                        array('label' => 'Export to Excel', 'description' => 'Admin Report Payment Excel'),
                    )),
                    array('label' => 'Payment Without Invoice', 'description' => 'Admin Report Payment Without Invoice', 'children' => array(
                        array('label' => 'Preview', 'description' => 'Admin Report Payment Without Invoice Preview'),
                        array('label' => 'Export to PDF', 'description' => 'Admin Report Payment Without Invoice Pdf'),
                        array('label' => 'Export to Excel', 'description' => 'Admin Report Payment Without Invoice Excel'),
                    )),
                )),
                array('label' => 'Access Productivity(CBT) Report', 'description' => 'Admin Report Productivity(CBT)', 'children' => array(
                    array('label' => 'Patient Cycle', 'description' => 'Admin Report Patient Cycle', 'children' => array(
                        array('label' => 'Preview', 'description' => 'Admin Report Patient Cycle Preview'),
//                        array('label' => 'Export to PDF', 'description' => 'Admin Report Fax Summary Pdf'),
//                        array('label' => 'Export to Excel', 'description' => 'Admin Report Fax Summary Excel'),
                    )),
                    array('label' => 'Patient With Different Branches', 'description' => 'Admin Report Patient With Different Branches', 'children' => array(
                        array('label' => 'Preview', 'description' => 'Admin Report Patient With Different Branches Preview'),
//                        array('label' => 'Export to PDF', 'description' => 'Admin Report Fax Summary Pdf'),
                        array('label' => 'Export to Excel', 'description' => 'Admin Report Patient With Different Branches Excel'),
                    )),
                    array('label' => 'Patient With Different Branches (Invoice)', 'description' => 'Admin Report Patient With Different Branches Invoice', 'children' => array(
                        array('label' => 'Preview', 'description' => 'Admin Report Patient With Different Branches Invoice Preview'),
//                        array('label' => 'Export to PDF', 'description' => 'Admin Report Fax Summary Pdf'),
                        array('label' => 'Export to Excel', 'description' => 'Admin Report Patient With Different Branches Invoice Excel'),
                    )),
                    array('label' => 'Fax Summary', 'description' => 'Admin Report Fax Summary', 'children' => array(
                        array('label' => 'Preview', 'description' => 'Admin Report Fax Summary Preview'),
                        array('label' => 'Export to PDF', 'description' => 'Admin Report Fax Summary Pdf'),
                        array('label' => 'Export to Excel', 'description' => 'Admin Report Fax Summary Excel'),
                    )),
                    array('label' => 'Access Report Productivity CBT Scheduling', 'description' => 'Admin Report Productivity CBT Scheduling', 'children' => array(
                        array('label' => 'Preview', 'description' => 'Admin Report Productivity CBT Scheduling Preview'),
                        array('label' => 'Export to PDF', 'description' => 'Admin Report Productivity CBT Scheduling Pdf'),
                        array('label' => 'Export to Excel', 'description' => 'Admin Report Productivity CBT Scheduling Excel'),
                    )),
                    array('label' => 'Access Report Productivity CBT Encounter', 'description' => 'Admin Report Productivity CBT Encounter', 'children' => array(
                        array('label' => 'Preview', 'description' => 'Admin Report Productivity CBT Encounter Preview'),
                        array('label' => 'Export to PDF', 'description' => 'Admin Report Productivity CBT Encounter Pdf'),
                        array('label' => 'Export to Excel', 'description' => 'Admin Report Productivity CBT Encounter Excel'),
                    )),
                    array('label' => 'Key Performance Indicator', 'description' => 'Admin Report KPI', 'children' => array(
                        array('label' => 'Preview', 'description' => 'Admin Report KPI Preview'),
                        array('label' => 'Export to PDF', 'description' => 'Admin Report KPI Pdf'),
                        array('label' => 'Export to Excel', 'description' => 'Admin Report KPI Excel'),
                    )),
                    array('label' => 'Access Report CBT Tracker', 'description' => 'Admin Report CBT Tracker', 'children' => array(
                        array('label' => 'Preview', 'description' => 'Admin Report CBT Tracker Preview'),
                        array('label' => 'Export to PDF', 'description' => 'Admin Report CBT Tracker Pdf'),
                        array('label' => 'Export to Excel', 'description' => 'Admin Report CBT Tracker Excel'),
                    )),
                )),

                array('label' => 'Access Marketing Report', 'description' => 'Admin Report Marketing', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Marketing Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Marketing Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Marketing Excel'),
                )),
                array('label' => 'Access Marketing Referral Report', 'description' => 'Admin Report Referral Marketing', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Referral Marketing Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Referral Marketing Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Referral Marketing Excel'),
                )),
                array('label' => 'Access Specialist Tracker Report', 'description' => 'Admin Report Specialist Referral Tracker', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Specialist Referral Tracker Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Specialist Referral Tracker Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Specialist Referral Tracker Excel'),
                )),
                array('label' => 'Access Letter Tracker Report', 'description' => 'Admin Report Letter Tracker', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Letter Tracker Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Letter Tracker Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Letter Tracker Excel'),
                )),
                array('label' => 'Access Letter Report', 'description' => 'Admin Report Letter', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Letter Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Letter Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Letter Excel'),
                )),
                array('label' => 'Access Affiliation Report', 'description' => 'Admin Report Affiliation', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Affiliation Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Affiliation Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Affiliation Excel'),
                )),
                array('label' => 'Access Patient Referring Affiliate Report', 'description' => 'Admin Report Patient Referring Provider', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Patient Referring Provider Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Patient Referring Provider Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Patient Referring Provider Excel'),
                )),
                array('label' => 'Access Appointment History Report', 'description' => 'Admin Report Appointment History', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Appointment History Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Appointment History Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Appointment History Excel'),
                )),
                array('label' => 'Access Patient Progress Report', 'description' => 'Admin Report Patient Progress', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Patient Progress Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Patient Progress Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Patient Progress Excel'),
                )),
                array('label' => 'Access Appointment Report', 'description' => 'Admin Report Appointment', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Appointment Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Appointment Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Appointment Excel'),
                )),
                array('label' => 'Access Conversion', 'description' => 'Admin Report Conversion', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Conversion Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Conversion Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Conversion Excel'),
                )),
                array('label' => 'Access Diagnosis Report', 'description' => 'Admin Report Diagnosis', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Diagnosis Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Diagnosis Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Diagnosis Excel'),
                )),
                array('label' => 'Access Fax Report', 'description' => 'Admin Report Fax', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Fax Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Fax Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Fax Excel'),
                )),
                array('label' => 'Access File Report', 'description' => 'Admin Report File', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report File Preview'),
//                    array('label' => 'Export to PDF', 'description' => 'Admin Report File Pdf'),
//                    array('label' => 'Export to Excel', 'description' => 'Admin Report File Excel'),
                )),
                array('label' => 'Access Fax Outbound', 'description' => 'Admin Report Fax Outbound', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Fax Outbound Preview'),
//                    array('label' => 'Export to PDF', 'description' => 'Admin Report Fax Pdf'),
//                    array('label' => 'Export to Excel', 'description' => 'Admin Report Fax Excel'),
                )),
                array('label' => 'Access Encounter Report', 'description' => 'Admin Report Encounter', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Encounter Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Encounter Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Encounter Excel'),
                )),
                array('label' => 'Access Insurance Report', 'description' => 'Admin Report Insurance', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Insurance Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Insurance Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Insurance Excel'),
                )),
                array('label' => 'Access Insurance Coverage Report', 'description' => 'Admin Report Insurance Coverage', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Insurance Coverage Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Insurance Coverage Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Insurance Coverage Excel'),
                )),
                array('label' => 'Access Medication Report', 'description' => 'Admin Report Medication', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Medication Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Medication Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Medication Excel'),
                )),
                array('label' => 'Access Patient Report', 'description' => 'Admin Report Patient', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Patient Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Patient Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Patient Excel'),
                )),
                array('label' => 'Access Referred By Tracking Report', 'description' => 'Admin Report Referred By Tracking', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Referred By Tracking Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Referred By Tracking Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Referred By Tracking Excel'),
                )),
                array('label' => 'Access Patient Data Transfer', 'description' => 'Admin Report Patient Data Transfer', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Patient Data Transfer Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Patient Data Transfer Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Patient Data Transfer Excel'),
                )),
                array('label' => 'Access Patient Billing File', 'description' => 'Admin Report Patient Billing File', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Patient Billing File Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Patient Billing File Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Patient Billing File Excel'),
                )),
                array('label' => 'Access Login Tracker Report', 'description' => 'Admin Report Login Tracker', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Login Tracker Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Login Tracker Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Login Tracker Excel'),
                )),
                array('label' => 'Access Referral Report', 'description' => 'Admin Report Referral', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Referral Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Referral Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Referral Excel'),
                )),
                array('label' => 'Access Sales Report', 'description' => 'Admin Report Sales', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Sales Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Sales Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Sales Excel'),
                )),
                array('label' => 'Access Booked Encounter Report', 'description' => 'Admin Report Booked Encounter', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Booked Encounter Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Booked Encounter Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Booked Encounter Excel'),
                )),
                array('label' => 'Access User Endorsed Report', 'description' => 'Admin Report User Endorsed', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report User Endorsed Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report User Endorsed Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report User Endorsed Excel'),
                )),
                array('label' => 'Access Status Rebooking Report', 'description' => 'Admin Report Status Rebooking', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Status Rebooking Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Status Rebooking Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Status Rebooking Excel'),
                )),
                array('label' => 'Access Reminder Report', 'description' => 'Admin Report Reminder', 'children' => array(
                    array('label' => 'Preview', 'description' => 'Admin Report Reminder Preview'),
                    array('label' => 'Export to PDF', 'description' => 'Admin Report Reminder Pdf'),
                    array('label' => 'Export to Excel', 'description' => 'Admin Report Reminder Excel'),
                )),
                array('label' => 'Access Status Report', 'description' => 'Admin Report Status'),

                //Dashboards
                array('label' => 'My Task Dashboard', 'description' => 'Admin Dashboard My Task'),
                array('label' => 'Endorsed Dashboard', 'description' => 'Admin Dashboard Endorsed'),
                array('label' => 'View New Fax Dashboard', 'description' => 'Admin Dashboard New Fax'),
                array('label' => 'View Letters Dashboard', 'description' => 'Admin Dashboard Letters'),
                array('label' => 'View Fax w/o Encounter Dashboard', 'description' => 'Admin Dashboard Patient With Fax No Encounter', 'children' => array(
                    array('label' => 'Export to Excel', 'description' => 'Admin Dashboard Fax No Encounter Excel'),
                )),
                array('label' => 'View Referral w/o Encounter Dashboard', 'description' => 'Admin Dashboard Patient With Referral No Encounter', 'children' => array(
                    array('label' => 'Export to Excel', 'description' => 'Admin Dashboard Patient With Referral No Encounter Excel'),
                )),
                array('label' => 'View Patient w/o Encounter Dashboard', 'description' => 'Admin Dashboard Patient Initial Encounter', 'children' => array(
                    array('label' => 'Export to Excel', 'description' => 'Admin Dashboard Initial Encounter Excel'),
                )),
                array('label' => 'View Appointment Notice Dashboard', 'description' => 'Admin Dashboard Appointment Notice', 'children' => array(
                    array('label' => 'Export to Excel', 'description' => 'Admin Dashboard Appointment Notice Excel'),
                )),
                array('label' => 'View Encounter Call Dashboard', 'description' => 'Admin Dashboard Patient Encounter Call'),
                array('label' => 'View For Rebooking Dashboard', 'description' => 'Admin Dashboard Patient For Rebooking', 'children' => array(
                    array('label' => 'Export to Excel', 'description' => 'Admin Dashboard Patient For Rebooking Excel'),
                )),
                array('label' => 'View 72 Hour Follow-up Dashboard', 'description' => 'Admin Dashboard Patient 72 Hours Follow Up', 'children' => array(
                    array('label' => 'Export to Excel', 'description' => 'Admin Dashboard Patient 72 Month Follow Up Excel'),
                )),
                array('label' => 'View 3 Month Follow-up Dashboard', 'description' => 'Admin Dashboard Patient 3 Month Follow Up', 'children' => array(
                    array('label' => 'Export to Excel', 'description' => 'Admin Dashboard Patient 3 Month Follow Up Excel'),
                )),
                array('label' => 'View 6 Month Follow-up Dashboard', 'description' => 'Admin Dashboard Patient 6 Month Follow Up', 'children' => array(
                    array('label' => 'Export to Excel', 'description' => 'Admin Dashboard Patient 6 Month Follow Up Excel'),
                )),
                array('label' => 'Management Dashboard', 'description' => 'Admin Management Dashboard'),
                array('label' => 'Clinician Dashboard', 'description' => 'Admin Clinician Dashboard'),

                //Insurance Menu
                array('label' => 'Manage Insurance', 'description' => 'Admin Insurance', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Insurance New'),
                    array('label' => 'Update', 'description' => 'Admin Insurance Update'),
                    array('label' => 'Delete', 'description' => 'Admin Insurance Delete'),
                )),

                //User Menu
                array('label' => 'User', 'description' => 'Admin Account User', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Account User New'),
                    array('label' => 'Update', 'description' => 'Admin Account User Update'),
                    array('label' => 'Delete', 'description' => 'Admin Account User Delete'),
                    array('label' => 'Details', 'description' => 'Admin Account User Detail', 'children' => array(
                        array('label' => 'Account User Company', 'description' => 'Admin Account User Company', 'children' => array(
                            array('label' => 'Add Company', 'description' => 'Admin Account User Company New'),
                            array('label' => 'Update Company', 'description' => 'Admin Account User Company Update'),
                            array('label' => 'Delete Company', 'description' => 'Admin Account User Company Delete'),
                        )),
                        array('label' => 'Account User Branch', 'description' => 'Admin Account User Health Facility', 'children' => array(
                            array('label' => 'Add Branch', 'description' => 'Admin Account User Health Facility'),
                            array('label' => 'Update Branch', 'description' => 'Admin Account User Health Facility Update'),
                            array('label' => 'Delete Branch', 'description' => 'Admin Account User Health Facility Delete'),
                        )),
                    )),
                )),

                //Specialist Menu
                array('label' => 'Specialist', 'description' => 'Admin Specialist', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Specialist New'),
                    array('label' => 'Update', 'description' => 'Admin Specialist Update'),
                    array('label' => 'Delete', 'description' => 'Admin Specialist Delete'),
                )),

                //Referring Physician Menu
                array('label' => 'Referring Physician', 'description' => 'Admin Referring Provider', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Referring Provider New'),
                    array('label' => 'Update', 'description' => 'Admin Referring Provider Update'),
                    array('label' => 'Delete', 'description' => 'Admin Referring Provider Delete'),
                )),

                //Referring Affiliate Menu
                array('label' => 'Referring Affiliate', 'description' => 'Admin Referring Health Facility', 'children' => array(
                    array('label' => 'Details', 'description' => 'Admin Referring Health Facility Detail', 'children' => array(
                        array('label' => 'Referring Affiliate Tab', 'description' => 'Admin Referring Health Facility Detail Referring Health Facility'),
                        array('label' => 'New', 'description' => 'Admin Referring Health Facility Provider New'),
                        array('label' => 'Update', 'description' => 'Admin Referring Health Facility Provider Update'),
                        array('label' => 'Delete', 'description' => 'Admin Referring Health Facility Provider Delete'),
                    )),
                    array('label' => 'New', 'description' => 'Admin Referring Health Facility New'),
                    array('label' => 'Update', 'description' => 'Admin Referring Health Facility Update'),
                    array('label' => 'Delete', 'description' => 'Admin Referring Health Facility Delete'),
                )),

                //Inventory Menu
                array('label' => 'Inventory Menu', 'description' => 'Admin Inventory Menu', 'children' => array(
                    array('label' => 'Inventory', 'description' => 'Admin Inventory', 'children' => array(
                        array('label' => 'New', 'description' => 'Admin Inventory New'),
                        array('label' => 'Update', 'description' => 'Admin Inventory Update'),
                        array('label' => 'Delete', 'description' => 'Admin Inventory Delete'),
                    )),
                    array('label' => 'Add Inventory', 'description' => 'Admin Add Inventory', 'children' => array(
                        array('label' => 'New', 'description' => 'Admin Add Inventory New'),
                        array('label' => 'Update', 'description' => 'Admin Add Inventory Update'),
                        array('label' => 'Delete', 'description' => 'Admin Add Inventory Delete', 'children' => array(
                            array('label' => 'Add Inventory Item', 'description' => 'Admin Add Inventory Item','children' => array(
                                array('label' => 'New', 'description' => 'Admin Add Inventory Item Update'),
                                array('label' => 'Update', 'description' => 'Admin Add Inventory Item Update'),
                                array('label' => 'Delete', 'description' => 'Admin Add Inventory Item Update Delete'),
                                array('label' => 'Send', 'description' => 'Admin Add Inventory Send'),
                            )),
                            array('label' => 'Add Inventory Payment', 'description' => 'Admin Add Inventory Payment','children' => array(
                                array('label' => 'New', 'description' => 'Admin Add Inventory Payment Update'),
                                array('label' => 'Update', 'description' => 'Admin Add Inventory Payment Update'),
                                array('label' => 'Delete', 'description' => 'Admin Add Inventory Payment Delete'),
                            )),
                        )),
                        array('label' => 'Transfer Inventory', 'description' => 'Admin Transfer Inventory','children' => array(
                            array('label' => 'New', 'description' => 'Admin Transfer Inventory Update'),
                            array('label' => 'Update', 'description' => 'Admin Transfer Inventory Update'),
                            array('label' => 'Delete', 'description' => 'Admin Transfer Inventory Delete', 'children' => array(
                                array('label' => 'Transfer Inventory Item', 'description' => 'Admin Transfer Inventory Item', 'children' => array(
                                    array('label' => 'New', 'description' => 'Admin Transfer Inventory Item Update'),
                                    array('label' => 'Update', 'description' => 'Admin Transfer Inventory Item Update'),
                                    array('label' => 'Delete', 'description' => 'Admin Transfer Inventory Item Delete'),
                                )),
                                array('label' => 'Transfer Inventory Item', 'description' => 'Admin Transfer Inventory Item', 'children' => array(
                                    array('label' => 'New', 'description' => 'Admin Transfer Inventory Item Update'),
                                    array('label' => 'Update', 'description' => 'Admin Transfer Inventory Item Update'),
                                    array('label' => 'Delete', 'description' => 'Admin Transfer Inventory Item Delete'),
                                    array('label' => 'Receive', 'description' => 'Admin Transfer Inventory Item Receive'),
                                    array('label' => 'Receive Update', 'description' => 'Admin Transfer Inventory Item Receive Update'),
                                    array('label' => 'Send', 'description' => 'Admin Transfer Inventory Item Send'),
                                )),
                            )),
                        )),
                    )),
                )),

                //Sales Agent Menu
                array('label' => 'Sales Agent', 'description' => 'Admin Sales Agent', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Sales Agent New'),
                    array('label' => 'Update', 'description' => 'Admin Sales Agent Update'),
                    array('label' => 'Delete', 'description' => 'Admin Sales Agent Delete'),
                    array('label' => 'Details', 'description' => 'Admin Sales Agent Detail', 'children' => array(
                        array('label' => 'Add Affiliate', 'description' => 'Admin Sales Agent New Referring Health Facility'),
                        array('label' => 'Update Affiliate', 'description' => 'Admin Sales Agent Referring Health Facility Update'),
                        array('label' => 'Delete Affiliate', 'description' => 'Admin Sales Agent Referring Health Facility Delete'),
                    )),
                )),

                //Account Staff Menu
                array('label' => 'Account Staff', 'description' => 'Admin Account Staff', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Account Staff New'),
                    array('label' => 'Update', 'description' => 'Admin Account Staff Update'),
                    array('label' => 'Delete', 'description' => 'Admin Account Staff Delete'),
//                    array('label' => 'Details', 'description' => 'Admin Account Staff Detail'),
                )),

                //Chat Menu
                array('label' => 'Chat', 'description' => 'Admin Chat', 'children' => array(
                    array('label' => 'New', 'description' => 'Admin Chat New'),
                    array('label' => 'Update', 'description' => 'Admin Chat Update'),
                    array('label' => 'Delete', 'description' => 'Admin Chat Delete'),
                    array('label' => 'Send', 'description' => 'Admin Chat Send Message'),
                )),

                array('label' => 'Access CMS', 'description' => 'Admin Cms', 'children' => array(
                    array('label' => 'Account CMS', 'description' => 'Admin Account CMS', 'children' => array(
                        array('label' => 'Account', 'description' => 'Admin Account'),
                        array('label' => 'Company', 'description' => 'Admin Company'),
                        array('label' => 'Branch', 'description' => 'Admin Branch'),
                    )),
                    array('label' => 'User CMS', 'description' => 'Admin Users CMS', 'children' => array(
                        array('label' => 'User', 'description' => 'Admin User'),
                        array('label' => 'User Group', 'description' => 'Admin User Group', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin User Group New'),
                            array('label' => 'Update', 'description' => 'Admin User Group Update'),
                            array('label' => 'Delete', 'description' => 'Admin User Group Delete', 'children' => array(
                                array('label' => 'Detail', 'description' => 'Admin User Group Detail', 'children' => array(
                                    array('label' => 'New', 'description' => 'Admin User Group Account User New'),
                                    array('label' => 'Update', 'description' => 'Admin User Group Account User Update'),
                                    array('label' => 'Delete', 'description' => 'Admin User Group Account User Delete'),
                                )),
                            )),
                        )),
                        array('label' => 'Account Staff', 'description' => 'Admin Account Staff', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Account Staff New'),
                            array('label' => 'Update', 'description' => 'Admin Account Staff Update'),
                            array('label' => 'Delete', 'description' => 'Admin Account Staff Delete'),
                        )),
                        array('label' => 'Sales Agent', 'description' => 'Admin Sales Agent', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Sales Agent New'),
                            array('label' => 'Update', 'description' => 'Admin Sales Agent Update'),
                            array('label' => 'Delete', 'description' => 'Admin Sales Agent Delete', 'children' => array(
                                array('label' => 'Detail', 'description' => 'Admin Sales Agent Detail'),
                                array('label' => 'Referring Affiliate', 'description' => 'Admin Sales Agent Detail Referring Health Facility', 'children' => array(
                                    array('label' => 'New', 'description' => 'Admin Sales Agent Detail Referring Health Facility New'),
                                    array('label' => 'Update', 'description' => 'Admin Sales Agent Detail Referring Health Facility Update'),
                                    array('label' => 'Delete', 'description' => 'Admin Sales Agent Detail Referring Health Facility Delete'),
                                )),

                            )),
                        )),
                    )),
                    array('label' => 'Admin Encounter CMS', 'description' => 'Admin Encounter CMS', 'children' => array(
                        array('label' => 'Encounter Type', 'description' => 'Admin Chart Type', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Chart Type New'),
                            array('label' => 'Update', 'description' => 'Admin Chart Type Update'),
                            array('label' => 'Delete', 'description' => 'Admin Chart Type Delete'),
                        )),
                        array('label' => 'Method', 'description' => 'Admin Chart Type Method', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Chart Type Method New'),
                            array('label' => 'Update', 'description' => 'Admin Chart Type Method Update'),
                            array('label' => 'Delete', 'description' => 'Admin Chart Type Method Delete'),
                        )),
                        array('label' => 'Status', 'description' => 'Admin Chart Type Status', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Chart Type Status New'),
                            array('label' => 'Update', 'description' => 'Admin Chart Type Status Update'),
                            array('label' => 'Delete', 'description' => 'Admin Chart Type Status Delete'),
                        )),
                        array('label' => 'Billing', 'description' => 'Admin Chart Type Billing', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Chart Type Billing New'),
                            array('label' => 'Update', 'description' => 'Admin Chart Type Billing Update'),
                            array('label' => 'Delete', 'description' => 'Admin Chart Type Billing Delete'),
                        )),
                        array('label' => 'Financing Company', 'description' => 'Admin Financing Company', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Financing Company New'),
                            array('label' => 'Update', 'description' => 'Admin Financing Company Update'),
                            array('label' => 'Delete', 'description' => 'Admin Financing Company Delete'),
                        )),
                    )),
                    array('label' => 'Admin Appointment CMS', 'description' => 'Admin Appointment CMS', 'children' => array(
                        array('label' => 'Appointment Status', 'description' => 'Admin Schedule Status', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Schedule Status New'),
                            array('label' => 'Update', 'description' => 'Admin Schedule Status Update'),
                            array('label' => 'Delete', 'description' => 'Admin Schedule Status Delete'),
                        )),
                        array('label' => 'Queuing Status', 'description' => 'Admin Schedule Queued Status', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Schedule Queued Status New'),
                            array('label' => 'Update', 'description' => 'Admin Schedule Queued Status Update'),
                            array('label' => 'Delete', 'description' => 'Admin Schedule Queued Status Delete'),
                        )),
                    )),
                    array('label' => 'Admin RX CMS', 'description' => 'Admin RX CMS', 'children' => array(
                        array('label' => 'Diagnosis', 'description' => 'Admin Diagnosis', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Diagnosis New'),
                            array('label' => 'Update', 'description' => 'Admin Diagnosis Update'),
                            array('label' => 'Delete', 'description' => 'Admin Diagnosis Delete'),
                        )),
                        array('label' => 'Medication', 'description' => 'Admin Medication', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Medication New'),
                            array('label' => 'Update', 'description' => 'Admin Medication Update'),
                            array('label' => 'Delete', 'description' => 'Admin Medication Delete'),
                        )),
                    )),
                    array('label' => 'Admin Referral CMS', 'description' => 'Admin Referral CMS', 'children' => array(
                        array('label' => 'Source', 'description' => 'Admin Source', 'children', array(
                            array('label' => 'New', 'description' => 'Admin Source New'),
                            array('label' => 'Update', 'description' => 'Admin Source Update'),
                            array('label' => 'Delete', 'description' => 'Admin Source Delete'),
                        )),
                        array('label' => 'Referring Physician', 'description' => 'Admin Referring Provider CMS', 'children', array(
                            array('label' => 'New', 'description' => 'Admin Referring Provider New'),
                            array('label' => 'Update', 'description' => 'Admin Referring Provider Update'),
                            array('label' => 'Delete', 'description' => 'Admin Referring Provider Delete'),
                        )),
                        array('label' => 'Referring Affiliate', 'description' => 'Admin Referring Health Facility CMS', 'children', array(
                            array('label' => 'New', 'description' => 'Admin Referring Health Facility New'),
                            array('label' => 'Update', 'description' => 'Admin Referring Health Facility Update'),
                            array('label' => 'Delete', 'description' => 'Admin Referring Health Facility Delete', 'children', array(
                                array('label' => 'Detail', 'description' => 'Admin Referring Health Facility Detail', 'children', array(
                                    array('label' => 'New', 'description' => 'Admin Referring Health Facility Provider New'),
                                    array('label' => 'Update', 'description' => 'Admin Referring Health Facility Provider Update'),
                                    array('label' => 'Delete', 'description' => 'Admin Referring Health Facility Provider Delete'),
                                )),
                            )),
                        )),
                    )),
                    array('label' => 'FAQs', 'description' => 'Admin Faq', 'children' => array(
                        array('label' => 'New', 'description' => 'Admin Faq New'),
                        array('label' => 'Update', 'description' => 'Admin Faq Update'),
                        array('label' => 'Delete', 'description' => 'Admin Faq Delete'),
                    )),
                    array('label' => 'Service', 'description' => 'Admin Service CMS', 'children' => array(
                        array('label' => 'New', 'description' => 'Admin Service New'),
                        array('label' => 'Update', 'description' => 'Admin Service Update'),
                        array('label' => 'Delete', 'description' => 'Admin Service Delete')
                    )),
                    array('label' => 'Admin Treatment Consideration CMS', 'description' => 'Admin Treatment Consideration CMS', 'children' => array(
                        array('label' => 'New', 'description' => 'Admin Treatment Consideration New'),
                        array('label' => 'Update', 'description' => 'Admin Treatment Consideration Update'),
                        array('label' => 'Delete', 'description' => 'Admin Treatment Consideration Delete')
                    )),
                    array('label' => 'Admin Treatment Plan CMS', 'description' => 'Admin Treatment Plan CMS', 'children' => array(
                        array('label' => 'New', 'description' => 'Admin Treatment Plan New'),
                        array('label' => 'Update', 'description' => 'Admin Treatment Plan Update'),
                        array('label' => 'Delete', 'description' => 'Admin Treatment Plan Delete')
                    )),
                    array('label' => 'Admin Items Devices CMS', 'description' => 'Admin Items Devices CMS', 'children' => array(
                        array('label' => 'Items', 'description' => 'Admin Items', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Items New'),
                            array('label' => 'Update', 'description' => 'Admin Items Update'),
                            array('label' => 'Delete', 'description' => 'Admin Items Delete', 'children' => array(
                                array('label' => 'Admin Items Detail Price', 'description' => 'Admin Items Detail', 'children' => array(
                                    array('label' => 'New', 'description' => 'Admin Items Price New'),
                                    array('label' => 'Update', 'description' => 'Admin Items Price Update'),
                                    array('label' => 'Delete', 'description' => 'Admin Items Price Delete'),
                                )),
                            )),
                        )),
                        array('label' => 'Devices', 'description' => 'Admin Device', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Device New'),
                            array('label' => 'Update', 'description' => 'Admin Device Update'),
                            array('label' => 'Delete', 'description' => 'Admin Device Delete'),
                        )),
                        array('label' => 'Category', 'description' => 'Admin Item Category', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Item Category New'),
                            array('label' => 'Update', 'description' => 'Admin Item Category Update'),
                            array('label' => 'Delete', 'description' => 'Admin Item Category Delete'),
                        )),
                        array('label' => 'Subcategory', 'description' => 'Admin Item Subcategory', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Item Subcategory New'),
                            array('label' => 'Update', 'description' => 'Admin Item Subcategory Update'),
                            array('label' => 'Delete', 'description' => 'Admin Item Subcategory Delete'),
                        )),
                    )),
                    array('label' => 'Admin Address CMS', 'description' => 'Admin Address CMS', 'children' => array(
                        array('label' => 'Country', 'description' => 'Admin Country', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Country New'),
                            array('label' => 'Update', 'description' => 'Admin Country Update'),
                            array('label' => 'Delete', 'description' => 'Admin Country Delete'),
                        )),
                        array('label' => 'Province', 'description' => 'Admin Province', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Province New'),
                            array('label' => 'Update', 'description' => 'Admin Province Update'),
                            array('label' => 'Delete', 'description' => 'Admin Province Delete'),
                        )),
                        array('label' => 'City', 'description' => 'Admin City', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin City New'),
                            array('label' => 'Update', 'description' => 'Admin City Update'),
                            array('label' => 'Delete', 'description' => 'Admin City Delete'),
                        )),
                        array('label' => 'Postal Code', 'description' => 'Admin Postal Code', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Postal Code New'),
                            array('label' => 'Update', 'description' => 'Admin Postal Code Update'),
                            array('label' => 'Delete', 'description' => 'Admin Postal Code Delete'),
                        )),
                    )),
                    array('label' => 'Access System Parameters', 'description' => 'Admin System Parameters', 'children' => array(
                        array('label' => 'Letter Template', 'description' => 'Admin Letter Template', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin Letter Template New'),
                            array('label' => 'Update', 'description' => 'Admin Letter Template Update'),
                            array('label' => 'Delete', 'description' => 'Admin Letter Template Delete'),
                        )),
                        array('label' => 'Account User Type', 'description' => 'Admin Account User Type'),
                        array('label' => 'Patient Type', 'description' => 'Admin Patient Type'),
                        array('label' => 'Insurance Type', 'description' => 'Admin Insurance Type'),
                        array('label' => 'File Type', 'description' => 'Admin File Type'),
                        array('label' => 'Reminder Type', 'description' => 'Admin Reminder Type'),
                        array('label' => 'Clinician Type', 'description' => 'Admin Clinician Type'),
                        array('label' => 'Branch Type', 'description' => 'Admin Branch Type'),
                        array('label' => 'Medication Type', 'description' => 'Admin Medication Type'),
                        array('label' => 'Diagnosis Type', 'description' => 'Admin Diagnosis Type'),
                        array('label' => 'Internal Status', 'description' => 'Admin Internal Status'),
                        array('label' => 'Ticket Status', 'description' => 'Admin Ticket Status'),
                        array('label' => 'Ticket Severity', 'description' => 'Admin Ticket Severity'),
                        array('label' => 'Letter Status', 'description' => 'Admin Letter Status'),
                        array('label' => 'AuditTrail', 'description' => 'Admin AuditTrail'),
                        array('label' => 'System Parameter', 'description' => 'Admin System Parameter', 'children' => array(
                            array('label' => 'New', 'description' => 'Admin System Parameter New'),
                            array('label' => 'Update', 'description' => 'Admin System Parameter Update'),
                            array('label' => 'Delete', 'description' => 'Admin System Parameter Delete'),
                        )),
                    )),
                )),
            )),
        );

    }
}