<?php
if (!isset($_SESSION)){
  session_start();
}
error_reporting(0);
include('accesscheck2.php');
require_once('Connections/courier.php'); 
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$id = $_POST['id'];
$item=$_POST['act'];

if($item =='saveappoint'){
$appoint_date = $_POST['appoint_date'];
$speciality = $_POST['specialist'];
$time2= $_POST['hour'].":".$_POST['min'];
$area = $_POST['specialisation'];	
$purpose =$_POST['purpose'];
$procedure = $_POST['procedure'];

$query_insert = "INSERT INTO `appointments` (`id`,`doctor_id`,`specialization`,`start_time`,`time`, `patient`,`purpose`,`procedure`) VALUES (NULL,'$speciality', '$area', '$appoint_date', '$time2', '$id','$purpose','$procedure')";	

$rs_query_insert = mysql_query($query_insert) or die(mysql_error());

include ('view_patient_visits.php');

}




if($item ==	'reassign_new')
{

$attend_new = $_POST['attending_officer_new'];
echo $attend_new;
//$visit_no = $rs_reass_query['process_claim_no'];
		
		
		$query_rsodest_officer = "SELECT * FROM users where id='$attend_new'";	     
$rsodest_officer = mysql_query($query_rsodest_officer, $courier) or die(mysql_error());
$row_rsodest_officer=mysql_fetch_assoc($rsodest_officer);
$attending_officer=$row_rsodest_officer['title']." ".$row_rsodest_officer['firstnames']." ".$row_rsodest_officer['surname'];
$area_specialisation=$row_rsodest_officer['area_specialisation'];
		
		$update_assigned = mysql_query("update process_claim_no set attending_officer_id ='$attend_new', attending_officer = '$attending_officer', area_specialisation='$area_specialisation' where patient_id='$id' and status='In Use'")or die(mysql_error());
		 
	include ('view_patient_visits.php');
}
?>