<?php include('accesscheck2.php'); 
require_once('Connections/courier.php');
require_once('functions/functions.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;
}
}

mysql_select_db($database_courier, $courier);
if(!isset($id)){
list($id, $doc_id) = explode("@@@", $_POST['id']);
}
?>

<div class="page-bar">
                        <ul class="page-breadcrumb">
                            <li>
                                <i class="icon-home"></i>
                                <a href="index.html">Home</a>
                                <i class="fa fa-angle-right"></i>
                            </li>
                            <li>
                                <span>Patient Profile</span>
                            </li>
                        </ul>
                        <div class="page-toolbar">
                             <div class="btn-group pull-right">
                                <button type="button" class="btn btn-fit-height grey-salt dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="1000" data-close-others="true"> Actions
                                    <i class="fa fa-angle-down"></i>
                                </button>
                                <ul class="dropdown-menu pull-right" role="menu">
                                    <li onclick="getstep('add_new_normal_patient');">
                                        <a href="#">
                                            <i class="icon-refresh"></i> Refresh</a>
                                    </li>
                                </ul>
                            </div>
                        </div>
</div>

<!--<h1 class="page-title"> Patient Profile <small></small></h1>-->
                    <!-- END PAGE HEADER-->
                    <div class="row">
                        <div class="col-md-12">
                            <!-- BEGIN PROFILE SIDEBAR -->
                            <div class="profile-sidebar">
                                <!-- PORTLET MAIN -->
                                <div class="portlet light profile-sidebar-portlet ">
                                    <!-- SIDEBAR USERPIC -->
                                    <div class="profile-userpic">
                                          <?php $picpath=$row_rsodest_patient['picpath']; 
										  
										  if(!$picpath){ 
											
											
											if($row_rsodest_patient['insurance_no1']){
											$inspicpath=getpicpath($row_rsodest_patient['insurance_company1']);
											
											if($inspicpath){
											
											$member_id=preg_replace("/[^0-9]/","",$row_rsodest_patient['insurance_no1']);
											
											$picpath=$inspicpath."/".ltrim($member_id,0).".jpg";
											}else{
											$picpath="images/profile.gif";		
											}
											}else{
											$picpath="images/profile.gif";	
											}
										  }
										  
										  ?>
                                        
                                        <img src="<?php echo $picpath;?>" class="img-responsive" alt=""> 
                                    </div>
                                    <div class="profile-usertitle">
                                        <div class="profile-usertitle-name"> PATIENT NAME </div>
                                        <div class="profile-usertitle-job"> PATIENT NO. </div>
                                    </div>
                                    <div class="profile-usermenu">
                                        <ul class="nav">
                                            <li class="patient-sub-menu active" id="patient_info" onclick="getProcess('view_patient_information', '#patient_page_wrapper', '<?php echo $id; ?>',this.id);">
                                                <a> <i class="icon-picture"></i> Upload Picture File </a>
                                            </li>
                                            <li class="patient-sub-menu " id="patient_edit" onclick="getProcess('edit_patient_information', '#patient_page_wrapper', '<?php echo $id; ?>',this.id);">
                                                <a> <i class="icon-camera"></i> Take Picture Camera </a>
                                            </li>
                                        </ul>
                                    </div>
                                    <!-- END MENU -->
                                </div>
                            </div>
                            <div class="profile-content">
                                <div class="row">
                                    <div class="col-md-12">
                                        <div class="portlet light " id="patient_page_wrapper" style="min-height:800px;">
                                            <div class="portlet-title">
                                                <div class="caption caption-md">
                                                    <i class="icon-globe theme-font hide"></i>
                                                    <span class="caption-subject font-blue-madison bold uppercase"> ADD NEW NORMAL PATIENT </span>
                                                </div>
                                            </div>
                                            <div class="portlet-body form">
                                                <div id="success_error_info_display"></div>
                                                <form role="form" action="#" id="edit_patient_info_form">
                                                    <div class="form-body">
                                                        <div class="row">
                                                            <div class="col-lg-12 col-xs-12 col-md-12">
                                                                <div class="col-md-6">
                                                                    <div class="form-group">
                                                                        <label class="control-label">Surname</label>
                                                                        <input type="text" name="surname" id="surname" value="<?php echo $row_rsodest_patient['surname'] ?>" class="form-control"> </div>
                                                                    <div class="form-group">
                                                                        <label class="control-label">Date Of Birth</label>
                                                                        <input type="text" name="dateofbirth" value="<?php echo $row_rsodest_patient['dateofbirth'] ?>" type="text" id="dateofbirth" class="form-control"> </div>
                                                                    <div class="form-group">
                                                                        <label class="control-label">Sex</label>
                                                                        <select name="sex" id="sex" class="form-control"  onchange="showpreg(this.value)">
                                                                            <option value="">-------- SELECT -------</option>
                                                                            <option value="Male" <?php if ($row_rsodest_patient['sex'] == 'Male') { ?> selected="selected" <?php } ?>>Male</option>
                                                                            <option value="Female" <?php if ($row_rsodest_patient['sex'] == 'Female') { ?> selected="selected" <?php } ?>>Female</option>
                                                                        </select>
                                                                    </div>
                                                                   
                                                                </div>
                                                                <div class="col-md-6">
                                                                    <div class="form-group">
                                                                        <label class="control-label">Other Names</label>
                                                                        <input type="text" value="<?php echo $row_rsodest_patient['othernames']; ?>" name="othernames" id="othernames" class="form-control"> 
                                                                    </div>
                                                                        <div class="form-group" style="display: none;">
                                                                        <label class="control-label">Marital Status</label>
                                                                        <select name="marital_status" id="marital_status" class="form-control">
                                                                            <option value="">-------- SELECT -------</option>
                                                                            <option value="DIVORCED" <?php if ($row_rsodest_patient['marital_status'] == 'DIVORCED') { ?> selected="selected" <?php } ?> >DIVORCED</option>
                                                                            <option value="MARRIED" <?php if ($row_rsodest_patient['marital_status'] == 'MARRIED') { ?> selected="selected" <?php } ?>>MARRIED</option>
                                                                            <option value="SEPARATED" <?php if ($row_rsodest_patient['marital_status'] == 'SEPARATED') { ?> selected="selected" <?php } ?>>SEPARATED</option>
                                                                            <option value="SINGLE" <?php if ($row_rsodest_patient['marital_status'] == 'SINGLE') { ?> selected="selected" <?php } ?>>SINGLE</option>
                                                                            <option value="WIDOW" <?php if ($row_rsodest_patient['marital_status'] == 'WIDOW') { ?> selected="selected" <?php } ?>>WIDOW</option>
                                                                            <option value="WIDOWER" <?php if ($row_rsodest_patient['marital_status'] == 'WIDOWER') { ?> selected="selected" <?php } ?>>WIDOWER</option>
                                                                        </select>
                                                                    </div>
                                                                    <div class="form-group">
                                                                        <label class="control-label">Tel/Mobile</label>
                                                                        <input type="text" value="<?php echo $row_rsodest_patient['tel']; ?>" name="tel" id="tel" class="form-control"> 
                                                                    </div>
                                                                     <div class="form-group">
                                                                        <label class="control-label">Email</label>
                                                                        <input type="text" value="<?php echo $row_rsodest_patient['email']; ?>" type="text" name="email" id="email" class="form-control"> 
                                                                    </div>
                                                                </div>
                                                            </div>



                                                        </div>

                                                    </div>
                                                    <div class="form-actions right">
                                                        <button type="reset" class="btn default"> Reset </button>
                                                        <a class="btn green" onclick="getstep('records_guest_insert_patient');return false;"> Save </a>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>