public function disable($nonadherence_id)
 {
     $this->load->database();
     $query = $this->db->query("UPDATE Non_Adherence_Reasons SET Active='0'WHERE id='{$nonadherence_id}'");
     $results = Non_Adherence_Reasons::getSource($nonadherence_id);
     //$this -> session -> set_userdata('message_counter','2');
     $this->session->set_userdata('msg_error', $results->Name . ' was disabled!');
     $this->session->set_flashdata('filter_datatable', $results->Name);
     //Filter datatable
     redirect('settings_management');
 }
 public function edit($record_no)
 {
     $facility_code = $this->session->userdata('facility');
     $ccc_id = '2';
     $sql = "select pv.*,p.first_name,p.other_name,p.last_name,p.id as p_id " . "from patient_visit pv," . "patient p " . "where pv.id='{$record_no}' " . "and pv.patient_id=p.patient_number_ccc " . "and facility='{$facility_code}'";
     $query = $this->db->query($sql);
     $results = $query->result_array();
     //print_r($results);
     if ($results) {
         $data['results'] = $results;
         //Get expriry date the batch
         foreach ($results as $value) {
             $batch_number = $value['batch_number'];
             $drug_ig = $value['drug_id'];
             $ccc_id = $value['ccc_store_sp'];
             $sql = "select expiry_date FROM drug_stock_balance WHERE batch_number='{$batch_number}' AND drug_id='{$drug_ig}' AND stock_type='{$ccc_id}' AND facility_code='{$facility_code}' LIMIT 1";
             $expiry_sql = $this->db->query($sql);
             $expiry_array = $expiry_sql->result_array();
             $expiry_date = "";
             $data['expiries'] = $expiry_array;
             foreach ($expiry_array as $row) {
                 $expiry_date = $row['expiry_date'];
                 //print_r($expiry_date);
                 $data['original_expiry_date'] = $expiry_date;
             }
         }
     } else {
         $data['results'] = "";
     }
     $data['purposes'] = Visit_Purpose::getAll();
     $data['record'] = $record_no;
     $data['ccc_id'] = $ccc_id;
     $data['regimens'] = Regimen::getRegimens();
     $data['non_adherence_reasons'] = Non_Adherence_Reasons::getAllHydrated();
     $data['regimen_changes'] = Regimen_Change_Purpose::getAllHydrated();
     $data['doses'] = Dose::getAllActive();
     $data['indications'] = Opportunistic_Infection::getAllHydrated();
     $data['content_view'] = 'edit_dispensing_v';
     $data['hide_side_menu'] = 1;
     $this->base_params($data);
 }