<?php
class classPanel
{
	private $organizationID=NULL; 
	private $panelID=NULL;
	private $type=NULL;
	private $company=NULL;
	private $discount=NULL;
	
	
	########################################## set functions ##############################
	  
	function setOrganizationID($organizationID)
	{
		if($organizationID!="")
		{
			$this->organizationID = $organizationID;
		}
		
	}
	
	function setPanelID($panelID)
	{
		if($panelID!="")
		{
			
			$this->panelID = $panelID;
			
		}
		else
		{
			throw new MyException(122100);
		}
	}
	
	function setPanelType($type) 
	{
		if($type!="")
		{
			$this->type = $type;
			
		}
		else
		{
			throw new MyException(122101);
		}
	}
		
	function setPanelCompany($company) 
	{
		if($company!="")
		{
			
			$this->company = $company;
			
		}
		else
		{
			throw new MyException(122102);
		}
	}
		
	function setCompanyDiscount($discount) 
	{
		if($discount!="")
		{
			
			$this->discount= $discount;
			
		}
		else
		{
			throw new MyException(122103);
		}
	}
		
		
		
	##################################################################### GET FUNCTIONS  ########################
	
	function getOrganizationID()
	{
		if($this->organizationID!="")
		{
			return $this->organizationID;
		}
		
	}

	public function getPanelID()
	{
		if($this->panelID!="")
		{
			return $this->panelID;
		}
		else
		{
			throw new MyException(122104);
		}
	}

	public function getPanelType()
	{
		if($this->type!="")
		{
			return $this->type;
		}
		else
		{
			//throw new MyException(122105);
		}
	}
	
	public function getPanelCompany()
	{
		if($this->company!="")
		{
			return $this->company;
		}
		else
		{
			throw new MyException(122106);
		}
	}
	
		
	public function getCompanyDiscount()
	{
		if($this->discount!="")
		{
			return $this->discount;
		}
		else
		{
			throw new MyException(122107);
		}
	}
		
	##################################################################### Check FUNCTIONS  #####################
	  
	function checkCompanyRegistered($company = NULL) 
	{
		$query = "SELECT company FROM patient_panel WHERE company = '$company'";
		$queryOb = new classQueryGlobal;
		$array = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($array[0]['company']))
		{
			return 0;
		}
		else
		{
			return 1;
		}
	}
		
	##################################################################### Main FUNCTIONS  ###################
	
	function insertPanel() 
	{
		if($this->checkCompanyRegistered($this->getPanelCompany()))
		{
	
			$type = $this->getPanelType();
			$company = $this->getPanelCompany();
			$discount = $this->getCompanyDiscount();
			$org_id = $this->getOrganizationID();
			
			$query="INSERT INTO patient_panel
			(
				type,
				company,
				discount,
				org_id
			) 
			VALUES 
			(
				'$type',
				'$company',
				'$discount',
				'$org_id'
			)";
				
			$queryOb = new classQueryGlobal;
			$this->panelID = $queryOb->check_fetch_query($query,'insert',$server="",$debug_mode="off");
		}
		else
		{
			throw new MyException(122108);
		}
	}
	
	##################################################################### Main FUNCTIONS UPDATE  ###################
	
	function updatePanel() 
	{	
		$panel_id = $this->getPanelID();
		$type = $this->getPanelType();
		$company = $this->getPanelCompany();
		$discount = $this->getCompanyDiscount();
		$org_id = $this->getOrganizationID();
		
		$query="UPDATE patient_panel SET
		
		type = '$type',
		company = '$company',
		discount = '$discount',
		org_id = '$org_id'

		WHERE panel_id = '$panel_id'";
		
			
		$queryOb = new classQueryGlobal;
		$queryOb->check_fetch_query($query,'update',$server="",$debug_mode="off");
		
	}
	
	
	function deletePanel()
	{
		$panel_id = $this->getPanelID();
		
		$query = "DELETE FROM patient_panel WHERE panel_id = '$panel_id'";
		$queryOb = new classQueryGlobal;
		$queryOb->check_fetch_query($query,'delete',$server="",$debug_mode="off");
	}
		
	##################################################################### Main FUNCTIONS RETRIEVE  #################
	
	function retrieveAllPanel()
	{
		$org_id = $this->getOrganizationID();
		$query = "SELECT * FROM patient_panel ";
		$queryOb = new classQueryGlobal;
		$panel_Array = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		if(isset($panel_Array[0]))
		{
			return $panel_Array;
		}
		
	}
		
	function retrievePanelByID()
	{
		$panel_id = $this->getPanelID();
		
		$query = "SELECT * FROM patient_panel WHERE panel_id = '$panel_id'";
		$queryOb = new classQueryGlobal;
		$opd_services = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($opd_services[0]))
		{
			return $opd_services;
		}
	}
		
	function retrievePanelTypeByID($panel_id)
	{
		$query = "SELECT  type FROM patient_panel WHERE panel_id = '$panel_id' ";
		$queryOb = new classQueryGlobal;
		$opd_services = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		return $opd_services[0]['type'];
		
	}
		
	function retrievePanelCompanyeByID($panel_id)
	{
		$query = "SELECT  company FROM patient_panel WHERE panel_id = '$panel_id' ";
		$queryOb = new classQueryGlobal;
		$opd_services = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		return $opd_services[0]['company'];
		
	}
	
	function retrievePanelDiscountByID($panel_id)
	{
		$query = "SELECT  discount FROM patient_panel WHERE panel_id = '$panel_id' ";
		$queryOb = new classQueryGlobal;
		$opd_services = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
	
		return $opd_services[0]['discount'];
		
	}
		
}

				
	  

?>