Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class hms_ad..

Decoded Output download

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
 
class hms_admin extends CI_Controller { 
	public function index() 
	{ 
		$this->load->library('session'); 
		$this->load->helper('url'); 
		$this->load->view('hms/hms_menu'); 
 
	} 
	 
	 
	public function index_user() 
	{ 
		$this->load->library('session'); 
		$this->load->helper('url'); 
		$this->load->view('hms/hms_menu_user'); 
 
	} 
	 
	public function dashboard() 
	{ 
		$this->load->library('session'); 
		$this->load->helper('url'); 
		$this->load->view('hms/dashboard.php'); 
 
	}	 
	 
		 
 
	public function get_affiliate() 
	{ 
		$this->load->library('session'); 
		$this->load->helper('url'); 
		$id=$this->session->userdata('uname'); 
		$this->db->where('e_uname',$id); 
		$data['menu']=$this->db->get('manage_employees'); 
		foreach($data['menu']->result() as $row) 
		{ 
		break; 
		} 
		$aid=$row->e_affiliateid; 
		return $aid; 
	} 
	public function get_affiliatename() 
	{ 
		$this->load->library('session'); 
		$this->load->helper('url'); 
		$id=$this->session->userdata('uname'); 
		$this->db->where('e_uname',$id); 
		$data['menu']=$this->db->get('manage_employees'); 
		foreach($data['menu']->result() as $row) 
		{ 
		break; 
		} 
		$aid=$row->e_affiliateid; 
		$this->db->where('affiliate_id',$aid); 
		$data['anm']=$this->db->get('manage_affiliate'); 
		foreach($data['anm']->result() as $row) 
		{ 
		break; 
		} 
		$anm=$row->affiliate_name; 
		return $anm; 
	} 
	public function get_af_emp_id() 
	{ 
		$this->load->library('session'); 
		$this->load->helper('url'); 
		$id=$this->session->userdata('e_email'); 
		$this->db->where('e_email',$id); 
		$data['emp_data']=$this->db->get('manage_employees'); 
		foreach($data['emp_data']->result() as $row) 
		{ 
		$empid=$row->emp_info_id; 
		return $empid; 
		} 
		 
	} 
	 
	 
	public function change_password() 
	{ 
	$this->load->helper('url'); 
 	$this->load->library('session'); 
 	$this->load->database(); 
	$enpid=$this->get_af_emp_id();	 
	 
	$this->db->where('emp_info_id',$enpid); 
	$data['manage_employees']=$this->db->get('manage_employees'); 
		 	 
	$data['empid']=$enpid; 
  	$this->load->view('hms/change_password',$data);	 
	} 
	 
	 
  public function edit_password_record() 
  { 
	$this->load->library('session'); 
 	$this->load->helper('url'); 
  	$row_id=$this->input->post('row_id'); 
 	$this->e_password=$this->input->post('new_pass'); 
	 
        $this->db->where('emp_id',$row_id);			 
	$this->db->update('manage_employees',$this);  	  
 	echo 'Record Updated';   
   
  }	 
	 
 
public function zone_master() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	//$aid=$this->get_affiliate(); 
	 
 
	$data['hms_zone_master']=$this->db->get('hms_zone_master');	 
	$this->load->view('hms/zone_master',$data);  
} 
 
	public function add_zone_record() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
 	$this->zone_name=$this->input->post('zonename'); 
 
    	 $this->db->insert('hms_zone_master',$this); 
        echo 'Recod Has Been Saved'; 
	} 
 
 
 
 
	 
	 
public function diagnos_master() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	//$aid=$this->get_affiliate(); 
	 
	$this->db->where('dig_parient','0');	 
	//$this->db->order_by('exam_cat_parent'); 
	$data['kk']=$this->db->get('hms_dignos_master'); 
$this->db->where('dig_parient','0'); 
	$data['test_name']=$this->db->get('hms_dignos_master');	 
	$this->load->view('hms/diagnos_master',$data);  
} 
 
	public function add_diagnose_record() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
 	$this->dig_title=$this->input->post('testname'); 
	 $this->dig_parient=$this->input->post('test_parient'); 
	$this->amount=$this->input->post('testamt'); 
	$this->status=$this->input->post('status'); 
    	 $this->db->insert('hms_dignos_master',$this); 
        echo 'Recod Has Been Saved'; 
	} 
	 
	public function edit_diagnose() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$id=$this->uri->segment(3); 
	$this->db->where('id',$id); 
	$data['ep_exam1']=$this->db->get('hms_dignos_master'); 
	$this->db->where('dig_parient','0'); 
	$data['ep_exam12']=$this->db->get('hms_dignos_master'); 
	$this->load->view('hms/edit_diagnos_master',$data);; 
	} 
	 
	public function update_diagnose_record() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$tid=$this->input->post('id'); 
 	$this->dig_title=$this->input->post('testname'); 
	 $this->dig_parient=$this->input->post('test_parient'); 
	$this->amount=$this->input->post('testamt'); 
	$this->status=$this->input->post('status');	  
	$this->db->where('id',$tid); 
    	 $this->db->update('hms_dignos_master',$this); 
        echo 'Recod Has Been Updated';	 
	} 
	public function delete_diagnose() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$id=$this->uri->segment(3); 
	$this->db->where('id',$id); 
	$this->db->delete('hms_dignos_master'); 
 	$this->diagnos_master(); 
	} 
	 
	 
	 
	public function assign_patient_test_fordiagnouse() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	foreach($data['hms_opd_patient']->result() as $row) 
	{ 
	break; 
	} 
	$data['phone']=$row->phone;	 
	$data['date_day']=$row->entry_date; 
	$data['doctor_id']=$row->doctor_id; 
	$data['pathlogu_name']=$row->collection_code; 
	$data['hospiatal_name']=$row->hospitalid;				 
	 
//	$this->db->where('afid',$aid);	 
//	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$this->db->where('dig_parient',0); 
	$this->db->order_by('id','asc'); 
	$data['test_name']=$this->db->get('hms_dignos_master');	 
	 
	$this->db->order_by('id','asc');	 
       	$data['test_name2']=$this->db->get('hms_dignos_master');	 
      	  
	       $date_day=date('Y-m-d'); 
	        
	     //  $data['date_day']=$date_day; 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid);		 
	$this->db->order_by('enter_date','desc');	 
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test_diagnose');	 
	 
	$this->db->where('afid',$aid);	 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$this->db->where('afid',$aid);	 
	$data['hms_hospital']=$this->db->get('hms_hospital');				 
	$this->load->view('hms/assign_patient_test_for_diagnouse',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
	} 
	 
	 
	public function delete_opd_test_diagnose() 
	{ 
 	$this->load->library('session'); 
         $this->load->helper('url'); 
 	$aid=$this->get_affiliate(); 
 	$id=$this->uri->segment(3); 
	$pid=$this->uri->segment(4);	  
 	$this->db->where('test_id',$id); 
	$this->db->where('patient_id',$pid);	  
 	$this->db->where('afid',$aid); 
 	$this->db->delete('hms_patient_assign_test_diagnose'); 
 	echo 'Record Deleted'; 
	} 
	 
	 
	 
	public function delete_opd_test_rate_diagnos() 
	{ 
 	$this->load->library('session'); 
         $this->load->helper('url'); 
 	$aid=$this->get_affiliate(); 
 	$id=$this->uri->segment(3); 
	$pid=$this->uri->segment(4);	  
	$this->db->where('test_pid',$id); 
	$this->db->where('patient_id',$pid);				 
	$data_count=$this->db->count_all_results('hms_opd_test_rate_diagnose'); 
	if($data_count>0) 
	{	  
 	$this->db->where('test_pid',$id); 
	$this->db->where('patient_id',$pid);	  
 	$this->db->delete('hms_opd_test_rate_diagnose'); 
 	echo 'Record Deleted'; 
	 } 
	 else 
	 { 
	  
	 }	 
	  
	}		 
	 
	public function add_pasient_test_diagnos_val() 
 	{ 
      		$this->load->library('session'); 
        	$this->load->helper('url'); 
		$afid=$this->get_affiliate(); 
		$empid=$this->get_af_emp_id();		 
		$ques=$this->input->post('value'); 
		$qui=explode(',',$ques); 
		$t=0; 
		for($t1=0;Count($qui)>$t1;$t1++) 
		{ 
		 
	//	$this->db->where('test_id',$qui[$t]);	 
		 
		$patient_id=$this->input->post('patient_name'); 
		$test_parient=$this->input->post('test_parient'); 
		$this->db->where('patient_id',$patient_id); 
	//	$this->db->where('test_parient',$test_parient); 
		$this->db->where('test_id',$qui[$t]); 
		$data['lastan1']=$this->db->count_all_results('hms_patient_assign_test_diagnose'); 
		 
	 
		if($data['lastan1']>=1) 
		{ 
	 
		   //echo $qui[$t].'Test already assigned ';     
		   //echo'Test already assigned '; 
		   //	break;   
		    
		} 
		else 
	      { 
               	$this->load->database(); 
               	$this->test_id=$qui[$t]; 	 
		$this->patient_id=$this->input->post('patient_name'); 
		$this->enter_date=$this->input->post('e_date'); 
		$this->test_parient=$this->input->post('test_parient'); 
		//$this->root_id=$this->input->post('root_name'); 
	         
		$this->doctor_id=$this->input->post('docid'); 
		$this->hospital_name=$this->input->post('hospital_name'); 
		$this->pathology_center=$this->input->post('pathlogy_name');			 
		 
		$this->afid=$afid; 
		$this->emp_id=$empid; 
		$this->db->set('status','1');			 
               	$this->db->insert('hms_patient_assign_test_diagnose',$this); 
		} 
               	$t++; 
                } 
                echo 'Patient Assigned Test';   
      	} 
	       
	       
	       
	public function print_opd_patient_test_report_sleep_day_diagnose() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	$today=$this->uri->segment(4); 
	 
	$data['today']=$today; 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('enter_date',$today);	 
	$data_count=$this->db->count_all_results('hms_patient_assign_test_diagnose'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
//	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('date_test',$today);		 
//	$this->db->group_by('test_parient'); 
	$data['hms_opd_test_rate']=$this->db->get('hms_opd_test_rate_diagnose');		 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('enter_date',$today);		 
//	$this->db->group_by('test_parient'); 
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test_diagnose');	 
	foreach($data['hms_opd_patient']->result() as $row_p) 
	{ 
	break; 
	} 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('doctor_id',$row_p->doctor_id); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_d) 
	{ 
	break; 
	}		 
	$data['doctor_name']=$row_d->name; 
	 
	 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('enter_date',$today);	 
	$this->db->group_by('patient_id');	 
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test_diagnose'); 
	foreach($data['hms_opd_assign_test_pat']->result() as $row) 
	{ 
	break; 
	} 
	$data['test_date']=$row->enter_date;			 
	 
	 
	 
	 
//	$this->db->where('dig_parient !=',0); 
	$data['test_name']=$this->db->get('hms_dignos_master');	 
	 
 
	 
//	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	 
	 
				 
	$this->load->view('hms/print_opd_diagnose_sleep',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
	}	      	 
	 
	public function add_pasient_opd_diagnose_test() 
 	{ 
   
		 
	$this->load->library('session'); 
        	$this->load->helper('url'); 
		$afid=$this->get_affiliate(); 
		$empid=$this->get_af_emp_id(); 
 
		$ques=$this->input->post('su_id'); 
		$qui=explode(',',$ques); 
	        $value_qui=$this->input->post('mark_val'); 
		$val_qui=explode('^',$value_qui); 
		 
		$t=1; 
       		for($t1=1;Count($qui)>$t1;$t1++) 
        	{ 
         	 $this->load->database(); 
		$this->test_val=$val_qui[$t]; ;	   
       		$this->test_id=$qui[$t]; 
		$this->patient_id=$this->input->post('patient_name'); 
		$this->enter_date=$this->input->post('e_date'); 
		$this->pathology_center=$this->input->post('pathlogy_name'); 
	        $this->hospital_name=$this->input->post('hospital_name'); 
                $this->doctor_id=$this->input->post('docid');		 
		$this->afid=$afid; 
		$this->emp_id=$empid; 
		$this->db->set('status','1');			 
               	$this->db->insert('hms_patient_assign_test_diagnose',$this);			 
			 
		$t++; 
		}		 
                echo 'Patient Assigned Test';   
      	} 
	       
public function print_opd_dignouse_sleep() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$patient_id=$this->uri->segment(3); 
	$en_date=$this->uri->segment(4);	 
	$this->db->where('afid',$aid);	 
	$this->db->where('id',$patient_id); 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$patient_id); 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$patient_id); 
	$this->db->where('enter_date',$en_date); 
	$this->db->group_by('patient_id');		 
	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test_diagnose'); 
	 
	$this->db->where('afid',$aid);	 
	$data['test_name']=$this->db->get('hms_dignos_master');	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate'); 
      	  
	       	  
       $data['today']=$en_date;	 
     	 
       $data['afid']=$aid; 
       	$this->db->where('afid',$aid);	        
       	$data['hms_pathology']=$this->db->get('hms_pathology');	 
      	  
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	 
  
        			 
	$this->load->view('hms/print_diagnouse_test_sleep',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}  
} 	       
	       
public function view_assign_patient_test_diagnose() 
{ 
		$this->load->library('session'); 
         	$this->load->helper('url'); 
 		$afid=$this->get_affiliate(); 
 		//$pid=$this->uri->segment(3); 
 	$this->db->where('afid',$afid);	 
 	$data_count=$this->db->count_all_results('hms_patient_assign_test_diagnose'); 
 	if($data_count>0) 
 	{ 
	$limit=30; 
	$start=$this->uri->segment(3); 
	$start1=$start*$limit; 
	 		 
 	$this->db->where('afid',$afid);	 
 	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
 	 
 //	$this->db->where('test_parient !=',0); 
 	$data['test_name']=$this->db->get('hms_dignos_master');	 
	  
	$this->db->where('afid',$afid); 
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test_diagnose',$limit,$start1);	  
  
 	$this->db->where('afid',$afid);	 
 	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	  
	$this->db->where('afid',$afid); 
	$data['total']=$this->db->count_all_results('hms_patient_assign_test_diagnose'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
 				 
 	$this->load->view('hms/view_patient_assign_test_diagnose',$data);	 
         } 
 	else 
 	{ 
 	echo 'Record not found'; 
 	} 
} 
	 
	public function add_department() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->db->where('afid',$aid); 
	$this->db->where('parient_id','0'); 
	$data['department']=$this->db->get('hms_department'); 
	 
	$this->db->where('afid',$aid); 
	$data['hms_department']=$this->db->get('hms_department');	 
	$this->load->view('hms/add_department',$data);   
	} 
	 
	public function save_department() 
	{ 
	$this->load->library('session'); 
	$this->load->helper('url'); 
	$aid=$this->get_affiliate(); 
	$this->name=$this->input->post('dep_name'); 
	$this->parient_id=$this->input->post('parient_dep'); 
	$this->description=$this->input->post('description'); 
	$this->afid=$this->get_affiliate(); 
	$this->db->insert('hms_department',$this);	 
	echo 'Record Added';	 
	} 
	 
	 
	public function edit_department() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$row_id=$this->uri->segment(3); 
	$this->db->where('afid',$aid); 
	$this->db->where('parient_id','0'); 
	$data['department']=$this->db->get('hms_department'); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('dep_id',$row_id); 
	$data['hms_department']=$this->db->get('hms_department');	 
	$this->load->view('hms/edit_department',$data);   
 
	} 
	 
	 
	public function update_department() 
	{ 
	$this->load->library('session'); 
	$this->load->helper('url'); 
	$aid=$this->get_affiliate(); 
	 
	$dep_id=$this->input->post('dep_id');	 
	$this->name=$this->input->post('dep_name'); 
	$this->parient_id=$this->input->post('parient_dep'); 
	$this->description=$this->input->post('description'); 
	$this->db->where('dep_id',$dep_id); 
	$this->db->where('afid',$aid); 
	$this->db->update('hms_department',$this);	 
	echo 'Record Updated'; 
	} 
	 
	public function delete_department() 
	{ 
	$this->load->library('session'); 
        $this->load->helper('url'); 
	$aid=$this->get_affiliate(); 
	$dep_id=$this->uri->segment(3); 
	$this->db->where('dep_id',$dep_id); 
	$this->db->where('afid',$aid); 
	$this->db->delete('hms_department'); 
	echo 'Record Deleted'; 
	}			 
	public function view_department() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->load->database(); 
	$this->db->where('afid',$aid); 
	$data_count=$this->db->count_all_results('hms_department'); 
	if($data_count>0) 
	{		 
	$limit=80; 
	$start=$this->uri->segment(3); 
	$start1=$start*$limit; 
//	$this->db->where('afid',$aid); 
//	$data['hms_department']=$this->db->get('hms_department',$limit,$start1); 
 
	$this->db->where('afid',$aid); 
	$this->db->where('parient_id','0'); 
	$this->db->order_by('dep_id','asc'); 
	$data['hms_department_parient']=$this->db->get('hms_department',$limit,$start1); 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('parient_id','0'); 
	$data['hms_department_all']=$this->db->get('hms_department');	 
	 
	$this->db->where('afid',$aid); 
	$data['total']=$this->db->count_all_results('hms_department'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_department',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	} 
	} 
	 
	public function view_department_second() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->load->database(); 
	$this->db->where('afid',$aid); 
	$data_count=$this->db->count_all_results('hms_department'); 
	if($data_count>0) 
	{		 
	$limit=80; 
	$start=$this->uri->segment(3); 
	$start1=$start*$limit; 
//	$this->db->where('afid',$aid); 
//	$data['hms_department']=$this->db->get('hms_department',$limit,$start1); 
 
	$this->db->where('afid',$aid); 
	$this->db->where('parient_id','0'); 
	$this->db->order_by('dep_id','asc'); 
	$data['hms_department_parient']=$this->db->get('hms_department',$limit,$start1); 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('parient_id','0'); 
	$data['hms_department_all']=$this->db->get('hms_department');	 
	 
	$this->db->where('afid',$aid); 
	$data['total']=$this->db->count_all_results('hms_department'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_department_second',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	} 
 
	}	 
	 
	 
	public function search_sub_dep() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$dep_id=$this->uri->segment(3); 
	$start=$this->uri->segment(4);	 
	$this->load->database(); 
	$this->db->where('afid',$aid); 
	//$this->db->where('parient_id','0'); 
	$data_count=$this->db->count_all_results('hms_department'); 
	if($data_count>0) 
	{		 
	$limit=50; 
 
	$start1=$start*$limit; 
	$this->db->where('afid',$aid); 
	$this->db->where('parient_id',$dep_id); 
	$this->db->order_by('dep_id','asc'); 
	$data['hms_department']=$this->db->get('hms_department',$limit,$start1); 
 
	$this->db->where('afid',$aid); 
	$this->db->where('parient_id','0'); 
	$this->db->order_by('dep_id','asc'); 
	$data['hms_department_parient']=$this->db->get('hms_department'); 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('parient_id','0'); 
	$data['hms_department_all']=$this->db->get('hms_department'); 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('parient_id',$dep_id); 
	$this->db->order_by('dep_id','asc');	 
	$data['total']=$this->db->count_all_results('hms_department'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$data['dep_id']=$dep_id; 
	$this->load->view('hms/view_sub_department',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
	}	 
	 
	 
	 
	 
	public function add_doctor() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->db->where('afid',$aid); 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	 
	$data['hms_zone_master']=$this->db->get(' hms_zone_master');			 
	$this->load->view('hms/add_doctor',$data); 
	} 
	 
public function save_doctor() 
{ 
	$this->load->library('session'); 
	$this->load->helper('url'); 
	$aid=$this->get_affiliate(); 
	$this->name=$this->input->post('doc_name'); 
//	$this->email=$this->input->post('email'); 
//	$this->password=$this->input->post('password'); 
	$this->address=$this->input->post('address'); 
	$this->phone=$this->input->post('phone'); 
	$this->degree=$this->input->post('qulification'); 
	$this->per=$this->input->post('perst');	 
	$this->per_rt=$this->input->post('perrt');	 
	$this->digper=$this->input->post('digperst'); 
	$this->dis_rt=$this->input->post('digperrt');	 
	$this->center_id=$this->input->post('pathlogy'); 
	$this->zone_id=$this->input->post('zone'); 
				 
	$this->afid=$aid; 
	$this->db->insert('hms_doctor',$this);	 
	echo 'Record Added'; 
} 
 
 
	public function update_doctor() 
	{ 
	$this->load->library('session'); 
	$this->load->helper('url'); 
	$aid=$this->get_affiliate(); 
	$doc_id=$this->input->post('doc_id');	 
	$this->name=$this->input->post('doc_name'); 
	$this->address=$this->input->post('address'); 
	$this->phone=$this->input->post('phone'); 
	$this->degree=$this->input->post('qulification'); 
	$this->per=$this->input->post('perst');	 
	$this->per_rt=$this->input->post('perrt');	 
	$this->digper=$this->input->post('digperst'); 
	$this->dis_rt=$this->input->post('digperrt'); 
	$this->center_id=$this->input->post('pathlogy'); 
	$this->zone_id=$this->input->post('zone');					 
	$this->db->where('doctor_id',$doc_id); 
	$this->db->where('afid',$aid); 
	$this->db->update('hms_doctor',$this);	 
	echo 'Record Updated'; 
	} 
	 
    public function edit_doctor() 
    { 
 	$this->load->helper('url'); 
    	$this->load->library('session'); 
    	$aid=$this->get_affiliate(); 
	     
    //	$this->db->where('afid',$aid); 
    //	$data['department']=$this->db->get('hms_department'); 
	     
	    	     
	$doctor_id=$this->uri->segment(3); 
	$this->db->where('doctor_id',$doctor_id); 
	$this->db->where('afid',$aid);	 
    	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	     
	$this->db->where('afid',$aid); 
	$data['hms_pathology2']=$this->db->get('hms_pathology'); 
	$data['hms_zone_master']=$this->db->get(' hms_zone_master');			    		 
    	$this->load->view('hms/edit_doctor',$data);    
    } 
 
    
 	public function delete_doctor() 
    	{ 
    	$this->load->library('session'); 
        $this->load->helper('url'); 
    	$aid=$this->get_affiliate(); 
    	$doc_id=$this->uri->segment(3); 
    	$this->db->where('doctor_id',$doc_id); 
    	$this->db->where('afid',$aid); 
    	$this->db->delete('hms_doctor'); 
    	echo 'Record Deleted'; 
    	}  
	     
	       
	public function view_doctor() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->load->database(); 
	$this->db->where('afid',$aid); 
	$data_count=$this->db->count_all_results('hms_doctor'); 
	if($data_count>0) 
	{		 
	$limit=50; 
	$start=$this->uri->segment(3); 
	$start1=$start*$limit; 
//	$this->db->where('afid',$aid); 
//	$data['hms_department']=$this->db->get('hms_department',$limit,$start1); 
	$this->db->where('afid',$aid); 
	$this->db->order_by('name','asc'); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
 
 
	$this->db->where('afid',$aid); 
	$this->db->order_by('name','asc'); 
	$data['hms_doctor_list']=$this->db->get('hms_doctor'); 
 
	$this->db->where('afid',$aid); 
	$data['hms_pathology']=$this->db->get('hms_pathology'); 
	 
	$data['hms_zone_master']=$this->db->get(' hms_zone_master'); 
			 
	$this->db->where('afid',$aid); 
	$data['total']=$this->db->count_all_results('hms_doctor'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_doctor',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	} 
 
	} 
	 
 
 
	public function view_doctor_second() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->load->database(); 
	$this->db->where('afid',$aid); 
	$data_count=$this->db->count_all_results('hms_doctor'); 
	if($data_count>0) 
	{		 
	$limit=10; 
	$start=$this->uri->segment(3); 
	$start1=$start*$limit; 
//	$this->db->where('afid',$aid); 
//	$data['hms_department']=$this->db->get('hms_department',$limit,$start1); 
 
	$this->db->where('afid',$aid); 
	$this->db->order_by('name','asc'); 
	$data['hms_doctor_list']=$this->db->get('hms_doctor',$limit,$start1); 
		 
	 
	$this->db->where('afid',$aid); 
	$data['total']=$this->db->count_all_results('hms_doctor'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_doctor_second',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	} 
 
	} 
	 
public function doctor_record() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$docid=$this->uri->segment(3);	 
	$this->db->where('afid',$aid); 
	$this->db->where('doctor_id',$docid); 
	$data_count=$this->db->count_all_results('hms_doctor'); 
	if($data_count>0) 
	{	 
	$this->db->where('afid',$aid); 
	$this->db->where('doctor_id',$docid);	 
	$this->db->order_by('doctor_id','asc'); 
	$data['hms_doctor_list']=$this->db->get('hms_doctor'); 
	$this->load->view('hms/view_doctor_record',$data);	 
	} 
	else 
	{ 
	echo 'Record Not fond'; 
	} 
} 
 
 
public function doctor_record_center() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$docid=$this->uri->segment(3);	 
	$this->db->where('afid',$aid); 
	$this->db->where('center_id',$docid); 
	$data_count=$this->db->count_all_results('hms_doctor'); 
	if($data_count>0) 
	{	 
	$this->db->where('afid',$aid); 
	$this->db->where('center_id',$docid);	 
	$this->db->order_by('name','asc'); 
	$data['hms_doctor_list']=$this->db->get('hms_doctor'); 
	$this->load->view('hms/view_doctor_record',$data);	 
	} 
	else 
	{ 
	echo 'Record Not fond'; 
	} 
}	 
	 
	public function call_doctor_dep_wise() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->load->database(); 
	$dep_id=$this->uri->segment(3);	 
	$this->db->where('afid',$aid); 
	$data_count=$this->db->count_all_results('hms_doctor'); 
	if($data_count>0) 
	{		 
	$limit=10; 
	$start=$this->uri->segment(4); 
	$start1=$start*$limit; 
 
 
	$this->db->where('afid',$aid); 
	$this->db->where('department_id',$dep_id);	 
	$this->db->order_by('doctor_id','asc'); 
	$data['hms_doctor_list']=$this->db->get('hms_doctor',$limit,$start1); 
		 
	$this->db->where('afid',$aid); 
	$data['hms_department_all']=$this->db->get('hms_department');	 
	$this->db->where('afid',$aid); 
	$data['total']=$this->db->count_all_results('hms_doctor'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_doctor_second',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	} 
 
	}	 
	 
	 
		 
	public function add_nurse() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->db->where('afid',$aid); 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$this->load->view('hms/add_nurse',$data); 
	} 
	 
	public function edit_nurse() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$nurse_id=$this->uri->segment(3);	 
	$this->db->where('afid',$aid); 
	$this->db->where('nurse_id',$nurse_id);	 
	$this->db->order_by('nurse_id','asc'); 
	$data['hms_nurse']=$this->db->get('hms_nurse');	 
	 
	$this->db->where('afid',$aid); 
	$data['hms_pathology']=$this->db->get('hms_pathology');		 
	$this->load->view('hms/edit_nurse',$data); 
	}	 
	 
	public function save_nurse() 
	{ 
	$this->load->library('session'); 
	$this->load->helper('url'); 
	$aid=$this->get_affiliate(); 
	$this->name=$this->input->post('doc_name'); 
//	$this->email=$this->input->post('email'); 
	$this->degree=$this->input->post('qulification'); 
	$this->address=$this->input->post('address'); 
	$this->phone=$this->input->post('phone'); 
	$this->center_id=$this->input->post('pathlogy');			 
	$this->afid=$aid; 
	$this->db->insert('hms_nurse',$this);	 
	echo 'Record Added'; 
	} 
	 
	public function update_nurse() 
	{ 
	$this->load->library('session'); 
	$this->load->helper('url'); 
	$aid=$this->get_affiliate(); 
	$nus_id=$this->input->post('nus_id');	 
	$this->name=$this->input->post('doc_name'); 
//	$this->email=$this->input->post('email'); 
	$this->degree=$this->input->post('qulification'); 
	$this->address=$this->input->post('address'); 
	$this->phone=$this->input->post('phone'); 
	$this->center_id=$this->input->post('pathlogy');	 
	$this->db->where('nurse_id',$nus_id);		 
	$this->db->where('afid',$aid); 
	$this->db->update('hms_nurse',$this);	 
	echo 'Record Updated'; 
	} 
	 
	public function delete_nurse() 
    	{ 
    	$this->load->library('session'); 
        $this->load->helper('url'); 
    	$aid=$this->get_affiliate(); 
    	$nurse_id=$this->uri->segment(3); 
	$file_name=$this->uri->segment(4);	     
    	$this->db->where('nurse_id',$nurse_id); 
    	$this->db->where('afid',$aid); 
    	$this->db->delete('hms_nurse'); 
   
//unlink("application/affiliate_pic_real/".$file_name); 
     
    	echo 'Record Deleted'; 
    	} 		 
	public function view_nurse() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->load->database(); 
	$this->db->where('afid',$aid); 
	$data_count=$this->db->count_all_results('hms_nurse'); 
	if($data_count<10) 
	{		 
	$limit=15; 
	$start=$this->uri->segment(3); 
	$start1=$start*$limit; 
//	$this->db->where('afid',$aid); 
//	$data['hms_department']=$this->db->get('hms_department',$limit,$start1); 
 
	$this->db->where('afid',$aid); 
	$this->db->order_by('nurse_id','asc'); 
	$data['hms_nurse_list']=$this->db->get('hms_nurse'); 
		 
	$this->db->where('afid',$aid); 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	 
	$this->db->where('afid',$aid); 
	$data['total']=$this->db->count_all_results('hms_nurse'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_nurse',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	} 
 
	} 
	 
	public function view_nurse_second() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->load->database(); 
	$this->db->where('afid',$aid); 
	$data_count=$this->db->count_all_results('hms_nurse'); 
	if($data_count>0) 
	{		 
	$limit=15; 
	$start=$this->uri->segment(3); 
	$start1=$start*$limit; 
//	$this->db->where('afid',$aid); 
//	$data['hms_department']=$this->db->get('hms_department',$limit,$start1); 
 
	$this->db->where('afid',$aid); 
	$this->db->order_by('nurse_id','asc'); 
	$data['hms_nurse_list']=$this->db->get('hms_nurse',$limit,$start1); 
		 
	 
	$this->db->where('afid',$aid); 
	$data['total']=$this->db->count_all_results('hms_nurse'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_nurse_second',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	} 
 
	}				 
		 
 
 
	public function add_bed() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->db->where('afid',$aid); 
	$this->db->where('parient_id','0'); 
	$data['department']=$this->db->get('hms_department');	 
	$this->load->view('hms/add_bed',$data); 
	} 
	 
 
	public function sub_dep() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$dep_id=$this->uri->segment(3); 
	$this->load->database(); 
	$this->db->where('afid',$aid); 
	$data_count=$this->db->count_all_results('hms_department'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('parient_id',$dep_id); 
	$this->db->order_by('dep_id','asc'); 
	$data['hms_department_sub']=$this->db->get('hms_department'); 
	$this->load->view('hms/sub_department',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
	}		 
	 
	 
	public function add_opd_patient() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->db->where('afid',$aid); 
	$this->db->order_by('name','asc'); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	 
	$this->db->where('afid',$aid); 
	$data['hms_nurse']=$this->db->get('hms_nurse'); 
	 
	$this->db->where('afid',$aid); 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$this->db->where('afid',$aid); 
	$data['hms_hospital']=$this->db->get('hms_hospital');	 
	 
	$this->db->where('emp_aff_id',$aid); 
	$data['emp_info_data']=$this->db->get('emp_info');	 
	 
		 
	$date=date('y-m-d'); 
//	$this->db->where('entry_date', $date); 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count<=30000) 
	{ 
	 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count<=30000) 
	{ 
	$this->db->select_max('token_no'); 
	$this->db->where('afid',$aid);	 
//	$this->db->where('entry_date',$date);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	foreach($data['hms_opd_patient']->result() as $row) 
		{ 
	//	break; 
		} 
		 
	$new_lot_id=$row->token_no; 
	$ac_auto_no=$new_lot_id+1;		 
	$data['toc_no']=$row->token_no+1; 
	 
	$chech_val=strlen($ac_auto_no);	 
	if($chech_val<=1) 
	{ 
	$data['regno']='ANG'.'869'.$ac_auto_no;		 
	} 
	else if($chech_val==2 || $chech_val >=2)	  
	{ 
	$data['regno']='ANG'.'869'.$ac_auto_no;	 
	} 
/* 
<!--	else if($chech_val==3)	  
	{ 
	$data['toc_no']='AC'.'-'.$type.$year.'-'.$branch_code.'000'.$ac_auto_no;	  
	} 
	else if($chech_val==4)	  
	{ 
	$data['toc_no']='AC'.'-'.$type.$year.'-'.$branch_code.'00'.$ac_auto_no;	 
	} 
	else if($chech_val==5)	  
	{ 
	$data['toc_no']='AC'.'-'.$type.$year.'-'.$branch_code.'0'.$ac_auto_no; 
	}	 
	else if($chech_val==6)	  
	{ 
	$data['toc_no']='AC'.'-'.$type.$year.'-'.$branch_code.$ac_auto_no; 
	 
	}--!>*/ 
	 
			 
	} 
	else 
	{ 
	$data['toc_no']=1; 
 
	$data['regno']='ANG'.'869'.'1';  		 
	}		 
	$this->load->view('hms/add_opd_patient',$data); 
	} 
	else 
	{ 
	 
	} 
	}	 
 
	 
	public function get_doctor_center() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$centerid=$this->uri->segment(3); 
 
	$this->db->where('afid',$aid); 
	$this->db->where('center_id',$centerid); 
	$this->db->order_by('name','asc'); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('center_id',$centerid); 
	$this->db->order_by('name','asc'); 
	$data['hms_nurse']=$this->db->get('hms_nurse');		 
	$this->load->view('hms/sub_doctor_name',$data);	 
	} 
	 
	 
	 
	public function get_doctor_name() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$centerid=$this->uri->segment(3); 
 
	$this->db->where('afid',$aid); 
	$this->db->where('center_id',$centerid); 
	$this->db->order_by('name','asc'); 
	$data['hms_doctor']=$this->db->get('hms_doctor');	 
	$this->load->view('hms/center_doctor_name',$data);	 
	}		 
	 
	 
	public function doctor_charge() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$doctorid=$this->uri->segment(3); 
	$this->load->database(); 
	$this->db->where('afid',$aid); 
	$data_count=$this->db->count_all_results('hms_doctor'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('doctor_id',$doctorid); 
//	$this->db->order_by('doctor_id','asc'); 
	$data['hms_doctor_sub']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor_sub']->result() as $row) 
	{ 
	break; 
	} 
	$data['fee_charge']=$row->treatment_charge; 
	$this->load->view('hms/sub_doctor_charge',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
	} 
	 
 
 
	public function save_opd_patient() 
	{ 
	$this->load->library('session'); 
	$this->load->helper('url'); 
	$aid=$this->get_affiliate(); 
	$af_emp_id=$this->get_af_emp_id(); 
	$this->token_no=$this->input->post('tcno'); 
	$this->grno=$this->input->post('grno');	 
	$this->patient_name=$this->input->post('patient_name');	 
	$this->gender=$this->input->post('gender'); 
	$this->age=$this->input->post('age');	 
	$this->phone=$this->input->post('phone'); 
	$this->doctor_id=$this->input->post('doctor');	 
	$this->collection_code=$this->input->post('collectby'); 
	$this->pathlogy_sign=$this->input->post('pathology_doctor');	 
	$this->entry_date=$this->input->post('date'); 
	$this->remarks=$this->input->post('remark'); 
	$this->clboy=$this->input->post('clboy'); 
	$this->hospitalid=$this->input->post('hospitalid');		 
	 
	$this->titlename=$this->input->post('titlename'); 
	$this->yearname=$this->input->post('yearname'); 
	$this->statusid=$this->input->post('statusid'); 
			 
	date_default_timezone_set('Asia/Calcutta'); 
	$this->entry_date_time=date("h:i a"); 
	$this->opd_emp_id=$af_emp_id;		 
	$this->afid=$aid; 
	$this->db->insert('hms_opd_patient',$this);	 
	echo 'Record Added'; 
	} 
	 
 
 
 
	public function add_view_opd_patient() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
 
	 
	$this->db->where('afid',$aid); 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$limit=150; 
	$start=$this->uri->segment(3); 
	$start1=$start*$limit; 
 
	$this->db->where('afid',$aid); 
	$this->db->order_by('id','desc'); 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient',$limit,$start1); 
	 
	$this->db->where('afid',$aid); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
				 
	$this->db->where('afid',$aid); 
	$data['total']=$this->db->count_all_results('hms_opd_patient'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_opd_patient',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
	 
	} 
	 
 
	public function second_opd_patient() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->db->where('afid',$aid); 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$limit=1150; 
	$start=$this->uri->segment(3); 
	$start1=$start*$limit; 
 
	$this->db->where('afid',$aid); 
	$this->db->order_by('id','desc'); 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient',$limit,$start1); 
	 
	$this->db->where('afid',$aid); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
				 
	$this->db->where('afid',$aid); 
	$data['total']=$this->db->count_all_results('hms_opd_patient'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_second_opd_patient',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	} 
	 
	} 
	 
	 
	public function search_opd_patient_date() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4);		 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate);		 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$limit=150; 
	$start=$this->uri->segment(5); 
	$start1=$start*$limit; 
 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->order_by('entry_date','desc');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
 
	$this->db->where('afid',$aid); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
				 
	$this->db->where('afid',$aid); 
	$data['total']=$this->db->count_all_results('hms_opd_patient'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_second_opd_patient_date_wise',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
	}	 
 
	public function search_opd_patient_rego_wise() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$rego=$this->uri->segment(3); 
//	$tdate=$this->uri->segment(4);		 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('phone',$rego);			 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$limit=150; 
	$start=$this->uri->segment(5); 
	$start1=$start*$limit; 
 
	$this->db->where('afid',$aid);	 
	$this->db->where('phone',$rego);		 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
 
	$this->db->where('afid',$aid); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
				 
	$this->db->where('afid',$aid); 
	$this->db->where('phone',$rego);		 
	$data['total']=$this->db->count_all_results('hms_opd_patient'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_second_opd_patient_date_wise',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
	} 
 
	public function print_opd_patient() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	foreach($data['hms_opd_patient']->result() as $row) 
	{ 
	break; 
	}	 
 
	$this->db->where('afid',$aid); 
	$this->db->where('doctor_id',$row->doctor_id); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
 
	foreach($data['hms_doctor']->result() as $row_doc) 
	{ 
	break; 
	} 
$data['doctor_name']=$row_doc->name;		 
	$this->db->where('afid',$aid); 
	$this->db->where('parient_id !=',0); 
	$this->db->where('dep_id !=',33); 
	$this->db->where('dep_id !=',34); 
//	$this->db->where('dep_id !=',35);	 
//	$this->db->group_by('parient_id');		 
	$data['hms_department']=$this->db->get('hms_department');	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	 
	 
				 
//	$this->load->view('hms/print_opd_doctor_paper',$data);	 
	$this->load->view('hms/print_opd_doctor_paper_new',$data);		 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
	} 
	 
 
	public function assign_patient_test() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	foreach($data['hms_opd_patient']->result() as $row) 
	{ 
	break; 
	} 
	$data['phone']=$row->phone;	 
	$data['date_day']=$row->entry_date;	 
	 
//	$this->db->where('afid',$aid);	 
//	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$this->db->where('test_parient',0); 
	$this->db->order_by('id','asc'); 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
	 
	$this->db->order_by('id','asc');	 
       	$data['test_name2']=$this->db->get('ho_m_test_master');	 
      	  
	       $date_day=date('Y-m-d'); 
	        
	     //  $data['date_day']=$date_day; 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
//	$this->db->where('enter_date',$date_day); 
	$this->db->where('test_panels','0');		 
//----------------show amount with parient--- 
 
$this->db->group_by('test_parient'); 
//-------------------------------------------------		 
	$this->db->order_by('enter_date','desc');	 
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test');	 
	 
				 
	$this->load->view('hms/assign_patient_test',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
	}	 
 
 
	public function add_pasient_test() 
 	{ 
      		$this->load->library('session'); 
        	$this->load->helper('url'); 
		$afid=$this->get_affiliate(); 
		$empid=$this->get_af_emp_id();		 
		$ques=$this->input->post('value'); 
		$qui=explode(',',$ques); 
		$t=0; 
		for($t1=0;Count($qui)>$t1;$t1++) 
		{ 
		 
	//	$this->db->where('test_id',$qui[$t]);	 
		 
		$patient_id=$this->input->post('patient_name'); 
		$test_parient=$this->input->post('test_parient'); 
		$this->db->where('patient_id',$patient_id); 
	//	$this->db->where('test_parient',$test_parient); 
		$this->db->where('test_id',$qui[$t]); 
		$data['lastan1']=$this->db->count_all_results('hms_patient_assign_test'); 
		 
	 
		if($data['lastan1']>=1) 
		{ 
	 
		   //echo $qui[$t].'Test already assigned ';     
		   //echo'Test already assigned '; 
		   //	break;   
		    
		} 
		else 
	      { 
               	$this->load->database(); 
               	$this->test_id=$qui[$t]; 	 
		$this->patient_id=$this->input->post('patient_name'); 
		$this->enter_date=$this->input->post('e_date'); 
		$this->test_parient=$this->input->post('test_parient'); 
		$this->root_id=$this->input->post('root_name'); 
		$this->afid=$afid; 
		$this->emp_id=$empid; 
		$this->db->set('status','1');			 
               	$this->db->insert('hms_patient_assign_test',$this); 
		} 
               	$t++; 
                } 
                echo 'Patient Assigned Test';   
      	}	 
       
       
	 public function view_assign_patient_test() 
 	{ 
 		$this->load->library('session'); 
         	$this->load->helper('url'); 
 		$afid=$this->get_affiliate(); 
 		//$pid=$this->uri->segment(3); 
 	$this->db->where('afid',$afid);	 
 	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
 	if($data_count>0) 
 	{ 
	$limit=30; 
	$start=$this->uri->segment(3); 
	$start1=$start*$limit; 
	 		 
 	$this->db->where('afid',$afid);	 
 	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
 	 
 //	$this->db->where('test_parient !=',0); 
 	$data['test_name']=$this->db->get('ho_m_test_master');	 
	  
	$this->db->where('afid',$afid); 
	$this->db->order_by('enter_date','desc');	 
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test',$limit,$start1);	  
  
 	$this->db->where('afid',$afid);	 
 	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	  
	$this->db->where('afid',$afid); 
	$this->db->order_by('enter_date','desc');	 
	$data['total']=$this->db->count_all_results('hms_patient_assign_test'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
 				 
 	$this->load->view('hms/view_patient_assign_test',$data);	 
         } 
 	else 
 	{ 
 	echo 'Record not found'; 
 	} 
  
 	}      
       
       
   
	        
public function search_opd_patient_test_report_date() 
{ 
       		$this->load->library('session'); 
               	$this->load->helper('url'); 
       		$afid=$this->get_affiliate(); 
       		//$pid=$this->uri->segment(3); 
		$fdate=$this->uri->segment(3); 
	     $tdate=$this->uri->segment(4);		              
       	$this->db->where('afid',$afid);	 
	$this->db->where('enter_date >=',$fdate);	 
	$this->db->where('enter_date <=',$tdate);	        
       	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
       	if($data_count>0) 
       	{ 
      	$limit=2150; 
      	$start=$this->uri->segment(5); 
      	$start1=$start*$limit; 
      	 		 
       	$this->db->where('afid',$afid);	 
       	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
       	 
       //	$this->db->where('test_parient !=',0); 
       	$data['test_name']=$this->db->get('ho_m_test_master');	 
      	  
      	$this->db->where('afid',$afid); 
	$this->db->where('enter_date >=',$fdate);	 
	$this->db->where('enter_date <=',$tdate);	       
	$this->db->group_by('patient_id');     
	$this->db->group_by('enter_date');     
       	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test',$limit,$start1);	  
        
       	$this->db->where('afid',$afid);	        
       	$data['hms_pathology']=$this->db->get('hms_pathology');	 
      	  
      	$this->db->where('afid',$afid); 
 
	$this->db->where('enter_date >=',$fdate);	 
	$this->db->where('enter_date <=',$tdate); 
	$this->db->group_by('patient_id'); 		       
	$data['total']=$this->db->count_all_results('hms_patient_assign_test'); 
      	$data['limit']=$limit; 
      	$data['start']=$start; 
      	$data['start1']=$start1; 
       				 
       	$this->load->view('hms/view_patient_assign_test_new_second',$data);	 
               } 
       	else 
       	{ 
       	echo 'Record not found'; 
       	} 
}	        
	        
	        
	public function update_test_val_opd() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	$p_date=$this->uri->segment(4); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('test_panels','0');	 
//	$this->db->where('enter_date',$p_date);	 
	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->order_by('id','asc');	 
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->group_by('patient_id');	 
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test'); 
	foreach($data['hms_opd_assign_test_pat']->result() as $row) 
	{ 
	break; 
	} 
	$data['test_date']=$row->enter_date;			 
	 
	$this->db->where('afid',$aid);	 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	//$this->db->where('test_parient !=',0); 
	$this->db->order_by('id','asc');	 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
				 
	$this->load->view('hms/update_patient_test_value',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
} 
 
 
	public function update_test_val_opd_user() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	$p_date=$this->uri->segment(4); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('test_panels','0');	 
//	$this->db->where('enter_date',$p_date);	 
	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->order_by('id','asc');	 
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->group_by('patient_id');	 
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test'); 
	foreach($data['hms_opd_assign_test_pat']->result() as $row) 
	{ 
	break; 
	} 
	$data['test_date']=$row->enter_date;			 
	 
	$this->db->where('afid',$aid);	 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	//$this->db->where('test_parient !=',0); 
	$this->db->order_by('id','asc');	 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
				 
	$this->load->view('hms/update_patient_test_value_user',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
   } 
 
	public function print_opd_patient_test_report() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	$p_date=$this->uri->segment(4); 
	$margin_bottom=$this->uri->segment(5); 
	$margin=$this->uri->segment(6);	 
	date_default_timezone_set('Asia/Calcutta'); 
	$data['report_time']=date("h:i a");	 
	$data['today']=date('d-m-Y'); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
//	$this->db->where('enter_date',$p_date);		 
	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid);	 
	$this->db->group_by('test_parient'); 
	$this->db->order_by('id','asc');		 
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	 
	 
	 
	 
		 
	foreach($data['hms_opd_patient']->result() as $row_p) 
	{ 
	break; 
	} 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('doctor_id',$row_p->doctor_id); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_d) 
	{ 
	break; 
	}		 
	$data['doctor_name']=$row_d->name; 
	 
	 
 
	$this->db->where('afid',$aid); 
	$this->db->where('nurse_id',$row_p->pathlogy_sign); 
	$data['hms_nurse']=$this->db->get('hms_nurse'); 
	foreach($data['hms_nurse']->result() as $row_n) 
	{ 
	break; 
	}		 
	$data['nurse_name']=$row_n->name; 
	$data['degree']=$row_n->degree; 
	$data['img_sign']=$row_n->img_sign;	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->group_by('patient_id');	 
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test'); 
	foreach($data['hms_opd_assign_test_pat']->result() as $row) 
	{ 
	break; 
	} 
	$data['test_date']=$row->enter_date;			 
	 
//	$this->db->where('id',$row->pathology_center); 
//	$this->db->where('afid',$aid);	 
//	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	//$this->db->where('test_parient !=',0); 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
	 
 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	 
	 
	$data['margin_top']=$margin; 
	$data['margin_bottom']=$margin_bottom;				 
//	$this->load->view('hms/barcode',$data);	 
//	$this->load->view('hms/demo',$data); 
	$this->load->view('hms/print_opd_test_report_new',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
	}	 
 
 
public function update_student_marks() 
{ 
		$this->load->library('session'); 
        	$this->load->helper('url'); 
		$afid=$this->get_affiliate(); 
		 
		$id=$this->input->post('checkid'); 
		$mark=$this->input->post('checkedoption2'); 
		$qui_id=explode(',',$id); 
		$qui=explode(',',$mark); 
	 
	       $t=0; 
		for($t1=0;Count($qui_id)>$t1;$t1++) 
		{ 
		$this->load->database(); 
		//$this->modify_emp_id=$this->input->post('eid');  
		$this->test_val=$qui[$t];  
		$this->db->where('id',$qui_id[$t]); 
	       $this->db->update('hms_patient_assign_test',$this); 
	        
		$t++; 
 
		} 
		 
}          
       
       
	public function add_pathology() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->db->where('afid',$aid); 
//	$data['department']=$this->db->get('hms_department');		 
	$this->load->view('hms/add_pathology'); 
	}   
	 
	 
	public function save_pathology() 
	{ 
	$this->load->library('session'); 
	$this->load->helper('url'); 
	$aid=$this->get_affiliate(); 
	$data_count=$this->db->count_all_results('hms_pathology'); 
	if($data_count>4) 
	{ 
	echo 'Only Four Centers Allow'; 
	} 
	else 
	{	 
	$this->pathology_name=$this->input->post('pos_name'); 
	$this->email=$this->input->post('email'); 
	$this->address=$this->input->post('address'); 
	$this->phone=$this->input->post('phone'); 
	 
	$this->firdoct=$this->input->post('firdoct'); 
	$this->fiedgree=$this->input->post('fiedgree'); 
	$this->secdoct=$this->input->post('secdoct'); 
	$this->secdgree=$this->input->post('secdgree'); 
				 
	$this->afid=$aid; 
	$this->db->insert('hms_pathology',$this);	 
	echo 'Record Added'; 
	} 
	}	     
      
      
	public function view_pathlogy() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->load->database(); 
	$this->db->where('afid',$aid); 
	$data_count=$this->db->count_all_results('hms_pathology'); 
	if($data_count>0) 
	{		 
	$limit=15; 
	$start=$this->uri->segment(3); 
	$start1=$start*$limit; 
	 
	$this->db->where('afid',$aid); 
	$data['hms_pathology']=$this->db->get('hms_pathology'); 
			 
	$this->db->where('afid',$aid); 
	$data['total']=$this->db->count_all_results('hms_pathology'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_pathology',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
	} 
	 
	 
	 
	 
	public function add_hosptal() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->db->where('afid',$aid); 
//	$data['department']=$this->db->get('hms_department');	 
	$this->db->where('afid',$aid); 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$data['hms_zone_master']=$this->db->get('hms_zone_master');		 
	$this->load->view('hms/add_hosptal',$data); 
	} 
	 
	 
	 
	public function save_hospital() 
	{ 
	$this->load->library('session'); 
	$this->load->helper('url'); 
	$aid=$this->get_affiliate(); 
	$data_count=$this->db->count_all_results('hms_hospital'); 
	if($data_count>400) 
	{ 
	echo 'Only Four Centers Allow'; 
	} 
	else 
	{	 
	$this->pathology_name=$this->input->post('pos_name'); 
	$this->email=$this->input->post('email'); 
	$this->address=$this->input->post('address'); 
	$this->phone=$this->input->post('phone'); 
	$this->per=$this->input->post('perst');	 
	$this->per_rt=$this->input->post('perrt');	 
	$this->digper=$this->input->post('digperst'); 
	$this->dig_rt=$this->input->post('digperrt');	 
	$this->pathlogy_id=$this->input->post('pathlogy'); 
	$this->zone_id=$this->input->post('zone_id'); 
						 
	$this->afid=$aid; 
	$this->db->insert('hms_hospital',$this);	 
	echo 'Record Added'; 
	} 
	} 
	 
	 
	public function view_hospital() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->load->database(); 
	$this->db->where('afid',$aid); 
	$data_count=$this->db->count_all_results('hms_hospital'); 
	if($data_count>0) 
	{		 
	$limit=15; 
	$start=$this->uri->segment(3); 
	$start1=$start*$limit; 
	 
	$this->db->where('afid',$aid); 
	$data['hms_hospital']=$this->db->get('hms_hospital'); 
	 
	$data['hms_zone_master']=$this->db->get('hms_zone_master'); 
			 
	$this->db->where('afid',$aid); 
	$data['total']=$this->db->count_all_results('hms_hospital'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_hospital',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
	} 
	 
	 
public function hospital_record() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$docid=$this->uri->segment(3);	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$docid); 
	$data_count=$this->db->count_all_results('hms_hospital'); 
	if($data_count>0) 
	{	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$docid);	 
	$this->db->order_by('id','asc'); 
	$data['hms_hospital']=$this->db->get('hms_hospital'); 
	$data['hms_zone_master']=$this->db->get('hms_zone_master'); 
	$this->load->view('hms/view_hospital_record',$data);	 
	} 
	else 
	{ 
	echo 'Record Not fond'; 
	} 
}	 
	 
	 
	public function delete_hospital() 
	{ 
 	$this->load->library('session'); 
         $this->load->helper('url'); 
 	$aid=$this->get_affiliate(); 
 	$id=$this->uri->segment(3); 
 	$this->db->where('id',$id); 
 	$this->db->where('afid',$aid); 
 	$this->db->delete('hms_hospital'); 
 	echo 'Record Deleted'; 
	} 
	 
  public function edit_hospital() 
  { 
  	$this->load->library('session'); 
        $this->load->helper('url'); 
   	$aid=$this->get_affiliate(); 
   	$id=$this->uri->segment(3);  
	$this->db->where('id',$id); 
 	$this->db->where('afid',$aid); 
 	$data['hms_hospital']=$this->db->get('hms_hospital'); 
	  
 
	$this->db->where('afid',$aid); 
	$data['hms_pathology']=$this->db->get('hms_pathology'); 
	 
	$data['hms_zone_master']=$this->db->get('hms_zone_master'); 
		  
	$this->load->view('hms/edit_hospital',$data);  	 	    
   
  } 
	public function update_hospital() 
	{ 
	$this->load->library('session'); 
	$this->load->helper('url'); 
	$aid=$this->get_affiliate(); 
	$row_id=$this->input->post('row_id');	 
	$this->pathology_name=$this->input->post('pos_name'); 
	$this->email=$this->input->post('email'); 
	$this->address=$this->input->post('address'); 
	$this->phone=$this->input->post('phone'); 
	$this->per=$this->input->post('perst');	 
	$this->per_rt=$this->input->post('perrt');	 
	$this->digper=$this->input->post('digperst'); 
	$this->dig_rt=$this->input->post('digperrt');	 
	$this->pathlogy_id=$this->input->post('pathlogy'); 
	$this->zone_id=$this->input->post('zone_id');				 
	$this->db->where('id',$row_id); 
	$this->db->update('hms_hospital',$this);	 
	echo 'Record Updated'; 
	} 			 	 
	 
 
 
public function increment($value,$flg) 
	{  
	if($flg==0) 
	{ 
	$len=strlen($value); 
	$original=substr($value,3,$len); 
	$original=$original+1; 
	$len=strlen($original); 
	if($len==1) 
	$original='0'.$original; 
	$original='com'.$original; 
	return $original; 
	} 
	else if($flg==3) 
	{ 
	$len=strlen($value); 
	$original=substr($value,4,$len); 
	$original=$original+1; 
	$len=strlen($original); 
	if($len==1) 
	$original='0'.$original; 
	$original='Aids'.$original; 
	return $original; 
	} 
	else 
	{	 
	$value=$value+1; 
	$len=strlen($value); 
	if($len==1) 
	$value=$value; 
         
        return $value; 
	} 
	} 
 
 
//--------------------------------------------------------------- 
 
 
  
	 
 
	public function delete_opd_patient() 
	{ 
 	$this->load->library('session'); 
         $this->load->helper('url'); 
 	$aid=$this->get_affiliate(); 
 	$id=$this->uri->segment(3); 
 	$this->db->where('id',$id); 
        $this->db->where('amount','0'); 
	 $this->db->where('amount_diagnose','0'); 
	$this->db->where('print_status','0');	 
 	$this->db->delete('hms_opd_patient'); 
	 	  
 	echo 'Record Deleted'; 
	} 
	 
 
	public function delete_opd_patient_lab_inside() 
	{ 
 	$this->load->library('session'); 
         $this->load->helper('url'); 
 	$aid=$this->get_affiliate(); 
 	$id=$this->uri->segment(3); 
 	$this->db->where('id',$id); 
        $this->db->where('statusid','0');	 
 	$this->db->delete('hms_opd_patient'); 
 	echo 'Record Deleted'; 
	}	 
	 
	 
public function edit_opd_patient() 
{ 
	$this->load->library('session'); 
         $this->load->helper('url'); 
 	$aid=$this->get_affiliate(); 
 	$id=$this->uri->segment(3); 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$id);	   
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
 
	$this->db->where('afid',$aid); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	 
	$this->db->where('afid',$aid); 
	$data['hms_nurse']=$this->db->get('hms_nurse'); 
	 
	$this->db->where('afid',$aid); 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$this->db->where('afid',$aid); 
	$data['hms_hospital']=$this->db->get('hms_hospital');		 
	 
	$this->db->where('emp_aff_id',$aid); 
	$data['emp_info_data']=$this->db->get('emp_info');	 
		 
	$this->load->view('hms/edit_opd_patient',$data);	 
		 
} 
 
	public function update_opd_patient() 
	{ 
	$this->load->library('session'); 
	$this->load->helper('url'); 
	$aid=$this->get_affiliate(); 
	$row_id=$this->input->post('row_id');	 
	$this->grno=$this->input->post('tcno'); 
	$this->patient_name=$this->input->post('patient_name');	 
	$this->gender=$this->input->post('gender'); 
	$this->age=$this->input->post('age');	 
	$this->phone=$this->input->post('phone'); 
	$this->doctor_id=$this->input->post('doctor');	 
	$this->collection_code=$this->input->post('collectby'); 
	 
	$this->titlename=$this->input->post('titlename'); 
	$this->yearname=$this->input->post('yearname');	 
$this->statusid=$this->input->post('statusid');	 
	$this->entry_date=$this->input->post('date'); 
	$this->clboy=$this->input->post('clboy'); 
	$this->remarks=$this->input->post('remark'); 
	$this->hospitalid=$this->input->post('hospitalid');		 
	$this->pathlogy_sign=$this->input->post('pathology_doctor');	 
//	date_default_timezone_set('Asia/Calcutta'); 
//	$this->entry_date_time=date("h:i a");				 
	$this->db->where('id',$row_id); 
	$this->db->update('hms_opd_patient',$this);	 
	echo 'Record Updated'; 
	} 
	 
	 
	public function delete_pathelogy() 
	{ 
 	$this->load->library('session'); 
         $this->load->helper('url'); 
 	$aid=$this->get_affiliate(); 
 	$id=$this->uri->segment(3); 
 	$this->db->where('id',$id); 
 	$this->db->where('afid',$aid); 
 	$this->db->delete('hms_pathology'); 
 	echo 'Record Deleted'; 
	} 
	 
  public function edit_pathelogy() 
  { 
  	$this->load->library('session'); 
        $this->load->helper('url'); 
   	$aid=$this->get_affiliate(); 
   	$id=$this->uri->segment(3);  
	$this->db->where('id',$id); 
 	$this->db->where('afid',$aid); 
 	$data['hms_pathology']=$this->db->get('hms_pathology'); 
	$this->load->view('hms/edit_pathology',$data);  	 	    
   
  } 
	public function update_pathology() 
	{ 
	$this->load->library('session'); 
	$this->load->helper('url'); 
	$aid=$this->get_affiliate(); 
	$row_id=$this->input->post('row_id');	 
	$this->pathology_name=$this->input->post('pos_name'); 
	$this->email=$this->input->post('email'); 
	$this->address=$this->input->post('address'); 
	$this->phone=$this->input->post('phone'); 
 
 
	$this->firdoct=$this->input->post('firdoct'); 
	$this->fiedgree=$this->input->post('fiedgree'); 
	$this->secdoct=$this->input->post('secdoct'); 
	$this->secdgree=$this->input->post('secdgree');	 
	 
			 
	$this->db->where('id',$row_id); 
	$this->db->update('hms_pathology',$this);	 
	echo 'Record Updated'; 
	}   
	      
	 
 
 
 
 
public function count_indate_out_date() 
{ 
   	$this->load->helper('url'); 
      	$this->load->library('session'); 
      	$aid=$this->get_affiliate();   
  	$entry_date=$this->uri->segment(3);  
	$today=$this->uri->segment(4); 	  	 
  	$startTimeStamp = strtotime($entry_date); 
  	$endTimeStamp = strtotime($today); 
  	$timeDiff = abs($endTimeStamp - $startTimeStamp); 
  	$numberDays = $timeDiff/86400+1;  // 86400 seconds in one day 
  // and you might want to convert to integer 
  	$data['numberDays'] = intval($numberDays); 
	$this->load->view('hms/find_count_date',$data);	   
} 
 
 
 
public function view_opd_day_report() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
 
	 
	$this->db->where('afid',$aid); 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$limit=30; 
	$start=$this->uri->segment(3); 
	$start1=$start*$limit; 
 
	$this->db->where('afid',$aid); 
	$this->db->order_by('entry_date','desc'); 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient',$limit,$start1); 
	 
	$this->db->where('afid',$aid); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
				 
	$this->db->where('afid',$aid); 
	$data['total']=$this->db->count_all_results('hms_opd_patient'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_opd_patient_day_report',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
}	       
 
 
	public function print_report_opd_patient_date() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4);		 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate);		 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$limit=1150; 
	$start=$this->uri->segment(5); 
	$start1=$start*$limit; 
$data['today']=$fdate; 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->order_by('entry_date','desc');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
 
	$this->db->where('afid',$aid); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		 
				 
	$this->db->where('afid',$aid); 
	$data['total']=$this->db->count_all_results('hms_opd_patient'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/print_report_opd_patient_date_wise',$data);	 
//	$this->load->view('hms/view_second_opd_patient_date_wise',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
	}	 
	 
 
 
 
public function view_lab_day_report() 
{ 
	$this->load->library('session'); 
        $this->load->helper('url'); 
       	$afid=$this->get_affiliate();				 
   //    	$this->load->view('hms/view_patient_assign_test_new'); 
       	$this->load->view('hms/view_lab_test_day_report');	       	 
}  
 
public function search_lab_test_day_report_date() 
{ 
       		$this->load->library('session'); 
               	$this->load->helper('url'); 
       		$afid=$this->get_affiliate(); 
		$fdate=$this->uri->segment(3); 
	     $tdate=$this->uri->segment(4);		              
       	$this->db->where('afid',$afid);	 
	$this->db->where('enter_date >=',$fdate);	 
	$this->db->where('enter_date <=',$tdate);	        
       	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
       	if($data_count>0) 
       	{    	 		 
       	$this->db->where('afid',$afid);	 
       	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
       	 
       //	$this->db->where('test_parient !=',0); 
       	$data['test_name']=$this->db->get('ho_m_test_master');	 
      	  
      	$this->db->where('afid',$afid); 
	$this->db->where('enter_date >=',$fdate);	 
	$this->db->where('enter_date <=',$tdate);	       
	$this->db->group_by('patient_id'); 
	$this->db->group_by('enter_date');	       
       	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test'); 
	       	  
       $data['today']=$fdate;	 
       $data['tday']=$tdate;	 
       $data['afid']=$afid; 
       	$this->db->where('afid',$afid);	        
       	$data['hms_pathology']=$this->db->get('hms_pathology');	 
      	  
	$this->db->where('affiliate_id',$afid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	 
  
        	$this->db->where('afid',$afid);	 
        	$data['hms_ipd_patient']=$this->db->get('hms_ipd_patient'); 
	        
      	$this->db->where('afid',$afid); 
      	$this->db->where('enter_date >=',$fdate);	 
      	$this->db->where('enter_date <=',$tdate);	       
      	$this->db->group_by('patient_id');     
      	$this->db->group_by('enter_date');     
             	$data['hms_ipd_patient_assign_test']=$this->db->get('hms_ipd_patient_assign_test');      
	        
       				 
       	$this->load->view('hms/print_lab_test_report_day',$data);	 
               } 
       	else 
       	{ 
       	echo 'Record not found'; 
       	} 
}	        
 
   
 
 
	public function show_test_parient_list() 
		{ 
      		$this->load->library('session'); 
               	$this->load->helper('url'); 
       		$afid=$this->get_affiliate(); 
		$test_parient=$this->uri->segment(3); 
	        $this->db->where('test_parient',$test_parient); 
		$this->db->order_by('id','asc'); 
	        $data['sub_test_name_parient']=$this->db->get('ho_m_test_master'); 
		 
	   $this->db->where('id',$test_parient); 
	   $data['sub_test_name_parient_root']=$this->db->get('ho_m_test_master');	 
	foreach($data['sub_test_name_parient_root']->result() as $row_p) 
	{ 
	break; 
	} 
	$data['root_name']=$row_p->root_id;		 
		 
      	        $this->load->view('hms/sub_parient_test_list',$data);	 
		}	        
 
 
 
	public function show_test_parient_list_diagnois() 
		{ 
      		$this->load->library('session'); 
               	$this->load->helper('url'); 
       		$afid=$this->get_affiliate(); 
		$test_parient=$this->uri->segment(3); 
	        $this->db->where('dig_parient',$test_parient); 
		$this->db->order_by('id','asc'); 
	        $data['sub_test_name_parient']=$this->db->get('hms_dignos_master'); 
		 
	   $this->db->where('id',$test_parient); 
	   $data['sub_test_name_parient_root']=$this->db->get('hms_dignos_master');	 
//	foreach($data['sub_test_name_parient_root']->result() as $row_p) 
//	{ 
//	break; 
//	} 
//	$data['root_name']=$row_p->root_id;		 
		 
      	        $this->load->view('hms/sub_parient_test_list_diagnos',$data);	 
		}	 
 
  
 
 
	public function print_opd_patient_test_report_sleep() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	$day=$this->uri->segment(4);	 
	$data['today']=$day;	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid);	 
	$this->db->where('enter_date',$day); 
	$this->db->group_by('test_parient'); 
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	 
	foreach($data['hms_opd_patient']->result() as $row_p) 
	{ 
	break; 
	} 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('doctor_id',$row_p->doctor_id); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_d) 
	{ 
	break; 
	}		 
	$data['doctor_name']=$row_d->name; 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('enter_date',$day); 
	$this->db->group_by('patient_id');	 
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test'); 
	foreach($data['hms_opd_assign_test_pat']->result() as $row) 
	{ 
	break; 
	} 
	$data['test_date']=$row->enter_date;			 
	 
	$this->db->where('id',$row->pathology_center); 
	$this->db->where('afid',$aid);	 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	//$this->db->where('test_parient !=',0); 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
	 
 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	 
	 
				 
	$this->load->view('hms/print_opd_test_report_sleep',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
	} 
 
 
	 
	 
	 
	public function delete_opd_test() 
	{ 
 	$this->load->library('session'); 
         $this->load->helper('url'); 
 	$aid=$this->get_affiliate(); 
 	$id=$this->uri->segment(3); 
	$pid=$this->uri->segment(4); 
	 
 	$this->db->where('test_parient',$id); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('print_status','0');				 
	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
	if($data_count>0) 
	{		  
 	$this->db->where('test_parient',$id); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('print_status','0');	  
 	$this->db->where('afid',$aid); 
 	$this->db->delete('hms_patient_assign_test'); 
 	echo 'Record Deleted'; 
	} 
	else 
	{ 
	 
	}	 
	} 
	 
	 
 
   
	public function assign_ipd_patient_particular2() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data_count=$this->db->count_all_results('hms_ipd_patient'); 
	if($data_count>0) 
	{ 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid);	 
	$data_count_val=$this->db->count_all_results('hms_ipd_patient_assign_particulars'); 
	if($data_count_val>0) 
	{ 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_ipd_patient'); 
	foreach($data['hms_opd_patient']->result () as $row_ipd) 
	{ 
	break; 
	} 
	$data['entry_date']= $row_ipd->entry_date; 
	 
	 
      	$this->db->where('afid',$aid);     
      	$this->db->where('bed_id',$row_ipd->bed_no); 	        	       	 
      	$data['hms_bed']=$this->db->get('hms_bed'); 
	       
	foreach($data['hms_bed']->result () as $row_bed) 
	{ 
	break; 
	} 
	$data['bed_number']= $row_bed->bed_number; 
	//$data['bed_rate']= $row_bed->rate;	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('dep_id',$row_ipd->sub_dep_id);	 
	$data['hms_department']=$this->db->get('hms_department'); 
	foreach($data['hms_department']->result () as $row_ward) 
	{ 
	break; 
	} 
	$data['ward']= $row_ward->name;		 
 
	 
	$this->db->where('afid',$aid); 
	$data['test_name']=$this->db->get('hms_particular');	 
	 
	$this->db->where('test_parient',0); 
	$data['test_name']=$this->db->get('hms_particular');	 
 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid);	 
	$data['hms_ipd_particulars']=$this->db->get('hms_ipd_patient_assign_particulars'); 
	 
//-----------today 1-6-15------ 
 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_ipd_patient']=$this->db->get('hms_ipd_patient');	 
	$this->db->where('afid',$aid); 
	$data['test_name2']=$this->db->get('hms_particular'); 
 
    	$this->db->where('afid',$aid); 
    	$this->db->where('patient_id',$pid); 
	$this->db->group_by('test_id');     
     	$data['hms_patient_assign_test']=$this->db->get('hms_ipd_patient_assign_particulars');		 
	 
	$this->load->view('hms/assign_ipd_patient_particular_mmmm_update_aviral',$data);	 
		 
//	$this->load->view('hms/assign_ipd_patient_particular_mmmm_update',$data);	 
	} 
	else 
	{ 
				 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_ipd_patient'); 
	foreach($data['hms_opd_patient']->result () as $row_ipd) 
	{ 
	break; 
	} 
	$data['entry_date']= $row_ipd->entry_date; 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('dep_id',$row_ipd->sub_dep_id);	 
	$data['hms_department']=$this->db->get('hms_department'); 
	foreach($data['hms_department']->result () as $row_ward) 
	{ 
	break; 
	} 
	$data['ward']= $row_ward->name;			 
 
	 
	$this->db->where('afid',$aid); 
	$data['test_name']=$this->db->get('hms_particular'); 
	 
	$this->db->where('test_parient',0); 
	$data['test_name']=$this->db->get('hms_particular');	 
	 
 
 
//-----------today 1-6-15------ 
 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_ipd_patient']=$this->db->get('hms_ipd_patient');	 
	$this->db->where('afid',$aid); 
	$data['test_name2']=$this->db->get('hms_particular'); 
 
    	$this->db->where('afid',$aid); 
    	$this->db->where('patient_id',$pid); 
	$this->db->group_by('test_id');     
     	$data['hms_patient_assign_test']=$this->db->get('hms_ipd_patient_assign_particulars');	 
	      
$this->load->view('hms/assign_ipd_patient_particular_aviral',$data);	     		 
				 
//	$this->load->view('hms/assign_ipd_patient_particular',$data); 
	}	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
	} 
	 
	public function show_particular_parient_list() 
		{ 
      		$this->load->library('session'); 
               	$this->load->helper('url'); 
       		$afid=$this->get_affiliate(); 
		$test_parient=$this->uri->segment(3); 
	$this->db->where('test_parient',$test_parient); 
	$data['sub_test_name_parient']=$this->db->get('hms_particular'); 
       	$this->load->view('hms/sub_parient_particular_list',$data);		 
} 
 
 
	public function show_particular_parient_list_update() 
		{ 
      		$this->load->library('session'); 
               	$this->load->helper('url'); 
       		$afid=$this->get_affiliate(); 
		$test_parient=$this->uri->segment(3); 
		$pid=$this->uri->segment(4); 
	$this->db->where('afid',$afid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('test_parient',$test_parient);		 
	$data_count_val=$this->db->count_all_results('hms_ipd_patient_assign_particulars'); 
	if($data_count_val>0) 
	{		 
	$this->db->where('test_parient',$test_parient); 
	$data['sub_test_name_parient']=$this->db->get('hms_particular'); 
	 
	$this->db->where('afid',$afid); 
	$this->db->where('patient_id',$pid);	 
	$data['hms_ipd_particulars']=$this->db->get('hms_ipd_patient_assign_particulars');	 
       	$this->load->view('hms/sub_parient_particular_list_update',$data); 
	 } 
      else 
      { 
	$this->db->where('test_parient',$test_parient); 
	$data['sub_test_name_parient']=$this->db->get('hms_particular'); 
       	$this->load->view('hms/sub_parient_particular_list',$data);       
       
      }	       		 
} 
 
		 
 
    
    
    
    
    
	public function print_opd_patient_test_report_sleep_day() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	$today=$this->uri->segment(4); 
	 
	$data['today']=$today; 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
//	$this->db->where('enter_date',$today);	 
	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
//	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('date_test',$today);		 
//	$this->db->group_by('test_parient'); 
	$data['hms_opd_test_rate']=$this->db->get('hms_opd_test_rate');		 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('enter_date',$today);		 
	$this->db->group_by('test_parient'); 
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	 
	foreach($data['hms_opd_patient']->result() as $row_p) 
	{ 
	break; 
	} 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('doctor_id',$row_p->doctor_id); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_d) 
	{ 
	break; 
	}		 
	$data['doctor_name']=$row_d->name; 
	 
	 
 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('enter_date',$today);	 
	$this->db->group_by('patient_id');	 
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test'); 
	foreach($data['hms_opd_assign_test_pat']->result() as $row) 
	{ 
	break; 
	} 
	$data['test_date']=$row->enter_date;			 
	 
	 
	 
	 
	//$this->db->where('test_parient !=',0); 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
	 
 
	 
//	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	 
	 
				 
	$this->load->view('hms/print_opd_test_report_sleep',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
	}   
	 
	 
	 
	 
	 
	 
 public function upload_img() 
    { 
   	$this->load->library('session'); 
	$this->load->helper('url'); 
	$data['aid']=$this->get_affiliate(); 
	$data['eid']=$this->uri->segment(3); 
	$this->load->view('hms/view_imguploader',$data); 
    } 
     
     
	public function view_center_report() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
 
	$this->db->where('afid',$aid); 
	$data['hms_pathology']=$this->db->get('hms_pathology'); 
	 
	$this->load->view('hms/view_center_report',$data);	 
	}  
	 
	 
	public function print_report_date_center() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4); 
	$centerid=$this->uri->segment(5);	 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$centerid);	 
	$data['hms_pathology']=$this->db->get('hms_pathology'); 
	foreach($data['hms_pathology']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['emp_name']=$row_name->pathology_name;	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('collection_code',$centerid);			 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('collection_code',$centerid); 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		 
				 
	$this->load->view('hms/print_report_center_wise',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	} 
	}	 
	 
	 
	public function view_day_report() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
 
        $this->db->where('afid',$aid); 
	$this->db->order_by('name','asc'); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	 
	$this->db->where('afid',$aid); 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	 
	$data['hms_zone_master']=$this->db->get('hms_zone_master');			 
	 
	$this->load->view('hms/view_doctor_report',$data);	 
	}     
	 
	 
	public function print_report_date_emp() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4); 
	$empid=$this->uri->segment(5);	 
	$data['disper']=$this->uri->segment(6);	 
	$data['disperrt']=$this->uri->segment(7);	 
	$pathlogy=$this->uri->segment(8);					 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('doctor_id',$empid);	 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['emp_name']=$row_name->name;	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pathlogy);	 
	$data['center']=$this->db->get('hms_pathology'); 
	foreach($data['center']->result() as $row_center) 
		{ 
		break; 
		} 
	$data['center_name']=$row_center->pathology_name;	 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('doctor_id',$empid);	 
	$this->db->where('collection_code',$pathlogy); 
	$this->db->where('tot_amount !=','0');				 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('doctor_id',$empid); 
	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount !=','0');		 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		 
				 
	$this->load->view('hms/print_report_date_wise',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	} 
	} 
	 
	 
	public function print_report_date_emp_first() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4); 
	$empid=$this->uri->segment(5);	 
	$pathlogy=$this->uri->segment(6);				 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('doctor_id',$empid);	 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['emp_name']=$row_name->name;	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pathlogy);	 
	$data['center']=$this->db->get('hms_pathology'); 
	foreach($data['center']->result() as $row_center) 
		{ 
		break; 
		} 
	$data['center_name']=$row_center->pathology_name;	 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('doctor_id',$empid); 
	$this->db->where('collection_code',$pathlogy);				 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('doctor_id',$empid); 
	$this->db->where('collection_code',$pathlogy);	 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		 
				 
	$this->load->view('hms/print_report_date_wise_first',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	} 
	}			 
	 
	 
	public function print_report_date_emp_first_diagnos() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4); 
	$empid=$this->uri->segment(5);	 
	$pathlogy=$this->uri->segment(6);				 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('doctor_id',$empid);	 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['emp_name']=$row_name->name;	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pathlogy);	 
	$data['center']=$this->db->get('hms_pathology'); 
	foreach($data['center']->result() as $row_center) 
		{ 
		break; 
		} 
	$data['center_name']=$row_center->pathology_name;	 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('doctor_id',$empid); 
	$this->db->where('collection_code',$pathlogy);				 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('doctor_id',$empid); 
	$this->db->where('collection_code',$pathlogy);	 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		 
				 
	$this->load->view('hms/print_report_date_wise_first_diagno',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	} 
	} 
	 
	public function print_report_date_emp_diagnos_all() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4); 
	$empid=$this->uri->segment(5);	 
	$data['disper']=$this->uri->segment(6);	 
	$data['disperrt']=$this->uri->segment(7);	 
	$pathlogy=$this->uri->segment(8);					 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('doctor_id',$empid);	 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['emp_name']=$row_name->name;	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pathlogy);	 
	$data['center']=$this->db->get('hms_pathology'); 
	foreach($data['center']->result() as $row_center) 
		{ 
		break; 
		} 
	$data['center_name']=$row_center->pathology_name;	 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('doctor_id',$empid);	 
	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount_diagnose !=','0');			 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('doctor_id',$empid); 
	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount_diagnose !=','0');	 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		 
				 
	$this->load->view('hms/print_report_date_wise_diagnos',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	} 
	}	 
	 
	 
public function student_mark_entry2() 
{ 
		$this->load->library('session'); 
        	$this->load->helper('url'); 
		$afid=$this->get_affiliate(); 
		$empid=$this->get_af_emp_id();	 
		$ques=$this->input->post('su_id'); 
		$qui=explode(',',$ques); 
	        $value_qui=$this->input->post('mark_val'); 
		$val_qui=explode('^',$value_qui); 
		 
		$t=1; 
		for($t1=1;Count($qui)>$t1;$t1++) 
		{			 
		$this->load->database(); 
		$this->test_id=$qui[$t];  
  		$this->patient_id=$this->input->post('patient_name'); 
  		$this->enter_date=$this->input->post('e_date'); 
		$this->test_parient=$this->input->post('test_parient');		   
  		$this->afid=$afid; 
		$this->emp_id=$empid;   
  		$this->db->set('status','1'); 
		$this->test_val=$val_qui[$t]; 			 
		$this->db->insert('hms_patient_assign_test',$this); 
		$t++; 
		//echo Count($qui); 
		} 
		 
					 
	echo 'Patient Assigned Test';   
}	 
 
 
	public function update_test_val_opd_second() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	$p_date=$this->uri->segment(4); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
//	$this->db->where('enter_date',$p_date);	 
	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid);	 
	$this->db->order_by('id','asc'); 
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->group_by('patient_id');	 
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test'); 
	foreach($data['hms_opd_assign_test_pat']->result() as $row) 
	{ 
	break; 
	} 
	$data['test_date']=$row->enter_date;			 
	 
	$this->db->where('afid',$aid);	 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	//$this->db->where('test_parient !=',0); 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
				 
	$this->load->view('hms/update_patient_test_value_second',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
} 
		  
//--------------------------------------------------------------------------------------------------		  
public function update_patient_test_amount() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	$paid_amt=$this->uri->segment(4); 
	$tot_bill=$this->uri->segment(5); 
	$dis_per=$this->uri->segment(6); 
	$dis_amt=$this->uri->segment(7); 
	if($dis_amt =='' || $dis_amt=='0') 
	{	 
	$this->amount=$paid_amt; 
	$this->tot_amount=$tot_bill; 
	$this->discount_per='0'; 
	$this->discount='0';		 
	$this->db->where('id',$pid); 
	$this->db->update('hms_opd_patient',$this);	 
        } 
	else 
	{ 
	$this->amount=$paid_amt; 
	$this->tot_amount=$tot_bill;	 
	$this->discount_per=$dis_per; 
	$this->discount=$dis_amt;		 
	$this->db->where('id',$pid); 
	$this->db->update('hms_opd_patient',$this);	 
	}	 
     } 
 
 
     
public function update_patient_test_amount_balance_admin() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	$balance_paid_amt=$this->uri->segment(4); 
	$paid_amt=$this->uri->segment(5); 
	$discount=$this->uri->segment(6); 
	 
	$this->amount=$balance_paid_amt+$paid_amt; 
	$this->discount=$discount;	 
	 
	$this->db->where('id',$pid); 
	$this->db->update('hms_opd_patient',$this); 
//	echo 'Record Updated'; 
 
	 
} 
 
 
public function update_diagnose_balance() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	$balance_paid_amt=$this->uri->segment(4); 
	$paid_amt=$this->uri->segment(5); 
	$discount=$this->uri->segment(6); 
	$disper=$this->uri->segment(7); 
	 
	$this->amount_diagnose=$balance_paid_amt+$paid_amt; 
	$this->discount_diagnos=$discount; 
        $this->discount_per_diagnos= round($disper,1);		 
	 
	$this->db->where('id',$pid); 
	$this->db->update('hms_opd_patient',$this); 
//	echo 'Record Updated';	 
	 
}      
 
public function update_patient_test_amount_balance() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	$balance_paid_amt=$this->uri->segment(4); 
	$paid_amt=$this->uri->segment(5); 
//	$discount=$this->uri->segment(6); 
	 
	$this->amount=$balance_paid_amt+$paid_amt; 
	$this->db->where('id',$pid); 
	$this->db->update('hms_opd_patient',$this); 
//	echo 'Record Updated';	 
	 
} 
 
 
 
public function update_patient_test_amount_diagnouse() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	$paid_amt=$this->uri->segment(4); 
	$tot_bill=$this->uri->segment(5); 
	$dis_per=$this->uri->segment(6); 
	$dis_amt=$this->uri->segment(7); 
	if($dis_amt =='' || $dis_amt=='0') 
	{	 
	$this->amount_diagnose=$paid_amt; 
	$this->tot_amount_diagnose=$tot_bill; 
	$this->discount_per_diagnos='0'; 
	$this->discount_diagnos='0';		 
	$this->db->where('id',$pid); 
	$this->db->update('hms_opd_patient',$this);	 
        } 
	else 
	{ 
	$this->amount_diagnose=$paid_amt; 
	$this->tot_amount_diagnose=$tot_bill;	 
	$this->discount_per_diagnos=$dis_per; 
	$this->discount_diagnos=$dis_amt;		 
	$this->db->where('id',$pid); 
	$this->db->update('hms_opd_patient',$this);	 
	}	 
     } 
 
 
  public function admin_emp_registationform() 
     { 
       $this->load->library('session'); 
       $this->load->helper('url'); 
       $aid=$this->get_affiliate(); 
      // $this->db->where('affilate_id',$aid);      
       $data['dep']=$this->db->get('manage_department');  
       $this->db->where('emp_aff_id',$aid); 
       $this->db->order_by('emp_id','desc'); 
       $data['lastan']=$this->db->count_all_results('emp_info'); 
       if($data['lastan']==0) 
        { 
	 
        $data['lastan']="1001"; 
        } 
        else 
        { 
$this->db->select_max('emp_enroll'); 
	$this->db->where('emp_aff_id',$aid);	 
//	$this->db->where('entry_date',$date);	 
	$data['emp_info ']=$this->db->get('emp_info '); 
	foreach($data['emp_info ']->result() as $row) 
		{ 
	//	break; 
		} 
		 
	$new_lot_id=$row->emp_enroll; 
	$ac_auto_no=$new_lot_id+1;		 
	$data['lastan']=$row->emp_enroll+1; 
      //  $data['lastan']=$this->increment($data['lastan'],1); 
        } 
	 
	$this->db->where('afid',$aid);	 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
		 
      		 
       $this->load->view('hms/admin_employee_register',$data);    
       } 
        
        
 
public function save_admin_emp() 
{ 
$this->load->library('session'); 
$this->load->helper('url'); 
//$this->emp_mac_id=$this->input->post('smachine'); 
$this->emp_enroll=$this->input->post('rolno'); 
//$this->emp_depart=$this->input->post('organitation'); 
//$this->emp_role=$this->input->post('degination'); 
$this->title=$this->input->post('title1'); 
 
$this->emp_fname=$this->input->post('fname'); 
$this->emp_mname=$this->input->post('mname'); 
$this->emp_lname=$this->input->post('lname'); 
$this->emp_dob=$this->input->post('dob'); 
$this->emp_contact=$this->input->post('contactno'); 
$this->emp_address=$this->input->post('fulladdress'); 
$this->join_date=$this->input->post('d_join'); 
$this->pathlogy_id=$this->input->post('pathlogy'); 
//$this->db->set('empl_status','0'); 
$this->emp_aff_id=$this->get_affiliate(); 
$this->db->insert('emp_info',$this); 
echo 'Emp Record has been Saved'; 
}       		  
	 
	 
    public function admin_employee_search() 
    { 
       $this->load->library('session'); 
       $this->load->helper('url'); 
       $aid=$this->get_affiliate(); 
      // $this->db->where('afid',$aid);	 
   //    $data['orgname']=$this->db->get('manage_department'); 
     //   $this->db->where('afid',$aid); 
  //     $data['managerole']=$this->db->get('manage_role'); 
     
       $this->db->where('emp_aff_id',$aid); 
      // $this->db->where('emp_is_employ','1'); 
  
       $data['empinfo']=$this->db->get('emp_info'); 
        
    
       		 
       $this->load->view('hms/admin_employee_search',$data); 
    }	 
     
     
     
public function search_admin_emprecord() 
{ 
$this->load->library('session'); 
$this->load->helper('url'); 
 
$aid=$this->get_affiliate(); 
$this->db->where('emp_aff_id',$aid); 
$fname=$this->uri->segment(3); 
if ($fname!='') 
{ 
$this->db->where('emp_fname',$fname); 
}			 
$data['empinfo']=$this->db->get('emp_info'); 
$this->load->view('hms/admin_employee_search',$data); 
} 
 
public function search_admin_emprollno() 
{ 
$this->load->library('session'); 
$this->load->helper('url'); 
 
$aid=$this->get_affiliate(); 
$this->db->where('emp_aff_id',$aid); 
$emprollno=$this->uri->segment(3); 
 
 
if ($emprollno!='') 
{ 
$this->db->where('emp_enroll',$emprollno); 
} 
				 
$data['empinfo']=$this->db->get('emp_info'); 
$this->load->view('hms/admin_employee_search',$data); 
} 
     
 
public function edit_admin_emp_record() 
{ 
$this->load->library('session'); 
$this->load->helper('url');    
$emp_id=$this->uri->segment(3); 
$this->db->where('emp_id',$emp_id);	 
$data['empinfo']=$this->db->get('emp_info');	 
 
//	$this->db->where('afid',$aid);	 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
				 
 
$this->load->view('hms/edit_admin_employee_register',$data); 
} 
 
 
public function update_admin_emp() 
{ 
$this->load->library('session'); 
$this->load->helper('url'); 
$this->emp_enroll=$this->input->post('rolno'); 
$this->title=$this->input->post('title1'); 
$this->emp_fname=$this->input->post('fname'); 
$this->emp_mname=$this->input->post('mname'); 
$this->emp_lname=$this->input->post('lname'); 
$this->emp_dob=$this->input->post('dob'); 
$this->emp_contact=$this->input->post('contactno'); 
$this->emp_address=$this->input->post('fulladdress'); 
$this->join_date=$this->input->post('d_join'); 
$this->pathlogy_id=$this->input->post('pathlogy'); 
$this->emp_aff_id=$this->get_affiliate(); 
$id=$this->input->post('id'); 
$this->db->where('emp_id',$id); 
//$this->db->where('emp_is_employ','1'); 
$this->db->update('emp_info',$this); 
echo 'Emp Record has been Updated'; 
} 
 
 
 
public function delete_adminemp_record() 
{ 
$this->load->library('session'); 
$this->load->helper('url'); 
$this->db->set('empl_status','1'); 
 
$aid=$this->get_affiliate(); 
$this->db->where('emp_aff_id',$aid);     
$emp_id=$this->uri->segment(3); 
$this->db->where('emp_id',$emp_id); 
$this->db->delete('emp_info'); 
//$this->db->delete('emp_info');	 
$aid=$this->get_affiliate(); 
$this->db->where('emp_aff_id',$aid); 			 
$data['empinfo']=$this->db->get('emp_info'); 
 
$this->load->view('hms/admin_employee_search',$data); 
 
} 
 
 
	public function add_opd_patient_user() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->db->where('afid',$aid); 
	$this->db->order_by('name','asc'); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	 
	$this->db->where('afid',$aid); 
	$data['hms_nurse']=$this->db->get('hms_nurse'); 
	 
	$this->db->where('afid',$aid); 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$this->db->where('afid',$aid); 
	$data['hms_hospital']=$this->db->get('hms_hospital');	 
	 
	$this->db->where('emp_aff_id',$aid); 
	$data['emp_info_data']=$this->db->get('emp_info');	 
	 
		 
	$date=date('y-m-d'); 
//	$this->db->where('entry_date', $date); 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count<=1000000) 
	{ 
	 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count<=1000000) 
	{ 
	$this->db->select_max('token_no'); 
	$this->db->where('afid',$aid);	 
//	$this->db->where('entry_date',$date);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	foreach($data['hms_opd_patient']->result() as $row) 
		{ 
	//	break; 
		} 
		 
	$new_lot_id=$row->token_no; 
	$ac_auto_no=$new_lot_id+1;		 
	$data['toc_no']=$row->token_no+1; 
	 
	$chech_val=strlen($ac_auto_no);	 
	if($chech_val<=1) 
	{ 
	$data['regno']='ANG'.'869'.$ac_auto_no;		 
	} 
	else if($chech_val==2 || $chech_val >=2)	  
	{ 
	$data['regno']='ANG'.'869'.$ac_auto_no;	 
	} 
	 
			 
	} 
	else 
	{ 
	$data['toc_no']=1; 
 
	$data['regno']='ANG'.'869'.'1';  		 
	}		 
	$this->load->view('hms/add_opd_patient_user',$data); 
	} 
	else 
	{ 
	 
	}	 
	} 
	 
	 
	public function add_view_opd_patient_user() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$empid=$this->get_af_emp_id(); 
	 
	$this->db->where('afid',$aid); 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$limit=150; 
	$start=$this->uri->segment(3); 
	$start1=$start*$limit; 
 
	$this->db->where('afid',$aid); 
//	$this->db->where('opd_emp_id',$empid); 
	$this->db->order_by('id','desc'); 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient',$limit,$start1); 
	 
	$this->db->where('afid',$aid); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
				 
	$this->db->where('afid',$aid); 
//	$this->db->where('opd_emp_id',$empid);	 
	$data['total']=$this->db->count_all_results('hms_opd_patient'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_opd_patient_user',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
	 
	}	 
	 
	public function second_opd_patient_user() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$empid=$this->get_af_emp_id(); 
	 
	$this->db->where('afid',$aid); 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$limit=150; 
	$start=$this->uri->segment(3); 
	$start1=$start*$limit; 
 
	$this->db->where('afid',$aid); 
//	$this->db->where('opd_emp_id',$empid);	 
	$this->db->order_by('id','desc'); 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient',$limit,$start1); 
	 
	$this->db->where('afid',$aid); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
				 
	$this->db->where('afid',$aid); 
//	$this->db->where('opd_emp_id',$empid);		 
	$data['total']=$this->db->count_all_results('hms_opd_patient'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_opd_patient_user_second',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	} 
 
 
	}	 
	 
public function edit_opd_patient_user() 
{ 
	$this->load->library('session'); 
         $this->load->helper('url'); 
 	$aid=$this->get_affiliate(); 
 	$id=$this->uri->segment(3); 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$id);	   
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
 
	$this->db->where('afid',$aid); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	 
	$this->db->where('afid',$aid); 
	$data['hms_nurse']=$this->db->get('hms_nurse'); 
	 
	$this->db->where('afid',$aid); 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$this->db->where('afid',$aid); 
	$data['hms_hospital']=$this->db->get('hms_hospital');		 
	 
	$this->db->where('emp_aff_id',$aid); 
	$data['emp_info_data']=$this->db->get('emp_info');	 
		 
	$this->load->view('hms/edit_opd_patient_user',$data);	 
		 
}	 
 
 
 
	public function update_opd_patient_user() 
	{ 
	$this->load->library('session'); 
	$this->load->helper('url'); 
	$aid=$this->get_affiliate(); 
	$row_id=$this->input->post('row_id');	 
	$this->token_no=$this->input->post('tcno'); 
	$this->patient_name=$this->input->post('patient_name');	 
	$this->gender=$this->input->post('gender'); 
	$this->age=$this->input->post('age');	 
	$this->phone=$this->input->post('phone'); 
	$this->doctor_id=$this->input->post('doctor');	 
	$this->collection_code=$this->input->post('collectby'); 
	$this->pathlogy_sign=$this->input->post('pathology_doctor');	 
	$this->entry_date=$this->input->post('date'); 
	$this->titlename=$this->input->post('titlename'); 
	$this->yearname=$this->input->post('yearname');			 
	$this->db->where('id',$row_id); 
	$this->db->update('hms_opd_patient',$this);	 
	echo 'Record Updated'; 
	} 
	 
	 
	public function search_opd_patient_date_user() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$empid=$this->get_af_emp_id(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4);		 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('opd_emp_id',$empid);				 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$limit=150; 
	$start=$this->uri->segment(5); 
	$start1=$start*$limit; 
 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('opd_emp_id',$empid);		 
	$this->db->order_by('entry_date','desc');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
 
	$this->db->where('afid',$aid); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
				 
	$this->db->where('afid',$aid); 
	$this->db->where('opd_emp_id',$empid);	 
	$data['total']=$this->db->count_all_results('hms_opd_patient'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_second_opd_patient_date_wise_user',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
	} 
	 
	 
//-----------------johri---------- 
      public function lab_part_payment_diagnose() 
      { 
   	$this->load->helper('url'); 
      	$this->load->library('session'); 
      	$aid=$this->get_affiliate(); 
	$af_emp_id=$this->get_af_emp_id();	       
      	$pid=$this->uri->segment(3); 
      	$entry_date=$this->uri->segment(4);    
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$this->db->where('entry_date',$entry_date);		 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$this->db->where('entry_date',$entry_date);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');	 
	foreach($data['hms_opd_patient']->result() as $row) 
		{ 
    	break; 
		} 
	$data['tot_amt']=$row->tot_amount_diagnose; 
	$data['paid_amt']=$row->amount_diagnose;	 
	$data['discount']=$row->discount_diagnos;	 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid);	 
	$this->db->group_by('patient_id'); 
	$data['second_patient_assign_test']=$this->db->get('hms_patient_assign_test_diagnose');	 
 
	$data['test_name']=$this->db->get('hms_dignos_master');	 
 
	 
		$this->load->view('hms/lab_part_payment_form_admin_diagnose',$data);				       
         } 
	 else 
	 { 
	 echo 'Record not found'; 
	 } 
      } 
 
       
      public function lab_part_payment() 
      { 
   	$this->load->helper('url'); 
      	$this->load->library('session'); 
      	$aid=$this->get_affiliate(); 
	$af_emp_id=$this->get_af_emp_id();	       
      	$pid=$this->uri->segment(3); 
      	$entry_date=$this->uri->segment(4);    
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$this->db->where('entry_date',$entry_date);		 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$this->db->where('entry_date',$entry_date);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');	 
	foreach($data['hms_opd_patient']->result() as $row) 
		{ 
    	break; 
		} 
	$data['tot_amt']=$row->tot_amount; 
	$data['paid_amt']=$row->amount;	 
	$data['discount']=$row->discount;	 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid);	 
	$this->db->group_by('patient_id'); 
	$data['second_patient_assign_test']=$this->db->get('hms_patient_assign_test');	 
 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
if($af_emp_id =='200')	 
{ 
	$this->load->view('hms/lab_part_payment_form_admin',$data); 
	} 
	else 
	{ 
	$this->load->view('hms/lab_part_payment_form',$data);	 
	}				       
         } 
	 else 
	 { 
	 echo 'Record not found'; 
	 } 
      }       
       
       
public function manage_test_rate() 
{ 
 
$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	 
	$data_count=$this->db->count_all_results('ho_m_test_master'); 
	if($data_count>0) 
	{		 
		$this->db->where('afid',$aid); 
	//	$this->db->where('id',$pid);	 
		$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
		 
		$this->db->where('afid',$aid); 
	//	$this->db->where('patient_id',$pid);	 
		$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	 
		 
		$this->db->where('afid',$aid); 
	//	$this->db->where('patient_id',$pid); 
		$this->db->group_by('patient_id');	 
		$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test'); 
		foreach($data['hms_opd_assign_test_pat']->result() as $row) 
		{ 
		break; 
		} 
	//	$data['test_date']=$row->enter_date;			 
		 
		$this->db->where('afid',$aid);	 
		$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$this->db->where('test_parient',0); 
//	$this->db->order_by('test_title','asc'); 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
				 
	$this->load->view('hms/manage_doctor_commission',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
} 
 
 
          public function update_commission_marks() 
             { 
		$this->load->library('session'); 
        	$this->load->helper('url'); 
		$afid=$this->get_affiliate(); 
		$id=$this->input->post('checkid'); 
		$mark=$this->input->post('checkedoption2'); 
		$qui_id=explode(',',$id); 
		$qui=explode(',',$mark); 
	 
	       $t=0; 
		for($t1=0;Count($qui_id)>$t1;$t1++) 
		{ 
		$this->load->database(); 
		//$this->modify_emp_id=$this->input->post('eid');  
		$this->amount=$qui[$t];  
		$this->db->where('id',$qui_id[$t]); 
	       $this->db->update('ho_m_test_master',$this); 
	        
		$t++; 
 
		} 
		 
             } 
 
 
 
public function view_patient_test_list() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
//	$this->db->where('afid',$aid);	 
//	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$this->db->where('test_parient',0); 
	$this->db->order_by('test_title','asc'); 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
	 
	$this->db->order_by('test_title','asc');	 
       	$data['test_name2']=$this->db->get('ho_m_test_master');	 
      	  
	       $date_day=date('Y-m-d'); 
	        
	       $data['date_day']=$date_day; 
	        
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('test_panels','0');	 
	$this->db->group_by('test_parient');		 
	$this->db->order_by('id','asc');	 
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test');	 
	 
				 
	$this->load->view('hms/assign_patient_test_list',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
 
} 
 
 
 
	public function print_test_report_select() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
       $af_emp_id=$this->get_af_emp_id();	 
	$pid=$this->uri->segment(3); 
	$p_date=$this->uri->segment(4); 
	$ques=$this->uri->segment(5); 
	$b_date=$this->uri->segment(6);	 
$data['ques']=$ques; 
$data['pid']=$pid; 
$data['aid']=$aid; 
 
if($b_date =='') 
{ 
	date_default_timezone_set('Asia/Calcutta'); 
	$data['report_time']=date("h:i a");	 
	$data['today']=date('d-m-Y'); 
	} 
	else 
	{ 
	date_default_timezone_set('Asia/Calcutta'); 
	$data['report_time']=date("h:i a");	 
	$data['today']=$b_date;	 
	} 
 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
//	$this->db->where('enter_date',$p_date);		 
	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	 
 
	$this->db->where('e_affiliateid',$aid); 
	$this->db->where('emp_info_id',$af_emp_id); 
	$data['manage_employees']=$this->db->get('manage_employees'); 
	foreach($data['manage_employees']->result() as $row_emp) 
	{ 
	break; 
	}		 
	$data['print_by']=$row_emp->e_fname.'&nbsp;'.$row_emp->e_lname; 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
//	$this->db->where('test_parient',125,155);		 
	$this->db->group_by('test_parient'); 
	$this->db->order_by('id','asc');		 
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	 
	 
	 
	 
		 
	foreach($data['hms_opd_patient']->result() as $row_p) 
	{ 
	break; 
	} 
 
 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('doctor_id',$row_p->doctor_id); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_d) 
	{ 
	break; 
	}		 
	$data['doctor_name']=$row_d->name; 
	 
	 
 
//	$this->db->where('afid',$aid); 
	$this->db->where('nurse_id',$row_p->pathlogy_sign); 
	$data['hms_nurse']=$this->db->get('hms_nurse'); 
	foreach($data['hms_nurse']->result() as $row_n) 
	{ 
	break; 
	}		 
	$data['nurse_name']=$row_n->name; 
	$data['degree']=$row_n->degree; 
	$data['img_sign']=$row_n->img_sign;	 
	 
	 
	$this->db->where('id',$row_p->collection_code); 
	$data['hms_pathology']=$this->db->get('hms_pathology'); 
	foreach($data['hms_pathology']->result() as $row_path) 
	{ 
	break; 
	}		 
	$data['pathology_name']=$row_path->pathology_name; 
	$data['firdoct']=$row_path->firdoct; 
	$data['fiedgree']=$row_path->fiedgree; 
	$data['secdoct']=$row_path->secdoct; 
	$data['secdgree']=$row_path->secdgree; 
	 
	 
        $this->db->where('id',$row_p->hospitalid); 
//	$this->db->where('enter_date',$p_date);		 
	$data_count_hos=$this->db->count_all_results('hms_hospital'); 
	if($data_count_hos>0) 
	{ 
        $this->db->where('id',$row_p->hospitalid); 
	$data['hms_hospital']=$this->db->get('hms_hospital'); 
	foreach($data['hms_hospital']->result() as $row_hospit) 
	{ 
	break; 
	}		 
	$data['hospital_name']=$row_hospit->pathology_name; 
	$data['hospital_address']=$row_hospit->address;		 
	 
	} 
	else 
	{ 
	$data['hospital_name']='0'; 
	}		 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->group_by('patient_id');	 
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test'); 
	foreach($data['hms_opd_assign_test_pat']->result() as $row) 
	{ 
	break; 
	} 
	$data['test_date']=$row->enter_date;			 
	 
 
	 
	//$this->db->where('test_parient !=',0); 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
	 
 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	 
 $result = substr($ques, 0, 4); 
 $result2 = substr($ques, 0, 5);	 
 	 
			 
//	$this->load->view('hms/barcode',$data);	 
 
 
 
		$this->load->view('hms/print_opd_test_report_new_select',$data); 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
	}	 
 
 
 
function dbbackup() 
     { 
       $this->load->dbutil();    
  $today=date('d-m-Y');    
       $backup =& $this->dbutil->backup();   
       $this->load->helper('file'); 
       write_file('D:\desktopbackup/your_DB.zip', $backup); 
echo 'Backup Has Been Generated'; 
     } 
      
      
      
public function change_text_record() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->db->where('test_parient','0'); 
	$this->db->order_by('test_title','asc'); 
	$data['ho_m_test_master']=$this->db->get('ho_m_test_master'); 
		 
	$this->load->view('hms/text_modifie',$data);   
 
}      
 
 
public function show_test_parient_list_modifie11() 
		{ 
      		$this->load->library('session'); 
               	$this->load->helper('url'); 
       		$afid=$this->get_affiliate(); 
		$test_parient=$this->uri->segment(3); 
	        $this->db->where('test_parient',$test_parient); 
		$this->db->order_by('id','asc'); 
	        $data['sub_test_name_parient']=$this->db->get('ho_m_test_master'); 
		 
	   $this->db->where('id',$test_parient); 
	   $data['sub_test_name_parient_root']=$this->db->get('ho_m_test_master');	 
	foreach($data['sub_test_name_parient_root']->result() as $row_p) 
	{ 
	break; 
	} 
	$data['root_name']=$row_p->root_id;		 
		 
      	        $this->load->view('hms/sub_parient_test_list_modifie',$data);	 
		} 
		 
	public function edit_e() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$id=$this->uri->segment(3); 
	$this->db->where('id',$id); 
	$data['ep_exam1']=$this->db->get('ho_m_test_master'); 
	 
	$data['ep_exam12']=$this->db->get('ho_m_test_master'); 
	 
	 
	$this->load->view('hms/app_edit',$data); 
	} 
	 
	 
	public function edit_e_root() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$id=$this->uri->segment(3); 
	$this->db->where('id',$id); 
	$data['ep_exam1']=$this->db->get('ho_m_test_master'); 
	 
	$data['ep_exam12']=$this->db->get('ho_m_test_master'); 
	 
	 
	$this->load->view('hms/app_edit_root',$data); 
	}		 
	 
	 
	public function delete_tt() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$id=$this->uri->segment(3); 
	$pid=$this->uri->segment(4);	 
	$this->db->where('id',$id); 
	$this->db->delete('ho_m_test_master'); 
	echo 'Record deleted'; 
 
$this->call_test_chield2($pid);	 
	} 
	 
	 
public function delete_parient_root() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$id=$this->uri->segment(3); 
	$this->db->where('id',$id); 
	$this->db->delete('ho_m_test_master'); 
//$this->call_test_chield2(); 
}	 
	 
	public function call_test_chield2($pid) 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$test_parient=$pid; 
	$this->db->where('id',$test_parient); 
	$this->db->order_by('test_title','asc');	 
	$data['kk']=$this->db->get('ho_m_test_master');	 
	$this->load->view('hospital/app_second',$data);   
	}			 
	public function call_test_chield() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$test_parient=$this->uri->segment(3); 
	$this->db->where('id',$test_parient); 
	$this->db->order_by('test_title','asc');	 
	$data['kk']=$this->db->get('ho_m_test_master');	 
	$this->load->view('hospital/app_second',$data);   
	} 
	 
	public function call_test_root_child() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$test_parient=$this->uri->segment(3); 
	$this->db->where('id',$test_parient); 
	$this->db->order_by('test_title','asc');	 
	$data['kk']=$this->db->get('ho_m_test_master');	 
	$this->load->view('hospital/app_second_root',$data);   
	} 
	 
	public function delete_tt_app() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$id=$this->uri->segment(3); 
	$pid=$this->uri->segment(4);	 
	$this->db->where('id',$id); 
	$this->db->delete('ho_m_test_master'); 
	echo 'Record deleted'; 
 
$this->call_test_chield2($pid);	 
	} 
	 
	 
public function add_capsules() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
//	$this->db->where('afid',$aid); 
//	$data['department']=$this->db->get('hms_department');		 
	$this->load->view('hms/add_capsules'); 
 
} 
 
	public function save_capsules() 
	{ 
	$this->load->library('session'); 
	$this->load->helper('url'); 
	$aid=$this->get_affiliate();	 
	$this->test_name=$this->input->post('cap_name'); 
	$this->amount=$this->input->post('amount');	 
	$this->db->insert('pathlogy_master',$this);	 
	echo 'Record Added'; 
	}			 
      	 
	public function view_capsules() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
//	$aid=$this->get_affiliate(); 
	$this->load->database(); 
 
	$data_count=$this->db->count_all_results('pathlogy_master'); 
	if($data_count>0) 
	{		 
	$limit=1150; 
	$start=$this->uri->segment(3); 
	$start1=$start*$limit; 
	 
	$this->db->order_by('id','desc'); 
	$data['pathlogy_master']=$this->db->get('pathlogy_master'); 
		 
	$data['total']=$this->db->count_all_results('pathlogy_master'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_capsules',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
	} 
	 
	public function edit_capsules() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
 
	$row_id=$this->uri->segment(3);	 
	$this->db->where('id',$row_id); 
	$data['pathlogy_master']=$this->db->get('pathlogy_master');	 
	$this->load->view('hms/edit_capsules',$data);   
 
	} 
	 
	public function update_capsules() 
	{ 
	$this->load->library('session'); 
	$this->load->helper('url'); 
	$row_id=$this->input->post('row_id');	 
	$this->test_name=$this->input->post('cap_name'); 
	$this->amount=$this->input->post('amount');	 
	$this->db->where('id',$row_id); 
	$this->db->update('pathlogy_master',$this);	 
	echo 'Record Updated'; 
	} 
	 
	public function delete_capsules() 
	{ 
 	$this->load->library('session'); 
         $this->load->helper('url'); 
 //	$aid=$this->get_affiliate(); 
 	$id=$this->uri->segment(3); 
 	$this->db->where('id',$id); 
 
 	$this->db->delete('pathlogy_master'); 
 	echo 'Record Deleted'; 
	} 
	 
public function create_panel() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
 
	$this->db->where('test_parient','0');	 
	$this->db->order_by('test_title','asc'); 
	$data['ho_m_test_master']=$this->db->get('ho_m_test_master'); 
	 
	 
	$this->db->order_by('test_name','asc'); 
	$data['pathlogy_master']=$this->db->get('pathlogy_master');	 
			 
	$this->load->view('hms/add_panels_master',$data); 
 
} 
 
 
	public function assign_panles_capsules() 
 	{ 
      		$this->load->library('session'); 
        	$this->load->helper('url'); 
		$afid=$this->get_affiliate(); 
	//	$empid=$this->get_af_emp_id();		 
		$ques=$this->input->post('value'); 
		$qui=explode(',',$ques); 
		$t=0; 
		for($t1=0;Count($qui)>$t1;$t1++) 
		{	 
	//	$this->db->where('test_id',$qui[$t]);	 
		 
		$cap_name=$this->input->post('cap_name'); 
		$this->db->where('cap_id',$cap_name); 
		$this->db->where('test_pa_id',$qui[$t]); 
		$data['lastan1']=$this->db->count_all_results('hms_panles_capules'); 
		 
	 
		if($data['lastan1']>=1) 
		{ 
	 
		   //echo $qui[$t].'Test already assigned ';     
		   //echo'Test already assigned '; 
		   //	break;   
		    
		} 
		else 
	      { 
               	$this->load->database(); 
               	$this->test_pa_id=$qui[$t]; 	 
		$this->cap_id=$this->input->post('cap_name'); 
	//	$this->db->set('status','1');			 
               	$this->db->insert('hms_panles_capules',$this); 
		} 
               	$t++; 
                } 
                echo 'Panels Assigned Capsules';   
      	} 
	       
	   
	public function view_panel() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
 
 
	 
	 
	$this->db->order_by('test_name','asc'); 
	$data['pathlogy_master']=$this->db->get('pathlogy_master');	 
			 
	$this->load->view('hms/view_panles',$data); 
	} 
	 
	 
	public function capsule_test_list() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
 	$id=$this->uri->segment(3);	 
 
	$this->db->where('cap_id',$id);	 
	$this->db->order_by('id','asc'); 
	$data['hms_panles_capules']=$this->db->get('hms_panles_capules'); 
	 
	$this->db->where('test_parient','0');	 
	$this->db->order_by('id','asc'); 
	$data['ho_m_test_master']=$this->db->get('ho_m_test_master');		 
	 
	$this->load->view('hms/sub_panels_capsules',$data);	 
	} 
	 
	public function delete_panel_master_record() 
	{ 
 	$this->load->library('session'); 
         $this->load->helper('url'); 
 //	$aid=$this->get_affiliate(); 
 	$id=$this->uri->segment(3); 
 	$this->db->where('id',$id); 
 
 	$this->db->delete('hms_panles_capules'); 
 	echo 'Record Deleted'; 
 
	} 
	 
	 
	public function assign_patient_panels_test() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
//	$this->db->where('afid',$aid);	 
//	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	 
	 
	$this->db->order_by('id','asc');	 
       	$data['test_name2']=$this->db->get('ho_m_test_master');	 
	        
	$this->db->order_by('id','asc');	 
       	$data['pathlogy_master']=$this->db->get('pathlogy_master');		        
      	  
	       $date_day=date('Y-m-d'); 
	        
	       $data['date_day']=$date_day; 
 
 
$data['pid']=$pid;	 
 
	$this->db->order_by('id','asc');	 
       	$data['pathlogy_master2']=$this->db->get('pathlogy_master');	 
				 
	$this->load->view('hms/assign_patient_panels_test',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
	} 
	 
	 
	public function panels_test_list() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$panels_id=$this->uri->segment(3); 
	$this->db->where('cap_id',$panels_id);	 
	$data_count=$this->db->count_all_results('hms_panles_capules'); 
	if($data_count>0) 
	{ 
	$this->db->where('cap_id',$panels_id);	 
	$data['hms_panles_capules']=$this->db->get('hms_panles_capules'); 
	 
	$this->db->where('test_parient',0); 
	$this->db->order_by('id','asc'); 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
	 
	$this->load->view('hms/capsul_panels_test',$data);		 
 
	} 
	else 
	{ 
	echo 'Record not found'; 
	} 
	 
	} 
	 
public function show_test_parient_list_for_panels() 
{ 
      		$this->load->library('session'); 
               	$this->load->helper('url'); 
       		$afid=$this->get_affiliate(); 
		$test_parient=$this->uri->segment(3); 
	        $this->db->where('test_parient',$test_parient); 
		$this->db->order_by('id','asc'); 
	        $data['sub_test_name_parient']=$this->db->get('ho_m_test_master'); 
		 
	   $this->db->where('id',$test_parient); 
	   $data['sub_test_name_parient_root']=$this->db->get('ho_m_test_master');	 
	foreach($data['sub_test_name_parient_root']->result() as $row_p) 
	{ 
	break; 
	} 
	$data['root_name']=$row_p->root_id;		 
		 
      	        $this->load->view('hms/sub_parient_test_list_for_panels',$data); 
 
 
} 
 
 
 
	public function assign_patient_panels_test_second() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	$panels_id=$this->uri->segment(4);	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
//	$this->db->where('afid',$aid);	 
//	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	 
	 
	$this->db->order_by('id','asc');	 
       	$data['test_name2']=$this->db->get('ho_m_test_master');	 
	        
	        
	$this->db->where('id',$panels_id);	 	 
       	$data['pathlogy_master']=$this->db->get('pathlogy_master'); 
	        
	        
	$this->db->where('cap_id',$panels_id);	 	 
       	$data['hms_panles_capules']=$this->db->get('hms_panles_capules'); 
 
	$this->db->order_by('id','asc');	 
       	$data['test_name']=$this->db->get('ho_m_test_master');		       	       		        
      	  
	       $date_day=date('Y-m-d'); 
	        
	       $data['date_day']=$date_day; 
 
	$data['pid']=$pid; 
 
	$this->db->order_by('id','asc');	 
       	$data['pathlogy_master2']=$this->db->get('pathlogy_master');	 
	 
				 
	$this->load->view('hms/assign_patient_panels_test_second',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
 
	} 
	 
	 
	public function add_pasient_test_for_panels() 
	{ 
      		$this->load->library('session'); 
        	$this->load->helper('url'); 
		$afid=$this->get_affiliate(); 
		$empid=$this->get_af_emp_id();		 
		$ques=$this->input->post('value'); 
		$qui=explode(',',$ques); 
		$t=0; 
		for($t1=0;Count($qui)>$t1;$t1++) 
		{ 
		 
	//	$this->db->where('test_id',$qui[$t]);	 
		 
		$patient_id=$this->input->post('patient_name'); 
		$test_parient=$this->input->post('test_parient'); 
		$this->db->where('patient_id',$patient_id); 
	//	$this->db->where('test_parient',$test_parient); 
		$this->db->where('test_id',$qui[$t]); 
		$data['lastan1']=$this->db->count_all_results('hms_patient_assign_test'); 
		 
	 
		if($data['lastan1']>=1) 
		{ 
	 
		   //echo $qui[$t].'Test already assigned ';     
		   //echo'Test already assigned '; 
		   //	break;   
		    
		} 
		else 
	      { 
               	$this->load->database(); 
               	$this->test_id=$qui[$t]; 	 
		$this->patient_id=$this->input->post('patient_name'); 
		$this->enter_date=$this->input->post('e_date'); 
		$this->test_parient=$this->input->post('test_parient'); 
		$this->root_id=$this->input->post('root_name'); 
		$this->test_panels=$this->input->post('test_panels');		 
		$this->afid=$afid; 
		$this->emp_id=$empid; 
		$this->db->set('status','1');			 
               	$this->db->insert('hms_patient_assign_test',$this); 
		} 
               	$t++; 
                } 
                echo 'Patient Assigned Test';  
 
	} 
	 
	public function delete_panels_test() 
	{ 
 	$this->load->library('session'); 
         $this->load->helper('url'); 
 	$aid=$this->get_affiliate(); 
 	$id=$this->uri->segment(3); 
	$pid=$this->uri->segment(4);	  
 	$this->db->where('test_panels',$id); 
	$this->db->where('patient_id',$pid);	  
 	$this->db->delete('hms_patient_assign_test'); 
 	echo 'Record Deleted'; 
	} 
	 
	public function update_panels_value() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	$p_date=$this->uri->segment(4); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
 
	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->order_by('id','asc');	 
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->group_by('test_parient');		 
	$this->db->order_by('id','asc');	 
	$data['hms_opd_assign_test44']=$this->db->get('hms_patient_assign_test');		 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->group_by('patient_id');	 
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test'); 
	foreach($data['hms_opd_assign_test_pat']->result() as $row) 
	{ 
	break; 
	} 
	$data['test_date']=$row->enter_date;			 
	 
//	$this->db->where('afid',$aid);	 
	$data['pathlogy_master']=$this->db->get('pathlogy_master');	 
	 
	$this->db->where('test_parient','0'); 
	$this->db->order_by('test_parient','asc');		 
	$data['test_name2']=$this->db->get('ho_m_test_master');	 
	 
	$this->db->order_by('id','asc');	 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
				 
	$this->load->view('hms/update_patient_test_value_panels',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
} 
 
 
public function panels_sub_test() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	$p_date=$this->uri->segment(4); 
	 
	$parient_id=$this->uri->segment(5);	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
//	$this->db->where('enter_date',$p_date);	 
	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('test_parient',$parient_id);	 
	$this->db->order_by('id','asc');	 
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	 
	 
	 
	$this->db->order_by('id','asc');	 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
				 
	$this->load->view('hms/sub_panels_mark_add',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
} 
 
 
public function view_patient_test_list_panles() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid);	 
	$this->db->where('test_panels !=','0');		 
	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
//	$this->db->where('afid',$aid);	 
//	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$this->db->where('test_parient',0); 
	$this->db->order_by('test_title','asc'); 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
	 
	$this->db->order_by('test_title','asc');	 
       	$data['test_name2']=$this->db->get('ho_m_test_master');	 
      	  
	       $date_day=date('Y-m-d'); 
	        
	       $data['date_day']=$date_day; 
	        
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('test_panels !=','0');	 
	$this->db->group_by('test_parient','test_panels');		 
	$this->db->order_by('id','asc');	 
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test');	 
	foreach($data['hms_patient_assign_test']->result() as $row) 
	{ 
	break; 
	} 
	$test_panels=$row->test_panels;	 
 
$this->db->where('id',$test_panels);	 
       	$data['pathlogy_master']=$this->db->get('pathlogy_master'); 
	        
	foreach($data['pathlogy_master']->result() as $row45) 
	{ 
	break; 
	} 
	$data['capsul_name']=$row45->test_name;	 
	 
	$data['capsul_id']=$row45->id;			       	 
				 
	$this->load->view('hms/assign_patient_test_list_panles',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
 
} 
 
 
	public function print_report_panels() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	$p_date=$this->uri->segment(4); 
	$ques=$this->uri->segment(5); 
	$panels_id=$this->uri->segment(6); 
		 
$data['ques']=$ques; 
$data['pid']=$pid; 
$data['aid']=$aid; 
	date_default_timezone_set('Asia/Calcutta'); 
	$data['report_time']=date("h:i a");	 
	$data['today']=date('d-m-Y'); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
//	$this->db->where('enter_date',$p_date);		 
	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	 
 
 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
//	$this->db->where('test_parient',125,155);		 
	$this->db->group_by('test_parient'); 
	$this->db->order_by('id','asc');		 
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	 
	 
	 
	 
		 
	foreach($data['hms_opd_patient']->result() as $row_p) 
	{ 
	break; 
	} 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('doctor_id',$row_p->doctor_id); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_d) 
	{ 
	break; 
	}		 
	$data['doctor_name']=$row_d->name; 
	 
	 
 
//	$this->db->where('afid',$aid); 
	$this->db->where('nurse_id',$row_p->pathlogy_sign); 
	$data['hms_nurse']=$this->db->get('hms_nurse'); 
	foreach($data['hms_nurse']->result() as $row_n) 
	{ 
	break; 
	}		 
	$data['nurse_name']=$row_n->name; 
	$data['degree']=$row_n->degree; 
	$data['img_sign']=$row_n->img_sign;	 
	 
	 
	$this->db->where('id',$row_p->collection_code); 
	$data['hms_pathology']=$this->db->get('hms_pathology'); 
	foreach($data['hms_pathology']->result() as $row_path) 
	{ 
	break; 
	}		 
	$data['pathology_name']=$row_path->pathology_name;	 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->group_by('patient_id');	 
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test'); 
	foreach($data['hms_opd_assign_test_pat']->result() as $row) 
	{ 
	break; 
	} 
	$data['test_date']=$row->enter_date;			 
	 
 
	 
	//$this->db->where('test_parient !=',0); 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
	 
 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	 
 $result = substr($ques, 0, 4); 
 $result2 = substr($ques, 0, 5);	 
 	 
	$this->db->where('id',$panels_id);	 
	$data['pathlogy_master']=$this->db->get('pathlogy_master'); 
	foreach($data['pathlogy_master']->result() as $row78) 
	{ 
	break; 
	} 
	$data['panels_name']=$row78->test_name;			 
		$this->load->view('hms/print_opd_test_report_new_select_panels',$data); 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
	} 
	 
	 
	public function print_panel_sleep() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	$today=$this->uri->segment(4); 
	 
	$data['today']=$today; 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('enter_date',$today);	 
	$this->db->where('test_panels !=','0'); 
	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('enter_date',$today);	 
	$this->db->where('test_panels !=','0');		 
	$this->db->group_by('test_parient'); 
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	 
	foreach($data['hms_opd_patient']->result() as $row_p) 
	{ 
	break; 
	} 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('doctor_id',$row_p->doctor_id); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_d) 
	{ 
	break; 
	}		 
	$data['doctor_name']=$row_d->name; 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('enter_date',$today);	 
	$this->db->group_by('patient_id');	 
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test'); 
	foreach($data['hms_opd_assign_test_pat']->result() as $row) 
	{ 
	break; 
	} 
	$data['test_date']=$row->enter_date;			 
$this->db->where('id',$row->test_panels);	 
	$data['panels_master']=$this->db->get('pathlogy_master');	 
	foreach($data['panels_master']->result() as $row_panels) 
	{ 
	break; 
	}	 
	$data['panels_name']=$row_panels->test_name; 
	$data['pales_amount']=$row_panels->amount;	 
	//$this->db->where('test_parient !=',0); 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
	 
	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	 
	 
				 
	$this->load->view('hms/print_opd_test_report_sleep_panels',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
	}   
			 
public function change_text_record_rate() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$this->db->where('test_parient','0'); 
	$this->db->order_by('test_title','asc'); 
	$data['ho_m_test_master']=$this->db->get('ho_m_test_master'); 
		 
	$this->load->view('hms/text_modifie_rate',$data);   
 
}  
 
	public function test_rate_fine() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$test_parient=$this->uri->segment(3); 
	$this->db->where('id',$test_parient); 
	$this->db->order_by('test_title','asc');	 
	$data['kk']=$this->db->get('ho_m_test_master');	 
 
	foreach($data['kk']->result() as $row) 
	{ 
	break; 
	}	 
	$data['rate']=$row->amount;	 
	 
	$this->load->view('hms/test_rate',$data);   
	} 
	 
public function name_wise_pai() 
{ 
		$bookids=array(); 
		$books=""; 
	 
		$this->load->helper('url'); 
		$aid=$this->get_affiliate(); 
		$title1=$this->uri->segment(3); 
		$title1=str_replace(":"," ",$title1); 
 
			 
		if($title1!='0') 
		{ 
		$query="patient_name like '".$title1."%'"; 
		$this->db->where($query); 
		} 
		 
		 
		$this->db->where($query); 
		$this->db->where('afid',$aid); 
		$this->db->order_by('patient_name','asc');			 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$limit=150; 
	$start=$this->uri->segment(4); 
	$start1=$start*$limit; 
 
		if($title1!='0') 
		{ 
		$query="patient_name like '".$title1."%'"; 
		$this->db->where($query); 
		} 
		 
		 
		$this->db->where($query); 
		$this->db->where('afid',$aid); 
		$this->db->order_by('patient_name','asc');		 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
 
	$this->db->where('afid',$aid); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
				 
		$this->db->where($query); 
		$this->db->where('afid',$aid); 
		$this->db->order_by('patient_name','asc');		 
	$data['total']=$this->db->count_all_results('hms_opd_patient'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_second_opd_patient_date_wise',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
} 
 
 
//------------------------------------------------ 
 
public function pateint_test_list_child() 
{ 
		$this->load->library('session'); 
        	$this->load->helper('url'); 
	$pid=$this->uri->segment(3); 
	$test_pid=$this->uri->segment(4); 
//	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('test_parient',$test_pid);	 
//	$this->db->where('enter_date',$p_date);	 
	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
	if($data_count>0) 
	{			 
	$this->db->where('patient_id',$pid); 
	$this->db->where('test_parient',$test_pid);	 
	$this->db->order_by('id','asc'); 
	$data['hms_opd_assign_test_3']=$this->db->get('hms_patient_assign_test');	 
		 
	 
	$this->db->where('test_parient !=',0); 
	$this->db->group_by('id'); 
	$data['test_name_3']=$this->db->get('ho_m_test_master'); 
	$this->load->view('hms/pateint_test_list_child',$data);	 
	} 
	else 
	{ 
	echo 'Record not found'; 
	}	 
} 
 
 
 
public function pateint_test_list_child_remove() 
{ 
		$this->load->library('session'); 
        	$this->load->helper('url'); 
	$pid=$this->uri->segment(3); 
	$test_pid=$this->uri->segment(4); 
//	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('test_id',$test_pid);	 
//	$this->db->where('enter_date',$p_date);	 
	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
	if($data_count>0) 
	{ 
		$this->db->set('remove','1'); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('test_id',$test_pid);					 
               	$this->db->update('hms_patient_assign_test',$this); 
	} 
	else 
	{ 
	echo 'Record not found'; 
	} 
 
} 
 
 
public function pateint_test_list_child_ok() 
{ 
		$this->load->library('session'); 
        	$this->load->helper('url'); 
	$pid=$this->uri->segment(3); 
	$test_pid=$this->uri->segment(4); 
//	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('test_id',$test_pid);	 
//	$this->db->where('enter_date',$p_date);	 
	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
	if($data_count>0) 
	{ 
		$this->db->set('remove','0'); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('test_id',$test_pid);					 
               	$this->db->update('hms_patient_assign_test',$this); 
	} 
	else 
	{ 
	echo 'Record not found'; 
	} 
 
} 
 
 
 
//	 
	 
//---------------------rate change-------------------- 
public function get_ch_tot() 
{ 
		$this->load->library('session'); 
        	$this->load->helper('url'); 
		$afid=$this->get_affiliate(); 
		 
		$id=$this->input->post('checkid'); 
		$mark=$this->input->post('checkedoption2'); 
		$qui_id=explode(',',$id); 
		$qui=explode(',',$mark); 
	 
	       $t=0; 
	       $test_val=""; 
		for($t1=0;Count($qui_id)>$t1;$t1++) 
		{ 
		$this->load->database(); 
		//$this->modify_emp_id=$this->input->post('eid');  
		$test_val +=$qui[$t];  
	     
		$t++; 
 
		} 
	$this->amt=$test_val; 
	$this->aid='0'; 
	$this->db->insert('hms_tot_bill',$this);		 
		 
 
} 
 
public function get_sum_amt() 
{ 
		$this->load->library('session'); 
        	$this->load->helper('url'); 
$this->db->order_by('id','desc');		 
$data['hms_tot_bill']=$this->db->get('hms_tot_bill'); 
	foreach($data['hms_tot_bill']->result() as $row_p) 
	{ 
	break; 
	} 
	$data['test_val']=$row_p->amt;		 
	$this->load->view('hms/chage_tot_amt',$data); 
} 
 
 
public function patient_bill_data_save() 
{ 
		$this->load->library('session'); 
        	$this->load->helper('url'); 
		$afid=$this->get_affiliate(); 
		 
	$af_emp_id=$this->get_af_emp_id();		 
 
	$this->db->where('aid','0');		 
	$this->db->delete('hms_tot_bill'); 
			 
		$id=$this->input->post('checkidd'); 
		$mark=$this->input->post('checkedoption24'); 
		$patient_id=$this->input->post('patient_name');  
		$date_test=$this->input->post('e_date'); 			 
		$qui_id=explode(',',$id); 
		$qui=explode(',',$mark); 
	 
	       $t=1; 
		for($t1=0;Count($qui_id)>$t1;$t1++) 
		{ 
	 
	$this->db->where('patient_id',$patient_id); 
//	$this->db->where('date_test',$date_test); 
	$this->db->where('test_pid',$qui_id[$t]);	 
			 
	$data_count=$this->db->count_all_results('hms_opd_test_rate'); 
	if($data_count>0) 
	{ 
 
	 
	} 
	else 
	{		 
		$this->load->database(); 
		$this->opd_emp_id=$af_emp_id;		 
		$this->patient_id=$this->input->post('patient_name');  
		$this->date_test=$this->input->post('e_date'); 	 
		$this->test_pid=$qui_id[$t]; 		 
		$this->amt=$qui[$t]; 
	 
	       $this->db->insert('hms_opd_test_rate',$this);     
	 	 
      }	     
       	$t++;		 								    	      						  		  		      		      	 	   		  			 
} 
} 
 
 
	public function delete_opd_test_rate() 
	{ 
 	$this->load->library('session'); 
         $this->load->helper('url'); 
 	$aid=$this->get_affiliate(); 
 	$id=$this->uri->segment(3); 
	$pid=$this->uri->segment(4);	  
	$this->db->where('test_pid',$id); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('print_status','0');					 
	$data_count=$this->db->count_all_results('hms_opd_test_rate'); 
	if($data_count >=1) 
	{	  
 	$this->db->where('test_pid',$id); 
	$this->db->where('patient_id',$pid); 
	$this->db->where('print_status','0');		  
 	$this->db->delete('hms_opd_test_rate'); 
 	echo 'Record Deleted'; 
	 } 
	 else 
	 { 
	  
	 }	 
	  
	} 
	 
	 
	 
public function patient_bill_data_save_diagnose() 
{ 
		$this->load->library('session'); 
        	$this->load->helper('url'); 
		$afid=$this->get_affiliate(); 
		 
	$af_emp_id=$this->get_af_emp_id();		 
 
//	$this->db->where('aid','0');		 
//	$this->db->delete('hms_tot_bill'); 
			 
		$id=$this->input->post('checkidd'); 
		$mark=$this->input->post('checkedoption24'); 
		$patient_id=$this->input->post('patient_name');  
		$date_test=$this->input->post('e_date'); 			 
		$qui_id=explode(',',$id); 
		$qui=explode(',',$mark); 
	 
	       $t=1; 
		for($t1=0;Count($qui_id)>$t1;$t1++) 
		{ 
	 
	$this->db->where('patient_id',$patient_id); 
//	$this->db->where('date_test',$date_test); 
	$this->db->where('test_pid',$qui_id[$t]);	 
			 
	$data_count=$this->db->count_all_results('hms_opd_test_rate_diagnose'); 
	if($data_count>0) 
	{ 
 
		$this->load->database(); 
		$this->patient_id=$this->input->post('patient_name');  
	//	$this->date_test=$this->input->post('e_date'); 	 
		$this->amt=$qui[$t]; 
		$this->opd_emp_id=$af_emp_id;		 
		//$this->test_pid=$qui_id[$t];  
		$this->db->where('test_pid',$qui_id[$t]); 
		$this->db->where('patient_id',$patient_id);	 
	       $this->db->update('hms_opd_test_rate_diagnose',$this);     
		$t++;	 
	} 
	else 
	{		 
		$this->load->database(); 
		$this->opd_emp_id=$af_emp_id;		 
		$this->patient_id=$this->input->post('patient_name');  
		$this->date_test=$this->input->post('e_date'); 	 
		$this->test_pid=$qui_id[$t]; 		 
		$this->amt=$qui[$t]; 
	 
	       $this->db->insert('hms_opd_test_rate_diagnose',$this);     
	 $t++;	 
      }	     
       			 								    	      						  		  		      		      	 	   		  			 
} 
}	 
 
//-------------------------end rate----------------										      					       
public function search_today_report_pid() 
{ 
       		$this->load->library('session'); 
               	$this->load->helper('url'); 
       		$afid=$this->get_affiliate(); 
       		//$pid=$this->uri->segment(3); 
		$fdate=$this->uri->segment(3); 
	     $tdate=$this->uri->segment(4); 
	      
	     $data['fdate']=$fdate; 
	     $data['tdate']=$tdate;	              
       	$this->db->where('afid',$afid);	 
	$this->db->where('enter_date >=',$fdate);	 
	$this->db->where('enter_date <=',$tdate);	        
       	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
       	if($data_count>0) 
       	{		 
       	$this->db->where('afid',$afid);	 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate);	        
       	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
       	 
       //	$this->db->where('test_parient !=',0); 
       	$data['test_name']=$this->db->get('ho_m_test_master');	 
      	  
      	$this->db->where('afid',$afid); 
	$this->db->where('enter_date >=',$fdate);	 
	$this->db->where('enter_date <=',$tdate);	       
	$this->db->group_by('patient_id');     
	$this->db->group_by('enter_date');     
       	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test');	  
        
       	$this->db->where('afid',$afid);	        
       	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	        
       	$this->db->where('afid',$afid);	        
       	$data['hms_doctor']=$this->db->get('hms_doctor');	        
	        
	$this->db->where('affiliate_id',$afid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	        
      	       				 
       	$this->load->view('hms/view_patient_today_report',$data);	 
               } 
       	else 
       	{ 
       	echo 'Record not found'; 
       	} 
} 
 
 
public function print_test() 
{ 
       		$this->load->library('session'); 
               	$this->load->helper('url'); 
	$afid=$this->get_affiliate();		        
	$this->db->where('affiliate_id',$afid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		        
       	$this->db->where('test_parient',0); 
       	$data['test_name']=$this->db->get('ho_m_test_master');	 
       	$this->load->view('hms/print_test',$data);	       		        
    
} 
 
 public function upload_rechecked() 
    { 
   	$this->load->library('session'); 
	$this->load->helper('url'); 
	$data['aid']=$this->get_affiliate(); 
	$eid=$this->uri->segment(3); 
	$data['eid']=$eid; 
   	$this->db->where('id',$eid);	   			 
   	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
   	if($data_count>0) 
   	{ 
 	$this->db->where('id',$eid);		    
$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test'); 
	foreach($data['hms_patient_assign_test']->result() as $row_p) 
	{ 
	break; 
	} 
	$data['test_text']=$row_p->text;	    
	   }	 
	$this->load->view('hms/add_rechecked_val',$data); 
    } 
     
     
   public function update_comment_recked() 
   { 
    
    	$this->load->library('session'); 
   	$this->load->helper('url');  
 	$id=$this->input->post('h1'); 
   	$this->db->where('id',$id);			 
   	$data_count=$this->db->count_all_results('hms_patient_assign_test'); 
   	if($data_count>0) 
   	{ 
   		$this->load->database(); 
   		$this->text=$this->input->post('h2');  
   		$this->db->where('id',$id); 
   	       $this->db->update('hms_patient_assign_test',$this);    	 
   	}  
	   else 
	   { 
	    
	   }  
   } 
    
    
    
public function apply_for_account() 
{ 
  	$this->load->library('session'); 
  	$this->load->helper('url'); 
$aid=$this->get_affiliate(); 
	$id=$this->uri->segment(3); 
	$data['id']=$id; 
	$data['id1']=$this->uri->segment(3); 
	$afid=$this->get_affiliate(); 
	 
	$this->db->where('emp_aff_id',$afid); 
	$this->db->where('emp_id',$id); 
	$data['emp_info']=$this->db->get('emp_info'); 
	 
//	$this->db->where('afid',$afid); 
	$data['manage_designation']=$this->db->get('manage_designation'); 
 
 
	$this->db->where('afid',$aid);	 
	$data['manage_assigne_designation']=$this->db->get('manage_assigne_designation'); 
 
	$this->load->view('hms/create_emp_account_form',$data); 
} 
 
public function emp_create_ac_number() 
{ 
$this->load->library('session'); 
$this->load->helper('url'); 
$afid=$this->get_affiliate(); 
$id=$this->input->post('emprollid'); 
	$this->db->where('e_affiliateid',$afid); 
	$this->db->where('emp_info_id',$id); 
	$data['lastan1']=$this->db->count_all_results('manage_employees'); 
	if($data['lastan1']>=1) 
	{ 
echo 'Exit Account'; 
} 
else 
{ 
$this->emp_info_id=$this->input->post('emprollid'); 
$this->e_fname=$this->input->post('f_name'); 
$this->e_lname=$this->input->post('l_name'); 
$this->entry_date=$this->input->post('stdate'); 
$this->e_contact=$this->input->post('emp_cont'); 
$this->e_address=$this->input->post('emp_address'); 
 
$this->e_affiliateid=$this->input->post('emp_afid'); 
$this->e_designation=$this->input->post('designation_type'); 
$this->e_email=$this->input->post('email'); 
$this->e_password=$this->input->post('pass'); 
 
$this->db->insert('manage_employees',$this); 
echo 'Created Account'; 
} 
} 
 
public function search_admin_empdep_view() 
{ 
$this->load->library('session'); 
$this->load->helper('url'); 
				 
$data['empinfo']=$this->db->get('emp_info'); 
 
 
$this->load->view('hms/employee_list_view_account',$data); 
 
} 
 
public function apply_for_account_edit() 
{ 
  	$this->load->library('session'); 
  	$this->load->helper('url'); 
	$id=$this->uri->segment(3); 
	$data['id']=$id; 
	$data['id1']=$this->uri->segment(3); 
	$afid=$this->get_affiliate(); 
	 
	$this->db->where('e_affiliateid',$afid); 
	$this->db->where('emp_info_id',$id); 
	$data['lastan1']=$this->db->count_all_results('manage_employees'); 
	if($data['lastan1']>=1) 
	{ 
	$this->db->where('e_affiliateid',$afid); 
	$this->db->where('emp_info_id',$id);		 
	$data['emp_info']=$this->db->get('manage_employees'); 
 
	$data['manage_designation']=$this->db->get('manage_designation'); 
 
	$this->load->view('hms/edit_emp_account_form',$data); 
         } 
	 else 
	 { 
	  
	 echo 'Employee Email and Password not Created'; 
	  
	 } 
} 
 
public function emp_update_ac_number() 
{ 
$this->load->library('session'); 
$this->load->helper('url'); 
$aid=$this->get_affiliate(); 
$emp_info_id=$this->input->post('emprollid'); 
 
$this->e_designation=$this->input->post('designation_type'); 
$this->e_email=$this->input->post('email'); 
$this->e_password=$this->input->post('pass'); 
$this->db->where('e_affiliateid',$aid); 
$this->db->where('emp_info_id',$emp_info_id); 
$this->db->update('manage_employees',$this); 
echo 'Account Updated'; 
 
} 
 
	public function assign_patient_test_user() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$pid=$this->uri->segment(3); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	foreach($data['hms_opd_patient']->result() as $row) 
	{ 
	break; 
	} 
	$data['phone']=$row->phone; 
	$data['date_day']=$row->entry_date;	 
	 
//	$this->db->where('afid',$aid);	 
//	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$this->db->where('test_parient',0); 
	$this->db->order_by('id','asc'); 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
	 
	$this->db->order_by('id','asc');	 
       	$data['test_name2']=$this->db->get('ho_m_test_master');	 
      	  
	       $date_day= $row->entry_date; 
	        
	        
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
//	$this->db->where('enter_date',$date_day); 
	$this->db->where('test_panels','0');		 
//----------------show amount with parient--- 
 
$this->db->group_by('test_parient'); 
//-------------------------------------------------		 
	$this->db->order_by('enter_date','desc');	 
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test');	 
	 
				 
	$this->load->view('hms/assign_patient_test_user',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
	} 
	 
public function name_wise_pai_user() 
{ 
		$bookids=array(); 
		$books=""; 
	 
		$this->load->helper('url'); 
		$aid=$this->get_affiliate(); 
		$title1=$this->uri->segment(3); 
		$title1=str_replace(":"," ",$title1); 
 
			 
		if($title1!='0') 
		{ 
		$query="patient_name like '".$title1."%'"; 
		$this->db->where($query); 
		} 
		 
		 
		$this->db->where($query); 
		$this->db->where('afid',$aid); 
		$this->db->order_by('patient_name','asc');			 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$limit=150; 
	$start=$this->uri->segment(4); 
	$start1=$start*$limit; 
 
		if($title1!='0') 
		{ 
		$query="patient_name like '".$title1."%'"; 
		$this->db->where($query); 
		} 
		 
		 
		$this->db->where($query); 
		$this->db->where('afid',$aid); 
		$this->db->order_by('patient_name','asc');		 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
 
	$this->db->where('afid',$aid); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
				 
		$this->db->where($query); 
		$this->db->where('afid',$aid); 
		$this->db->order_by('patient_name','asc');		 
	$data['total']=$this->db->count_all_results('hms_opd_patient'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_second_opd_patient_date_wise_user',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
} 
 
	public function search_opd_patient_rego_wise_user() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$rego=$this->uri->segment(3); 
//	$tdate=$this->uri->segment(4);		 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('phone',$rego);			 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$limit=150; 
	$start=$this->uri->segment(5); 
	$start1=$start*$limit; 
 
	$this->db->where('afid',$aid);	 
	$this->db->where('phone',$rego);		 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
 
	$this->db->where('afid',$aid); 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
				 
	$this->db->where('afid',$aid); 
	$this->db->where('phone',$rego);		 
	$data['total']=$this->db->count_all_results('hms_opd_patient'); 
	$data['limit']=$limit; 
	$data['start']=$start; 
	$data['start1']=$start1; 
	$this->load->view('hms/view_second_opd_patient_date_wise_user',$data);	 
          } 
	else 
	{ 
	echo 'Record not found'; 
	}	 
	}		 
     
 //-------------------------------------------------------------- 
  
	public function view_boy_report() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
 
	$this->db->where('emp_aff_id',$aid); 
	$data['emp_info']=$this->db->get('emp_info'); 
	 
	$this->db->where('afid',$aid); 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$this->load->view('hms/view_boy_report',$data);	 
	}   
	 
	 
	 
	public function call_emp_center() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$paid=$this->uri->segment(3); 
 
	$this->db->where('pathlogy_id',$paid);			 
	$data_count=$this->db->count_all_results('emp_info '); 
	if($data_count>0) 
	{ 
	$this->db->where('pathlogy_id',$paid); 
	$data['emp_info']=$this->db->get('emp_info'); 
	 
	$this->load->view('hms/view_sub_emp',$data);			 
	} 
	else 
	{ 
	 
	echo 'No record found'; 
	} 
	}	 
	 
	 
	public function print_report_date_boy() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4); 
	$centerid=$this->uri->segment(5);	 
	 
	 
	$this->db->where('emp_aff_id',$aid); 
	$this->db->where('emp_enroll',$centerid);	 
	$data['emp_info']=$this->db->get('emp_info'); 
	foreach($data['emp_info']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['emp_name']=$row_name->emp_fname.'&nbsp;'.$row_name->emp_mname.'&nbsp;'.$row_name->emp_lname;	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('clboy',$centerid);			 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('clboy',$centerid); 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		 
				 
	$this->load->view('hms/print_report_boy_wise',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	} 
	} 
 
public function get_pid_record() 
{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
 	$reg=$this->uri->segment(3); 
	$age=$this->uri->segment(4); 
	$date=$this->uri->segment(5); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('age',$age);	 
	$this->db->where('entry_date',$date); 
	$this->db->where('phone',$reg);			 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	$this->db->where('afid',$aid); 
	$this->db->where('age',$age);	 
	$this->db->where('entry_date',$date); 
	$this->db->where('phone',$reg);		 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	foreach($data['hms_opd_patient']->result() as $row_name) 
		{ 
		break; 
		} 
echo	$data['pid']=$row_name->id; 
	 
	$this->db->where('test_parient',0); 
	$this->db->order_by('test_title','asc'); 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
	 
	$this->db->order_by('test_title','asc');	 
       	$data['test_name2']=$this->db->get('ho_m_test_master');	 
      	  
	   //    $date_day=date('Y-m-d'); 
	        
	       $data['date_day']=$date; 
	        
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$row_name->id); 
	$this->db->where('test_panels','0');	 
	$this->db->group_by('test_parient');		 
	$this->db->order_by('id','asc');	 
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test');	 
	 
				 
	$this->load->view('hms/out_report',$data);	 
		 
	} 
	else 
	{ 
	echo 'Record not found'; 
	} 
 
} 
 
 
     public function delite_slip_record() 
     { 
 	$this->load->library('session'); 
         $this->load->helper('url'); 
 //	$aid=$this->get_affiliate(); 
 	$pid=$this->uri->segment(3); 
	  
 //	$this->db->where('test_pid',$id); 
	$this->db->where('patient_id',$pid);	  
 	$this->db->delete('hms_opd_test_rate'); 
 	echo 'Record Deleted'; 
        } 
	 
	public function get_doctor_rate() 
	{ 
 	$this->load->library('session'); 
         $this->load->helper('url'); 
 	$pid=$this->uri->segment(3); 
 
	$this->db->where('doctor_id',$pid);			 
	$data_count=$this->db->count_all_results('hms_doctor'); 
	if($data_count>0) 
	{ 
	$this->db->where('doctor_id',$pid);		 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['per']=$row_name->per; 
	$data['digper']=$row_name->digper;	 
				 
	$this->load->view('hms/doctor_rate',$data);	 
	} 
	else 
	{ 
	 
	echo 'No Record Found'; 
	} 
	} 
	 
	 
	public function view_day_report_hospital() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
 
        $this->db->where('afid',$aid); 
	$this->db->order_by('pathology_name','asc'); 
	$data['hms_hospital']=$this->db->get('hms_hospital'); 
	 
	$this->db->where('afid',$aid); 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$data['hms_zone_master']=$this->db->get('hms_zone_master');	 
	 
	$this->load->view('hms/view_hospital_report',$data);	 
	} 
	 
        public function get_hospital_rate() 
       { 
	$this->load->library('session'); 
         $this->load->helper('url'); 
 	$pid=$this->uri->segment(3); 
 
	$this->db->where('id',$pid);			 
	$data_count=$this->db->count_all_results('hms_hospital'); 
	if($data_count>0) 
	{ 
	$this->db->where('id',$pid);		 
	$data['hms_hospital']=$this->db->get('hms_hospital'); 
	foreach($data['hms_hospital']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['per']=$row_name->per; 
	$data['digper']=$row_name->digper;	 
				 
	$this->load->view('hms/doctor_rate',$data);	 
	} 
	else 
	{ 
	 
	echo 'No Record Found'; 
	} 
       } 
        
      
   public function get_hospital_pathlogy() 
   { 
 	$this->load->library('session'); 
            $this->load->helper('url'); 
    	$pid=$this->uri->segment(3); 
    
   	$this->db->where('pathlogy_id',$pid);			 
   	$data_count=$this->db->count_all_results('hms_hospital'); 
   	if($data_count>0) 
   	{ 
   	$this->db->where('pathlogy_id',$pid);		 
   	$data['hms_hospital']=$this->db->get('hms_hospital'); 
  				 
   	$this->load->view('hms/sub_hospital',$data);	 
   	} 
   	else 
   	{ 
   	 
   	echo 'No Record Found'; 
   	}   
    
   }     
        
        
        
        
	public function print_report_date_emp_first_hospital() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4); 
	$empid=$this->uri->segment(5);	 
	$pathlogy=$this->uri->segment(6);				 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$empid);	 
	$data['hms_hospital']=$this->db->get('hms_hospital'); 
	foreach($data['hms_hospital']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['emp_name']=$row_name->pathology_name;	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pathlogy);	 
	$data['center']=$this->db->get('hms_pathology'); 
	foreach($data['center']->result() as $row_center) 
		{ 
		break; 
		} 
	$data['center_name']=$row_center->pathology_name;	 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('hospitalid',$empid); 
	$this->db->where('collection_code',$pathlogy);				 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('hospitalid',$empid); 
	$this->db->where('collection_code',$pathlogy);	 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		 
				 
	$this->load->view('hms/print_report_date_wise_first_hospital',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	} 
	}        
        
	public function print_report_date_emp_hospital() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4); 
	$empid=$this->uri->segment(5);	 
	$data['disper']=$this->uri->segment(6);	 
	$data['disperrt']=$this->uri->segment(7);	 
	$pathlogy=$this->uri->segment(8);					 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$empid);	 
	$data['hms_hospital']=$this->db->get('hms_hospital'); 
	foreach($data['hms_hospital']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['emp_name']=$row_name->pathology_name;	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pathlogy);	 
	$data['center']=$this->db->get('hms_pathology'); 
	foreach($data['center']->result() as $row_center) 
		{ 
		break; 
		} 
	$data['center_name']=$row_center->pathology_name;	 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('hospitalid',$empid);	 
	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount !=','0');				 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('hospitalid',$empid); 
	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount !=','0');		 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		 
				 
	$this->load->view('hms/print_report_date_wise_hospital',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	} 
	} 
	 
	public function print_report_date_emp_first_diagnos_hospital() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4); 
	$empid=$this->uri->segment(5);	 
	$pathlogy=$this->uri->segment(6);				 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$empid);	 
	$data['hms_hospital']=$this->db->get('hms_hospital'); 
	foreach($data['hms_hospital']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['emp_name']=$row_name->pathology_name;	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pathlogy);	 
	$data['center']=$this->db->get('hms_pathology'); 
	foreach($data['center']->result() as $row_center) 
		{ 
		break; 
		} 
	$data['center_name']=$row_center->pathology_name;	 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('hospitalid',$empid); 
	$this->db->where('collection_code',$pathlogy);				 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('hospitalid',$empid); 
	$this->db->where('collection_code',$pathlogy);	 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		 
				 
	$this->load->view('hms/print_report_date_wise_first_diagno_hospital',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	} 
	} 
	 
	 
	public function print_report_date_emp_diagnos_all_hospital() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4); 
	$empid=$this->uri->segment(5);	 
	$data['disper']=$this->uri->segment(6);	 
	$data['disperrt']=$this->uri->segment(7);	 
	$pathlogy=$this->uri->segment(8);					 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$empid);	 
	$data['hms_hospital']=$this->db->get('hms_hospital'); 
	foreach($data['hms_hospital']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['emp_name']=$row_name->pathology_name;	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pathlogy);	 
	$data['center']=$this->db->get('hms_pathology'); 
	foreach($data['center']->result() as $row_center) 
		{ 
		break; 
		} 
	$data['center_name']=$row_center->pathology_name;	 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('hospitalid',$empid);	 
	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount_diagnose !=','0');					 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('hospitalid',$empid); 
	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount_diagnose !=','0');			 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		 
				 
	$this->load->view('hms/print_report_date_wise_diagnos_hospital',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	} 
	} 
	 
	 
	public function assign_patient_test_fordiagnouse_user() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$userid=$this->get_af_emp_id(); 
	$pid=$this->uri->segment(3); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{		 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	foreach($data['hms_opd_patient']->result() as $row) 
	{ 
	break; 
	} 
	$data['phone']=$row->phone;	 
	$data['date_day']=$row->entry_date; 
	$data['doctor_id']=$row->doctor_id; 
	$data['pathlogu_name']=$row->collection_code; 
	$data['hospiatal_name']=$row->hospitalid; 
	 
					 
	 
//	$this->db->where('afid',$aid);	 
//	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$this->db->where('dig_parient',0); 
	$this->db->order_by('id','asc'); 
	$data['test_name']=$this->db->get('hms_dignos_master');	 
	 
	$this->db->order_by('id','asc');	 
       	$data['test_name2']=$this->db->get('hms_dignos_master');	 
      	  
	       $date_day=date('Y-m-d'); 
	        
	      $data['date_day']=$date_day; 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid); 
//	$this->db->where('enter_date',$date_day); 
	$this->db->where('emp_id',$userid);			 
	$this->db->order_by('enter_date','desc');	 
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test_diagnose');	 
	 
	$this->db->where('afid',$aid);	 
	$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$this->db->where('afid',$aid);	 
	$data['hms_hospital']=$this->db->get('hms_hospital');				 
	$this->load->view('hms/assign_patient_test_for_diagnouse_user',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
	} 
	 
	 
	public function update_print_status() 
	{ 
	 
	$this->load->helper('url'); 
	$this->load->library('session'); 
 
	$pid=$this->uri->segment(3); 
//	$d_date=$this->uri->segment(4);	 
	 
	$this->db->set('print_status','1'); 
 
	$this->db->where('patient_id',$pid); 
//	$this->db->where('enter_date',$d_date); 
	$this->db->update('hms_patient_assign_test',$this); 
	 
	 
	$this->db->set('print_status','1'); 
 
	$this->db->where('patient_id',$pid); 
//	$this->db->where('date_test',$d_date); 
	$this->db->update('hms_opd_test_rate',$this);	 
	 
	 
	$this->db->set('statusid','1'); 
	$this->db->where('id',$pid); 
	$this->db->update('hms_opd_patient',$this);	 
	echo 'Update status';		 
	} 
	 
	 
	public function patient_part_paydata() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
 
	$pid=$this->uri->segment(3); 
	$paid_amt=$this->uri->segment(4); 
//	$fdate=$this->uri->segment(5);		 
	$this->patient_id=$pid; 
	$this->padi_amt_lab=$paid_amt; 
        $this->p_date=date('Y-m-d');					 
        $this->db->insert('hms_patient_part_payment_lab',$this); 
	} 
	 
 
 public function lab_part_payment_diagnose_user() 
      { 
   	$this->load->helper('url'); 
      	$this->load->library('session'); 
      	$aid=$this->get_affiliate(); 
	$af_emp_id=$this->get_af_emp_id();	       
      	$pid=$this->uri->segment(3); 
      	$entry_date=$this->uri->segment(4);    
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$this->db->where('entry_date',$entry_date);		 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pid);	 
	$this->db->where('entry_date',$entry_date);	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');	 
	foreach($data['hms_opd_patient']->result() as $row) 
		{ 
    	break; 
		} 
	$data['tot_amt']=$row->tot_amount_diagnose; 
	$data['paid_amt']=$row->amount_diagnose;	 
	$data['discount']=$row->discount_diagnos;	 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('patient_id',$pid);	 
	$this->db->group_by('patient_id'); 
	$data['second_patient_assign_test']=$this->db->get('hms_patient_assign_test_diagnose');	 
 
	$data['test_name']=$this->db->get('hms_dignos_master');	 
 
	 
		$this->load->view('hms/lab_part_payment_form_admin_diagnose_user',$data);				       
         } 
	 else 
	 { 
	 echo 'Record not found'; 
	 } 
      } 
	 
	public function patient_part_paydata_diagnose() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
 
	$pid=$this->uri->segment(3); 
	$paid_amt=$this->uri->segment(4); 
//	$fdate=$this->uri->segment(5);		 
	$this->patient_id=$pid; 
	$this->paid_diagnose=$paid_amt; 
        $this->p_date=date('Y-m-d');					 
        $this->db->insert('hms_patient_part_payment_lab',$this); 
	} 
	 
	 
public function manage_test_special() 
{ 
 
$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	 
	$data_count=$this->db->count_all_results('ho_m_test_master'); 
	if($data_count>0) 
	{		 
		$this->db->where('afid',$aid); 
	//	$this->db->where('id',$pid);	 
		$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
		 
		$this->db->where('afid',$aid); 
	//	$this->db->where('patient_id',$pid);	 
		$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	 
		 
		$this->db->where('afid',$aid); 
	//	$this->db->where('patient_id',$pid); 
		$this->db->group_by('patient_id');	 
		$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test'); 
		foreach($data['hms_opd_assign_test_pat']->result() as $row) 
		{ 
		break; 
		} 
	//	$data['test_date']=$row->enter_date;			 
		 
		$this->db->where('afid',$aid);	 
		$data['hms_pathology']=$this->db->get('hms_pathology');	 
	 
	$this->db->where('test_parient',0); 
//	$this->db->order_by('test_title','asc'); 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
				 
	$this->load->view('hms/manage_doctor_commission_testspecial',$data);	 
        } 
	else 
	{ 
	echo 'Record not found'; 
	} 
     } 
      
      
         public function update_special_test() 
             { 
		$this->load->library('session'); 
        	$this->load->helper('url'); 
		$afid=$this->get_affiliate(); 
		$id=$this->input->post('checkid'); 
		$mark=$this->input->post('checkedoption2'); 
		$qui_id=explode(',',$id); 
		$qui=explode(',',$mark); 
	 
	       $t=0; 
		for($t1=0;Count($qui_id)>$t1;$t1++) 
		{ 
		$this->load->database(); 
		//$this->modify_emp_id=$this->input->post('eid');  
		$this->status=$qui[$t];  
		$this->db->where('id',$qui_id[$t]); 
	       $this->db->update('ho_m_test_master',$this); 
	        
		$t++; 
 
		} 
		 
            } 
     		 
	public function print_report_date_emp2() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4); 
	$zone=$this->uri->segment(5);	 
//	$data['disper']=$this->uri->segment(5);	 
//	$data['disperrt']=$this->uri->segment(6);	 
//	$pathlogy=$this->uri->segment(8);					 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('zone_id',$zone);	 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['emp_name']=$row_name->name;	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
	 
	 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('doctor_id',$empid);	 
//	$this->db->where('collection_code',$pathlogy); 
	$this->db->where('tot_amount !=','0');				 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('doctor_id',$empid); 
//	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount !=','0');		 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		 
				 
	$this->load->view('hms/print_report_date_wise_new',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	} 
	} 
	 
	 
	 
	public function print_report_date_emp_diagnos_all2() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4); 
	$zone=$this->uri->segment(5);	 
//	$data['disper']=$this->uri->segment(6);	 
//	$data['disperrt']=$this->uri->segment(7);	 
//	$pathlogy=$this->uri->segment(8);					 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('zone_id',$zone);	 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['emp_name']=$row_name->name;	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
	 
	 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('doctor_id',$empid);	 
//	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount_diagnose !=','0');			 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('doctor_id',$empid); 
//	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount_diagnose !=','0');	 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		 
				 
	$this->load->view('hms/print_report_date_wise_diagnos_new',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	} 
	} 
	 
	 
	public function print_report_date_emp_hospital2() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4); 
	$zone=$this->uri->segment(5);	 
//	$data['disper']=$this->uri->segment(6);	 
//	$data['disperrt']=$this->uri->segment(7);	 
//	$pathlogy=$this->uri->segment(8);					 
	 
	 
	$this->db->where('afid',$aid); 
$this->db->where('zone_id',$zone); 
	$data['hms_hospital']=$this->db->get('hms_hospital'); 
	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
	 
	 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('hospitalid',$empid);	 
//	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount !=','0');				 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('hospitalid',$empid); 
//	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount !=','0');		 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');											 
				 
	$this->load->view('hms/print_report_date_wise_hospital_new',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	} 
	} 
	 
	 
	public function print_report_date_emp_diagnos_all_hospital2() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4); 
	$zone=$this->uri->segment(5); 
$data['fdate']	=$fdate; 
$data['tdate']=$tdate; 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('zone_id',$zone); 
	$this->db->order_by('id','asc');	 
	$data['hms_hospital']=$this->db->get('hms_hospital');	 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('hospitalid',$empid);	 
//	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount_diagnose !=','0');					 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('hospitalid',$empid); 
//	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount_diagnose !=','0');			 
	$this->db->group_by('id');	 
	$data['hms_opd_patient111']=$this->db->get('hms_opd_patient'); 
		 
				 
	$this->load->view('hms/print_report_date_wise_diagnos_hospital_new',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	} 
	} 
	 
	 
   public function test_report() 
    { 
 
	$this->load->helper('url'); 
	$this->load->library('session');	 
	$this->load->view('hms/view_test_report_count'); 
 
   } 
    
    
    
   public function print_report_date_test_count() 
   { 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4); 
         $afid=$this->get_affiliate();		 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate);				 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
 
	 
	$this->db->where('test_parient','0');	 
	$this->db->order_by('id','asc'); 
	$data['test_name']=$this->db->get('ho_m_test_master');	 
	 
	 
	 
	$this->db->where('dig_parient !=','0');	 
	$this->db->order_by('id','asc'); 
	$data['diagnos_name']=$this->db->get('hms_dignos_master');		 
	 
	$this->db->where('affiliate_id',$afid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');				 
	$this->load->view('hms/print_report_test_cont',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	}    
    
    
    
   } 
    
    
  	public function view_day_report_user() 
   		{ 
   		$this->load->helper('url'); 
   		$this->load->library('session'); 
   		$aid=$this->get_affiliate(); 
   	 
   	        $this->db->where('afid',$aid); 
   		$this->db->order_by('name','asc'); 
   		$data['hms_doctor']=$this->db->get('hms_doctor'); 
   		 
   		$this->db->where('afid',$aid); 
   		$data['hms_pathology']=$this->db->get('hms_pathology');		 
   		 
   		$this->load->view('hms/view_doctor_report_user',$data);	 
   		} 
		    
	public function print_report_date_emp_first_user() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4); 
	$empid=$this->uri->segment(5);	 
	$pathlogy=$this->uri->segment(6);				 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('doctor_id',$empid);	 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['emp_name']=$row_name->name;	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pathlogy);	 
	$data['center']=$this->db->get('hms_pathology'); 
	foreach($data['center']->result() as $row_center) 
		{ 
		break; 
		} 
	$data['center_name']=$row_center->pathology_name;	 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('doctor_id',$empid); 
	$this->db->where('collection_code',$pathlogy);				 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('doctor_id',$empid); 
	$this->db->where('collection_code',$pathlogy);	 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		 
				 
	$this->load->view('hms/print_report_date_wise_first_user',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	} 
	} 
	 
			     	 
	public function print_report_date_emp_first_diagnos_user() 
	{ 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$fdate=$this->uri->segment(3); 
	$tdate=$this->uri->segment(4); 
	$empid=$this->uri->segment(5);	 
	$pathlogy=$this->uri->segment(6);				 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('doctor_id',$empid);	 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['emp_name']=$row_name->name;	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
	 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('id',$pathlogy);	 
	$data['center']=$this->db->get('hms_pathology'); 
	foreach($data['center']->result() as $row_center) 
		{ 
		break; 
		} 
	$data['center_name']=$row_center->pathology_name;	 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('doctor_id',$empid); 
	$this->db->where('collection_code',$pathlogy);				 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('doctor_id',$empid); 
	$this->db->where('collection_code',$pathlogy);	 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		 
				 
	$this->load->view('hms/print_report_date_wise_first_diagno_user',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	} 
	} 
	 
 
 
    
  	public function view_todayday_report_dcuser() 
   		{ 
   		$this->load->helper('url'); 
   		$this->load->library('session'); 
   		$aid=$this->get_affiliate(); 
   	 
   	        $this->db->where('afid',$aid); 
   		$this->db->order_by('name','asc'); 
   		$data['hms_doctor']=$this->db->get('hms_doctor'); 
   		 
   		$this->db->where('afid',$aid); 
   		$data['hms_pathology']=$this->db->get('hms_pathology');		 
   		 
   		$this->load->view('hms/view_doctor_todaydcreport_user',$data);	 
   		} 
 
	 
     public function print_report_today_dcs() 
     { 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
//	$fdate=date('Y-m-d'); 
//	$tdate=date('Y-m-d'); 
	$zone=$this->uri->segment(3);	 
	$fdate=$this->uri->segment(4);	 
	$tdate=$this->uri->segment(5);	 
//	$pathlogy=$this->uri->segment(8);					 
	 
	 
	$this->db->where('afid',$aid); 
//	$this->db->where('zone_id',$zone);	 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['emp_name']=$row_name->name;	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
	 
	 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('doctor_id',$empid);	 
//	$this->db->where('collection_code',$pathlogy); 
	$this->db->where('tot_amount !=','0');				 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('doctor_id',$empid); 
//	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount !=','0');		 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('doctor_id',$empid); 
//	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount_diagnose !=','0');	 
	$this->db->group_by('id');	 
	$data['hms_opd_patient4']=$this->db->get('hms_opd_patient'); 
	 
		 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		 
				 
	$this->load->view('hms/print_report_dc_today',$data);	 
	 
				 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	} 
 
      } 
       
       
      public function print_report_today_dcs_diagnos() 
      { 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
//	$fdate=date('Y-m-d'); 
//	$tdate=date('Y-m-d'); 
	$zone=$this->uri->segment(3);	 
	$fdate=$this->uri->segment(4);	 
	$tdate=$this->uri->segment(5);	 
//	$pathlogy=$this->uri->segment(8);					 
	 
	 
	$this->db->where('afid',$aid); 
//	$this->db->where('zone_id',$zone);	 
	$data['hms_doctor']=$this->db->get('hms_doctor'); 
	foreach($data['hms_doctor']->result() as $row_name) 
		{ 
		break; 
		} 
	$data['emp_name']=$row_name->name;	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
	 
	 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('doctor_id',$empid);	 
//	$this->db->where('collection_code',$pathlogy); 
	$this->db->where('tot_amount_diagnose !=','0');				 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('doctor_id',$empid); 
//	$this->db->where('collection_code',$pathlogy);	 
//	$this->db->where('tot_amount !=','0');		 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('doctor_id',$empid); 
//	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount_diagnose !=','0');	 
	$this->db->group_by('id');	 
	$data['hms_opd_patient4']=$this->db->get('hms_opd_patient'); 
	 
		 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		 
				 
	$this->load->view('hms/print_report_dc_today_diagnos',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	}       
       
      } 
       
       
  public function print_report_today_dcs_hospital() 
  { 
	$this->load->helper('url'); 
	$this->load->library('session'); 
	$aid=$this->get_affiliate(); 
	$zone=$this->uri->segment(3); 
	$fdate=$this->uri->segment(4); 
	$tdate=$this->uri->segment(5); 
		 
//	$data['disper']=$this->uri->segment(6);	 
//	$data['disperrt']=$this->uri->segment(7);	 
//	$pathlogy=$this->uri->segment(8);					 
	 
	 
	$this->db->where('afid',$aid); 
//$this->db->where('zone_id',$zone); 
	$data['hms_hospital']=$this->db->get('hms_hospital'); 
	 
	$data['fdate']=$fdate; 
	$data['tdate']=$tdate; 
	 
	 
		 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
	$this->db->where('tot_amount !=','0');				 
	$data_count=$this->db->count_all_results('hms_opd_patient'); 
	if($data_count>0) 
	{ 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('hospitalid',$empid); 
//	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount !=','0');		 
	$this->db->group_by('id');	 
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient'); 
	 
	$this->db->where('afid',$aid); 
	$this->db->where('entry_date >=',$fdate);	 
	$this->db->where('entry_date <=',$tdate); 
//	$this->db->where('doctor_id',$empid); 
//	$this->db->where('collection_code',$pathlogy);	 
	$this->db->where('tot_amount_diagnose !=','0');	 
	$this->db->group_by('id');	 
	$data['hms_opd_patient4']=$this->db->get('hms_opd_patient');	 
	 
	 
	$this->db->where('affiliate_id',$aid); 
	$data['manage_affiliate']=$this->db->get('manage_affiliate');											 
				 
	$this->load->view('hms/print_report_dc_today_hospital',$data);					 
          } 
	else 
	{ 
	echo 'Record not Found'; 
	}   
   
  }    												       				 
	      			 								    	      						  		  		      		      	 	   		  			 
} 
 ?>

Did this file decode correctly?

Original Code

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class hms_admin extends CI_Controller {
	public function index()
	{
		$this->load->library('session');
		$this->load->helper('url');
		$this->load->view('hms/hms_menu');

	}
	
	
	public function index_user()
	{
		$this->load->library('session');
		$this->load->helper('url');
		$this->load->view('hms/hms_menu_user');

	}
	
	public function dashboard()
	{
		$this->load->library('session');
		$this->load->helper('url');
		$this->load->view('hms/dashboard.php');

	}	
	
		

	public function get_affiliate()
	{
		$this->load->library('session');
		$this->load->helper('url');
		$id=$this->session->userdata('uname');
		$this->db->where('e_uname',$id);
		$data['menu']=$this->db->get('manage_employees');
		foreach($data['menu']->result() as $row)
		{
		break;
		}
		$aid=$row->e_affiliateid;
		return $aid;
	}
	public function get_affiliatename()
	{
		$this->load->library('session');
		$this->load->helper('url');
		$id=$this->session->userdata('uname');
		$this->db->where('e_uname',$id);
		$data['menu']=$this->db->get('manage_employees');
		foreach($data['menu']->result() as $row)
		{
		break;
		}
		$aid=$row->e_affiliateid;
		$this->db->where('affiliate_id',$aid);
		$data['anm']=$this->db->get('manage_affiliate');
		foreach($data['anm']->result() as $row)
		{
		break;
		}
		$anm=$row->affiliate_name;
		return $anm;
	}
	public function get_af_emp_id()
	{
		$this->load->library('session');
		$this->load->helper('url');
		$id=$this->session->userdata('e_email');
		$this->db->where('e_email',$id);
		$data['emp_data']=$this->db->get('manage_employees');
		foreach($data['emp_data']->result() as $row)
		{
		$empid=$row->emp_info_id;
		return $empid;
		}
		
	}
	
	
	public function change_password()
	{
	$this->load->helper('url');
 	$this->load->library('session');
 	$this->load->database();
	$enpid=$this->get_af_emp_id();	
	
	$this->db->where('emp_info_id',$enpid);
	$data['manage_employees']=$this->db->get('manage_employees');
		 	
	$data['empid']=$enpid;
  	$this->load->view('hms/change_password',$data);	
	}
	
	
  public function edit_password_record()
  {
	$this->load->library('session');
 	$this->load->helper('url');
  	$row_id=$this->input->post('row_id');
 	$this->e_password=$this->input->post('new_pass');
	
        $this->db->where('emp_id',$row_id);			
	$this->db->update('manage_employees',$this);  	 
 	echo 'Record Updated';  
  
  }	
	

public function zone_master()
{
	$this->load->helper('url');
	$this->load->library('session');
	//$aid=$this->get_affiliate();
	

	$data['hms_zone_master']=$this->db->get('hms_zone_master');	
	$this->load->view('hms/zone_master',$data); 
}

	public function add_zone_record()
	{
	$this->load->helper('url');
	$this->load->library('session');
 	$this->zone_name=$this->input->post('zonename');

    	 $this->db->insert('hms_zone_master',$this);
        echo 'Recod Has Been Saved';
	}




	
	
public function diagnos_master()
{
	$this->load->helper('url');
	$this->load->library('session');
	//$aid=$this->get_affiliate();
	
	$this->db->where('dig_parient','0');	
	//$this->db->order_by('exam_cat_parent');
	$data['kk']=$this->db->get('hms_dignos_master');
$this->db->where('dig_parient','0');
	$data['test_name']=$this->db->get('hms_dignos_master');	
	$this->load->view('hms/diagnos_master',$data); 
}

	public function add_diagnose_record()
	{
	$this->load->helper('url');
	$this->load->library('session');
 	$this->dig_title=$this->input->post('testname');
	 $this->dig_parient=$this->input->post('test_parient');
	$this->amount=$this->input->post('testamt');
	$this->status=$this->input->post('status');
    	 $this->db->insert('hms_dignos_master',$this);
        echo 'Recod Has Been Saved';
	}
	
	public function edit_diagnose()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$id=$this->uri->segment(3);
	$this->db->where('id',$id);
	$data['ep_exam1']=$this->db->get('hms_dignos_master');
	$this->db->where('dig_parient','0');
	$data['ep_exam12']=$this->db->get('hms_dignos_master');
	$this->load->view('hms/edit_diagnos_master',$data);;
	}
	
	public function update_diagnose_record()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$tid=$this->input->post('id');
 	$this->dig_title=$this->input->post('testname');
	 $this->dig_parient=$this->input->post('test_parient');
	$this->amount=$this->input->post('testamt');
	$this->status=$this->input->post('status');	 
	$this->db->where('id',$tid);
    	 $this->db->update('hms_dignos_master',$this);
        echo 'Recod Has Been Updated';	
	}
	public function delete_diagnose()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$id=$this->uri->segment(3);
	$this->db->where('id',$id);
	$this->db->delete('hms_dignos_master');
 	$this->diagnos_master();
	}
	
	
	
	public function assign_patient_test_fordiagnouse()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	foreach($data['hms_opd_patient']->result() as $row)
	{
	break;
	}
	$data['phone']=$row->phone;	
	$data['date_day']=$row->entry_date;
	$data['doctor_id']=$row->doctor_id;
	$data['pathlogu_name']=$row->collection_code;
	$data['hospiatal_name']=$row->hospitalid;				
	
//	$this->db->where('afid',$aid);	
//	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$this->db->where('dig_parient',0);
	$this->db->order_by('id','asc');
	$data['test_name']=$this->db->get('hms_dignos_master');	
	
	$this->db->order_by('id','asc');	
       	$data['test_name2']=$this->db->get('hms_dignos_master');	
      	 
	       $date_day=date('Y-m-d');
	       
	     //  $data['date_day']=$date_day;
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);		
	$this->db->order_by('enter_date','desc');	
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test_diagnose');	
	
	$this->db->where('afid',$aid);	
	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$this->db->where('afid',$aid);	
	$data['hms_hospital']=$this->db->get('hms_hospital');				
	$this->load->view('hms/assign_patient_test_for_diagnouse',$data);	
        }
	else
	{
	echo 'Record not found';
	}
	}
	
	
	public function delete_opd_test_diagnose()
	{
 	$this->load->library('session');
         $this->load->helper('url');
 	$aid=$this->get_affiliate();
 	$id=$this->uri->segment(3);
	$pid=$this->uri->segment(4);	 
 	$this->db->where('test_id',$id);
	$this->db->where('patient_id',$pid);	 
 	$this->db->where('afid',$aid);
 	$this->db->delete('hms_patient_assign_test_diagnose');
 	echo 'Record Deleted';
	}
	
	
	
	public function delete_opd_test_rate_diagnos()
	{
 	$this->load->library('session');
         $this->load->helper('url');
 	$aid=$this->get_affiliate();
 	$id=$this->uri->segment(3);
	$pid=$this->uri->segment(4);	 
	$this->db->where('test_pid',$id);
	$this->db->where('patient_id',$pid);				
	$data_count=$this->db->count_all_results('hms_opd_test_rate_diagnose');
	if($data_count>0)
	{	 
 	$this->db->where('test_pid',$id);
	$this->db->where('patient_id',$pid);	 
 	$this->db->delete('hms_opd_test_rate_diagnose');
 	echo 'Record Deleted';
	 }
	 else
	 {
	 
	 }	
	 
	}		
	
	public function add_pasient_test_diagnos_val()
 	{
      		$this->load->library('session');
        	$this->load->helper('url');
		$afid=$this->get_affiliate();
		$empid=$this->get_af_emp_id();		
		$ques=$this->input->post('value');
		$qui=explode(',',$ques);
		$t=0;
		for($t1=0;Count($qui)>$t1;$t1++)
		{
		
	//	$this->db->where('test_id',$qui[$t]);	
		
		$patient_id=$this->input->post('patient_name');
		$test_parient=$this->input->post('test_parient');
		$this->db->where('patient_id',$patient_id);
	//	$this->db->where('test_parient',$test_parient);
		$this->db->where('test_id',$qui[$t]);
		$data['lastan1']=$this->db->count_all_results('hms_patient_assign_test_diagnose');
		
	
		if($data['lastan1']>=1)
		{
	
		   //echo $qui[$t].'Test already assigned ';    
		   //echo'Test already assigned ';
		   //	break;  
		   
		}
		else
	      {
               	$this->load->database();
               	$this->test_id=$qui[$t]; 	
		$this->patient_id=$this->input->post('patient_name');
		$this->enter_date=$this->input->post('e_date');
		$this->test_parient=$this->input->post('test_parient');
		//$this->root_id=$this->input->post('root_name');
	        
		$this->doctor_id=$this->input->post('docid');
		$this->hospital_name=$this->input->post('hospital_name');
		$this->pathology_center=$this->input->post('pathlogy_name');			
		
		$this->afid=$afid;
		$this->emp_id=$empid;
		$this->db->set('status','1');			
               	$this->db->insert('hms_patient_assign_test_diagnose',$this);
		}
               	$t++;
                }
                echo 'Patient Assigned Test';  
      	}
	      
	      
	      
	public function print_opd_patient_test_report_sleep_day_diagnose()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	$today=$this->uri->segment(4);
	
	$data['today']=$today;
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('enter_date',$today);	
	$data_count=$this->db->count_all_results('hms_patient_assign_test_diagnose');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
//	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('date_test',$today);		
//	$this->db->group_by('test_parient');
	$data['hms_opd_test_rate']=$this->db->get('hms_opd_test_rate_diagnose');		
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('enter_date',$today);		
//	$this->db->group_by('test_parient');
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test_diagnose');	
	foreach($data['hms_opd_patient']->result() as $row_p)
	{
	break;
	}
	
	
	$this->db->where('afid',$aid);
	$this->db->where('doctor_id',$row_p->doctor_id);
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_d)
	{
	break;
	}		
	$data['doctor_name']=$row_d->name;
	
	
	
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('enter_date',$today);	
	$this->db->group_by('patient_id');	
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test_diagnose');
	foreach($data['hms_opd_assign_test_pat']->result() as $row)
	{
	break;
	}
	$data['test_date']=$row->enter_date;			
	
	
	
	
//	$this->db->where('dig_parient !=',0);
	$data['test_name']=$this->db->get('hms_dignos_master');	
	

	
//	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	
	
				
	$this->load->view('hms/print_opd_diagnose_sleep',$data);	
          }
	else
	{
	echo 'Record not found';
	}	
	}	      	
	
	public function add_pasient_opd_diagnose_test()
 	{
  
		
	$this->load->library('session');
        	$this->load->helper('url');
		$afid=$this->get_affiliate();
		$empid=$this->get_af_emp_id();

		$ques=$this->input->post('su_id');
		$qui=explode(',',$ques);
	        $value_qui=$this->input->post('mark_val');
		$val_qui=explode('^',$value_qui);
		
		$t=1;
       		for($t1=1;Count($qui)>$t1;$t1++)
        	{
         	 $this->load->database();
		$this->test_val=$val_qui[$t]; ;	  
       		$this->test_id=$qui[$t];
		$this->patient_id=$this->input->post('patient_name');
		$this->enter_date=$this->input->post('e_date');
		$this->pathology_center=$this->input->post('pathlogy_name');
	        $this->hospital_name=$this->input->post('hospital_name');
                $this->doctor_id=$this->input->post('docid');		
		$this->afid=$afid;
		$this->emp_id=$empid;
		$this->db->set('status','1');			
               	$this->db->insert('hms_patient_assign_test_diagnose',$this);			
			
		$t++;
		}		
                echo 'Patient Assigned Test';  
      	}
	      
public function print_opd_dignouse_sleep()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$patient_id=$this->uri->segment(3);
	$en_date=$this->uri->segment(4);	
	$this->db->where('afid',$aid);	
	$this->db->where('id',$patient_id);
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$patient_id);
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$patient_id);
	$this->db->where('enter_date',$en_date);
	$this->db->group_by('patient_id');		
	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test_diagnose');
	
	$this->db->where('afid',$aid);	
	$data['test_name']=$this->db->get('hms_dignos_master');	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');
      	 
	       	 
       $data['today']=$en_date;	
     	
       $data['afid']=$aid;
       	$this->db->where('afid',$aid);	       
       	$data['hms_pathology']=$this->db->get('hms_pathology');	
      	 
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	
 
        			
	$this->load->view('hms/print_diagnouse_test_sleep',$data);	
          }
	else
	{
	echo 'Record not found';
	} 
} 	      
	      
public function view_assign_patient_test_diagnose()
{
		$this->load->library('session');
         	$this->load->helper('url');
 		$afid=$this->get_affiliate();
 		//$pid=$this->uri->segment(3);
 	$this->db->where('afid',$afid);	
 	$data_count=$this->db->count_all_results('hms_patient_assign_test_diagnose');
 	if($data_count>0)
 	{
	$limit=30;
	$start=$this->uri->segment(3);
	$start1=$start*$limit;
	 		
 	$this->db->where('afid',$afid);	
 	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
 	
 //	$this->db->where('test_parient !=',0);
 	$data['test_name']=$this->db->get('hms_dignos_master');	
	 
	$this->db->where('afid',$afid);
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test_diagnose',$limit,$start1);	 
 
 	$this->db->where('afid',$afid);	
 	$data['hms_pathology']=$this->db->get('hms_pathology');	
	 
	$this->db->where('afid',$afid);
	$data['total']=$this->db->count_all_results('hms_patient_assign_test_diagnose');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
 				
 	$this->load->view('hms/view_patient_assign_test_diagnose',$data);	
         }
 	else
 	{
 	echo 'Record not found';
 	}
}
	
	public function add_department()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->db->where('afid',$aid);
	$this->db->where('parient_id','0');
	$data['department']=$this->db->get('hms_department');
	
	$this->db->where('afid',$aid);
	$data['hms_department']=$this->db->get('hms_department');	
	$this->load->view('hms/add_department',$data);  
	}
	
	public function save_department()
	{
	$this->load->library('session');
	$this->load->helper('url');
	$aid=$this->get_affiliate();
	$this->name=$this->input->post('dep_name');
	$this->parient_id=$this->input->post('parient_dep');
	$this->description=$this->input->post('description');
	$this->afid=$this->get_affiliate();
	$this->db->insert('hms_department',$this);	
	echo 'Record Added';	
	}
	
	
	public function edit_department()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$row_id=$this->uri->segment(3);
	$this->db->where('afid',$aid);
	$this->db->where('parient_id','0');
	$data['department']=$this->db->get('hms_department');
	
	$this->db->where('afid',$aid);
	$this->db->where('dep_id',$row_id);
	$data['hms_department']=$this->db->get('hms_department');	
	$this->load->view('hms/edit_department',$data);  

	}
	
	
	public function update_department()
	{
	$this->load->library('session');
	$this->load->helper('url');
	$aid=$this->get_affiliate();
	
	$dep_id=$this->input->post('dep_id');	
	$this->name=$this->input->post('dep_name');
	$this->parient_id=$this->input->post('parient_dep');
	$this->description=$this->input->post('description');
	$this->db->where('dep_id',$dep_id);
	$this->db->where('afid',$aid);
	$this->db->update('hms_department',$this);	
	echo 'Record Updated';
	}
	
	public function delete_department()
	{
	$this->load->library('session');
        $this->load->helper('url');
	$aid=$this->get_affiliate();
	$dep_id=$this->uri->segment(3);
	$this->db->where('dep_id',$dep_id);
	$this->db->where('afid',$aid);
	$this->db->delete('hms_department');
	echo 'Record Deleted';
	}			
	public function view_department()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->load->database();
	$this->db->where('afid',$aid);
	$data_count=$this->db->count_all_results('hms_department');
	if($data_count>0)
	{		
	$limit=80;
	$start=$this->uri->segment(3);
	$start1=$start*$limit;
//	$this->db->where('afid',$aid);
//	$data['hms_department']=$this->db->get('hms_department',$limit,$start1);

	$this->db->where('afid',$aid);
	$this->db->where('parient_id','0');
	$this->db->order_by('dep_id','asc');
	$data['hms_department_parient']=$this->db->get('hms_department',$limit,$start1);
		
	$this->db->where('afid',$aid);
	$this->db->where('parient_id','0');
	$data['hms_department_all']=$this->db->get('hms_department');	
	
	$this->db->where('afid',$aid);
	$data['total']=$this->db->count_all_results('hms_department');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_department',$data);	
          }
	else
	{
	echo 'Record not found';
	}
	}
	
	public function view_department_second()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->load->database();
	$this->db->where('afid',$aid);
	$data_count=$this->db->count_all_results('hms_department');
	if($data_count>0)
	{		
	$limit=80;
	$start=$this->uri->segment(3);
	$start1=$start*$limit;
//	$this->db->where('afid',$aid);
//	$data['hms_department']=$this->db->get('hms_department',$limit,$start1);

	$this->db->where('afid',$aid);
	$this->db->where('parient_id','0');
	$this->db->order_by('dep_id','asc');
	$data['hms_department_parient']=$this->db->get('hms_department',$limit,$start1);
		
	$this->db->where('afid',$aid);
	$this->db->where('parient_id','0');
	$data['hms_department_all']=$this->db->get('hms_department');	
	
	$this->db->where('afid',$aid);
	$data['total']=$this->db->count_all_results('hms_department');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_department_second',$data);	
          }
	else
	{
	echo 'Record not found';
	}

	}	
	
	
	public function search_sub_dep()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$dep_id=$this->uri->segment(3);
	$start=$this->uri->segment(4);	
	$this->load->database();
	$this->db->where('afid',$aid);
	//$this->db->where('parient_id','0');
	$data_count=$this->db->count_all_results('hms_department');
	if($data_count>0)
	{		
	$limit=50;

	$start1=$start*$limit;
	$this->db->where('afid',$aid);
	$this->db->where('parient_id',$dep_id);
	$this->db->order_by('dep_id','asc');
	$data['hms_department']=$this->db->get('hms_department',$limit,$start1);

	$this->db->where('afid',$aid);
	$this->db->where('parient_id','0');
	$this->db->order_by('dep_id','asc');
	$data['hms_department_parient']=$this->db->get('hms_department');
		
	$this->db->where('afid',$aid);
	$this->db->where('parient_id','0');
	$data['hms_department_all']=$this->db->get('hms_department');
		
	$this->db->where('afid',$aid);
	$this->db->where('parient_id',$dep_id);
	$this->db->order_by('dep_id','asc');	
	$data['total']=$this->db->count_all_results('hms_department');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$data['dep_id']=$dep_id;
	$this->load->view('hms/view_sub_department',$data);	
          }
	else
	{
	echo 'Record not found';
	}	
	}	
	
	
	
	
	public function add_doctor()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->db->where('afid',$aid);
	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	
	$data['hms_zone_master']=$this->db->get(' hms_zone_master');			
	$this->load->view('hms/add_doctor',$data);
	}
	
public function save_doctor()
{
	$this->load->library('session');
	$this->load->helper('url');
	$aid=$this->get_affiliate();
	$this->name=$this->input->post('doc_name');
//	$this->email=$this->input->post('email');
//	$this->password=$this->input->post('password');
	$this->address=$this->input->post('address');
	$this->phone=$this->input->post('phone');
	$this->degree=$this->input->post('qulification');
	$this->per=$this->input->post('perst');	
	$this->per_rt=$this->input->post('perrt');	
	$this->digper=$this->input->post('digperst');
	$this->dis_rt=$this->input->post('digperrt');	
	$this->center_id=$this->input->post('pathlogy');
	$this->zone_id=$this->input->post('zone');
				
	$this->afid=$aid;
	$this->db->insert('hms_doctor',$this);	
	echo 'Record Added';
}


	public function update_doctor()
	{
	$this->load->library('session');
	$this->load->helper('url');
	$aid=$this->get_affiliate();
	$doc_id=$this->input->post('doc_id');	
	$this->name=$this->input->post('doc_name');
	$this->address=$this->input->post('address');
	$this->phone=$this->input->post('phone');
	$this->degree=$this->input->post('qulification');
	$this->per=$this->input->post('perst');	
	$this->per_rt=$this->input->post('perrt');	
	$this->digper=$this->input->post('digperst');
	$this->dis_rt=$this->input->post('digperrt');
	$this->center_id=$this->input->post('pathlogy');
	$this->zone_id=$this->input->post('zone');					
	$this->db->where('doctor_id',$doc_id);
	$this->db->where('afid',$aid);
	$this->db->update('hms_doctor',$this);	
	echo 'Record Updated';
	}
	
    public function edit_doctor()
    {
 	$this->load->helper('url');
    	$this->load->library('session');
    	$aid=$this->get_affiliate();
	    
    //	$this->db->where('afid',$aid);
    //	$data['department']=$this->db->get('hms_department');
	    
	    	    
	$doctor_id=$this->uri->segment(3);
	$this->db->where('doctor_id',$doctor_id);
	$this->db->where('afid',$aid);	
    	$data['hms_doctor']=$this->db->get('hms_doctor');
	    
	$this->db->where('afid',$aid);
	$data['hms_pathology2']=$this->db->get('hms_pathology');
	$data['hms_zone_master']=$this->db->get(' hms_zone_master');			    		
    	$this->load->view('hms/edit_doctor',$data);   
    }

   
 	public function delete_doctor()
    	{
    	$this->load->library('session');
        $this->load->helper('url');
    	$aid=$this->get_affiliate();
    	$doc_id=$this->uri->segment(3);
    	$this->db->where('doctor_id',$doc_id);
    	$this->db->where('afid',$aid);
    	$this->db->delete('hms_doctor');
    	echo 'Record Deleted';
    	} 
	    
	      
	public function view_doctor()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->load->database();
	$this->db->where('afid',$aid);
	$data_count=$this->db->count_all_results('hms_doctor');
	if($data_count>0)
	{		
	$limit=50;
	$start=$this->uri->segment(3);
	$start1=$start*$limit;
//	$this->db->where('afid',$aid);
//	$data['hms_department']=$this->db->get('hms_department',$limit,$start1);
	$this->db->where('afid',$aid);
	$this->db->order_by('name','asc');
	$data['hms_doctor']=$this->db->get('hms_doctor');


	$this->db->where('afid',$aid);
	$this->db->order_by('name','asc');
	$data['hms_doctor_list']=$this->db->get('hms_doctor');

	$this->db->where('afid',$aid);
	$data['hms_pathology']=$this->db->get('hms_pathology');
	
	$data['hms_zone_master']=$this->db->get(' hms_zone_master');
			
	$this->db->where('afid',$aid);
	$data['total']=$this->db->count_all_results('hms_doctor');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_doctor',$data);	
          }
	else
	{
	echo 'Record not found';
	}

	}
	


	public function view_doctor_second()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->load->database();
	$this->db->where('afid',$aid);
	$data_count=$this->db->count_all_results('hms_doctor');
	if($data_count>0)
	{		
	$limit=10;
	$start=$this->uri->segment(3);
	$start1=$start*$limit;
//	$this->db->where('afid',$aid);
//	$data['hms_department']=$this->db->get('hms_department',$limit,$start1);

	$this->db->where('afid',$aid);
	$this->db->order_by('name','asc');
	$data['hms_doctor_list']=$this->db->get('hms_doctor',$limit,$start1);
		
	
	$this->db->where('afid',$aid);
	$data['total']=$this->db->count_all_results('hms_doctor');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_doctor_second',$data);	
          }
	else
	{
	echo 'Record not found';
	}

	}
	
public function doctor_record()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$docid=$this->uri->segment(3);	
	$this->db->where('afid',$aid);
	$this->db->where('doctor_id',$docid);
	$data_count=$this->db->count_all_results('hms_doctor');
	if($data_count>0)
	{	
	$this->db->where('afid',$aid);
	$this->db->where('doctor_id',$docid);	
	$this->db->order_by('doctor_id','asc');
	$data['hms_doctor_list']=$this->db->get('hms_doctor');
	$this->load->view('hms/view_doctor_record',$data);	
	}
	else
	{
	echo 'Record Not fond';
	}
}


public function doctor_record_center()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$docid=$this->uri->segment(3);	
	$this->db->where('afid',$aid);
	$this->db->where('center_id',$docid);
	$data_count=$this->db->count_all_results('hms_doctor');
	if($data_count>0)
	{	
	$this->db->where('afid',$aid);
	$this->db->where('center_id',$docid);	
	$this->db->order_by('name','asc');
	$data['hms_doctor_list']=$this->db->get('hms_doctor');
	$this->load->view('hms/view_doctor_record',$data);	
	}
	else
	{
	echo 'Record Not fond';
	}
}	
	
	public function call_doctor_dep_wise()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->load->database();
	$dep_id=$this->uri->segment(3);	
	$this->db->where('afid',$aid);
	$data_count=$this->db->count_all_results('hms_doctor');
	if($data_count>0)
	{		
	$limit=10;
	$start=$this->uri->segment(4);
	$start1=$start*$limit;


	$this->db->where('afid',$aid);
	$this->db->where('department_id',$dep_id);	
	$this->db->order_by('doctor_id','asc');
	$data['hms_doctor_list']=$this->db->get('hms_doctor',$limit,$start1);
		
	$this->db->where('afid',$aid);
	$data['hms_department_all']=$this->db->get('hms_department');	
	$this->db->where('afid',$aid);
	$data['total']=$this->db->count_all_results('hms_doctor');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_doctor_second',$data);	
          }
	else
	{
	echo 'Record not found';
	}

	}	
	
	
		
	public function add_nurse()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->db->where('afid',$aid);
	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$this->load->view('hms/add_nurse',$data);
	}
	
	public function edit_nurse()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$nurse_id=$this->uri->segment(3);	
	$this->db->where('afid',$aid);
	$this->db->where('nurse_id',$nurse_id);	
	$this->db->order_by('nurse_id','asc');
	$data['hms_nurse']=$this->db->get('hms_nurse');	
	
	$this->db->where('afid',$aid);
	$data['hms_pathology']=$this->db->get('hms_pathology');		
	$this->load->view('hms/edit_nurse',$data);
	}	
	
	public function save_nurse()
	{
	$this->load->library('session');
	$this->load->helper('url');
	$aid=$this->get_affiliate();
	$this->name=$this->input->post('doc_name');
//	$this->email=$this->input->post('email');
	$this->degree=$this->input->post('qulification');
	$this->address=$this->input->post('address');
	$this->phone=$this->input->post('phone');
	$this->center_id=$this->input->post('pathlogy');			
	$this->afid=$aid;
	$this->db->insert('hms_nurse',$this);	
	echo 'Record Added';
	}
	
	public function update_nurse()
	{
	$this->load->library('session');
	$this->load->helper('url');
	$aid=$this->get_affiliate();
	$nus_id=$this->input->post('nus_id');	
	$this->name=$this->input->post('doc_name');
//	$this->email=$this->input->post('email');
	$this->degree=$this->input->post('qulification');
	$this->address=$this->input->post('address');
	$this->phone=$this->input->post('phone');
	$this->center_id=$this->input->post('pathlogy');	
	$this->db->where('nurse_id',$nus_id);		
	$this->db->where('afid',$aid);
	$this->db->update('hms_nurse',$this);	
	echo 'Record Updated';
	}
	
	public function delete_nurse()
    	{
    	$this->load->library('session');
        $this->load->helper('url');
    	$aid=$this->get_affiliate();
    	$nurse_id=$this->uri->segment(3);
	$file_name=$this->uri->segment(4);	    
    	$this->db->where('nurse_id',$nurse_id);
    	$this->db->where('afid',$aid);
    	$this->db->delete('hms_nurse');
  
//unlink("application/affiliate_pic_real/".$file_name);
    
    	echo 'Record Deleted';
    	} 		
	public function view_nurse()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->load->database();
	$this->db->where('afid',$aid);
	$data_count=$this->db->count_all_results('hms_nurse');
	if($data_count<10)
	{		
	$limit=15;
	$start=$this->uri->segment(3);
	$start1=$start*$limit;
//	$this->db->where('afid',$aid);
//	$data['hms_department']=$this->db->get('hms_department',$limit,$start1);

	$this->db->where('afid',$aid);
	$this->db->order_by('nurse_id','asc');
	$data['hms_nurse_list']=$this->db->get('hms_nurse');
		
	$this->db->where('afid',$aid);
	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	
	$this->db->where('afid',$aid);
	$data['total']=$this->db->count_all_results('hms_nurse');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_nurse',$data);	
          }
	else
	{
	echo 'Record not found';
	}

	}
	
	public function view_nurse_second()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->load->database();
	$this->db->where('afid',$aid);
	$data_count=$this->db->count_all_results('hms_nurse');
	if($data_count>0)
	{		
	$limit=15;
	$start=$this->uri->segment(3);
	$start1=$start*$limit;
//	$this->db->where('afid',$aid);
//	$data['hms_department']=$this->db->get('hms_department',$limit,$start1);

	$this->db->where('afid',$aid);
	$this->db->order_by('nurse_id','asc');
	$data['hms_nurse_list']=$this->db->get('hms_nurse',$limit,$start1);
		
	
	$this->db->where('afid',$aid);
	$data['total']=$this->db->count_all_results('hms_nurse');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_nurse_second',$data);	
          }
	else
	{
	echo 'Record not found';
	}

	}				
		


	public function add_bed()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->db->where('afid',$aid);
	$this->db->where('parient_id','0');
	$data['department']=$this->db->get('hms_department');	
	$this->load->view('hms/add_bed',$data);
	}
	

	public function sub_dep()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$dep_id=$this->uri->segment(3);
	$this->load->database();
	$this->db->where('afid',$aid);
	$data_count=$this->db->count_all_results('hms_department');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('parient_id',$dep_id);
	$this->db->order_by('dep_id','asc');
	$data['hms_department_sub']=$this->db->get('hms_department');
	$this->load->view('hms/sub_department',$data);	
          }
	else
	{
	echo 'Record not found';
	}	
	}		
	
	
	public function add_opd_patient()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->db->where('afid',$aid);
	$this->db->order_by('name','asc');
	$data['hms_doctor']=$this->db->get('hms_doctor');
	
	$this->db->where('afid',$aid);
	$data['hms_nurse']=$this->db->get('hms_nurse');
	
	$this->db->where('afid',$aid);
	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$this->db->where('afid',$aid);
	$data['hms_hospital']=$this->db->get('hms_hospital');	
	
	$this->db->where('emp_aff_id',$aid);
	$data['emp_info_data']=$this->db->get('emp_info');	
	
		
	$date=date('y-m-d');
//	$this->db->where('entry_date', $date);
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count<=30000)
	{
	
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count<=30000)
	{
	$this->db->select_max('token_no');
	$this->db->where('afid',$aid);	
//	$this->db->where('entry_date',$date);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	foreach($data['hms_opd_patient']->result() as $row)
		{
	//	break;
		}
		
	$new_lot_id=$row->token_no;
	$ac_auto_no=$new_lot_id+1;		
	$data['toc_no']=$row->token_no+1;
	
	$chech_val=strlen($ac_auto_no);	
	if($chech_val<=1)
	{
	$data['regno']='ANG'.'869'.$ac_auto_no;		
	}
	else if($chech_val==2 || $chech_val >=2)	 
	{
	$data['regno']='ANG'.'869'.$ac_auto_no;	
	}
/*
<!--	else if($chech_val==3)	 
	{
	$data['toc_no']='AC'.'-'.$type.$year.'-'.$branch_code.'000'.$ac_auto_no;	 
	}
	else if($chech_val==4)	 
	{
	$data['toc_no']='AC'.'-'.$type.$year.'-'.$branch_code.'00'.$ac_auto_no;	
	}
	else if($chech_val==5)	 
	{
	$data['toc_no']='AC'.'-'.$type.$year.'-'.$branch_code.'0'.$ac_auto_no;
	}	
	else if($chech_val==6)	 
	{
	$data['toc_no']='AC'.'-'.$type.$year.'-'.$branch_code.$ac_auto_no;
	
	}--!>*/
	
			
	}
	else
	{
	$data['toc_no']=1;

	$data['regno']='ANG'.'869'.'1';  		
	}		
	$this->load->view('hms/add_opd_patient',$data);
	}
	else
	{
	
	}
	}	

	
	public function get_doctor_center()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$centerid=$this->uri->segment(3);

	$this->db->where('afid',$aid);
	$this->db->where('center_id',$centerid);
	$this->db->order_by('name','asc');
	$data['hms_doctor']=$this->db->get('hms_doctor');
	
	$this->db->where('afid',$aid);
	$this->db->where('center_id',$centerid);
	$this->db->order_by('name','asc');
	$data['hms_nurse']=$this->db->get('hms_nurse');		
	$this->load->view('hms/sub_doctor_name',$data);	
	}
	
	
	
	public function get_doctor_name()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$centerid=$this->uri->segment(3);

	$this->db->where('afid',$aid);
	$this->db->where('center_id',$centerid);
	$this->db->order_by('name','asc');
	$data['hms_doctor']=$this->db->get('hms_doctor');	
	$this->load->view('hms/center_doctor_name',$data);	
	}		
	
	
	public function doctor_charge()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$doctorid=$this->uri->segment(3);
	$this->load->database();
	$this->db->where('afid',$aid);
	$data_count=$this->db->count_all_results('hms_doctor');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('doctor_id',$doctorid);
//	$this->db->order_by('doctor_id','asc');
	$data['hms_doctor_sub']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor_sub']->result() as $row)
	{
	break;
	}
	$data['fee_charge']=$row->treatment_charge;
	$this->load->view('hms/sub_doctor_charge',$data);	
        }
	else
	{
	echo 'Record not found';
	}
	}
	


	public function save_opd_patient()
	{
	$this->load->library('session');
	$this->load->helper('url');
	$aid=$this->get_affiliate();
	$af_emp_id=$this->get_af_emp_id();
	$this->token_no=$this->input->post('tcno');
	$this->grno=$this->input->post('grno');	
	$this->patient_name=$this->input->post('patient_name');	
	$this->gender=$this->input->post('gender');
	$this->age=$this->input->post('age');	
	$this->phone=$this->input->post('phone');
	$this->doctor_id=$this->input->post('doctor');	
	$this->collection_code=$this->input->post('collectby');
	$this->pathlogy_sign=$this->input->post('pathology_doctor');	
	$this->entry_date=$this->input->post('date');
	$this->remarks=$this->input->post('remark');
	$this->clboy=$this->input->post('clboy');
	$this->hospitalid=$this->input->post('hospitalid');		
	
	$this->titlename=$this->input->post('titlename');
	$this->yearname=$this->input->post('yearname');
	$this->statusid=$this->input->post('statusid');
			
	date_default_timezone_set('Asia/Calcutta');
	$this->entry_date_time=date("h:i a");
	$this->opd_emp_id=$af_emp_id;		
	$this->afid=$aid;
	$this->db->insert('hms_opd_patient',$this);	
	echo 'Record Added';
	}
	



	public function add_view_opd_patient()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();

	
	$this->db->where('afid',$aid);
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$limit=150;
	$start=$this->uri->segment(3);
	$start1=$start*$limit;

	$this->db->where('afid',$aid);
	$this->db->order_by('id','desc');
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient',$limit,$start1);
	
	$this->db->where('afid',$aid);
	$data['hms_doctor']=$this->db->get('hms_doctor');
				
	$this->db->where('afid',$aid);
	$data['total']=$this->db->count_all_results('hms_opd_patient');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_opd_patient',$data);	
          }
	else
	{
	echo 'Record not found';
	}	
	
	}
	

	public function second_opd_patient()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->db->where('afid',$aid);
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$limit=1150;
	$start=$this->uri->segment(3);
	$start1=$start*$limit;

	$this->db->where('afid',$aid);
	$this->db->order_by('id','desc');
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient',$limit,$start1);
	
	$this->db->where('afid',$aid);
	$data['hms_doctor']=$this->db->get('hms_doctor');
				
	$this->db->where('afid',$aid);
	$data['total']=$this->db->count_all_results('hms_opd_patient');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_second_opd_patient',$data);	
          }
	else
	{
	echo 'Record not found';
	}
	
	}
	
	
	public function search_opd_patient_date()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);		
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);		
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$limit=150;
	$start=$this->uri->segment(5);
	$start1=$start*$limit;

	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->order_by('entry_date','desc');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');

	$this->db->where('afid',$aid);
	$data['hms_doctor']=$this->db->get('hms_doctor');
				
	$this->db->where('afid',$aid);
	$data['total']=$this->db->count_all_results('hms_opd_patient');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_second_opd_patient_date_wise',$data);	
          }
	else
	{
	echo 'Record not found';
	}	
	}	

	public function search_opd_patient_rego_wise()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$rego=$this->uri->segment(3);
//	$tdate=$this->uri->segment(4);		
	
	$this->db->where('afid',$aid);
	$this->db->where('phone',$rego);			
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$limit=150;
	$start=$this->uri->segment(5);
	$start1=$start*$limit;

	$this->db->where('afid',$aid);	
	$this->db->where('phone',$rego);		
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');

	$this->db->where('afid',$aid);
	$data['hms_doctor']=$this->db->get('hms_doctor');
				
	$this->db->where('afid',$aid);
	$this->db->where('phone',$rego);		
	$data['total']=$this->db->count_all_results('hms_opd_patient');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_second_opd_patient_date_wise',$data);	
          }
	else
	{
	echo 'Record not found';
	}	
	}

	public function print_opd_patient()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	foreach($data['hms_opd_patient']->result() as $row)
	{
	break;
	}	

	$this->db->where('afid',$aid);
	$this->db->where('doctor_id',$row->doctor_id);
	$data['hms_doctor']=$this->db->get('hms_doctor');

	foreach($data['hms_doctor']->result() as $row_doc)
	{
	break;
	}
$data['doctor_name']=$row_doc->name;		
	$this->db->where('afid',$aid);
	$this->db->where('parient_id !=',0);
	$this->db->where('dep_id !=',33);
	$this->db->where('dep_id !=',34);
//	$this->db->where('dep_id !=',35);	
//	$this->db->group_by('parient_id');		
	$data['hms_department']=$this->db->get('hms_department');	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	
	
				
//	$this->load->view('hms/print_opd_doctor_paper',$data);	
	$this->load->view('hms/print_opd_doctor_paper_new',$data);		
          }
	else
	{
	echo 'Record not found';
	}	
	}
	

	public function assign_patient_test()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	foreach($data['hms_opd_patient']->result() as $row)
	{
	break;
	}
	$data['phone']=$row->phone;	
	$data['date_day']=$row->entry_date;	
	
//	$this->db->where('afid',$aid);	
//	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$this->db->where('test_parient',0);
	$this->db->order_by('id','asc');
	$data['test_name']=$this->db->get('ho_m_test_master');	
	
	$this->db->order_by('id','asc');	
       	$data['test_name2']=$this->db->get('ho_m_test_master');	
      	 
	       $date_day=date('Y-m-d');
	       
	     //  $data['date_day']=$date_day;
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
//	$this->db->where('enter_date',$date_day);
	$this->db->where('test_panels','0');		
//----------------show amount with parient---

$this->db->group_by('test_parient');
//-------------------------------------------------		
	$this->db->order_by('enter_date','desc');	
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test');	
	
				
	$this->load->view('hms/assign_patient_test',$data);	
        }
	else
	{
	echo 'Record not found';
	}
	}	


	public function add_pasient_test()
 	{
      		$this->load->library('session');
        	$this->load->helper('url');
		$afid=$this->get_affiliate();
		$empid=$this->get_af_emp_id();		
		$ques=$this->input->post('value');
		$qui=explode(',',$ques);
		$t=0;
		for($t1=0;Count($qui)>$t1;$t1++)
		{
		
	//	$this->db->where('test_id',$qui[$t]);	
		
		$patient_id=$this->input->post('patient_name');
		$test_parient=$this->input->post('test_parient');
		$this->db->where('patient_id',$patient_id);
	//	$this->db->where('test_parient',$test_parient);
		$this->db->where('test_id',$qui[$t]);
		$data['lastan1']=$this->db->count_all_results('hms_patient_assign_test');
		
	
		if($data['lastan1']>=1)
		{
	
		   //echo $qui[$t].'Test already assigned ';    
		   //echo'Test already assigned ';
		   //	break;  
		   
		}
		else
	      {
               	$this->load->database();
               	$this->test_id=$qui[$t]; 	
		$this->patient_id=$this->input->post('patient_name');
		$this->enter_date=$this->input->post('e_date');
		$this->test_parient=$this->input->post('test_parient');
		$this->root_id=$this->input->post('root_name');
		$this->afid=$afid;
		$this->emp_id=$empid;
		$this->db->set('status','1');			
               	$this->db->insert('hms_patient_assign_test',$this);
		}
               	$t++;
                }
                echo 'Patient Assigned Test';  
      	}	
      
      
	 public function view_assign_patient_test()
 	{
 		$this->load->library('session');
         	$this->load->helper('url');
 		$afid=$this->get_affiliate();
 		//$pid=$this->uri->segment(3);
 	$this->db->where('afid',$afid);	
 	$data_count=$this->db->count_all_results('hms_patient_assign_test');
 	if($data_count>0)
 	{
	$limit=30;
	$start=$this->uri->segment(3);
	$start1=$start*$limit;
	 		
 	$this->db->where('afid',$afid);	
 	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
 	
 //	$this->db->where('test_parient !=',0);
 	$data['test_name']=$this->db->get('ho_m_test_master');	
	 
	$this->db->where('afid',$afid);
	$this->db->order_by('enter_date','desc');	
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test',$limit,$start1);	 
 
 	$this->db->where('afid',$afid);	
 	$data['hms_pathology']=$this->db->get('hms_pathology');	
	 
	$this->db->where('afid',$afid);
	$this->db->order_by('enter_date','desc');	
	$data['total']=$this->db->count_all_results('hms_patient_assign_test');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
 				
 	$this->load->view('hms/view_patient_assign_test',$data);	
         }
 	else
 	{
 	echo 'Record not found';
 	}
 
 	}     
      
      
  
	       
public function search_opd_patient_test_report_date()
{
       		$this->load->library('session');
               	$this->load->helper('url');
       		$afid=$this->get_affiliate();
       		//$pid=$this->uri->segment(3);
		$fdate=$this->uri->segment(3);
	     $tdate=$this->uri->segment(4);		             
       	$this->db->where('afid',$afid);	
	$this->db->where('enter_date >=',$fdate);	
	$this->db->where('enter_date <=',$tdate);	       
       	$data_count=$this->db->count_all_results('hms_patient_assign_test');
       	if($data_count>0)
       	{
      	$limit=2150;
      	$start=$this->uri->segment(5);
      	$start1=$start*$limit;
      	 		
       	$this->db->where('afid',$afid);	
       	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
       	
       //	$this->db->where('test_parient !=',0);
       	$data['test_name']=$this->db->get('ho_m_test_master');	
      	 
      	$this->db->where('afid',$afid);
	$this->db->where('enter_date >=',$fdate);	
	$this->db->where('enter_date <=',$tdate);	      
	$this->db->group_by('patient_id');    
	$this->db->group_by('enter_date');    
       	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test',$limit,$start1);	 
       
       	$this->db->where('afid',$afid);	       
       	$data['hms_pathology']=$this->db->get('hms_pathology');	
      	 
      	$this->db->where('afid',$afid);

	$this->db->where('enter_date >=',$fdate);	
	$this->db->where('enter_date <=',$tdate);
	$this->db->group_by('patient_id'); 		      
	$data['total']=$this->db->count_all_results('hms_patient_assign_test');
      	$data['limit']=$limit;
      	$data['start']=$start;
      	$data['start1']=$start1;
       				
       	$this->load->view('hms/view_patient_assign_test_new_second',$data);	
               }
       	else
       	{
       	echo 'Record not found';
       	}
}	       
	       
	       
	public function update_test_val_opd()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	$p_date=$this->uri->segment(4);
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('test_panels','0');	
//	$this->db->where('enter_date',$p_date);	
	$data_count=$this->db->count_all_results('hms_patient_assign_test');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->order_by('id','asc');	
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->group_by('patient_id');	
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test');
	foreach($data['hms_opd_assign_test_pat']->result() as $row)
	{
	break;
	}
	$data['test_date']=$row->enter_date;			
	
	$this->db->where('afid',$aid);	
	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	//$this->db->where('test_parient !=',0);
	$this->db->order_by('id','asc');	
	$data['test_name']=$this->db->get('ho_m_test_master');	
				
	$this->load->view('hms/update_patient_test_value',$data);	
        }
	else
	{
	echo 'Record not found';
	}
}


	public function update_test_val_opd_user()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	$p_date=$this->uri->segment(4);
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('test_panels','0');	
//	$this->db->where('enter_date',$p_date);	
	$data_count=$this->db->count_all_results('hms_patient_assign_test');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->order_by('id','asc');	
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->group_by('patient_id');	
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test');
	foreach($data['hms_opd_assign_test_pat']->result() as $row)
	{
	break;
	}
	$data['test_date']=$row->enter_date;			
	
	$this->db->where('afid',$aid);	
	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	//$this->db->where('test_parient !=',0);
	$this->db->order_by('id','asc');	
	$data['test_name']=$this->db->get('ho_m_test_master');	
				
	$this->load->view('hms/update_patient_test_value_user',$data);	
        }
	else
	{
	echo 'Record not found';
	}
   }

	public function print_opd_patient_test_report()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	$p_date=$this->uri->segment(4);
	$margin_bottom=$this->uri->segment(5);
	$margin=$this->uri->segment(6);	
	date_default_timezone_set('Asia/Calcutta');
	$data['report_time']=date("h:i a");	
	$data['today']=date('d-m-Y');
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
//	$this->db->where('enter_date',$p_date);		
	$data_count=$this->db->count_all_results('hms_patient_assign_test');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);	
	$this->db->group_by('test_parient');
	$this->db->order_by('id','asc');		
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	
	
	
	
		
	foreach($data['hms_opd_patient']->result() as $row_p)
	{
	break;
	}
	
	$this->db->where('afid',$aid);
	$this->db->where('doctor_id',$row_p->doctor_id);
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_d)
	{
	break;
	}		
	$data['doctor_name']=$row_d->name;
	
	

	$this->db->where('afid',$aid);
	$this->db->where('nurse_id',$row_p->pathlogy_sign);
	$data['hms_nurse']=$this->db->get('hms_nurse');
	foreach($data['hms_nurse']->result() as $row_n)
	{
	break;
	}		
	$data['nurse_name']=$row_n->name;
	$data['degree']=$row_n->degree;
	$data['img_sign']=$row_n->img_sign;	
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->group_by('patient_id');	
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test');
	foreach($data['hms_opd_assign_test_pat']->result() as $row)
	{
	break;
	}
	$data['test_date']=$row->enter_date;			
	
//	$this->db->where('id',$row->pathology_center);
//	$this->db->where('afid',$aid);	
//	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	//$this->db->where('test_parient !=',0);
	$data['test_name']=$this->db->get('ho_m_test_master');	
	

	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	
	
	$data['margin_top']=$margin;
	$data['margin_bottom']=$margin_bottom;				
//	$this->load->view('hms/barcode',$data);	
//	$this->load->view('hms/demo',$data);
	$this->load->view('hms/print_opd_test_report_new',$data);	
          }
	else
	{
	echo 'Record not found';
	}	
	}	


public function update_student_marks()
{
		$this->load->library('session');
        	$this->load->helper('url');
		$afid=$this->get_affiliate();
		
		$id=$this->input->post('checkid');
		$mark=$this->input->post('checkedoption2');
		$qui_id=explode(',',$id);
		$qui=explode(',',$mark);
	
	       $t=0;
		for($t1=0;Count($qui_id)>$t1;$t1++)
		{
		$this->load->database();
		//$this->modify_emp_id=$this->input->post('eid'); 
		$this->test_val=$qui[$t]; 
		$this->db->where('id',$qui_id[$t]);
	       $this->db->update('hms_patient_assign_test',$this);
	       
		$t++;

		}
		
}         
      
      
	public function add_pathology()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->db->where('afid',$aid);
//	$data['department']=$this->db->get('hms_department');		
	$this->load->view('hms/add_pathology');
	}  
	
	
	public function save_pathology()
	{
	$this->load->library('session');
	$this->load->helper('url');
	$aid=$this->get_affiliate();
	$data_count=$this->db->count_all_results('hms_pathology');
	if($data_count>4)
	{
	echo 'Only Four Centers Allow';
	}
	else
	{	
	$this->pathology_name=$this->input->post('pos_name');
	$this->email=$this->input->post('email');
	$this->address=$this->input->post('address');
	$this->phone=$this->input->post('phone');
	
	$this->firdoct=$this->input->post('firdoct');
	$this->fiedgree=$this->input->post('fiedgree');
	$this->secdoct=$this->input->post('secdoct');
	$this->secdgree=$this->input->post('secdgree');
				
	$this->afid=$aid;
	$this->db->insert('hms_pathology',$this);	
	echo 'Record Added';
	}
	}	    
     
     
	public function view_pathlogy()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->load->database();
	$this->db->where('afid',$aid);
	$data_count=$this->db->count_all_results('hms_pathology');
	if($data_count>0)
	{		
	$limit=15;
	$start=$this->uri->segment(3);
	$start1=$start*$limit;
	
	$this->db->where('afid',$aid);
	$data['hms_pathology']=$this->db->get('hms_pathology');
			
	$this->db->where('afid',$aid);
	$data['total']=$this->db->count_all_results('hms_pathology');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_pathology',$data);	
        }
	else
	{
	echo 'Record not found';
	}
	}
	
	
	
	
	public function add_hosptal()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->db->where('afid',$aid);
//	$data['department']=$this->db->get('hms_department');	
	$this->db->where('afid',$aid);
	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$data['hms_zone_master']=$this->db->get('hms_zone_master');		
	$this->load->view('hms/add_hosptal',$data);
	}
	
	
	
	public function save_hospital()
	{
	$this->load->library('session');
	$this->load->helper('url');
	$aid=$this->get_affiliate();
	$data_count=$this->db->count_all_results('hms_hospital');
	if($data_count>400)
	{
	echo 'Only Four Centers Allow';
	}
	else
	{	
	$this->pathology_name=$this->input->post('pos_name');
	$this->email=$this->input->post('email');
	$this->address=$this->input->post('address');
	$this->phone=$this->input->post('phone');
	$this->per=$this->input->post('perst');	
	$this->per_rt=$this->input->post('perrt');	
	$this->digper=$this->input->post('digperst');
	$this->dig_rt=$this->input->post('digperrt');	
	$this->pathlogy_id=$this->input->post('pathlogy');
	$this->zone_id=$this->input->post('zone_id');
						
	$this->afid=$aid;
	$this->db->insert('hms_hospital',$this);	
	echo 'Record Added';
	}
	}
	
	
	public function view_hospital()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->load->database();
	$this->db->where('afid',$aid);
	$data_count=$this->db->count_all_results('hms_hospital');
	if($data_count>0)
	{		
	$limit=15;
	$start=$this->uri->segment(3);
	$start1=$start*$limit;
	
	$this->db->where('afid',$aid);
	$data['hms_hospital']=$this->db->get('hms_hospital');
	
	$data['hms_zone_master']=$this->db->get('hms_zone_master');
			
	$this->db->where('afid',$aid);
	$data['total']=$this->db->count_all_results('hms_hospital');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_hospital',$data);	
        }
	else
	{
	echo 'Record not found';
	}
	}
	
	
public function hospital_record()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$docid=$this->uri->segment(3);	
	$this->db->where('afid',$aid);
	$this->db->where('id',$docid);
	$data_count=$this->db->count_all_results('hms_hospital');
	if($data_count>0)
	{	
	$this->db->where('afid',$aid);
	$this->db->where('id',$docid);	
	$this->db->order_by('id','asc');
	$data['hms_hospital']=$this->db->get('hms_hospital');
	$data['hms_zone_master']=$this->db->get('hms_zone_master');
	$this->load->view('hms/view_hospital_record',$data);	
	}
	else
	{
	echo 'Record Not fond';
	}
}	
	
	
	public function delete_hospital()
	{
 	$this->load->library('session');
         $this->load->helper('url');
 	$aid=$this->get_affiliate();
 	$id=$this->uri->segment(3);
 	$this->db->where('id',$id);
 	$this->db->where('afid',$aid);
 	$this->db->delete('hms_hospital');
 	echo 'Record Deleted';
	}
	
  public function edit_hospital()
  {
  	$this->load->library('session');
        $this->load->helper('url');
   	$aid=$this->get_affiliate();
   	$id=$this->uri->segment(3); 
	$this->db->where('id',$id);
 	$this->db->where('afid',$aid);
 	$data['hms_hospital']=$this->db->get('hms_hospital');
	 

	$this->db->where('afid',$aid);
	$data['hms_pathology']=$this->db->get('hms_pathology');
	
	$data['hms_zone_master']=$this->db->get('hms_zone_master');
		 
	$this->load->view('hms/edit_hospital',$data);  	 	   
  
  }
	public function update_hospital()
	{
	$this->load->library('session');
	$this->load->helper('url');
	$aid=$this->get_affiliate();
	$row_id=$this->input->post('row_id');	
	$this->pathology_name=$this->input->post('pos_name');
	$this->email=$this->input->post('email');
	$this->address=$this->input->post('address');
	$this->phone=$this->input->post('phone');
	$this->per=$this->input->post('perst');	
	$this->per_rt=$this->input->post('perrt');	
	$this->digper=$this->input->post('digperst');
	$this->dig_rt=$this->input->post('digperrt');	
	$this->pathlogy_id=$this->input->post('pathlogy');
	$this->zone_id=$this->input->post('zone_id');				
	$this->db->where('id',$row_id);
	$this->db->update('hms_hospital',$this);	
	echo 'Record Updated';
	} 			 	
	


public function increment($value,$flg)
	{ 
	if($flg==0)
	{
	$len=strlen($value);
	$original=substr($value,3,$len);
	$original=$original+1;
	$len=strlen($original);
	if($len==1)
	$original='0'.$original;
	$original='com'.$original;
	return $original;
	}
	else if($flg==3)
	{
	$len=strlen($value);
	$original=substr($value,4,$len);
	$original=$original+1;
	$len=strlen($original);
	if($len==1)
	$original='0'.$original;
	$original='Aids'.$original;
	return $original;
	}
	else
	{	
	$value=$value+1;
	$len=strlen($value);
	if($len==1)
	$value=$value;
        
        return $value;
	}
	}


//---------------------------------------------------------------


 
	

	public function delete_opd_patient()
	{
 	$this->load->library('session');
         $this->load->helper('url');
 	$aid=$this->get_affiliate();
 	$id=$this->uri->segment(3);
 	$this->db->where('id',$id);
        $this->db->where('amount','0');
	 $this->db->where('amount_diagnose','0');
	$this->db->where('print_status','0');	
 	$this->db->delete('hms_opd_patient');
	 	 
 	echo 'Record Deleted';
	}
	

	public function delete_opd_patient_lab_inside()
	{
 	$this->load->library('session');
         $this->load->helper('url');
 	$aid=$this->get_affiliate();
 	$id=$this->uri->segment(3);
 	$this->db->where('id',$id);
        $this->db->where('statusid','0');	
 	$this->db->delete('hms_opd_patient');
 	echo 'Record Deleted';
	}	
	
	
public function edit_opd_patient()
{
	$this->load->library('session');
         $this->load->helper('url');
 	$aid=$this->get_affiliate();
 	$id=$this->uri->segment(3);
	$this->db->where('afid',$aid);
	$this->db->where('id',$id);	  
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');

	$this->db->where('afid',$aid);
	$data['hms_doctor']=$this->db->get('hms_doctor');
	
	$this->db->where('afid',$aid);
	$data['hms_nurse']=$this->db->get('hms_nurse');
	
	$this->db->where('afid',$aid);
	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$this->db->where('afid',$aid);
	$data['hms_hospital']=$this->db->get('hms_hospital');		
	
	$this->db->where('emp_aff_id',$aid);
	$data['emp_info_data']=$this->db->get('emp_info');	
		
	$this->load->view('hms/edit_opd_patient',$data);	
		
}

	public function update_opd_patient()
	{
	$this->load->library('session');
	$this->load->helper('url');
	$aid=$this->get_affiliate();
	$row_id=$this->input->post('row_id');	
	$this->grno=$this->input->post('tcno');
	$this->patient_name=$this->input->post('patient_name');	
	$this->gender=$this->input->post('gender');
	$this->age=$this->input->post('age');	
	$this->phone=$this->input->post('phone');
	$this->doctor_id=$this->input->post('doctor');	
	$this->collection_code=$this->input->post('collectby');
	
	$this->titlename=$this->input->post('titlename');
	$this->yearname=$this->input->post('yearname');	
$this->statusid=$this->input->post('statusid');	
	$this->entry_date=$this->input->post('date');
	$this->clboy=$this->input->post('clboy');
	$this->remarks=$this->input->post('remark');
	$this->hospitalid=$this->input->post('hospitalid');		
	$this->pathlogy_sign=$this->input->post('pathology_doctor');	
//	date_default_timezone_set('Asia/Calcutta');
//	$this->entry_date_time=date("h:i a");				
	$this->db->where('id',$row_id);
	$this->db->update('hms_opd_patient',$this);	
	echo 'Record Updated';
	}
	
	
	public function delete_pathelogy()
	{
 	$this->load->library('session');
         $this->load->helper('url');
 	$aid=$this->get_affiliate();
 	$id=$this->uri->segment(3);
 	$this->db->where('id',$id);
 	$this->db->where('afid',$aid);
 	$this->db->delete('hms_pathology');
 	echo 'Record Deleted';
	}
	
  public function edit_pathelogy()
  {
  	$this->load->library('session');
        $this->load->helper('url');
   	$aid=$this->get_affiliate();
   	$id=$this->uri->segment(3); 
	$this->db->where('id',$id);
 	$this->db->where('afid',$aid);
 	$data['hms_pathology']=$this->db->get('hms_pathology');
	$this->load->view('hms/edit_pathology',$data);  	 	   
  
  }
	public function update_pathology()
	{
	$this->load->library('session');
	$this->load->helper('url');
	$aid=$this->get_affiliate();
	$row_id=$this->input->post('row_id');	
	$this->pathology_name=$this->input->post('pos_name');
	$this->email=$this->input->post('email');
	$this->address=$this->input->post('address');
	$this->phone=$this->input->post('phone');


	$this->firdoct=$this->input->post('firdoct');
	$this->fiedgree=$this->input->post('fiedgree');
	$this->secdoct=$this->input->post('secdoct');
	$this->secdgree=$this->input->post('secdgree');	
	
			
	$this->db->where('id',$row_id);
	$this->db->update('hms_pathology',$this);	
	echo 'Record Updated';
	}  
	     
	




public function count_indate_out_date()
{
   	$this->load->helper('url');
      	$this->load->library('session');
      	$aid=$this->get_affiliate();  
  	$entry_date=$this->uri->segment(3); 
	$today=$this->uri->segment(4); 	  	
  	$startTimeStamp = strtotime($entry_date);
  	$endTimeStamp = strtotime($today);
  	$timeDiff = abs($endTimeStamp - $startTimeStamp);
  	$numberDays = $timeDiff/86400+1;  // 86400 seconds in one day
  // and you might want to convert to integer
  	$data['numberDays'] = intval($numberDays);
	$this->load->view('hms/find_count_date',$data);	  
}



public function view_opd_day_report()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();

	
	$this->db->where('afid',$aid);
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$limit=30;
	$start=$this->uri->segment(3);
	$start1=$start*$limit;

	$this->db->where('afid',$aid);
	$this->db->order_by('entry_date','desc');
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient',$limit,$start1);
	
	$this->db->where('afid',$aid);
	$data['hms_doctor']=$this->db->get('hms_doctor');
				
	$this->db->where('afid',$aid);
	$data['total']=$this->db->count_all_results('hms_opd_patient');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_opd_patient_day_report',$data);	
          }
	else
	{
	echo 'Record not found';
	}	
}	      


	public function print_report_opd_patient_date()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);		
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);		
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$limit=1150;
	$start=$this->uri->segment(5);
	$start1=$start*$limit;
$data['today']=$fdate;
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->order_by('entry_date','desc');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');

	$this->db->where('afid',$aid);
	$data['hms_doctor']=$this->db->get('hms_doctor');
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		
				
	$this->db->where('afid',$aid);
	$data['total']=$this->db->count_all_results('hms_opd_patient');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/print_report_opd_patient_date_wise',$data);	
//	$this->load->view('hms/view_second_opd_patient_date_wise',$data);	
          }
	else
	{
	echo 'Record not found';
	}	
	}	
	



public function view_lab_day_report()
{
	$this->load->library('session');
        $this->load->helper('url');
       	$afid=$this->get_affiliate();				
   //    	$this->load->view('hms/view_patient_assign_test_new');
       	$this->load->view('hms/view_lab_test_day_report');	       	
} 

public function search_lab_test_day_report_date()
{
       		$this->load->library('session');
               	$this->load->helper('url');
       		$afid=$this->get_affiliate();
		$fdate=$this->uri->segment(3);
	     $tdate=$this->uri->segment(4);		             
       	$this->db->where('afid',$afid);	
	$this->db->where('enter_date >=',$fdate);	
	$this->db->where('enter_date <=',$tdate);	       
       	$data_count=$this->db->count_all_results('hms_patient_assign_test');
       	if($data_count>0)
       	{    	 		
       	$this->db->where('afid',$afid);	
       	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
       	
       //	$this->db->where('test_parient !=',0);
       	$data['test_name']=$this->db->get('ho_m_test_master');	
      	 
      	$this->db->where('afid',$afid);
	$this->db->where('enter_date >=',$fdate);	
	$this->db->where('enter_date <=',$tdate);	      
	$this->db->group_by('patient_id');
	$this->db->group_by('enter_date');	      
       	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test');
	       	 
       $data['today']=$fdate;	
       $data['tday']=$tdate;	
       $data['afid']=$afid;
       	$this->db->where('afid',$afid);	       
       	$data['hms_pathology']=$this->db->get('hms_pathology');	
      	 
	$this->db->where('affiliate_id',$afid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	
 
        	$this->db->where('afid',$afid);	
        	$data['hms_ipd_patient']=$this->db->get('hms_ipd_patient');
	       
      	$this->db->where('afid',$afid);
      	$this->db->where('enter_date >=',$fdate);	
      	$this->db->where('enter_date <=',$tdate);	      
      	$this->db->group_by('patient_id');    
      	$this->db->group_by('enter_date');    
             	$data['hms_ipd_patient_assign_test']=$this->db->get('hms_ipd_patient_assign_test');     
	       
       				
       	$this->load->view('hms/print_lab_test_report_day',$data);	
               }
       	else
       	{
       	echo 'Record not found';
       	}
}	       

  


	public function show_test_parient_list()
		{
      		$this->load->library('session');
               	$this->load->helper('url');
       		$afid=$this->get_affiliate();
		$test_parient=$this->uri->segment(3);
	        $this->db->where('test_parient',$test_parient);
		$this->db->order_by('id','asc');
	        $data['sub_test_name_parient']=$this->db->get('ho_m_test_master');
		
	   $this->db->where('id',$test_parient);
	   $data['sub_test_name_parient_root']=$this->db->get('ho_m_test_master');	
	foreach($data['sub_test_name_parient_root']->result() as $row_p)
	{
	break;
	}
	$data['root_name']=$row_p->root_id;		
		
      	        $this->load->view('hms/sub_parient_test_list',$data);	
		}	       



	public function show_test_parient_list_diagnois()
		{
      		$this->load->library('session');
               	$this->load->helper('url');
       		$afid=$this->get_affiliate();
		$test_parient=$this->uri->segment(3);
	        $this->db->where('dig_parient',$test_parient);
		$this->db->order_by('id','asc');
	        $data['sub_test_name_parient']=$this->db->get('hms_dignos_master');
		
	   $this->db->where('id',$test_parient);
	   $data['sub_test_name_parient_root']=$this->db->get('hms_dignos_master');	
//	foreach($data['sub_test_name_parient_root']->result() as $row_p)
//	{
//	break;
//	}
//	$data['root_name']=$row_p->root_id;		
		
      	        $this->load->view('hms/sub_parient_test_list_diagnos',$data);	
		}	

 


	public function print_opd_patient_test_report_sleep()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	$day=$this->uri->segment(4);	
	$data['today']=$day;	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);	
	$this->db->where('enter_date',$day);
	$this->db->group_by('test_parient');
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	
	foreach($data['hms_opd_patient']->result() as $row_p)
	{
	break;
	}
	
	
	$this->db->where('afid',$aid);
	$this->db->where('doctor_id',$row_p->doctor_id);
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_d)
	{
	break;
	}		
	$data['doctor_name']=$row_d->name;
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('enter_date',$day);
	$this->db->group_by('patient_id');	
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test');
	foreach($data['hms_opd_assign_test_pat']->result() as $row)
	{
	break;
	}
	$data['test_date']=$row->enter_date;			
	
	$this->db->where('id',$row->pathology_center);
	$this->db->where('afid',$aid);	
	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	//$this->db->where('test_parient !=',0);
	$data['test_name']=$this->db->get('ho_m_test_master');	
	

	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	
	
				
	$this->load->view('hms/print_opd_test_report_sleep',$data);	
          }
	else
	{
	echo 'Record not found';
	}	
	}


	
	
	
	public function delete_opd_test()
	{
 	$this->load->library('session');
         $this->load->helper('url');
 	$aid=$this->get_affiliate();
 	$id=$this->uri->segment(3);
	$pid=$this->uri->segment(4);
	
 	$this->db->where('test_parient',$id);
	$this->db->where('patient_id',$pid);
	$this->db->where('print_status','0');				
	$data_count=$this->db->count_all_results('hms_patient_assign_test');
	if($data_count>0)
	{		 
 	$this->db->where('test_parient',$id);
	$this->db->where('patient_id',$pid);
	$this->db->where('print_status','0');	 
 	$this->db->where('afid',$aid);
 	$this->db->delete('hms_patient_assign_test');
 	echo 'Record Deleted';
	}
	else
	{
	
	}	
	}
	
	

  
	public function assign_ipd_patient_particular2()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data_count=$this->db->count_all_results('hms_ipd_patient');
	if($data_count>0)
	{
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);	
	$data_count_val=$this->db->count_all_results('hms_ipd_patient_assign_particulars');
	if($data_count_val>0)
	{
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_ipd_patient');
	foreach($data['hms_opd_patient']->result () as $row_ipd)
	{
	break;
	}
	$data['entry_date']= $row_ipd->entry_date;
	
	
      	$this->db->where('afid',$aid);    
      	$this->db->where('bed_id',$row_ipd->bed_no); 	        	       	
      	$data['hms_bed']=$this->db->get('hms_bed');
	      
	foreach($data['hms_bed']->result () as $row_bed)
	{
	break;
	}
	$data['bed_number']= $row_bed->bed_number;
	//$data['bed_rate']= $row_bed->rate;	
	
	$this->db->where('afid',$aid);
	$this->db->where('dep_id',$row_ipd->sub_dep_id);	
	$data['hms_department']=$this->db->get('hms_department');
	foreach($data['hms_department']->result () as $row_ward)
	{
	break;
	}
	$data['ward']= $row_ward->name;		

	
	$this->db->where('afid',$aid);
	$data['test_name']=$this->db->get('hms_particular');	
	
	$this->db->where('test_parient',0);
	$data['test_name']=$this->db->get('hms_particular');	

	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);	
	$data['hms_ipd_particulars']=$this->db->get('hms_ipd_patient_assign_particulars');
	
//-----------today 1-6-15------

	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_ipd_patient']=$this->db->get('hms_ipd_patient');	
	$this->db->where('afid',$aid);
	$data['test_name2']=$this->db->get('hms_particular');

    	$this->db->where('afid',$aid);
    	$this->db->where('patient_id',$pid);
	$this->db->group_by('test_id');    
     	$data['hms_patient_assign_test']=$this->db->get('hms_ipd_patient_assign_particulars');		
	
	$this->load->view('hms/assign_ipd_patient_particular_mmmm_update_aviral',$data);	
		
//	$this->load->view('hms/assign_ipd_patient_particular_mmmm_update',$data);	
	}
	else
	{
				
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_ipd_patient');
	foreach($data['hms_opd_patient']->result () as $row_ipd)
	{
	break;
	}
	$data['entry_date']= $row_ipd->entry_date;
	
	$this->db->where('afid',$aid);
	$this->db->where('dep_id',$row_ipd->sub_dep_id);	
	$data['hms_department']=$this->db->get('hms_department');
	foreach($data['hms_department']->result () as $row_ward)
	{
	break;
	}
	$data['ward']= $row_ward->name;			

	
	$this->db->where('afid',$aid);
	$data['test_name']=$this->db->get('hms_particular');
	
	$this->db->where('test_parient',0);
	$data['test_name']=$this->db->get('hms_particular');	
	


//-----------today 1-6-15------

	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_ipd_patient']=$this->db->get('hms_ipd_patient');	
	$this->db->where('afid',$aid);
	$data['test_name2']=$this->db->get('hms_particular');

    	$this->db->where('afid',$aid);
    	$this->db->where('patient_id',$pid);
	$this->db->group_by('test_id');    
     	$data['hms_patient_assign_test']=$this->db->get('hms_ipd_patient_assign_particulars');	
	     
$this->load->view('hms/assign_ipd_patient_particular_aviral',$data);	     		
				
//	$this->load->view('hms/assign_ipd_patient_particular',$data);
	}	
        }
	else
	{
	echo 'Record not found';
	}
	}
	
	public function show_particular_parient_list()
		{
      		$this->load->library('session');
               	$this->load->helper('url');
       		$afid=$this->get_affiliate();
		$test_parient=$this->uri->segment(3);
	$this->db->where('test_parient',$test_parient);
	$data['sub_test_name_parient']=$this->db->get('hms_particular');
       	$this->load->view('hms/sub_parient_particular_list',$data);		
}


	public function show_particular_parient_list_update()
		{
      		$this->load->library('session');
               	$this->load->helper('url');
       		$afid=$this->get_affiliate();
		$test_parient=$this->uri->segment(3);
		$pid=$this->uri->segment(4);
	$this->db->where('afid',$afid);
	$this->db->where('patient_id',$pid);
	$this->db->where('test_parient',$test_parient);		
	$data_count_val=$this->db->count_all_results('hms_ipd_patient_assign_particulars');
	if($data_count_val>0)
	{		
	$this->db->where('test_parient',$test_parient);
	$data['sub_test_name_parient']=$this->db->get('hms_particular');
	
	$this->db->where('afid',$afid);
	$this->db->where('patient_id',$pid);	
	$data['hms_ipd_particulars']=$this->db->get('hms_ipd_patient_assign_particulars');	
       	$this->load->view('hms/sub_parient_particular_list_update',$data);
	 }
      else
      {
	$this->db->where('test_parient',$test_parient);
	$data['sub_test_name_parient']=$this->db->get('hms_particular');
       	$this->load->view('hms/sub_parient_particular_list',$data);      
      
      }	       		
}

		

   
   
   
   
   
	public function print_opd_patient_test_report_sleep_day()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	$today=$this->uri->segment(4);
	
	$data['today']=$today;
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
//	$this->db->where('enter_date',$today);	
	$data_count=$this->db->count_all_results('hms_patient_assign_test');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
//	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('date_test',$today);		
//	$this->db->group_by('test_parient');
	$data['hms_opd_test_rate']=$this->db->get('hms_opd_test_rate');		
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('enter_date',$today);		
	$this->db->group_by('test_parient');
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	
	foreach($data['hms_opd_patient']->result() as $row_p)
	{
	break;
	}
	
	
	$this->db->where('afid',$aid);
	$this->db->where('doctor_id',$row_p->doctor_id);
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_d)
	{
	break;
	}		
	$data['doctor_name']=$row_d->name;
	
	

	
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('enter_date',$today);	
	$this->db->group_by('patient_id');	
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test');
	foreach($data['hms_opd_assign_test_pat']->result() as $row)
	{
	break;
	}
	$data['test_date']=$row->enter_date;			
	
	
	
	
	//$this->db->where('test_parient !=',0);
	$data['test_name']=$this->db->get('ho_m_test_master');	
	

	
//	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	
	
				
	$this->load->view('hms/print_opd_test_report_sleep',$data);	
          }
	else
	{
	echo 'Record not found';
	}	
	}  
	
	
	
	
	
	
 public function upload_img()
    {
   	$this->load->library('session');
	$this->load->helper('url');
	$data['aid']=$this->get_affiliate();
	$data['eid']=$this->uri->segment(3);
	$this->load->view('hms/view_imguploader',$data);
    }
    
    
	public function view_center_report()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();

	$this->db->where('afid',$aid);
	$data['hms_pathology']=$this->db->get('hms_pathology');
	
	$this->load->view('hms/view_center_report',$data);	
	} 
	
	
	public function print_report_date_center()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);
	$centerid=$this->uri->segment(5);	
	
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$centerid);	
	$data['hms_pathology']=$this->db->get('hms_pathology');
	foreach($data['hms_pathology']->result() as $row_name)
		{
		break;
		}
	$data['emp_name']=$row_name->pathology_name;	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('collection_code',$centerid);			
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('collection_code',$centerid);
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		
				
	$this->load->view('hms/print_report_center_wise',$data);					
          }
	else
	{
	echo 'Record not Found';
	}
	}	
	
	
	public function view_day_report()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();

        $this->db->where('afid',$aid);
	$this->db->order_by('name','asc');
	$data['hms_doctor']=$this->db->get('hms_doctor');
	
	$this->db->where('afid',$aid);
	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	
	$data['hms_zone_master']=$this->db->get('hms_zone_master');			
	
	$this->load->view('hms/view_doctor_report',$data);	
	}    
	
	
	public function print_report_date_emp()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);
	$empid=$this->uri->segment(5);	
	$data['disper']=$this->uri->segment(6);	
	$data['disperrt']=$this->uri->segment(7);	
	$pathlogy=$this->uri->segment(8);					
	
	
	$this->db->where('afid',$aid);
	$this->db->where('doctor_id',$empid);	
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_name)
		{
		break;
		}
	$data['emp_name']=$row_name->name;	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pathlogy);	
	$data['center']=$this->db->get('hms_pathology');
	foreach($data['center']->result() as $row_center)
		{
		break;
		}
	$data['center_name']=$row_center->pathology_name;	
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('doctor_id',$empid);	
	$this->db->where('collection_code',$pathlogy);
	$this->db->where('tot_amount !=','0');				
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('doctor_id',$empid);
	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount !=','0');		
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		
				
	$this->load->view('hms/print_report_date_wise',$data);					
          }
	else
	{
	echo 'Record not Found';
	}
	}
	
	
	public function print_report_date_emp_first()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);
	$empid=$this->uri->segment(5);	
	$pathlogy=$this->uri->segment(6);				
	
	
	$this->db->where('afid',$aid);
	$this->db->where('doctor_id',$empid);	
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_name)
		{
		break;
		}
	$data['emp_name']=$row_name->name;	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
	
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pathlogy);	
	$data['center']=$this->db->get('hms_pathology');
	foreach($data['center']->result() as $row_center)
		{
		break;
		}
	$data['center_name']=$row_center->pathology_name;	
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('doctor_id',$empid);
	$this->db->where('collection_code',$pathlogy);				
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('doctor_id',$empid);
	$this->db->where('collection_code',$pathlogy);	
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		
				
	$this->load->view('hms/print_report_date_wise_first',$data);					
          }
	else
	{
	echo 'Record not Found';
	}
	}			
	
	
	public function print_report_date_emp_first_diagnos()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);
	$empid=$this->uri->segment(5);	
	$pathlogy=$this->uri->segment(6);				
	
	
	$this->db->where('afid',$aid);
	$this->db->where('doctor_id',$empid);	
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_name)
		{
		break;
		}
	$data['emp_name']=$row_name->name;	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
	
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pathlogy);	
	$data['center']=$this->db->get('hms_pathology');
	foreach($data['center']->result() as $row_center)
		{
		break;
		}
	$data['center_name']=$row_center->pathology_name;	
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('doctor_id',$empid);
	$this->db->where('collection_code',$pathlogy);				
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('doctor_id',$empid);
	$this->db->where('collection_code',$pathlogy);	
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		
				
	$this->load->view('hms/print_report_date_wise_first_diagno',$data);					
          }
	else
	{
	echo 'Record not Found';
	}
	}
	
	public function print_report_date_emp_diagnos_all()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);
	$empid=$this->uri->segment(5);	
	$data['disper']=$this->uri->segment(6);	
	$data['disperrt']=$this->uri->segment(7);	
	$pathlogy=$this->uri->segment(8);					
	
	
	$this->db->where('afid',$aid);
	$this->db->where('doctor_id',$empid);	
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_name)
		{
		break;
		}
	$data['emp_name']=$row_name->name;	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pathlogy);	
	$data['center']=$this->db->get('hms_pathology');
	foreach($data['center']->result() as $row_center)
		{
		break;
		}
	$data['center_name']=$row_center->pathology_name;	
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('doctor_id',$empid);	
	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount_diagnose !=','0');			
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('doctor_id',$empid);
	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount_diagnose !=','0');	
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		
				
	$this->load->view('hms/print_report_date_wise_diagnos',$data);					
          }
	else
	{
	echo 'Record not Found';
	}
	}	
	
	
public function student_mark_entry2()
{
		$this->load->library('session');
        	$this->load->helper('url');
		$afid=$this->get_affiliate();
		$empid=$this->get_af_emp_id();	
		$ques=$this->input->post('su_id');
		$qui=explode(',',$ques);
	        $value_qui=$this->input->post('mark_val');
		$val_qui=explode('^',$value_qui);
		
		$t=1;
		for($t1=1;Count($qui)>$t1;$t1++)
		{			
		$this->load->database();
		$this->test_id=$qui[$t]; 
  		$this->patient_id=$this->input->post('patient_name');
  		$this->enter_date=$this->input->post('e_date');
		$this->test_parient=$this->input->post('test_parient');		  
  		$this->afid=$afid;
		$this->emp_id=$empid;  
  		$this->db->set('status','1');
		$this->test_val=$val_qui[$t]; 			
		$this->db->insert('hms_patient_assign_test',$this);
		$t++;
		//echo Count($qui);
		}
		
					
	echo 'Patient Assigned Test';  
}	


	public function update_test_val_opd_second()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	$p_date=$this->uri->segment(4);
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
//	$this->db->where('enter_date',$p_date);	
	$data_count=$this->db->count_all_results('hms_patient_assign_test');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);	
	$this->db->order_by('id','asc');
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->group_by('patient_id');	
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test');
	foreach($data['hms_opd_assign_test_pat']->result() as $row)
	{
	break;
	}
	$data['test_date']=$row->enter_date;			
	
	$this->db->where('afid',$aid);	
	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	//$this->db->where('test_parient !=',0);
	$data['test_name']=$this->db->get('ho_m_test_master');	
				
	$this->load->view('hms/update_patient_test_value_second',$data);	
        }
	else
	{
	echo 'Record not found';
	}
}
		 
//--------------------------------------------------------------------------------------------------		 
public function update_patient_test_amount()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	$paid_amt=$this->uri->segment(4);
	$tot_bill=$this->uri->segment(5);
	$dis_per=$this->uri->segment(6);
	$dis_amt=$this->uri->segment(7);
	if($dis_amt =='' || $dis_amt=='0')
	{	
	$this->amount=$paid_amt;
	$this->tot_amount=$tot_bill;
	$this->discount_per='0';
	$this->discount='0';		
	$this->db->where('id',$pid);
	$this->db->update('hms_opd_patient',$this);	
        }
	else
	{
	$this->amount=$paid_amt;
	$this->tot_amount=$tot_bill;	
	$this->discount_per=$dis_per;
	$this->discount=$dis_amt;		
	$this->db->where('id',$pid);
	$this->db->update('hms_opd_patient',$this);	
	}	
     }


    
public function update_patient_test_amount_balance_admin()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	$balance_paid_amt=$this->uri->segment(4);
	$paid_amt=$this->uri->segment(5);
	$discount=$this->uri->segment(6);
	
	$this->amount=$balance_paid_amt+$paid_amt;
	$this->discount=$discount;	
	
	$this->db->where('id',$pid);
	$this->db->update('hms_opd_patient',$this);
//	echo 'Record Updated';

	
}


public function update_diagnose_balance()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	$balance_paid_amt=$this->uri->segment(4);
	$paid_amt=$this->uri->segment(5);
	$discount=$this->uri->segment(6);
	$disper=$this->uri->segment(7);
	
	$this->amount_diagnose=$balance_paid_amt+$paid_amt;
	$this->discount_diagnos=$discount;
        $this->discount_per_diagnos= round($disper,1);		
	
	$this->db->where('id',$pid);
	$this->db->update('hms_opd_patient',$this);
//	echo 'Record Updated';	
	
}     

public function update_patient_test_amount_balance()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	$balance_paid_amt=$this->uri->segment(4);
	$paid_amt=$this->uri->segment(5);
//	$discount=$this->uri->segment(6);
	
	$this->amount=$balance_paid_amt+$paid_amt;
	$this->db->where('id',$pid);
	$this->db->update('hms_opd_patient',$this);
//	echo 'Record Updated';	
	
}



public function update_patient_test_amount_diagnouse()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	$paid_amt=$this->uri->segment(4);
	$tot_bill=$this->uri->segment(5);
	$dis_per=$this->uri->segment(6);
	$dis_amt=$this->uri->segment(7);
	if($dis_amt =='' || $dis_amt=='0')
	{	
	$this->amount_diagnose=$paid_amt;
	$this->tot_amount_diagnose=$tot_bill;
	$this->discount_per_diagnos='0';
	$this->discount_diagnos='0';		
	$this->db->where('id',$pid);
	$this->db->update('hms_opd_patient',$this);	
        }
	else
	{
	$this->amount_diagnose=$paid_amt;
	$this->tot_amount_diagnose=$tot_bill;	
	$this->discount_per_diagnos=$dis_per;
	$this->discount_diagnos=$dis_amt;		
	$this->db->where('id',$pid);
	$this->db->update('hms_opd_patient',$this);	
	}	
     }


  public function admin_emp_registationform()
     {
       $this->load->library('session');
       $this->load->helper('url');
       $aid=$this->get_affiliate();
      // $this->db->where('affilate_id',$aid);     
       $data['dep']=$this->db->get('manage_department'); 
       $this->db->where('emp_aff_id',$aid);
       $this->db->order_by('emp_id','desc');
       $data['lastan']=$this->db->count_all_results('emp_info');
       if($data['lastan']==0)
        {
	
        $data['lastan']="1001";
        }
        else
        {
$this->db->select_max('emp_enroll');
	$this->db->where('emp_aff_id',$aid);	
//	$this->db->where('entry_date',$date);	
	$data['emp_info ']=$this->db->get('emp_info ');
	foreach($data['emp_info ']->result() as $row)
		{
	//	break;
		}
		
	$new_lot_id=$row->emp_enroll;
	$ac_auto_no=$new_lot_id+1;		
	$data['lastan']=$row->emp_enroll+1;
      //  $data['lastan']=$this->increment($data['lastan'],1);
        }
	
	$this->db->where('afid',$aid);	
	$data['hms_pathology']=$this->db->get('hms_pathology');	
		
      		
       $this->load->view('hms/admin_employee_register',$data);   
       }
       
       

public function save_admin_emp()
{
$this->load->library('session');
$this->load->helper('url');
//$this->emp_mac_id=$this->input->post('smachine');
$this->emp_enroll=$this->input->post('rolno');
//$this->emp_depart=$this->input->post('organitation');
//$this->emp_role=$this->input->post('degination');
$this->title=$this->input->post('title1');

$this->emp_fname=$this->input->post('fname');
$this->emp_mname=$this->input->post('mname');
$this->emp_lname=$this->input->post('lname');
$this->emp_dob=$this->input->post('dob');
$this->emp_contact=$this->input->post('contactno');
$this->emp_address=$this->input->post('fulladdress');
$this->join_date=$this->input->post('d_join');
$this->pathlogy_id=$this->input->post('pathlogy');
//$this->db->set('empl_status','0');
$this->emp_aff_id=$this->get_affiliate();
$this->db->insert('emp_info',$this);
echo 'Emp Record has been Saved';
}       		 
	
	
    public function admin_employee_search()
    {
       $this->load->library('session');
       $this->load->helper('url');
       $aid=$this->get_affiliate();
      // $this->db->where('afid',$aid);	
   //    $data['orgname']=$this->db->get('manage_department');
     //   $this->db->where('afid',$aid);
  //     $data['managerole']=$this->db->get('manage_role');
    
       $this->db->where('emp_aff_id',$aid);
      // $this->db->where('emp_is_employ','1');
 
       $data['empinfo']=$this->db->get('emp_info');
       
   
       		
       $this->load->view('hms/admin_employee_search',$data);
    }	
    
    
    
public function search_admin_emprecord()
{
$this->load->library('session');
$this->load->helper('url');

$aid=$this->get_affiliate();
$this->db->where('emp_aff_id',$aid);
$fname=$this->uri->segment(3);
if ($fname!='')
{
$this->db->where('emp_fname',$fname);
}			
$data['empinfo']=$this->db->get('emp_info');
$this->load->view('hms/admin_employee_search',$data);
}

public function search_admin_emprollno()
{
$this->load->library('session');
$this->load->helper('url');

$aid=$this->get_affiliate();
$this->db->where('emp_aff_id',$aid);
$emprollno=$this->uri->segment(3);


if ($emprollno!='')
{
$this->db->where('emp_enroll',$emprollno);
}
				
$data['empinfo']=$this->db->get('emp_info');
$this->load->view('hms/admin_employee_search',$data);
}
    

public function edit_admin_emp_record()
{
$this->load->library('session');
$this->load->helper('url');   
$emp_id=$this->uri->segment(3);
$this->db->where('emp_id',$emp_id);	
$data['empinfo']=$this->db->get('emp_info');	

//	$this->db->where('afid',$aid);	
	$data['hms_pathology']=$this->db->get('hms_pathology');	
				

$this->load->view('hms/edit_admin_employee_register',$data);
}


public function update_admin_emp()
{
$this->load->library('session');
$this->load->helper('url');
$this->emp_enroll=$this->input->post('rolno');
$this->title=$this->input->post('title1');
$this->emp_fname=$this->input->post('fname');
$this->emp_mname=$this->input->post('mname');
$this->emp_lname=$this->input->post('lname');
$this->emp_dob=$this->input->post('dob');
$this->emp_contact=$this->input->post('contactno');
$this->emp_address=$this->input->post('fulladdress');
$this->join_date=$this->input->post('d_join');
$this->pathlogy_id=$this->input->post('pathlogy');
$this->emp_aff_id=$this->get_affiliate();
$id=$this->input->post('id');
$this->db->where('emp_id',$id);
//$this->db->where('emp_is_employ','1');
$this->db->update('emp_info',$this);
echo 'Emp Record has been Updated';
}



public function delete_adminemp_record()
{
$this->load->library('session');
$this->load->helper('url');
$this->db->set('empl_status','1');

$aid=$this->get_affiliate();
$this->db->where('emp_aff_id',$aid);    
$emp_id=$this->uri->segment(3);
$this->db->where('emp_id',$emp_id);
$this->db->delete('emp_info');
//$this->db->delete('emp_info');	
$aid=$this->get_affiliate();
$this->db->where('emp_aff_id',$aid); 			
$data['empinfo']=$this->db->get('emp_info');

$this->load->view('hms/admin_employee_search',$data);

}


	public function add_opd_patient_user()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->db->where('afid',$aid);
	$this->db->order_by('name','asc');
	$data['hms_doctor']=$this->db->get('hms_doctor');
	
	$this->db->where('afid',$aid);
	$data['hms_nurse']=$this->db->get('hms_nurse');
	
	$this->db->where('afid',$aid);
	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$this->db->where('afid',$aid);
	$data['hms_hospital']=$this->db->get('hms_hospital');	
	
	$this->db->where('emp_aff_id',$aid);
	$data['emp_info_data']=$this->db->get('emp_info');	
	
		
	$date=date('y-m-d');
//	$this->db->where('entry_date', $date);
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count<=1000000)
	{
	
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count<=1000000)
	{
	$this->db->select_max('token_no');
	$this->db->where('afid',$aid);	
//	$this->db->where('entry_date',$date);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	foreach($data['hms_opd_patient']->result() as $row)
		{
	//	break;
		}
		
	$new_lot_id=$row->token_no;
	$ac_auto_no=$new_lot_id+1;		
	$data['toc_no']=$row->token_no+1;
	
	$chech_val=strlen($ac_auto_no);	
	if($chech_val<=1)
	{
	$data['regno']='ANG'.'869'.$ac_auto_no;		
	}
	else if($chech_val==2 || $chech_val >=2)	 
	{
	$data['regno']='ANG'.'869'.$ac_auto_no;	
	}
	
			
	}
	else
	{
	$data['toc_no']=1;

	$data['regno']='ANG'.'869'.'1';  		
	}		
	$this->load->view('hms/add_opd_patient_user',$data);
	}
	else
	{
	
	}	
	}
	
	
	public function add_view_opd_patient_user()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$empid=$this->get_af_emp_id();
	
	$this->db->where('afid',$aid);
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$limit=150;
	$start=$this->uri->segment(3);
	$start1=$start*$limit;

	$this->db->where('afid',$aid);
//	$this->db->where('opd_emp_id',$empid);
	$this->db->order_by('id','desc');
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient',$limit,$start1);
	
	$this->db->where('afid',$aid);
	$data['hms_doctor']=$this->db->get('hms_doctor');
				
	$this->db->where('afid',$aid);
//	$this->db->where('opd_emp_id',$empid);	
	$data['total']=$this->db->count_all_results('hms_opd_patient');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_opd_patient_user',$data);	
          }
	else
	{
	echo 'Record not found';
	}	
	
	}	
	
	public function second_opd_patient_user()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$empid=$this->get_af_emp_id();
	
	$this->db->where('afid',$aid);
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$limit=150;
	$start=$this->uri->segment(3);
	$start1=$start*$limit;

	$this->db->where('afid',$aid);
//	$this->db->where('opd_emp_id',$empid);	
	$this->db->order_by('id','desc');
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient',$limit,$start1);
	
	$this->db->where('afid',$aid);
	$data['hms_doctor']=$this->db->get('hms_doctor');
				
	$this->db->where('afid',$aid);
//	$this->db->where('opd_emp_id',$empid);		
	$data['total']=$this->db->count_all_results('hms_opd_patient');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_opd_patient_user_second',$data);	
          }
	else
	{
	echo 'Record not found';
	}


	}	
	
public function edit_opd_patient_user()
{
	$this->load->library('session');
         $this->load->helper('url');
 	$aid=$this->get_affiliate();
 	$id=$this->uri->segment(3);
	$this->db->where('afid',$aid);
	$this->db->where('id',$id);	  
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');

	$this->db->where('afid',$aid);
	$data['hms_doctor']=$this->db->get('hms_doctor');
	
	$this->db->where('afid',$aid);
	$data['hms_nurse']=$this->db->get('hms_nurse');
	
	$this->db->where('afid',$aid);
	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$this->db->where('afid',$aid);
	$data['hms_hospital']=$this->db->get('hms_hospital');		
	
	$this->db->where('emp_aff_id',$aid);
	$data['emp_info_data']=$this->db->get('emp_info');	
		
	$this->load->view('hms/edit_opd_patient_user',$data);	
		
}	



	public function update_opd_patient_user()
	{
	$this->load->library('session');
	$this->load->helper('url');
	$aid=$this->get_affiliate();
	$row_id=$this->input->post('row_id');	
	$this->token_no=$this->input->post('tcno');
	$this->patient_name=$this->input->post('patient_name');	
	$this->gender=$this->input->post('gender');
	$this->age=$this->input->post('age');	
	$this->phone=$this->input->post('phone');
	$this->doctor_id=$this->input->post('doctor');	
	$this->collection_code=$this->input->post('collectby');
	$this->pathlogy_sign=$this->input->post('pathology_doctor');	
	$this->entry_date=$this->input->post('date');
	$this->titlename=$this->input->post('titlename');
	$this->yearname=$this->input->post('yearname');			
	$this->db->where('id',$row_id);
	$this->db->update('hms_opd_patient',$this);	
	echo 'Record Updated';
	}
	
	
	public function search_opd_patient_date_user()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$empid=$this->get_af_emp_id();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);		
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('opd_emp_id',$empid);				
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$limit=150;
	$start=$this->uri->segment(5);
	$start1=$start*$limit;

	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('opd_emp_id',$empid);		
	$this->db->order_by('entry_date','desc');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');

	$this->db->where('afid',$aid);
	$data['hms_doctor']=$this->db->get('hms_doctor');
				
	$this->db->where('afid',$aid);
	$this->db->where('opd_emp_id',$empid);	
	$data['total']=$this->db->count_all_results('hms_opd_patient');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_second_opd_patient_date_wise_user',$data);	
          }
	else
	{
	echo 'Record not found';
	}	
	}
	
	
//-----------------johri----------
      public function lab_part_payment_diagnose()
      {
   	$this->load->helper('url');
      	$this->load->library('session');
      	$aid=$this->get_affiliate();
	$af_emp_id=$this->get_af_emp_id();	      
      	$pid=$this->uri->segment(3);
      	$entry_date=$this->uri->segment(4);   
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$this->db->where('entry_date',$entry_date);		
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$this->db->where('entry_date',$entry_date);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');	
	foreach($data['hms_opd_patient']->result() as $row)
		{
    	break;
		}
	$data['tot_amt']=$row->tot_amount_diagnose;
	$data['paid_amt']=$row->amount_diagnose;	
	$data['discount']=$row->discount_diagnos;	
	
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);	
	$this->db->group_by('patient_id');
	$data['second_patient_assign_test']=$this->db->get('hms_patient_assign_test_diagnose');	

	$data['test_name']=$this->db->get('hms_dignos_master');	

	
		$this->load->view('hms/lab_part_payment_form_admin_diagnose',$data);				      
         }
	 else
	 {
	 echo 'Record not found';
	 }
      }

      
      public function lab_part_payment()
      {
   	$this->load->helper('url');
      	$this->load->library('session');
      	$aid=$this->get_affiliate();
	$af_emp_id=$this->get_af_emp_id();	      
      	$pid=$this->uri->segment(3);
      	$entry_date=$this->uri->segment(4);   
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$this->db->where('entry_date',$entry_date);		
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$this->db->where('entry_date',$entry_date);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');	
	foreach($data['hms_opd_patient']->result() as $row)
		{
    	break;
		}
	$data['tot_amt']=$row->tot_amount;
	$data['paid_amt']=$row->amount;	
	$data['discount']=$row->discount;	
	
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);	
	$this->db->group_by('patient_id');
	$data['second_patient_assign_test']=$this->db->get('hms_patient_assign_test');	

	$data['test_name']=$this->db->get('ho_m_test_master');	
if($af_emp_id =='200')	
{
	$this->load->view('hms/lab_part_payment_form_admin',$data);
	}
	else
	{
	$this->load->view('hms/lab_part_payment_form',$data);	
	}				      
         }
	 else
	 {
	 echo 'Record not found';
	 }
      }      
      
      
public function manage_test_rate()
{

$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	
	$data_count=$this->db->count_all_results('ho_m_test_master');
	if($data_count>0)
	{		
		$this->db->where('afid',$aid);
	//	$this->db->where('id',$pid);	
		$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
		
		$this->db->where('afid',$aid);
	//	$this->db->where('patient_id',$pid);	
		$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	
		
		$this->db->where('afid',$aid);
	//	$this->db->where('patient_id',$pid);
		$this->db->group_by('patient_id');	
		$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test');
		foreach($data['hms_opd_assign_test_pat']->result() as $row)
		{
		break;
		}
	//	$data['test_date']=$row->enter_date;			
		
		$this->db->where('afid',$aid);	
		$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$this->db->where('test_parient',0);
//	$this->db->order_by('test_title','asc');
	$data['test_name']=$this->db->get('ho_m_test_master');	
				
	$this->load->view('hms/manage_doctor_commission',$data);	
        }
	else
	{
	echo 'Record not found';
	}
}


          public function update_commission_marks()
             {
		$this->load->library('session');
        	$this->load->helper('url');
		$afid=$this->get_affiliate();
		$id=$this->input->post('checkid');
		$mark=$this->input->post('checkedoption2');
		$qui_id=explode(',',$id);
		$qui=explode(',',$mark);
	
	       $t=0;
		for($t1=0;Count($qui_id)>$t1;$t1++)
		{
		$this->load->database();
		//$this->modify_emp_id=$this->input->post('eid'); 
		$this->amount=$qui[$t]; 
		$this->db->where('id',$qui_id[$t]);
	       $this->db->update('ho_m_test_master',$this);
	       
		$t++;

		}
		
             }



public function view_patient_test_list()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
//	$this->db->where('afid',$aid);	
//	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$this->db->where('test_parient',0);
	$this->db->order_by('test_title','asc');
	$data['test_name']=$this->db->get('ho_m_test_master');	
	
	$this->db->order_by('test_title','asc');	
       	$data['test_name2']=$this->db->get('ho_m_test_master');	
      	 
	       $date_day=date('Y-m-d');
	       
	       $data['date_day']=$date_day;
	       
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('test_panels','0');	
	$this->db->group_by('test_parient');		
	$this->db->order_by('id','asc');	
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test');	
	
				
	$this->load->view('hms/assign_patient_test_list',$data);	
        }
	else
	{
	echo 'Record not found';
	}

}



	public function print_test_report_select()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
       $af_emp_id=$this->get_af_emp_id();	
	$pid=$this->uri->segment(3);
	$p_date=$this->uri->segment(4);
	$ques=$this->uri->segment(5);
	$b_date=$this->uri->segment(6);	
$data['ques']=$ques;
$data['pid']=$pid;
$data['aid']=$aid;

if($b_date =='')
{
	date_default_timezone_set('Asia/Calcutta');
	$data['report_time']=date("h:i a");	
	$data['today']=date('d-m-Y');
	}
	else
	{
	date_default_timezone_set('Asia/Calcutta');
	$data['report_time']=date("h:i a");	
	$data['today']=$b_date;	
	}

	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
//	$this->db->where('enter_date',$p_date);		
	$data_count=$this->db->count_all_results('hms_patient_assign_test');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	

	$this->db->where('e_affiliateid',$aid);
	$this->db->where('emp_info_id',$af_emp_id);
	$data['manage_employees']=$this->db->get('manage_employees');
	foreach($data['manage_employees']->result() as $row_emp)
	{
	break;
	}		
	$data['print_by']=$row_emp->e_fname.'&nbsp;'.$row_emp->e_lname;
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
//	$this->db->where('test_parient',125,155);		
	$this->db->group_by('test_parient');
	$this->db->order_by('id','asc');		
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	
	
	
	
		
	foreach($data['hms_opd_patient']->result() as $row_p)
	{
	break;
	}


	
	$this->db->where('afid',$aid);
	$this->db->where('doctor_id',$row_p->doctor_id);
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_d)
	{
	break;
	}		
	$data['doctor_name']=$row_d->name;
	
	

//	$this->db->where('afid',$aid);
	$this->db->where('nurse_id',$row_p->pathlogy_sign);
	$data['hms_nurse']=$this->db->get('hms_nurse');
	foreach($data['hms_nurse']->result() as $row_n)
	{
	break;
	}		
	$data['nurse_name']=$row_n->name;
	$data['degree']=$row_n->degree;
	$data['img_sign']=$row_n->img_sign;	
	
	
	$this->db->where('id',$row_p->collection_code);
	$data['hms_pathology']=$this->db->get('hms_pathology');
	foreach($data['hms_pathology']->result() as $row_path)
	{
	break;
	}		
	$data['pathology_name']=$row_path->pathology_name;
	$data['firdoct']=$row_path->firdoct;
	$data['fiedgree']=$row_path->fiedgree;
	$data['secdoct']=$row_path->secdoct;
	$data['secdgree']=$row_path->secdgree;
	
	
        $this->db->where('id',$row_p->hospitalid);
//	$this->db->where('enter_date',$p_date);		
	$data_count_hos=$this->db->count_all_results('hms_hospital');
	if($data_count_hos>0)
	{
        $this->db->where('id',$row_p->hospitalid);
	$data['hms_hospital']=$this->db->get('hms_hospital');
	foreach($data['hms_hospital']->result() as $row_hospit)
	{
	break;
	}		
	$data['hospital_name']=$row_hospit->pathology_name;
	$data['hospital_address']=$row_hospit->address;		
	
	}
	else
	{
	$data['hospital_name']='0';
	}		
	
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->group_by('patient_id');	
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test');
	foreach($data['hms_opd_assign_test_pat']->result() as $row)
	{
	break;
	}
	$data['test_date']=$row->enter_date;			
	

	
	//$this->db->where('test_parient !=',0);
	$data['test_name']=$this->db->get('ho_m_test_master');	
	

	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	
 $result = substr($ques, 0, 4);
 $result2 = substr($ques, 0, 5);	
 	
			
//	$this->load->view('hms/barcode',$data);	



		$this->load->view('hms/print_opd_test_report_new_select',$data);
          }
	else
	{
	echo 'Record not found';
	}	
	}	



function dbbackup()
     {
       $this->load->dbutil();   
  $today=date('d-m-Y');   
       $backup =& $this->dbutil->backup();  
       $this->load->helper('file');
       write_file('D:\desktopbackup/your_DB.zip', $backup);
echo 'Backup Has Been Generated';
     }
     
     
     
public function change_text_record()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->db->where('test_parient','0');
	$this->db->order_by('test_title','asc');
	$data['ho_m_test_master']=$this->db->get('ho_m_test_master');
		
	$this->load->view('hms/text_modifie',$data);  

}     


public function show_test_parient_list_modifie11()
		{
      		$this->load->library('session');
               	$this->load->helper('url');
       		$afid=$this->get_affiliate();
		$test_parient=$this->uri->segment(3);
	        $this->db->where('test_parient',$test_parient);
		$this->db->order_by('id','asc');
	        $data['sub_test_name_parient']=$this->db->get('ho_m_test_master');
		
	   $this->db->where('id',$test_parient);
	   $data['sub_test_name_parient_root']=$this->db->get('ho_m_test_master');	
	foreach($data['sub_test_name_parient_root']->result() as $row_p)
	{
	break;
	}
	$data['root_name']=$row_p->root_id;		
		
      	        $this->load->view('hms/sub_parient_test_list_modifie',$data);	
		}
		
	public function edit_e()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$id=$this->uri->segment(3);
	$this->db->where('id',$id);
	$data['ep_exam1']=$this->db->get('ho_m_test_master');
	
	$data['ep_exam12']=$this->db->get('ho_m_test_master');
	
	
	$this->load->view('hms/app_edit',$data);
	}
	
	
	public function edit_e_root()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$id=$this->uri->segment(3);
	$this->db->where('id',$id);
	$data['ep_exam1']=$this->db->get('ho_m_test_master');
	
	$data['ep_exam12']=$this->db->get('ho_m_test_master');
	
	
	$this->load->view('hms/app_edit_root',$data);
	}		
	
	
	public function delete_tt()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$id=$this->uri->segment(3);
	$pid=$this->uri->segment(4);	
	$this->db->where('id',$id);
	$this->db->delete('ho_m_test_master');
	echo 'Record deleted';

$this->call_test_chield2($pid);	
	}
	
	
public function delete_parient_root()
{
	$this->load->helper('url');
	$this->load->library('session');
	$id=$this->uri->segment(3);
	$this->db->where('id',$id);
	$this->db->delete('ho_m_test_master');
//$this->call_test_chield2();
}	
	
	public function call_test_chield2($pid)
	{
	$this->load->helper('url');
	$this->load->library('session');
	$test_parient=$pid;
	$this->db->where('id',$test_parient);
	$this->db->order_by('test_title','asc');	
	$data['kk']=$this->db->get('ho_m_test_master');	
	$this->load->view('hospital/app_second',$data);  
	}			
	public function call_test_chield()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$test_parient=$this->uri->segment(3);
	$this->db->where('id',$test_parient);
	$this->db->order_by('test_title','asc');	
	$data['kk']=$this->db->get('ho_m_test_master');	
	$this->load->view('hospital/app_second',$data);  
	}
	
	public function call_test_root_child()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$test_parient=$this->uri->segment(3);
	$this->db->where('id',$test_parient);
	$this->db->order_by('test_title','asc');	
	$data['kk']=$this->db->get('ho_m_test_master');	
	$this->load->view('hospital/app_second_root',$data);  
	}
	
	public function delete_tt_app()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$id=$this->uri->segment(3);
	$pid=$this->uri->segment(4);	
	$this->db->where('id',$id);
	$this->db->delete('ho_m_test_master');
	echo 'Record deleted';

$this->call_test_chield2($pid);	
	}
	
	
public function add_capsules()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
//	$this->db->where('afid',$aid);
//	$data['department']=$this->db->get('hms_department');		
	$this->load->view('hms/add_capsules');

}

	public function save_capsules()
	{
	$this->load->library('session');
	$this->load->helper('url');
	$aid=$this->get_affiliate();	
	$this->test_name=$this->input->post('cap_name');
	$this->amount=$this->input->post('amount');	
	$this->db->insert('pathlogy_master',$this);	
	echo 'Record Added';
	}			
      	
	public function view_capsules()
	{
	$this->load->helper('url');
	$this->load->library('session');
//	$aid=$this->get_affiliate();
	$this->load->database();

	$data_count=$this->db->count_all_results('pathlogy_master');
	if($data_count>0)
	{		
	$limit=1150;
	$start=$this->uri->segment(3);
	$start1=$start*$limit;
	
	$this->db->order_by('id','desc');
	$data['pathlogy_master']=$this->db->get('pathlogy_master');
		
	$data['total']=$this->db->count_all_results('pathlogy_master');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_capsules',$data);	
        }
	else
	{
	echo 'Record not found';
	}
	}
	
	public function edit_capsules()
	{
	$this->load->helper('url');
	$this->load->library('session');

	$row_id=$this->uri->segment(3);	
	$this->db->where('id',$row_id);
	$data['pathlogy_master']=$this->db->get('pathlogy_master');	
	$this->load->view('hms/edit_capsules',$data);  

	}
	
	public function update_capsules()
	{
	$this->load->library('session');
	$this->load->helper('url');
	$row_id=$this->input->post('row_id');	
	$this->test_name=$this->input->post('cap_name');
	$this->amount=$this->input->post('amount');	
	$this->db->where('id',$row_id);
	$this->db->update('pathlogy_master',$this);	
	echo 'Record Updated';
	}
	
	public function delete_capsules()
	{
 	$this->load->library('session');
         $this->load->helper('url');
 //	$aid=$this->get_affiliate();
 	$id=$this->uri->segment(3);
 	$this->db->where('id',$id);

 	$this->db->delete('pathlogy_master');
 	echo 'Record Deleted';
	}
	
public function create_panel()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();

	$this->db->where('test_parient','0');	
	$this->db->order_by('test_title','asc');
	$data['ho_m_test_master']=$this->db->get('ho_m_test_master');
	
	
	$this->db->order_by('test_name','asc');
	$data['pathlogy_master']=$this->db->get('pathlogy_master');	
			
	$this->load->view('hms/add_panels_master',$data);

}


	public function assign_panles_capsules()
 	{
      		$this->load->library('session');
        	$this->load->helper('url');
		$afid=$this->get_affiliate();
	//	$empid=$this->get_af_emp_id();		
		$ques=$this->input->post('value');
		$qui=explode(',',$ques);
		$t=0;
		for($t1=0;Count($qui)>$t1;$t1++)
		{	
	//	$this->db->where('test_id',$qui[$t]);	
		
		$cap_name=$this->input->post('cap_name');
		$this->db->where('cap_id',$cap_name);
		$this->db->where('test_pa_id',$qui[$t]);
		$data['lastan1']=$this->db->count_all_results('hms_panles_capules');
		
	
		if($data['lastan1']>=1)
		{
	
		   //echo $qui[$t].'Test already assigned ';    
		   //echo'Test already assigned ';
		   //	break;  
		   
		}
		else
	      {
               	$this->load->database();
               	$this->test_pa_id=$qui[$t]; 	
		$this->cap_id=$this->input->post('cap_name');
	//	$this->db->set('status','1');			
               	$this->db->insert('hms_panles_capules',$this);
		}
               	$t++;
                }
                echo 'Panels Assigned Capsules';  
      	}
	      
	  
	public function view_panel()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();


	
	
	$this->db->order_by('test_name','asc');
	$data['pathlogy_master']=$this->db->get('pathlogy_master');	
			
	$this->load->view('hms/view_panles',$data);
	}
	
	
	public function capsule_test_list()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
 	$id=$this->uri->segment(3);	

	$this->db->where('cap_id',$id);	
	$this->db->order_by('id','asc');
	$data['hms_panles_capules']=$this->db->get('hms_panles_capules');
	
	$this->db->where('test_parient','0');	
	$this->db->order_by('id','asc');
	$data['ho_m_test_master']=$this->db->get('ho_m_test_master');		
	
	$this->load->view('hms/sub_panels_capsules',$data);	
	}
	
	public function delete_panel_master_record()
	{
 	$this->load->library('session');
         $this->load->helper('url');
 //	$aid=$this->get_affiliate();
 	$id=$this->uri->segment(3);
 	$this->db->where('id',$id);

 	$this->db->delete('hms_panles_capules');
 	echo 'Record Deleted';

	}
	
	
	public function assign_patient_panels_test()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
//	$this->db->where('afid',$aid);	
//	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	
	
	$this->db->order_by('id','asc');	
       	$data['test_name2']=$this->db->get('ho_m_test_master');	
	       
	$this->db->order_by('id','asc');	
       	$data['pathlogy_master']=$this->db->get('pathlogy_master');		       
      	 
	       $date_day=date('Y-m-d');
	       
	       $data['date_day']=$date_day;


$data['pid']=$pid;	

	$this->db->order_by('id','asc');	
       	$data['pathlogy_master2']=$this->db->get('pathlogy_master');	
				
	$this->load->view('hms/assign_patient_panels_test',$data);	
        }
	else
	{
	echo 'Record not found';
	}
	}
	
	
	public function panels_test_list()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$panels_id=$this->uri->segment(3);
	$this->db->where('cap_id',$panels_id);	
	$data_count=$this->db->count_all_results('hms_panles_capules');
	if($data_count>0)
	{
	$this->db->where('cap_id',$panels_id);	
	$data['hms_panles_capules']=$this->db->get('hms_panles_capules');
	
	$this->db->where('test_parient',0);
	$this->db->order_by('id','asc');
	$data['test_name']=$this->db->get('ho_m_test_master');	
	
	$this->load->view('hms/capsul_panels_test',$data);		

	}
	else
	{
	echo 'Record not found';
	}
	
	}
	
public function show_test_parient_list_for_panels()
{
      		$this->load->library('session');
               	$this->load->helper('url');
       		$afid=$this->get_affiliate();
		$test_parient=$this->uri->segment(3);
	        $this->db->where('test_parient',$test_parient);
		$this->db->order_by('id','asc');
	        $data['sub_test_name_parient']=$this->db->get('ho_m_test_master');
		
	   $this->db->where('id',$test_parient);
	   $data['sub_test_name_parient_root']=$this->db->get('ho_m_test_master');	
	foreach($data['sub_test_name_parient_root']->result() as $row_p)
	{
	break;
	}
	$data['root_name']=$row_p->root_id;		
		
      	        $this->load->view('hms/sub_parient_test_list_for_panels',$data);


}



	public function assign_patient_panels_test_second()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	$panels_id=$this->uri->segment(4);	
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
//	$this->db->where('afid',$aid);	
//	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	
	
	$this->db->order_by('id','asc');	
       	$data['test_name2']=$this->db->get('ho_m_test_master');	
	       
	       
	$this->db->where('id',$panels_id);	 	
       	$data['pathlogy_master']=$this->db->get('pathlogy_master');
	       
	       
	$this->db->where('cap_id',$panels_id);	 	
       	$data['hms_panles_capules']=$this->db->get('hms_panles_capules');

	$this->db->order_by('id','asc');	
       	$data['test_name']=$this->db->get('ho_m_test_master');		       	       		       
      	 
	       $date_day=date('Y-m-d');
	       
	       $data['date_day']=$date_day;

	$data['pid']=$pid;

	$this->db->order_by('id','asc');	
       	$data['pathlogy_master2']=$this->db->get('pathlogy_master');	
	
				
	$this->load->view('hms/assign_patient_panels_test_second',$data);	
        }
	else
	{
	echo 'Record not found';
	}

	}
	
	
	public function add_pasient_test_for_panels()
	{
      		$this->load->library('session');
        	$this->load->helper('url');
		$afid=$this->get_affiliate();
		$empid=$this->get_af_emp_id();		
		$ques=$this->input->post('value');
		$qui=explode(',',$ques);
		$t=0;
		for($t1=0;Count($qui)>$t1;$t1++)
		{
		
	//	$this->db->where('test_id',$qui[$t]);	
		
		$patient_id=$this->input->post('patient_name');
		$test_parient=$this->input->post('test_parient');
		$this->db->where('patient_id',$patient_id);
	//	$this->db->where('test_parient',$test_parient);
		$this->db->where('test_id',$qui[$t]);
		$data['lastan1']=$this->db->count_all_results('hms_patient_assign_test');
		
	
		if($data['lastan1']>=1)
		{
	
		   //echo $qui[$t].'Test already assigned ';    
		   //echo'Test already assigned ';
		   //	break;  
		   
		}
		else
	      {
               	$this->load->database();
               	$this->test_id=$qui[$t]; 	
		$this->patient_id=$this->input->post('patient_name');
		$this->enter_date=$this->input->post('e_date');
		$this->test_parient=$this->input->post('test_parient');
		$this->root_id=$this->input->post('root_name');
		$this->test_panels=$this->input->post('test_panels');		
		$this->afid=$afid;
		$this->emp_id=$empid;
		$this->db->set('status','1');			
               	$this->db->insert('hms_patient_assign_test',$this);
		}
               	$t++;
                }
                echo 'Patient Assigned Test'; 

	}
	
	public function delete_panels_test()
	{
 	$this->load->library('session');
         $this->load->helper('url');
 	$aid=$this->get_affiliate();
 	$id=$this->uri->segment(3);
	$pid=$this->uri->segment(4);	 
 	$this->db->where('test_panels',$id);
	$this->db->where('patient_id',$pid);	 
 	$this->db->delete('hms_patient_assign_test');
 	echo 'Record Deleted';
	}
	
	public function update_panels_value()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	$p_date=$this->uri->segment(4);
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);

	$data_count=$this->db->count_all_results('hms_patient_assign_test');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->order_by('id','asc');	
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->group_by('test_parient');		
	$this->db->order_by('id','asc');	
	$data['hms_opd_assign_test44']=$this->db->get('hms_patient_assign_test');		
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->group_by('patient_id');	
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test');
	foreach($data['hms_opd_assign_test_pat']->result() as $row)
	{
	break;
	}
	$data['test_date']=$row->enter_date;			
	
//	$this->db->where('afid',$aid);	
	$data['pathlogy_master']=$this->db->get('pathlogy_master');	
	
	$this->db->where('test_parient','0');
	$this->db->order_by('test_parient','asc');		
	$data['test_name2']=$this->db->get('ho_m_test_master');	
	
	$this->db->order_by('id','asc');	
	$data['test_name']=$this->db->get('ho_m_test_master');	
				
	$this->load->view('hms/update_patient_test_value_panels',$data);	
        }
	else
	{
	echo 'Record not found';
	}
}


public function panels_sub_test()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	$p_date=$this->uri->segment(4);
	
	$parient_id=$this->uri->segment(5);	
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
//	$this->db->where('enter_date',$p_date);	
	$data_count=$this->db->count_all_results('hms_patient_assign_test');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('test_parient',$parient_id);	
	$this->db->order_by('id','asc');	
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	
	
	
	$this->db->order_by('id','asc');	
	$data['test_name']=$this->db->get('ho_m_test_master');	
				
	$this->load->view('hms/sub_panels_mark_add',$data);	
        }
	else
	{
	echo 'Record not found';
	}
}


public function view_patient_test_list_panles()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);	
	$this->db->where('test_panels !=','0');		
	$data_count=$this->db->count_all_results('hms_patient_assign_test');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
//	$this->db->where('afid',$aid);	
//	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$this->db->where('test_parient',0);
	$this->db->order_by('test_title','asc');
	$data['test_name']=$this->db->get('ho_m_test_master');	
	
	$this->db->order_by('test_title','asc');	
       	$data['test_name2']=$this->db->get('ho_m_test_master');	
      	 
	       $date_day=date('Y-m-d');
	       
	       $data['date_day']=$date_day;
	       
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('test_panels !=','0');	
	$this->db->group_by('test_parient','test_panels');		
	$this->db->order_by('id','asc');	
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test');	
	foreach($data['hms_patient_assign_test']->result() as $row)
	{
	break;
	}
	$test_panels=$row->test_panels;	

$this->db->where('id',$test_panels);	
       	$data['pathlogy_master']=$this->db->get('pathlogy_master');
	       
	foreach($data['pathlogy_master']->result() as $row45)
	{
	break;
	}
	$data['capsul_name']=$row45->test_name;	
	
	$data['capsul_id']=$row45->id;			       	
				
	$this->load->view('hms/assign_patient_test_list_panles',$data);	
        }
	else
	{
	echo 'Record not found';
	}

}


	public function print_report_panels()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	$p_date=$this->uri->segment(4);
	$ques=$this->uri->segment(5);
	$panels_id=$this->uri->segment(6);
		
$data['ques']=$ques;
$data['pid']=$pid;
$data['aid']=$aid;
	date_default_timezone_set('Asia/Calcutta');
	$data['report_time']=date("h:i a");	
	$data['today']=date('d-m-Y');
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
//	$this->db->where('enter_date',$p_date);		
	$data_count=$this->db->count_all_results('hms_patient_assign_test');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	


	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
//	$this->db->where('test_parient',125,155);		
	$this->db->group_by('test_parient');
	$this->db->order_by('id','asc');		
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	
	
	
	
		
	foreach($data['hms_opd_patient']->result() as $row_p)
	{
	break;
	}
	
	$this->db->where('afid',$aid);
	$this->db->where('doctor_id',$row_p->doctor_id);
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_d)
	{
	break;
	}		
	$data['doctor_name']=$row_d->name;
	
	

//	$this->db->where('afid',$aid);
	$this->db->where('nurse_id',$row_p->pathlogy_sign);
	$data['hms_nurse']=$this->db->get('hms_nurse');
	foreach($data['hms_nurse']->result() as $row_n)
	{
	break;
	}		
	$data['nurse_name']=$row_n->name;
	$data['degree']=$row_n->degree;
	$data['img_sign']=$row_n->img_sign;	
	
	
	$this->db->where('id',$row_p->collection_code);
	$data['hms_pathology']=$this->db->get('hms_pathology');
	foreach($data['hms_pathology']->result() as $row_path)
	{
	break;
	}		
	$data['pathology_name']=$row_path->pathology_name;	
	
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->group_by('patient_id');	
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test');
	foreach($data['hms_opd_assign_test_pat']->result() as $row)
	{
	break;
	}
	$data['test_date']=$row->enter_date;			
	

	
	//$this->db->where('test_parient !=',0);
	$data['test_name']=$this->db->get('ho_m_test_master');	
	

	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	
 $result = substr($ques, 0, 4);
 $result2 = substr($ques, 0, 5);	
 	
	$this->db->where('id',$panels_id);	
	$data['pathlogy_master']=$this->db->get('pathlogy_master');
	foreach($data['pathlogy_master']->result() as $row78)
	{
	break;
	}
	$data['panels_name']=$row78->test_name;			
		$this->load->view('hms/print_opd_test_report_new_select_panels',$data);
          }
	else
	{
	echo 'Record not found';
	}	
	}
	
	
	public function print_panel_sleep()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	$today=$this->uri->segment(4);
	
	$data['today']=$today;
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('enter_date',$today);	
	$this->db->where('test_panels !=','0');
	$data_count=$this->db->count_all_results('hms_patient_assign_test');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('enter_date',$today);	
	$this->db->where('test_panels !=','0');		
	$this->db->group_by('test_parient');
	$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	
	foreach($data['hms_opd_patient']->result() as $row_p)
	{
	break;
	}
	
	
	$this->db->where('afid',$aid);
	$this->db->where('doctor_id',$row_p->doctor_id);
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_d)
	{
	break;
	}		
	$data['doctor_name']=$row_d->name;
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('enter_date',$today);	
	$this->db->group_by('patient_id');	
	$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test');
	foreach($data['hms_opd_assign_test_pat']->result() as $row)
	{
	break;
	}
	$data['test_date']=$row->enter_date;			
$this->db->where('id',$row->test_panels);	
	$data['panels_master']=$this->db->get('pathlogy_master');	
	foreach($data['panels_master']->result() as $row_panels)
	{
	break;
	}	
	$data['panels_name']=$row_panels->test_name;
	$data['pales_amount']=$row_panels->amount;	
	//$this->db->where('test_parient !=',0);
	$data['test_name']=$this->db->get('ho_m_test_master');	
	
	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	
	
				
	$this->load->view('hms/print_opd_test_report_sleep_panels',$data);	
          }
	else
	{
	echo 'Record not found';
	}	
	}  
			
public function change_text_record_rate()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$this->db->where('test_parient','0');
	$this->db->order_by('test_title','asc');
	$data['ho_m_test_master']=$this->db->get('ho_m_test_master');
		
	$this->load->view('hms/text_modifie_rate',$data);  

} 

	public function test_rate_fine()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$test_parient=$this->uri->segment(3);
	$this->db->where('id',$test_parient);
	$this->db->order_by('test_title','asc');	
	$data['kk']=$this->db->get('ho_m_test_master');	

	foreach($data['kk']->result() as $row)
	{
	break;
	}	
	$data['rate']=$row->amount;	
	
	$this->load->view('hms/test_rate',$data);  
	}
	
public function name_wise_pai()
{
		$bookids=array();
		$books="";
	
		$this->load->helper('url');
		$aid=$this->get_affiliate();
		$title1=$this->uri->segment(3);
		$title1=str_replace(":"," ",$title1);

			
		if($title1!='0')
		{
		$query="patient_name like '".$title1."%'";
		$this->db->where($query);
		}
		
		
		$this->db->where($query);
		$this->db->where('afid',$aid);
		$this->db->order_by('patient_name','asc');			
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$limit=150;
	$start=$this->uri->segment(4);
	$start1=$start*$limit;

		if($title1!='0')
		{
		$query="patient_name like '".$title1."%'";
		$this->db->where($query);
		}
		
		
		$this->db->where($query);
		$this->db->where('afid',$aid);
		$this->db->order_by('patient_name','asc');		
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');

	$this->db->where('afid',$aid);
	$data['hms_doctor']=$this->db->get('hms_doctor');
				
		$this->db->where($query);
		$this->db->where('afid',$aid);
		$this->db->order_by('patient_name','asc');		
	$data['total']=$this->db->count_all_results('hms_opd_patient');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_second_opd_patient_date_wise',$data);	
          }
	else
	{
	echo 'Record not found';
	}	
}


//------------------------------------------------

public function pateint_test_list_child()
{
		$this->load->library('session');
        	$this->load->helper('url');
	$pid=$this->uri->segment(3);
	$test_pid=$this->uri->segment(4);
//	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('test_parient',$test_pid);	
//	$this->db->where('enter_date',$p_date);	
	$data_count=$this->db->count_all_results('hms_patient_assign_test');
	if($data_count>0)
	{			
	$this->db->where('patient_id',$pid);
	$this->db->where('test_parient',$test_pid);	
	$this->db->order_by('id','asc');
	$data['hms_opd_assign_test_3']=$this->db->get('hms_patient_assign_test');	
		
	
	$this->db->where('test_parient !=',0);
	$this->db->group_by('id');
	$data['test_name_3']=$this->db->get('ho_m_test_master');
	$this->load->view('hms/pateint_test_list_child',$data);	
	}
	else
	{
	echo 'Record not found';
	}	
}



public function pateint_test_list_child_remove()
{
		$this->load->library('session');
        	$this->load->helper('url');
	$pid=$this->uri->segment(3);
	$test_pid=$this->uri->segment(4);
//	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('test_id',$test_pid);	
//	$this->db->where('enter_date',$p_date);	
	$data_count=$this->db->count_all_results('hms_patient_assign_test');
	if($data_count>0)
	{
		$this->db->set('remove','1');
	$this->db->where('patient_id',$pid);
	$this->db->where('test_id',$test_pid);					
               	$this->db->update('hms_patient_assign_test',$this);
	}
	else
	{
	echo 'Record not found';
	}

}


public function pateint_test_list_child_ok()
{
		$this->load->library('session');
        	$this->load->helper('url');
	$pid=$this->uri->segment(3);
	$test_pid=$this->uri->segment(4);
//	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
	$this->db->where('test_id',$test_pid);	
//	$this->db->where('enter_date',$p_date);	
	$data_count=$this->db->count_all_results('hms_patient_assign_test');
	if($data_count>0)
	{
		$this->db->set('remove','0');
	$this->db->where('patient_id',$pid);
	$this->db->where('test_id',$test_pid);					
               	$this->db->update('hms_patient_assign_test',$this);
	}
	else
	{
	echo 'Record not found';
	}

}



//	
	
//---------------------rate change--------------------
public function get_ch_tot()
{
		$this->load->library('session');
        	$this->load->helper('url');
		$afid=$this->get_affiliate();
		
		$id=$this->input->post('checkid');
		$mark=$this->input->post('checkedoption2');
		$qui_id=explode(',',$id);
		$qui=explode(',',$mark);
	
	       $t=0;
	       $test_val="";
		for($t1=0;Count($qui_id)>$t1;$t1++)
		{
		$this->load->database();
		//$this->modify_emp_id=$this->input->post('eid'); 
		$test_val +=$qui[$t]; 
	    
		$t++;

		}
	$this->amt=$test_val;
	$this->aid='0';
	$this->db->insert('hms_tot_bill',$this);		
		

}

public function get_sum_amt()
{
		$this->load->library('session');
        	$this->load->helper('url');
$this->db->order_by('id','desc');		
$data['hms_tot_bill']=$this->db->get('hms_tot_bill');
	foreach($data['hms_tot_bill']->result() as $row_p)
	{
	break;
	}
	$data['test_val']=$row_p->amt;		
	$this->load->view('hms/chage_tot_amt',$data);
}


public function patient_bill_data_save()
{
		$this->load->library('session');
        	$this->load->helper('url');
		$afid=$this->get_affiliate();
		
	$af_emp_id=$this->get_af_emp_id();		

	$this->db->where('aid','0');		
	$this->db->delete('hms_tot_bill');
			
		$id=$this->input->post('checkidd');
		$mark=$this->input->post('checkedoption24');
		$patient_id=$this->input->post('patient_name'); 
		$date_test=$this->input->post('e_date'); 			
		$qui_id=explode(',',$id);
		$qui=explode(',',$mark);
	
	       $t=1;
		for($t1=0;Count($qui_id)>$t1;$t1++)
		{
	
	$this->db->where('patient_id',$patient_id);
//	$this->db->where('date_test',$date_test);
	$this->db->where('test_pid',$qui_id[$t]);	
			
	$data_count=$this->db->count_all_results('hms_opd_test_rate');
	if($data_count>0)
	{

	
	}
	else
	{		
		$this->load->database();
		$this->opd_emp_id=$af_emp_id;		
		$this->patient_id=$this->input->post('patient_name'); 
		$this->date_test=$this->input->post('e_date'); 	
		$this->test_pid=$qui_id[$t]; 		
		$this->amt=$qui[$t];
	
	       $this->db->insert('hms_opd_test_rate',$this);    
	 	
      }	    
       	$t++;		 								    	      						  		  		      		      	 	   		  			
}
}


	public function delete_opd_test_rate()
	{
 	$this->load->library('session');
         $this->load->helper('url');
 	$aid=$this->get_affiliate();
 	$id=$this->uri->segment(3);
	$pid=$this->uri->segment(4);	 
	$this->db->where('test_pid',$id);
	$this->db->where('patient_id',$pid);
	$this->db->where('print_status','0');					
	$data_count=$this->db->count_all_results('hms_opd_test_rate');
	if($data_count >=1)
	{	 
 	$this->db->where('test_pid',$id);
	$this->db->where('patient_id',$pid);
	$this->db->where('print_status','0');		 
 	$this->db->delete('hms_opd_test_rate');
 	echo 'Record Deleted';
	 }
	 else
	 {
	 
	 }	
	 
	}
	
	
	
public function patient_bill_data_save_diagnose()
{
		$this->load->library('session');
        	$this->load->helper('url');
		$afid=$this->get_affiliate();
		
	$af_emp_id=$this->get_af_emp_id();		

//	$this->db->where('aid','0');		
//	$this->db->delete('hms_tot_bill');
			
		$id=$this->input->post('checkidd');
		$mark=$this->input->post('checkedoption24');
		$patient_id=$this->input->post('patient_name'); 
		$date_test=$this->input->post('e_date'); 			
		$qui_id=explode(',',$id);
		$qui=explode(',',$mark);
	
	       $t=1;
		for($t1=0;Count($qui_id)>$t1;$t1++)
		{
	
	$this->db->where('patient_id',$patient_id);
//	$this->db->where('date_test',$date_test);
	$this->db->where('test_pid',$qui_id[$t]);	
			
	$data_count=$this->db->count_all_results('hms_opd_test_rate_diagnose');
	if($data_count>0)
	{

		$this->load->database();
		$this->patient_id=$this->input->post('patient_name'); 
	//	$this->date_test=$this->input->post('e_date'); 	
		$this->amt=$qui[$t];
		$this->opd_emp_id=$af_emp_id;		
		//$this->test_pid=$qui_id[$t]; 
		$this->db->where('test_pid',$qui_id[$t]);
		$this->db->where('patient_id',$patient_id);	
	       $this->db->update('hms_opd_test_rate_diagnose',$this);    
		$t++;	
	}
	else
	{		
		$this->load->database();
		$this->opd_emp_id=$af_emp_id;		
		$this->patient_id=$this->input->post('patient_name'); 
		$this->date_test=$this->input->post('e_date'); 	
		$this->test_pid=$qui_id[$t]; 		
		$this->amt=$qui[$t];
	
	       $this->db->insert('hms_opd_test_rate_diagnose',$this);    
	 $t++;	
      }	    
       			 								    	      						  		  		      		      	 	   		  			
}
}	

//-------------------------end rate----------------										      					      
public function search_today_report_pid()
{
       		$this->load->library('session');
               	$this->load->helper('url');
       		$afid=$this->get_affiliate();
       		//$pid=$this->uri->segment(3);
		$fdate=$this->uri->segment(3);
	     $tdate=$this->uri->segment(4);
	     
	     $data['fdate']=$fdate;
	     $data['tdate']=$tdate;	             
       	$this->db->where('afid',$afid);	
	$this->db->where('enter_date >=',$fdate);	
	$this->db->where('enter_date <=',$tdate);	       
       	$data_count=$this->db->count_all_results('hms_patient_assign_test');
       	if($data_count>0)
       	{		
       	$this->db->where('afid',$afid);	
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);	       
       	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
       	
       //	$this->db->where('test_parient !=',0);
       	$data['test_name']=$this->db->get('ho_m_test_master');	
      	 
      	$this->db->where('afid',$afid);
	$this->db->where('enter_date >=',$fdate);	
	$this->db->where('enter_date <=',$tdate);	      
	$this->db->group_by('patient_id');    
	$this->db->group_by('enter_date');    
       	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test');	 
       
       	$this->db->where('afid',$afid);	       
       	$data['hms_pathology']=$this->db->get('hms_pathology');	
	       
       	$this->db->where('afid',$afid);	       
       	$data['hms_doctor']=$this->db->get('hms_doctor');	       
	       
	$this->db->where('affiliate_id',$afid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');	       
      	       				
       	$this->load->view('hms/view_patient_today_report',$data);	
               }
       	else
       	{
       	echo 'Record not found';
       	}
}


public function print_test()
{
       		$this->load->library('session');
               	$this->load->helper('url');
	$afid=$this->get_affiliate();		       
	$this->db->where('affiliate_id',$afid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		       
       	$this->db->where('test_parient',0);
       	$data['test_name']=$this->db->get('ho_m_test_master');	
       	$this->load->view('hms/print_test',$data);	       		       
   
}

 public function upload_rechecked()
    {
   	$this->load->library('session');
	$this->load->helper('url');
	$data['aid']=$this->get_affiliate();
	$eid=$this->uri->segment(3);
	$data['eid']=$eid;
   	$this->db->where('id',$eid);	   			
   	$data_count=$this->db->count_all_results('hms_patient_assign_test');
   	if($data_count>0)
   	{
 	$this->db->where('id',$eid);		   
$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test');
	foreach($data['hms_patient_assign_test']->result() as $row_p)
	{
	break;
	}
	$data['test_text']=$row_p->text;	   
	   }	
	$this->load->view('hms/add_rechecked_val',$data);
    }
    
    
   public function update_comment_recked()
   {
   
    	$this->load->library('session');
   	$this->load->helper('url'); 
 	$id=$this->input->post('h1');
   	$this->db->where('id',$id);			
   	$data_count=$this->db->count_all_results('hms_patient_assign_test');
   	if($data_count>0)
   	{
   		$this->load->database();
   		$this->text=$this->input->post('h2'); 
   		$this->db->where('id',$id);
   	       $this->db->update('hms_patient_assign_test',$this);    	
   	} 
	   else
	   {
	   
	   } 
   }
   
   
   
public function apply_for_account()
{
  	$this->load->library('session');
  	$this->load->helper('url');
$aid=$this->get_affiliate();
	$id=$this->uri->segment(3);
	$data['id']=$id;
	$data['id1']=$this->uri->segment(3);
	$afid=$this->get_affiliate();
	
	$this->db->where('emp_aff_id',$afid);
	$this->db->where('emp_id',$id);
	$data['emp_info']=$this->db->get('emp_info');
	
//	$this->db->where('afid',$afid);
	$data['manage_designation']=$this->db->get('manage_designation');


	$this->db->where('afid',$aid);	
	$data['manage_assigne_designation']=$this->db->get('manage_assigne_designation');

	$this->load->view('hms/create_emp_account_form',$data);
}

public function emp_create_ac_number()
{
$this->load->library('session');
$this->load->helper('url');
$afid=$this->get_affiliate();
$id=$this->input->post('emprollid');
	$this->db->where('e_affiliateid',$afid);
	$this->db->where('emp_info_id',$id);
	$data['lastan1']=$this->db->count_all_results('manage_employees');
	if($data['lastan1']>=1)
	{
echo 'Exit Account';
}
else
{
$this->emp_info_id=$this->input->post('emprollid');
$this->e_fname=$this->input->post('f_name');
$this->e_lname=$this->input->post('l_name');
$this->entry_date=$this->input->post('stdate');
$this->e_contact=$this->input->post('emp_cont');
$this->e_address=$this->input->post('emp_address');

$this->e_affiliateid=$this->input->post('emp_afid');
$this->e_designation=$this->input->post('designation_type');
$this->e_email=$this->input->post('email');
$this->e_password=$this->input->post('pass');

$this->db->insert('manage_employees',$this);
echo 'Created Account';
}
}

public function search_admin_empdep_view()
{
$this->load->library('session');
$this->load->helper('url');
				
$data['empinfo']=$this->db->get('emp_info');


$this->load->view('hms/employee_list_view_account',$data);

}

public function apply_for_account_edit()
{
  	$this->load->library('session');
  	$this->load->helper('url');
	$id=$this->uri->segment(3);
	$data['id']=$id;
	$data['id1']=$this->uri->segment(3);
	$afid=$this->get_affiliate();
	
	$this->db->where('e_affiliateid',$afid);
	$this->db->where('emp_info_id',$id);
	$data['lastan1']=$this->db->count_all_results('manage_employees');
	if($data['lastan1']>=1)
	{
	$this->db->where('e_affiliateid',$afid);
	$this->db->where('emp_info_id',$id);		
	$data['emp_info']=$this->db->get('manage_employees');

	$data['manage_designation']=$this->db->get('manage_designation');

	$this->load->view('hms/edit_emp_account_form',$data);
         }
	 else
	 {
	 
	 echo 'Employee Email and Password not Created';
	 
	 }
}

public function emp_update_ac_number()
{
$this->load->library('session');
$this->load->helper('url');
$aid=$this->get_affiliate();
$emp_info_id=$this->input->post('emprollid');

$this->e_designation=$this->input->post('designation_type');
$this->e_email=$this->input->post('email');
$this->e_password=$this->input->post('pass');
$this->db->where('e_affiliateid',$aid);
$this->db->where('emp_info_id',$emp_info_id);
$this->db->update('manage_employees',$this);
echo 'Account Updated';

}

	public function assign_patient_test_user()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$pid=$this->uri->segment(3);
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	foreach($data['hms_opd_patient']->result() as $row)
	{
	break;
	}
	$data['phone']=$row->phone;
	$data['date_day']=$row->entry_date;	
	
//	$this->db->where('afid',$aid);	
//	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$this->db->where('test_parient',0);
	$this->db->order_by('id','asc');
	$data['test_name']=$this->db->get('ho_m_test_master');	
	
	$this->db->order_by('id','asc');	
       	$data['test_name2']=$this->db->get('ho_m_test_master');	
      	 
	       $date_day= $row->entry_date;
	       
	       
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
//	$this->db->where('enter_date',$date_day);
	$this->db->where('test_panels','0');		
//----------------show amount with parient---

$this->db->group_by('test_parient');
//-------------------------------------------------		
	$this->db->order_by('enter_date','desc');	
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test');	
	
				
	$this->load->view('hms/assign_patient_test_user',$data);	
        }
	else
	{
	echo 'Record not found';
	}
	}
	
public function name_wise_pai_user()
{
		$bookids=array();
		$books="";
	
		$this->load->helper('url');
		$aid=$this->get_affiliate();
		$title1=$this->uri->segment(3);
		$title1=str_replace(":"," ",$title1);

			
		if($title1!='0')
		{
		$query="patient_name like '".$title1."%'";
		$this->db->where($query);
		}
		
		
		$this->db->where($query);
		$this->db->where('afid',$aid);
		$this->db->order_by('patient_name','asc');			
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$limit=150;
	$start=$this->uri->segment(4);
	$start1=$start*$limit;

		if($title1!='0')
		{
		$query="patient_name like '".$title1."%'";
		$this->db->where($query);
		}
		
		
		$this->db->where($query);
		$this->db->where('afid',$aid);
		$this->db->order_by('patient_name','asc');		
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');

	$this->db->where('afid',$aid);
	$data['hms_doctor']=$this->db->get('hms_doctor');
				
		$this->db->where($query);
		$this->db->where('afid',$aid);
		$this->db->order_by('patient_name','asc');		
	$data['total']=$this->db->count_all_results('hms_opd_patient');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_second_opd_patient_date_wise_user',$data);	
          }
	else
	{
	echo 'Record not found';
	}	
}

	public function search_opd_patient_rego_wise_user()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$rego=$this->uri->segment(3);
//	$tdate=$this->uri->segment(4);		
	
	$this->db->where('afid',$aid);
	$this->db->where('phone',$rego);			
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$limit=150;
	$start=$this->uri->segment(5);
	$start1=$start*$limit;

	$this->db->where('afid',$aid);	
	$this->db->where('phone',$rego);		
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');

	$this->db->where('afid',$aid);
	$data['hms_doctor']=$this->db->get('hms_doctor');
				
	$this->db->where('afid',$aid);
	$this->db->where('phone',$rego);		
	$data['total']=$this->db->count_all_results('hms_opd_patient');
	$data['limit']=$limit;
	$data['start']=$start;
	$data['start1']=$start1;
	$this->load->view('hms/view_second_opd_patient_date_wise_user',$data);	
          }
	else
	{
	echo 'Record not found';
	}	
	}		
    
 //--------------------------------------------------------------
 
	public function view_boy_report()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();

	$this->db->where('emp_aff_id',$aid);
	$data['emp_info']=$this->db->get('emp_info');
	
	$this->db->where('afid',$aid);
	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$this->load->view('hms/view_boy_report',$data);	
	}  
	
	
	
	public function call_emp_center()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$paid=$this->uri->segment(3);

	$this->db->where('pathlogy_id',$paid);			
	$data_count=$this->db->count_all_results('emp_info ');
	if($data_count>0)
	{
	$this->db->where('pathlogy_id',$paid);
	$data['emp_info']=$this->db->get('emp_info');
	
	$this->load->view('hms/view_sub_emp',$data);			
	}
	else
	{
	
	echo 'No record found';
	}
	}	
	
	
	public function print_report_date_boy()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);
	$centerid=$this->uri->segment(5);	
	
	
	$this->db->where('emp_aff_id',$aid);
	$this->db->where('emp_enroll',$centerid);	
	$data['emp_info']=$this->db->get('emp_info');
	foreach($data['emp_info']->result() as $row_name)
		{
		break;
		}
	$data['emp_name']=$row_name->emp_fname.'&nbsp;'.$row_name->emp_mname.'&nbsp;'.$row_name->emp_lname;	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('clboy',$centerid);			
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('clboy',$centerid);
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		
				
	$this->load->view('hms/print_report_boy_wise',$data);					
          }
	else
	{
	echo 'Record not Found';
	}
	}

public function get_pid_record()
{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
 	$reg=$this->uri->segment(3);
	$age=$this->uri->segment(4);
	$date=$this->uri->segment(5);
	
	$this->db->where('afid',$aid);
	$this->db->where('age',$age);	
	$this->db->where('entry_date',$date);
	$this->db->where('phone',$reg);			
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	$this->db->where('afid',$aid);
	$this->db->where('age',$age);	
	$this->db->where('entry_date',$date);
	$this->db->where('phone',$reg);		
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	foreach($data['hms_opd_patient']->result() as $row_name)
		{
		break;
		}
echo	$data['pid']=$row_name->id;
	
	$this->db->where('test_parient',0);
	$this->db->order_by('test_title','asc');
	$data['test_name']=$this->db->get('ho_m_test_master');	
	
	$this->db->order_by('test_title','asc');	
       	$data['test_name2']=$this->db->get('ho_m_test_master');	
      	 
	   //    $date_day=date('Y-m-d');
	       
	       $data['date_day']=$date;
	       
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$row_name->id);
	$this->db->where('test_panels','0');	
	$this->db->group_by('test_parient');		
	$this->db->order_by('id','asc');	
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test');	
	
				
	$this->load->view('hms/out_report',$data);	
		
	}
	else
	{
	echo 'Record not found';
	}

}


     public function delite_slip_record()
     {
 	$this->load->library('session');
         $this->load->helper('url');
 //	$aid=$this->get_affiliate();
 	$pid=$this->uri->segment(3);
	 
 //	$this->db->where('test_pid',$id);
	$this->db->where('patient_id',$pid);	 
 	$this->db->delete('hms_opd_test_rate');
 	echo 'Record Deleted';
        }
	
	public function get_doctor_rate()
	{
 	$this->load->library('session');
         $this->load->helper('url');
 	$pid=$this->uri->segment(3);

	$this->db->where('doctor_id',$pid);			
	$data_count=$this->db->count_all_results('hms_doctor');
	if($data_count>0)
	{
	$this->db->where('doctor_id',$pid);		
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_name)
		{
		break;
		}
	$data['per']=$row_name->per;
	$data['digper']=$row_name->digper;	
				
	$this->load->view('hms/doctor_rate',$data);	
	}
	else
	{
	
	echo 'No Record Found';
	}
	}
	
	
	public function view_day_report_hospital()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();

        $this->db->where('afid',$aid);
	$this->db->order_by('pathology_name','asc');
	$data['hms_hospital']=$this->db->get('hms_hospital');
	
	$this->db->where('afid',$aid);
	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$data['hms_zone_master']=$this->db->get('hms_zone_master');	
	
	$this->load->view('hms/view_hospital_report',$data);	
	}
	
        public function get_hospital_rate()
       {
	$this->load->library('session');
         $this->load->helper('url');
 	$pid=$this->uri->segment(3);

	$this->db->where('id',$pid);			
	$data_count=$this->db->count_all_results('hms_hospital');
	if($data_count>0)
	{
	$this->db->where('id',$pid);		
	$data['hms_hospital']=$this->db->get('hms_hospital');
	foreach($data['hms_hospital']->result() as $row_name)
		{
		break;
		}
	$data['per']=$row_name->per;
	$data['digper']=$row_name->digper;	
				
	$this->load->view('hms/doctor_rate',$data);	
	}
	else
	{
	
	echo 'No Record Found';
	}
       }
       
     
   public function get_hospital_pathlogy()
   {
 	$this->load->library('session');
            $this->load->helper('url');
    	$pid=$this->uri->segment(3);
   
   	$this->db->where('pathlogy_id',$pid);			
   	$data_count=$this->db->count_all_results('hms_hospital');
   	if($data_count>0)
   	{
   	$this->db->where('pathlogy_id',$pid);		
   	$data['hms_hospital']=$this->db->get('hms_hospital');
  				
   	$this->load->view('hms/sub_hospital',$data);	
   	}
   	else
   	{
   	
   	echo 'No Record Found';
   	}  
   
   }    
       
       
       
       
	public function print_report_date_emp_first_hospital()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);
	$empid=$this->uri->segment(5);	
	$pathlogy=$this->uri->segment(6);				
	
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$empid);	
	$data['hms_hospital']=$this->db->get('hms_hospital');
	foreach($data['hms_hospital']->result() as $row_name)
		{
		break;
		}
	$data['emp_name']=$row_name->pathology_name;	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
	
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pathlogy);	
	$data['center']=$this->db->get('hms_pathology');
	foreach($data['center']->result() as $row_center)
		{
		break;
		}
	$data['center_name']=$row_center->pathology_name;	
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('hospitalid',$empid);
	$this->db->where('collection_code',$pathlogy);				
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('hospitalid',$empid);
	$this->db->where('collection_code',$pathlogy);	
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		
				
	$this->load->view('hms/print_report_date_wise_first_hospital',$data);					
          }
	else
	{
	echo 'Record not Found';
	}
	}       
       
	public function print_report_date_emp_hospital()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);
	$empid=$this->uri->segment(5);	
	$data['disper']=$this->uri->segment(6);	
	$data['disperrt']=$this->uri->segment(7);	
	$pathlogy=$this->uri->segment(8);					
	
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$empid);	
	$data['hms_hospital']=$this->db->get('hms_hospital');
	foreach($data['hms_hospital']->result() as $row_name)
		{
		break;
		}
	$data['emp_name']=$row_name->pathology_name;	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pathlogy);	
	$data['center']=$this->db->get('hms_pathology');
	foreach($data['center']->result() as $row_center)
		{
		break;
		}
	$data['center_name']=$row_center->pathology_name;	
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('hospitalid',$empid);	
	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount !=','0');				
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('hospitalid',$empid);
	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount !=','0');		
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		
				
	$this->load->view('hms/print_report_date_wise_hospital',$data);					
          }
	else
	{
	echo 'Record not Found';
	}
	}
	
	public function print_report_date_emp_first_diagnos_hospital()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);
	$empid=$this->uri->segment(5);	
	$pathlogy=$this->uri->segment(6);				
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$empid);	
	$data['hms_hospital']=$this->db->get('hms_hospital');
	foreach($data['hms_hospital']->result() as $row_name)
		{
		break;
		}
	$data['emp_name']=$row_name->pathology_name;	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
	
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pathlogy);	
	$data['center']=$this->db->get('hms_pathology');
	foreach($data['center']->result() as $row_center)
		{
		break;
		}
	$data['center_name']=$row_center->pathology_name;	
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('hospitalid',$empid);
	$this->db->where('collection_code',$pathlogy);				
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('hospitalid',$empid);
	$this->db->where('collection_code',$pathlogy);	
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		
				
	$this->load->view('hms/print_report_date_wise_first_diagno_hospital',$data);					
          }
	else
	{
	echo 'Record not Found';
	}
	}
	
	
	public function print_report_date_emp_diagnos_all_hospital()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);
	$empid=$this->uri->segment(5);	
	$data['disper']=$this->uri->segment(6);	
	$data['disperrt']=$this->uri->segment(7);	
	$pathlogy=$this->uri->segment(8);					
	
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$empid);	
	$data['hms_hospital']=$this->db->get('hms_hospital');
	foreach($data['hms_hospital']->result() as $row_name)
		{
		break;
		}
	$data['emp_name']=$row_name->pathology_name;	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pathlogy);	
	$data['center']=$this->db->get('hms_pathology');
	foreach($data['center']->result() as $row_center)
		{
		break;
		}
	$data['center_name']=$row_center->pathology_name;	
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('hospitalid',$empid);	
	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount_diagnose !=','0');					
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('hospitalid',$empid);
	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount_diagnose !=','0');			
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		
				
	$this->load->view('hms/print_report_date_wise_diagnos_hospital',$data);					
          }
	else
	{
	echo 'Record not Found';
	}
	}
	
	
	public function assign_patient_test_fordiagnouse_user()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$userid=$this->get_af_emp_id();
	$pid=$this->uri->segment(3);
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{		
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	foreach($data['hms_opd_patient']->result() as $row)
	{
	break;
	}
	$data['phone']=$row->phone;	
	$data['date_day']=$row->entry_date;
	$data['doctor_id']=$row->doctor_id;
	$data['pathlogu_name']=$row->collection_code;
	$data['hospiatal_name']=$row->hospitalid;
	
					
	
//	$this->db->where('afid',$aid);	
//	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$this->db->where('dig_parient',0);
	$this->db->order_by('id','asc');
	$data['test_name']=$this->db->get('hms_dignos_master');	
	
	$this->db->order_by('id','asc');	
       	$data['test_name2']=$this->db->get('hms_dignos_master');	
      	 
	       $date_day=date('Y-m-d');
	       
	      $data['date_day']=$date_day;
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);
//	$this->db->where('enter_date',$date_day);
	$this->db->where('emp_id',$userid);			
	$this->db->order_by('enter_date','desc');	
 	$data['hms_patient_assign_test']=$this->db->get('hms_patient_assign_test_diagnose');	
	
	$this->db->where('afid',$aid);	
	$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$this->db->where('afid',$aid);	
	$data['hms_hospital']=$this->db->get('hms_hospital');				
	$this->load->view('hms/assign_patient_test_for_diagnouse_user',$data);	
        }
	else
	{
	echo 'Record not found';
	}
	}
	
	
	public function update_print_status()
	{
	
	$this->load->helper('url');
	$this->load->library('session');

	$pid=$this->uri->segment(3);
//	$d_date=$this->uri->segment(4);	
	
	$this->db->set('print_status','1');

	$this->db->where('patient_id',$pid);
//	$this->db->where('enter_date',$d_date);
	$this->db->update('hms_patient_assign_test',$this);
	
	
	$this->db->set('print_status','1');

	$this->db->where('patient_id',$pid);
//	$this->db->where('date_test',$d_date);
	$this->db->update('hms_opd_test_rate',$this);	
	
	
	$this->db->set('statusid','1');
	$this->db->where('id',$pid);
	$this->db->update('hms_opd_patient',$this);	
	echo 'Update status';		
	}
	
	
	public function patient_part_paydata()
	{
	$this->load->helper('url');
	$this->load->library('session');

	$pid=$this->uri->segment(3);
	$paid_amt=$this->uri->segment(4);
//	$fdate=$this->uri->segment(5);		
	$this->patient_id=$pid;
	$this->padi_amt_lab=$paid_amt;
        $this->p_date=date('Y-m-d');					
        $this->db->insert('hms_patient_part_payment_lab',$this);
	}
	

 public function lab_part_payment_diagnose_user()
      {
   	$this->load->helper('url');
      	$this->load->library('session');
      	$aid=$this->get_affiliate();
	$af_emp_id=$this->get_af_emp_id();	      
      	$pid=$this->uri->segment(3);
      	$entry_date=$this->uri->segment(4);   
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$this->db->where('entry_date',$entry_date);		
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	$this->db->where('afid',$aid);
	$this->db->where('id',$pid);	
	$this->db->where('entry_date',$entry_date);	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');	
	foreach($data['hms_opd_patient']->result() as $row)
		{
    	break;
		}
	$data['tot_amt']=$row->tot_amount_diagnose;
	$data['paid_amt']=$row->amount_diagnose;	
	$data['discount']=$row->discount_diagnos;	
	
	
	$this->db->where('afid',$aid);
	$this->db->where('patient_id',$pid);	
	$this->db->group_by('patient_id');
	$data['second_patient_assign_test']=$this->db->get('hms_patient_assign_test_diagnose');	

	$data['test_name']=$this->db->get('hms_dignos_master');	

	
		$this->load->view('hms/lab_part_payment_form_admin_diagnose_user',$data);				      
         }
	 else
	 {
	 echo 'Record not found';
	 }
      }
	
	public function patient_part_paydata_diagnose()
	{
	$this->load->helper('url');
	$this->load->library('session');

	$pid=$this->uri->segment(3);
	$paid_amt=$this->uri->segment(4);
//	$fdate=$this->uri->segment(5);		
	$this->patient_id=$pid;
	$this->paid_diagnose=$paid_amt;
        $this->p_date=date('Y-m-d');					
        $this->db->insert('hms_patient_part_payment_lab',$this);
	}
	
	
public function manage_test_special()
{

$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	
	$data_count=$this->db->count_all_results('ho_m_test_master');
	if($data_count>0)
	{		
		$this->db->where('afid',$aid);
	//	$this->db->where('id',$pid);	
		$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
		
		$this->db->where('afid',$aid);
	//	$this->db->where('patient_id',$pid);	
		$data['hms_opd_assign_test']=$this->db->get('hms_patient_assign_test');	
		
		$this->db->where('afid',$aid);
	//	$this->db->where('patient_id',$pid);
		$this->db->group_by('patient_id');	
		$data['hms_opd_assign_test_pat']=$this->db->get('hms_patient_assign_test');
		foreach($data['hms_opd_assign_test_pat']->result() as $row)
		{
		break;
		}
	//	$data['test_date']=$row->enter_date;			
		
		$this->db->where('afid',$aid);	
		$data['hms_pathology']=$this->db->get('hms_pathology');	
	
	$this->db->where('test_parient',0);
//	$this->db->order_by('test_title','asc');
	$data['test_name']=$this->db->get('ho_m_test_master');	
				
	$this->load->view('hms/manage_doctor_commission_testspecial',$data);	
        }
	else
	{
	echo 'Record not found';
	}
     }
     
     
         public function update_special_test()
             {
		$this->load->library('session');
        	$this->load->helper('url');
		$afid=$this->get_affiliate();
		$id=$this->input->post('checkid');
		$mark=$this->input->post('checkedoption2');
		$qui_id=explode(',',$id);
		$qui=explode(',',$mark);
	
	       $t=0;
		for($t1=0;Count($qui_id)>$t1;$t1++)
		{
		$this->load->database();
		//$this->modify_emp_id=$this->input->post('eid'); 
		$this->status=$qui[$t]; 
		$this->db->where('id',$qui_id[$t]);
	       $this->db->update('ho_m_test_master',$this);
	       
		$t++;

		}
		
            }
     		
	public function print_report_date_emp2()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);
	$zone=$this->uri->segment(5);	
//	$data['disper']=$this->uri->segment(5);	
//	$data['disperrt']=$this->uri->segment(6);	
//	$pathlogy=$this->uri->segment(8);					
	
	
	$this->db->where('afid',$aid);
	$this->db->where('zone_id',$zone);	
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_name)
		{
		break;
		}
	$data['emp_name']=$row_name->name;	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
	
	
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('doctor_id',$empid);	
//	$this->db->where('collection_code',$pathlogy);
	$this->db->where('tot_amount !=','0');				
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('doctor_id',$empid);
//	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount !=','0');		
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		
				
	$this->load->view('hms/print_report_date_wise_new',$data);					
          }
	else
	{
	echo 'Record not Found';
	}
	}
	
	
	
	public function print_report_date_emp_diagnos_all2()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);
	$zone=$this->uri->segment(5);	
//	$data['disper']=$this->uri->segment(6);	
//	$data['disperrt']=$this->uri->segment(7);	
//	$pathlogy=$this->uri->segment(8);					
	
	
	$this->db->where('afid',$aid);
	$this->db->where('zone_id',$zone);	
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_name)
		{
		break;
		}
	$data['emp_name']=$row_name->name;	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
	
	
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('doctor_id',$empid);	
//	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount_diagnose !=','0');			
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('doctor_id',$empid);
//	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount_diagnose !=','0');	
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		
				
	$this->load->view('hms/print_report_date_wise_diagnos_new',$data);					
          }
	else
	{
	echo 'Record not Found';
	}
	}
	
	
	public function print_report_date_emp_hospital2()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);
	$zone=$this->uri->segment(5);	
//	$data['disper']=$this->uri->segment(6);	
//	$data['disperrt']=$this->uri->segment(7);	
//	$pathlogy=$this->uri->segment(8);					
	
	
	$this->db->where('afid',$aid);
$this->db->where('zone_id',$zone);
	$data['hms_hospital']=$this->db->get('hms_hospital');
	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
	
	
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('hospitalid',$empid);	
//	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount !=','0');				
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('hospitalid',$empid);
//	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount !=','0');		
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');											
				
	$this->load->view('hms/print_report_date_wise_hospital_new',$data);					
          }
	else
	{
	echo 'Record not Found';
	}
	}
	
	
	public function print_report_date_emp_diagnos_all_hospital2()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);
	$zone=$this->uri->segment(5);
$data['fdate']	=$fdate;
$data['tdate']=$tdate;
	
	$this->db->where('afid',$aid);
	$this->db->where('zone_id',$zone);
	$this->db->order_by('id','asc');	
	$data['hms_hospital']=$this->db->get('hms_hospital');	
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('hospitalid',$empid);	
//	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount_diagnose !=','0');					
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('hospitalid',$empid);
//	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount_diagnose !=','0');			
	$this->db->group_by('id');	
	$data['hms_opd_patient111']=$this->db->get('hms_opd_patient');
		
				
	$this->load->view('hms/print_report_date_wise_diagnos_hospital_new',$data);					
          }
	else
	{
	echo 'Record not Found';
	}
	}
	
	
   public function test_report()
    {

	$this->load->helper('url');
	$this->load->library('session');	
	$this->load->view('hms/view_test_report_count');

   }
   
   
   
   public function print_report_date_test_count()
   {
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);
         $afid=$this->get_affiliate();		
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);				
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	

	
	$this->db->where('test_parient','0');	
	$this->db->order_by('id','asc');
	$data['test_name']=$this->db->get('ho_m_test_master');	
	
	
	
	$this->db->where('dig_parient !=','0');	
	$this->db->order_by('id','asc');
	$data['diagnos_name']=$this->db->get('hms_dignos_master');		
	
	$this->db->where('affiliate_id',$afid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');				
	$this->load->view('hms/print_report_test_cont',$data);					
          }
	else
	{
	echo 'Record not Found';
	}   
   
   
   
   }
   
   
  	public function view_day_report_user()
   		{
   		$this->load->helper('url');
   		$this->load->library('session');
   		$aid=$this->get_affiliate();
   	
   	        $this->db->where('afid',$aid);
   		$this->db->order_by('name','asc');
   		$data['hms_doctor']=$this->db->get('hms_doctor');
   		
   		$this->db->where('afid',$aid);
   		$data['hms_pathology']=$this->db->get('hms_pathology');		
   		
   		$this->load->view('hms/view_doctor_report_user',$data);	
   		}
		   
	public function print_report_date_emp_first_user()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);
	$empid=$this->uri->segment(5);	
	$pathlogy=$this->uri->segment(6);				
	
	
	$this->db->where('afid',$aid);
	$this->db->where('doctor_id',$empid);	
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_name)
		{
		break;
		}
	$data['emp_name']=$row_name->name;	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
	
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pathlogy);	
	$data['center']=$this->db->get('hms_pathology');
	foreach($data['center']->result() as $row_center)
		{
		break;
		}
	$data['center_name']=$row_center->pathology_name;	
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('doctor_id',$empid);
	$this->db->where('collection_code',$pathlogy);				
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('doctor_id',$empid);
	$this->db->where('collection_code',$pathlogy);	
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		
				
	$this->load->view('hms/print_report_date_wise_first_user',$data);					
          }
	else
	{
	echo 'Record not Found';
	}
	}
	
			     	
	public function print_report_date_emp_first_diagnos_user()
	{
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$fdate=$this->uri->segment(3);
	$tdate=$this->uri->segment(4);
	$empid=$this->uri->segment(5);	
	$pathlogy=$this->uri->segment(6);				
	
	
	$this->db->where('afid',$aid);
	$this->db->where('doctor_id',$empid);	
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_name)
		{
		break;
		}
	$data['emp_name']=$row_name->name;	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
	
	
	$this->db->where('afid',$aid);
	$this->db->where('id',$pathlogy);	
	$data['center']=$this->db->get('hms_pathology');
	foreach($data['center']->result() as $row_center)
		{
		break;
		}
	$data['center_name']=$row_center->pathology_name;	
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('doctor_id',$empid);
	$this->db->where('collection_code',$pathlogy);				
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('doctor_id',$empid);
	$this->db->where('collection_code',$pathlogy);	
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		
				
	$this->load->view('hms/print_report_date_wise_first_diagno_user',$data);					
          }
	else
	{
	echo 'Record not Found';
	}
	}
	


   
  	public function view_todayday_report_dcuser()
   		{
   		$this->load->helper('url');
   		$this->load->library('session');
   		$aid=$this->get_affiliate();
   	
   	        $this->db->where('afid',$aid);
   		$this->db->order_by('name','asc');
   		$data['hms_doctor']=$this->db->get('hms_doctor');
   		
   		$this->db->where('afid',$aid);
   		$data['hms_pathology']=$this->db->get('hms_pathology');		
   		
   		$this->load->view('hms/view_doctor_todaydcreport_user',$data);	
   		}

	
     public function print_report_today_dcs()
     {
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
//	$fdate=date('Y-m-d');
//	$tdate=date('Y-m-d');
	$zone=$this->uri->segment(3);	
	$fdate=$this->uri->segment(4);	
	$tdate=$this->uri->segment(5);	
//	$pathlogy=$this->uri->segment(8);					
	
	
	$this->db->where('afid',$aid);
//	$this->db->where('zone_id',$zone);	
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_name)
		{
		break;
		}
	$data['emp_name']=$row_name->name;	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
	
	
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('doctor_id',$empid);	
//	$this->db->where('collection_code',$pathlogy);
	$this->db->where('tot_amount !=','0');				
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('doctor_id',$empid);
//	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount !=','0');		
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('doctor_id',$empid);
//	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount_diagnose !=','0');	
	$this->db->group_by('id');	
	$data['hms_opd_patient4']=$this->db->get('hms_opd_patient');
	
		
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		
				
	$this->load->view('hms/print_report_dc_today',$data);	
	
				
          }
	else
	{
	echo 'Record not Found';
	}

      }
      
      
      public function print_report_today_dcs_diagnos()
      {
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
//	$fdate=date('Y-m-d');
//	$tdate=date('Y-m-d');
	$zone=$this->uri->segment(3);	
	$fdate=$this->uri->segment(4);	
	$tdate=$this->uri->segment(5);	
//	$pathlogy=$this->uri->segment(8);					
	
	
	$this->db->where('afid',$aid);
//	$this->db->where('zone_id',$zone);	
	$data['hms_doctor']=$this->db->get('hms_doctor');
	foreach($data['hms_doctor']->result() as $row_name)
		{
		break;
		}
	$data['emp_name']=$row_name->name;	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
	
	
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('doctor_id',$empid);	
//	$this->db->where('collection_code',$pathlogy);
	$this->db->where('tot_amount_diagnose !=','0');				
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('doctor_id',$empid);
//	$this->db->where('collection_code',$pathlogy);	
//	$this->db->where('tot_amount !=','0');		
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('doctor_id',$empid);
//	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount_diagnose !=','0');	
	$this->db->group_by('id');	
	$data['hms_opd_patient4']=$this->db->get('hms_opd_patient');
	
		
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');		
				
	$this->load->view('hms/print_report_dc_today_diagnos',$data);					
          }
	else
	{
	echo 'Record not Found';
	}      
      
      }
      
      
  public function print_report_today_dcs_hospital()
  {
	$this->load->helper('url');
	$this->load->library('session');
	$aid=$this->get_affiliate();
	$zone=$this->uri->segment(3);
	$fdate=$this->uri->segment(4);
	$tdate=$this->uri->segment(5);
		
//	$data['disper']=$this->uri->segment(6);	
//	$data['disperrt']=$this->uri->segment(7);	
//	$pathlogy=$this->uri->segment(8);					
	
	
	$this->db->where('afid',$aid);
//$this->db->where('zone_id',$zone);
	$data['hms_hospital']=$this->db->get('hms_hospital');
	
	$data['fdate']=$fdate;
	$data['tdate']=$tdate;
	
	
		
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
	$this->db->where('tot_amount !=','0');				
	$data_count=$this->db->count_all_results('hms_opd_patient');
	if($data_count>0)
	{
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('hospitalid',$empid);
//	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount !=','0');		
	$this->db->group_by('id');	
	$data['hms_opd_patient']=$this->db->get('hms_opd_patient');
	
	$this->db->where('afid',$aid);
	$this->db->where('entry_date >=',$fdate);	
	$this->db->where('entry_date <=',$tdate);
//	$this->db->where('doctor_id',$empid);
//	$this->db->where('collection_code',$pathlogy);	
	$this->db->where('tot_amount_diagnose !=','0');	
	$this->db->group_by('id');	
	$data['hms_opd_patient4']=$this->db->get('hms_opd_patient');	
	
	
	$this->db->where('affiliate_id',$aid);
	$data['manage_affiliate']=$this->db->get('manage_affiliate');											
				
	$this->load->view('hms/print_report_dc_today_hospital',$data);					
          }
	else
	{
	echo 'Record not Found';
	}  
  
  }    												       				
	      			 								    	      						  		  		      		      	 	   		  			
}

Function Calls

defined 1

Variables

None

Stats

MD5 d54bf6718e8521112f1102406455ff2c
Eval Count 0
Decode Time 2648 ms