public function listing()
 {
     $access_level = $this->session->userdata('user_indicator');
     $source = 0;
     if ($access_level == "pharmacist") {
         $source = $this->session->userdata('facility');
     }
     $data = array();
     $data['styles'] = array("jquery-ui.css");
     $data['scripts'] = array("jquery-ui.js");
     $data['regimens'] = Regimen::getAll($source);
     $data['regimens_enabled'] = Regimen::getAllEnabled($source);
     $data['regimen_categories'] = Regimen_Category::getAll();
     $data['regimen_service_types'] = Regimen_Service_Type::getAll();
     $data['drug_codes'] = Drugcode::getAll($source);
     $data['drug_codes_enabled'] = Drugcode::getAllEnabled($source);
     $this->base_params($data);
 }
Beispiel #2
0
 public function listing()
 {
     $access_level = $this->session->userdata('user_indicator');
     $source = 0;
     if ($access_level == "pharmacist") {
         $source = $this->session->userdata('facility');
     }
     $data = array();
     $data['content_view'] = "regimen_listing_v";
     $data['styles'] = array("jquery-ui.css");
     $data['scripts'] = array("jquery-ui.js");
     $regimens = Regimen::getAllHydrated($source, $access_level);
     $tmpl = array('table_open' => '<table id="regimen_setting" class="table table-bordered table-hover table-striped setting_table">');
     $this->table->set_template($tmpl);
     $this->table->set_heading('id', 'Regimen', 'Line', 'Regimen Category', 'Type Of Service', 'Options');
     foreach ($regimens as $regimen) {
         $links = "";
         $drug = $regimen['id'];
         $type_of_service = $regimen['Regimen_Service_Type'];
         //if($type_of_service!="ART" && $access_level!="system_administrator"){
         if ($access_level != "facility_administrator") {
             $array_param = array('id' => $regimen['id'], 'role' => 'button', 'class' => 'edit_user', 'data-toggle' => 'modal');
             if ($regimen['Enabled'] == 1) {
                 //$links .= anchor('' . $regimen['id'], 'Edit', array('class' => 'edit_user','id'=>$regimen['id']));
                 $links .= anchor('#edit_form', 'Edit', $array_param);
             }
         } elseif ($access_level == "facility_administrator") {
             //href="#entry_form" role="button" id="new_regimen" class="btn" data-toggle="modal"
             $array_param = array('id' => $regimen['id'], 'role' => 'button', 'class' => 'edit_user', 'data-toggle' => 'modal');
             if ($regimen['Enabled'] == 1) {
                 $links .= anchor('#edit_form', 'Edit', $array_param);
             }
         }
         if ($regimen['Enabled'] == 1 && @$regimen['Merged_To']) {
             $links .= " | ";
             $links .= anchor('regimen_management/disable/' . $regimen['id'], 'Disable', array('class' => 'disable_user actual'));
         }
         if ($regimen['Enabled'] == 1 && @$regimen['Merged_To'] == "" && $access_level == "facility_administrator") {
             $links .= " | ";
             $links .= anchor('regimen_management/disable/' . $regimen['id'], 'Disable', array('class' => 'disable_user actual'));
             $links .= " | ";
             $links .= "<a href='#' class='merge_drug' id='{$drug}'>Merge</a>";
         }
         if ($regimen['Enabled'] == 0 && $access_level == "facility_administrator") {
             $links .= anchor('regimen_management/enable/' . $regimen['id'], 'Enable', array('class' => 'enable_user actual'));
         }
         if ($regimen['Merged_To'] != '') {
             if ($access_level == "facility_administrator") {
                 $links .= " | ";
                 $links .= anchor('regimen_management/unmerge/' . $regimen['id'], 'Unmerge', array('class' => 'unmerge_drug'));
             }
             $checkbox = "<input type='checkbox' name='drugcodes' id='drugcodes' class='drugcodes' value='{$drug}' disabled/>";
         } else {
             $checkbox = "<input type='checkbox' name='drugcodes' id='drugcodes' class='drugcodes' value='{$drug}'/>";
         }
         $mapped = "";
         if ($regimen['map'] != 0) {
             $mapped = "<b>(mapped)</b>";
         }
         if ($regimen['Regimen_Code']) {
             $regimen_code = $regimen['Regimen_Code'] . " | " . $regimen['Regimen_Desc'];
         } else {
             $regimen_code = $regimen['Regimen_Desc'];
         }
         $this->table->add_row($regimen['id'], $checkbox . "" . $regimen_code . " " . $mapped, $regimen['Line'], $regimen['Regimen_Category'], $regimen['Regimen_Service_Type'], $links);
     }
     $data['access_level'] = $access_level;
     $data['regimens'] = $this->table->generate();
     $data['regimen_categories'] = Regimen_Category::getAll();
     $data['regimen_service_types'] = Regimen_Service_Type::getAll();
     $sql = "SELECT s.id,s.code,s.name,sr.Name as category_name,s.category_id\n                FROM sync_regimen s \n                LEFT JOIN sync_regimen_category sr ON sr.id = s.category_id\n                WHERE s.id NOT IN(SELECT r.map\n                                  FROM regimen r\n                                  WHERE r.map !='0')\n                OR s.name LIKE '%other%'\n                OR s.code LIKE '%x%'\n                ORDER BY s.category_id,s.code asc";
     $query = $this->db->query($sql);
     $unmapped_regimens = $query->result_array();
     $sync_regimens = Sync_Regimen::getActive();
     $data['edit_mappings'] = $unmapped_regimens;
     $data['mappings'] = $sync_regimens;
     $this->base_params($data);
 }