<?php
include("common/connection.php");
login_check();

$Lead_Req_Id=$_REQUEST['Lid'];
$user_type_sql="select User_Type from user_master where User_Name='".$_SESSION['user']."'";
$user_type_query=mysqli_query($con,$user_type_sql);
$user_type=mysqli_fetch_array($user_type_query);
?>

<!doctype html>
<html class="no-js" lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>Patient Assessment | Buurtzorg</title>
    <?php include("headerlink.php"); ?> 
    <link rel="stylesheet" href="css/pa.css">
    
     
    
   
    
     <link rel="stylesheet" href="css/form/all-type-forms.css">
    <!-- x-editor CSS
		============================================ -->
    <link rel="stylesheet" href="css/editor/select2.css">
    <link rel="stylesheet" href="css/editor/datetimepicker.css">
    <link rel="stylesheet" href="css/editor/bootstrap-editable.css">
    <link rel="stylesheet" href="css/editor/x-editor-style.css">

    
    <script>
	function unlock_form() {
	 
	$('#edit_c_form  input'). prop("disabled", false);
	//$('#not_editable  input'). prop("disabled", true);
	$('#edit_c_form  textarea'). prop("disabled", false);
	$('#edit_c_form  select'). prop("disabled", false);
	$('#update_btn').show();
	$('#edit_btn_1').hide();
	
 
	}
	</script>
    
    <script>
	function personaliz_label(per) {
	 
	
	 $('#ps').text(per);
	
	}
	
 
	</script> 
    <?php
	 $lead_basic_sql="select * from lead_master where Lead_ID='".$Lead_Req_Id."'";
	 $lead_basic_query=mysqli_query($con,$lead_basic_sql);
	 $lead_details=mysqli_fetch_array($lead_basic_query);
	?>   
    
    <script type="text/javascript">
	function ShowPersonalize()
	{
	   if(document.getElementById("personalize").checked==true)
	   {
	   
	      $('#personalize_div').show();
	   }
	   else
	   {
	      $('#personalize_div').hide();
	   }
	
	}
	</script> 
    
<script>
function isNumberKey(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode;
	if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57))
		{
			return false;
		}
	else
		{
			return true;
		}
}

</script> 

<script>
	function delete_medication(per)
	{
	
	//alert(per);
	 
	 $.ajax({
		url:"ajax_delete_medication.php",
		type:"POST",
		data:{'id':per},
		success:function(f)
		{
		   //alert(f);
		   
			  window.location.href='patient_assessment_3.php?Lid=<?php echo $_REQUEST['Lid'] ?>';
			
		}
		})
	}
	</script>   
</head>

<body> 
    <!--[if lt IE 8]>
		<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
	<![endif]-->
    <!-- Start Left menu area -->
    
    
             
	<style>
    input { border:0 !important; border-bottom:1px solid #ccc !important; padding-left:0 !important; padding-top:0px !important;  padding-bottom:3px !important;  height:auto !important; } label { font-weight:normal !important; font-size:12px !important;} textarea {border:0 !important; border-bottom:1px solid #ccc !important; padding-left:0 !important; padding-top:3px !important;  padding-bottom:3px !important; text-transform:uppercase } 
    select { border:0 !important; border-bottom:1px solid #ccc !important; padding-left:0 !important; padding-top:0px !important;  padding-bottom:3px !important;  height:auto !important; } .panel-body {padding:0 !important; padding-top:10px !important;  } option, select {font-size:12px !important;  }
    </style>
    <?php include("left-menu.php"); ?>
    
    
    
    <!-- End Left menu area -->
    <!-- Start Welcome area -->
    <div class="all-content-wrapper">
        
        
       <?php include("header-menu.php"); ?> 
        
       
                                        	
        <!-- Static Table Start -->
        <div class="static-table-area">
        
       
        
        
        
            <div class="container-fluid">
                <div class="row">
                
                
                    
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" >
                         
                         
                         <div class="row" style="margin:0"> 
                         
                        <?php include 'progress.php' ?> 
                          
                          </div>
                        
                         
                         
                         <div class="panel-group" id="accordion">
    <div class="panel panel-default">
      <div class="panel-heading"  data-parent="#accordion" href="#collapse1"  data-toggle="collapse">
        <h4 class="panel-title" >
          <a>CURRENT MEDICATIONS</a>
        </h4>
      </div>
      <div id="collapse1" class="panel-collapse collapse in">
        <div class="panel-body">
        
      <?php
	  if($_REQUEST['Patient_Medication'])
	  {
	      $delEc="delete from patient_current_madication where Lead_ID='".$_REQUEST['Lid']."'";
		  mysqli_query($con,$delEc);
	  
	     $count_current_med=$_REQUEST['count_current_med'];
		 $count_past_med=$_REQUEST['count_past_med'];
		 
		 
		  for ($i = 1; $i <= $count_current_med; $i++)
		 {
			$drugname=$_REQUEST['drugname'.$i];
			$drugdose=$_REQUEST['drugdose'.$i];
			$drugtime=$_REQUEST['drugtime'.$i];
			
			
			
			if($drugname!='' && $drugdose!=''  && $drugtime!='')
			{
				$Sql_Add_Contact="insert into patient_current_madication(Lead_ID,Drug_Name,Dose,Taking_TIme)values('".$_REQUEST['Lid']."','".$drugname."','".$drugdose."','".$drugtime."')";
				$Qry_Add_Contact=mysqli_query($con,$Sql_Add_Contact);
			}
		}
	  
	  
	    $delMed="delete from patient_past_madication where Lead_ID='".$_REQUEST['Lid']."'";
		 mysqli_query($con,$delMed);
	  
	     for ($i = 1; $i <= $count_past_med; $i++)
		 {
		     $Medical_Name=$_REQUEST['Medical_Name'.$i];
			 if(isset($Medical_Name))
			 {
			    $Sql_Add_Medical="insert into patient_past_madication(Lead_ID, Medical_Name)values('".$_REQUEST['Lid']."','".$Medical_Name."')";
				 mysqli_query($con,$Sql_Add_Medical);
			 }
		 }
		 ?>
          <script>window.location.href="patient_assessment_4.php?Lid=<?php echo $_REQUEST['Lid']; ?>"</script>
         <?php
	  
	  }
	  ?>  
        
        
        
        <form method="post" id="form_s_4">
                

<div class="col-sm-12 col-xs-12" >
<button class="btn  btn-primary add_form_field"  style=" float:left; padding-left:10px !important;  padding:2px 8px !important; margin-bottom:10px;" type="submit">Add New Field &nbsp;<span style="font-size:16px; font-weight:bold;">+ </span></button>
</div>

                           
          <div class="col-sm-12 col-xs-12 " id="container1" >
          <?php
		  	$Patient_Medication=Numrow_Chk($con,'patient_current_madication','Lead_ID',$_REQUEST['Lid']); 
			if($Patient_Medication==0)
			{
		  ?>
           <div class="form-group  col-xs-12 col-sm-3" style="padding:0">
                <label>Name of Drug</label>
                <input name="drugname1" id="drugname1" type="text" class="form-control"  
                 data-rule-required="true" data-msg-required="Please enter patient id" style="background-color:#FFFFFF" >
            </div>
            
            <div class="col-sm-1"></div>
            
            <div class="form-group  col-xs-6 col-sm-3" style="padding:0; padding-right:7px">
                <label>Dose</label>
                <input name="drugdose1" id="drugdose1" type="text" class="form-control"  
                 data-rule-required="true" data-msg-required="Please enter patient id">
            </div>
            
            <div class="col-sm-1"></div>
            
            <div class="form-group  col-xs-6 col-sm-3" style="padding:0; padding-left:7px">
                <label>Taking Since</label>
                <input name="drugtime1" id="drugtime1" type="text" class="form-control"  
                 data-rule-required="true" data-msg-required="Please enter patient id">
            </div>
            
            <?php
			}
			else
			{
			     $z=1;
			     $Sql_Medication="select * from patient_current_madication where Lead_ID='".$_REQUEST['Lid']."' order by SLN";
			     $Qry_Medication=mysqli_query($con,$Sql_Medication);
				 while($Fetch_Medication=mysqli_fetch_array($Qry_Medication))	
				 {
				 ?>
                   <div class="form-group  col-xs-12 col-sm-3" style="padding:0">
                <label>Name of Drug</label>
                <input name="drugname<?php echo $z; ?>" id="drugname<?php echo $z; ?>" type="text" class="form-control"  
                 data-rule-required="true" data-msg-required="Please enter patient id" style="background-color:#FFFFFF"  value="<?php echo $Fetch_Medication['Drug_Name'] ?>">
            </div>
            
            <div class="col-sm-1"></div>
            
            <div class="form-group  col-xs-5 col-sm-3" style="padding:0; padding-right:7px">
                <label>Dose</label>
                <input name="drugdose<?php echo $z; ?>" id="drugdose<?php echo $z; ?>" type="text" class="form-control"  
                 data-rule-required="true" data-msg-required="Please enter patient id"  value="<?php echo $Fetch_Medication['Dose'] ?>">
            </div>
            
            <div class="col-sm-1"></div>
            
            <div class="form-group  col-xs-5 col-sm-3" style="padding:0; padding-left:7px">
                <label>Taking Since</label>
                <input name="drugtime<?php echo $z; ?>" id="drugtime<?php echo $z; ?>" type="text" class="form-control"  
                 data-rule-required="true" data-msg-required="Please enter patient id"  value="<?php echo $Fetch_Medication['Taking_TIme'] ?>">
            </div>
                 <a class="col-xs-2 col-sm-1" style="color:#333333; font-size:22px; padding:0; xmargin-top:-10px; margin-bottom: 10px; text-align:right; cursor:pointer;" onClick="delete_medication('<?php echo $Fetch_Medication['SLN'] ?>')" ><i class="fa fa-trash-o" aria-hidden="true" data-toggle="tooltip" data-placement="left" title="Delete" ></i></a>
                 <?php
				 $z++;
				 
				 }								
			    
			
			}
			if($Patient_Medication==0)
			{
			  $Pm=1;
			}
			else
			{
			  $Pm=$Patient_Medication;
			}
			?>
           </div>
           <input type="hidden" name="count_current_med" id="count_current_med" value="<?php echo $Pm; ?>">
           
           <div class="col-sm-12 col-xs-12" style="font-size:15px; margin-bottom:8px">
            	  Past Medical History 
           </div>
           
         <!--  
           <div class="col-sm-6 col-xs-6">
            <div class="checkbox">
      			          <label><input type="checkbox" value="">Diabetes</label></div>
            <div class="checkbox">
                          <label><input type="checkbox" value="">Heart murmur</label></div> 
            <div class="checkbox">
                          <label><input type="checkbox" value="">Crohn's disease</label></div>
            <div class="checkbox">
                          <label><input type="checkbox" value="">High Blood Pressure</label></div>  
            <div class="checkbox">
                          <label><input type="checkbox" value="">Pneumonia</label></div>
            <div class="checkbox">
                          <label><input type="checkbox" value="">Colitis</label></div>
            <div class="checkbox">
                          <label><input type="checkbox" value="">High cholesterol</label></div> 
            <div class="checkbox">
                          <label><input type="checkbox" value="">Pulmonary embolism </label></div>  
            <div class="checkbox">
                          <label><input type="checkbox" value="">Anemia </label></div>
            <div class="checkbox">
                          <label><input type="checkbox" value="">Hypothyroidism </label></div>  
            <div class="checkbox">
                          <label><input type="checkbox" value="">Asthma</label></div> 
            <div class="checkbox">             
                          <label><input type="checkbox" value="">Jaundice</label></div>
            <div class="checkbox">
                          <label style="white-space: nowrap"><input type="checkbox" value="">Stomach or peptic ulcer  </label></div>
   		   </div>
           
           <div class="col-sm-6 col-xs-6">
             
                         
              
            <div class="checkbox">
                          <label><input type="checkbox" value="">Goiter</label></div>
            <div class="checkbox">
                          <label><input type="checkbox" value="">Emphysema </label></div> 
            <div class="checkbox">
                          <label><input type="checkbox" value="">Hepatitis</label></div>
            <div class="checkbox">
                          <label><input type="checkbox" value="" id="Cancercheckbox" onChange="valueChangedCancer()">Cancer</label></div> 
            <div class="checkbox">
                          <label><input type="checkbox" value="">Stroke</label></div>
            
            <div class="checkbox">
                          <label><input type="checkbox" value="">Leukemia</label></div>  
            <div class="checkbox">
                          <label><input type="checkbox" value="">Epilepsy (seizures)</label></div>   
            <div class="checkbox">
                          <label><input type="checkbox" value="">Psoriasis</label></div>  
            <div class="checkbox">
                          <label><input type="checkbox" value="">Cataracts </label></div> 
            <div class="checkbox">
                          <label><input type="checkbox" value="">Tuberculosis</label></div>
            <div class="checkbox">
                          <label><input type="checkbox" value="">Angina</label></div>
            <div class="checkbox">
                          <label><input type="checkbox" value="">Kidney disease</label></div>  
            <div class="checkbox">
                          <label><input type="checkbox" value="">HIV/AIDS</label></div>
                          
           </div>-->
           
           
           
           
           <?php
		   $m=1;
		   $Cancer=0;
		   $SqlMedList="select * from medication_list_master where Active='Yes'";
		   $RsMedList=mysqli_query($con,$SqlMedList);
		   while($RowMedList=mysqli_fetch_array($RsMedList))
		   {
		     $PatientPastMed=Numrow_Chk($con,'patient_past_madication','Lead_ID',$_REQUEST['Lid'],'Medical_Name',$RowMedList['Medical_Name']);
			  if($RowMedList['Medical_Name']=="Cancer" && $PatientPastMed>0){
			  $Cancer=1;
			   }
		   ?>
           <div class="col-xs-6">
           <div class="checkbox">
      			          <label><input type="checkbox" name="Medical_Name<?php echo $m; ?>" id="Medical_Name<?php echo $m; ?>" value="<?php echo $RowMedList['Medical_Name']; ?>" <?php if($RowMedList['Medical_Name']=="Cancer"){?>onChange="valueChangedCancer(<?php echo $m; ?>)"<?php } ?> <?php if($PatientPastMed>0){echo "checked";} ?>><?php echo $RowMedList['Medical_Name']; ?></label></div>
            </div>   
            <?php
			$m++;
			}
			?>
            
               <input type="hidden" name="count_past_med" id="count_past_med" value="<?php echo $m; ?>">            
                          
           
           <div class="col-sm-4 col-xs-12"  id="CancerType_div" style="padding-top:10px; <?php if($Cancer!=1){?>display:none<?php } ?>"  >
           <div class="form-group">
               <label>Enter Cancer Type</label>
               <input name="CancerType" id="CancerType" type="text" class="form-control"  >
            </div>
           </div>
           
           
           
           
           
           
           <div class="col-sm-4 col-xs-12"  id="Othermedical_div" style="padding-top:10px"  >
           <div class="form-group">
               <label>Other medical conditions</label>
               <input name="Othermedical" id="Othermedical" type="text" class="form-control"  >
            </div>
           </div>
           
           
            

<script type="text/javascript">
function valueChangedCancer(per)
{
    if($('#Medical_Name'+per).is(":checked"))   
        $("#CancerType_div").slideDown();
    else
        $("#CancerType_div").slideUp();
}
</script>
           
   
       
 <div class="col-sm-12" style="margin:0; padding:0">
          <div class="col-sm-6 col-xs-6">
       <div class="form-group"> 
             <a href="patient_assessment_2.php?Lid=<?php echo $_REQUEST['Lid']; ?>"><input type="button" class="btn  btn-primary" name="Patient_Info" value="Previous" style="margin-top:10px; float:left; padding-left:10px !important;  padding:5px 8px !important; margin-bottom:10px;"  ></a>
         </div>                                                       
      </div>      
               
                                               
           <div class="col-sm-6 col-xs-6">
                                           <div class="form-group"> 
                                                 <input type="submit" class="btn  btn-primary " name="Patient_Medication" value="Save and Next" style="margin-top:10px; float:right; padding-left:10px !important; margin-bottom:12px !important; padding:5px 8px !important"  >
                                             </div>                                                       
                                           </div>                                
      </div> 
                    
     </form>
        </div>
        
      
        
      </div>
    </div>
    
    
 
  </div> 
                         
                    </div> 
                    
                    
                 
                 
                              
                                      
                        </div>
                    </div>
                </div>
                
                
            </div>
        </div>
        <!-- Static Table End -->
        <div class="footer-copyright-area">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="footer-copy-right">
                            <p>Copyright © 2019. All rights reserved. </p>
                           
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

     <!-- jquery
		============================================ -->
     
       <script src="js/vendor/jquery-1.12.4.min.js"></script>
    <!-- bootstrap JS
		============================================ -->
    <script src="js/bootstrap.min.js"></script>
    <!-- wow JS
		============================================ -->
    <script src="js/wow.min.js"></script>
    <!-- price-slider JS
		============================================ -->
    <script src="js/jquery-price-slider.js"></script>
    <!-- meanmenu JS
		============================================ -->
    <script src="js/jquery.meanmenu.js"></script>
    <!-- owl.carousel JS
		============================================ -->
    <script src="js/owl.carousel.min.js"></script>
    <!-- sticky JS
		============================================ -->
    <script src="js/jquery.sticky.js"></script>
    <!-- scrollUp JS
		============================================ -->
    <script src="js/jquery.scrollUp.min.js"></script>
    
    <script src="js/scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
    <script src="js/scrollbar/mCustomScrollbar-active.js"></script>

     
    
     <!--  editable JS
		============================================ -->
    <script src="js/editable/jquery.mockjax.js"></script>
    <script src="js/editable/mock-active.js"></script>
    <script src="js/editable/select2.js"></script>
    <script src="js/editable/moment.min.js"></script>
    <script src="js/editable/bootstrap-datetimepicker.js"></script>
    <script src="js/editable/bootstrap-editable.js"></script>
    <script src="js/editable/xediable-active.js"></script>
 	
    
    <!-- datepicker JS
		============================================ -->
    <script src="js/datepicker/jquery-ui.min.js"></script>
    <script src="js/datepicker/datepicker-active.js"></script>
    
    <!-- mCustomScrollbar JS
		============================================ -->
    <script src="js/scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
    <script src="js/scrollbar/mCustomScrollbar-active.js"></script>
    <!-- metisMenu JS
		============================================ -->
    <script src="js/metisMenu/metisMenu.min.js"></script>
    <script src="js/metisMenu/metisMenu-active.js"></script>
    <!-- peity JS
		============================================ -->
    <script src="js/peity/jquery.peity.min.js"></script>
    <script src="js/peity/peity-active.js"></script>
    <!-- sparkline JS
		============================================ -->
    <script src="js/sparkline/jquery.sparkline.min.js"></script>
    <script src="js/sparkline/sparkline-active.js"></script>
    <!-- tab JS
		============================================ -->
    <script src="js/tab.js"></script>
    <!-- plugins JS
		============================================ -->
    <script src="js/plugins.js"></script>
    <!-- main JS
		============================================ -->
    <script src="js/main.js"></script>
    <!-- tawk chat JS
		============================================ -->
    
   <!-- form validate JS
		============================================ -->
    <script src="js/form-validation/jquery.form.min.js"></script>
    <script src="js/form-validation/jquery.validate.min.js"></script>
    <script src="js/form-validation/form-active.js"></script>
    
    
    
    
   
      <script>
				function Reffered_opt_function() {
				 var Reffered_opt = $("#Reffered_opt123").val();
				 if(Reffered_opt=="Dr") {
				 $("#Doctor_div").show(400);
					}
					
					if(Reffered_opt!="Dr") {
				 $("#Doctor_div").hide(400);
					}
				}
				</script>   
    
    
    
    <script>
$(document).ready(function() {
   $("body").tooltip({ 
   	selector: '[data-toggle=tooltip]' 
	 });
});
 
</script> 
  
               
<script>
$('button.call_btn_1').click(function() {
    //var text = $(this).text();
	var text = $(this).data('value_santanu');
	//alert(text)
	$('#hidden_call_box').val(text);
	$('#response').val(text);
    // do something with the text
});
</script> 
                                                
                                                
                                                
                                                
       <!-- bootstrap-clockpicker -->
      <link rel="stylesheet" type="text/css" href="css/bootstrap-clockpicker.min.css">
    <script type="text/javascript" src="js/bootstrap-clockpicker.min.js"></script>


     



<script type="text/javascript">
$("form#form_s_1").validate({
          
      showErrors: function(errorMap, errorList) {
          // Clean up any tooltips for valid elements
          $.each(this.validElements(), function (index, element) {
              var $element = $(element);
              $element.data("title", "") // Clear the title - there is no error associated anymore
                  .removeClass("error")
                  .tooltip("destroy");
          });
          // Create new tooltips for invalid elements
          $.each(errorList, function (index, error) {
              var $element = $(error.element);

              $element.tooltip("destroy") // Destroy any pre-existing tooltip so we can repopulate with new tooltip content
                  .data("title", error.message)
                  .addClass("error")
                  .tooltip(); // Create a new tooltip based on the error messsage we just set in the title
          });
      },

     
	  
});

$("form#form_s_2").validate({
          
      showErrors: function(errorMap, errorList) {
          // Clean up any tooltips for valid elements
          $.each(this.validElements(), function (index, element) {
              var $element = $(element);
              $element.data("title", "") // Clear the title - there is no error associated anymore
                  .removeClass("error")
                  .tooltip("destroy");
          });
          // Create new tooltips for invalid elements
          $.each(errorList, function (index, error) {
              var $element = $(error.element);

              $element.tooltip("destroy") // Destroy any pre-existing tooltip so we can repopulate with new tooltip content
                  .data("title", error.message)
                  .addClass("error")
                  .tooltip(); // Create a new tooltip based on the error messsage we just set in the title
          });
      },

     
	  
});
</script>                                          
                                                
                                                
 <!-- <script>
		CKEDITOR.replace( 'editor1', {
			height: 150,
			width: 700,
		} );
	</script> -->                                             
                                                
  <script>
  $(document).ready(function() {
    var max_fields = 10;
    var wrapper = $("#container1");
    var add_button = $(".add_form_field");

   // var x = 1;
       var x = $('#count_current_med').val();
    $(add_button).click(function(e) {
        e.preventDefault();
        if (x < max_fields) {
            x++;
            $(wrapper).append('<div class="col-sm-12" style="padding:0"><div class="form-group  col-xs-12 col-sm-3" style="padding:0"><label>Name of Drug</label><input name="drugname'+x+'" id="drugname'+x+'" type="text" class="form-control" data-rule-required="true" data-msg-required="Please enter patient id"></div><div class="col-sm-1"></div><div class="form-group  col-xs-5 col-sm-3" style="padding:0; padding-right:7px"><label>Dose</label><input name="drugdose'+x+'" id="drugdose'+x+'" type="text" class="form-control" data-rule-required="true" data-msg-required="Please enter patient id"></div><div class="col-sm-1"></div><div class="form-group  col-xs-5 col-sm-3" style="padding:0; padding-left:7px"><label>Taking Since</label><input name="drugtime'+x+'" id="drugtime'+x+'" type="text" class="form-control" data-rule-required="true" data-msg-required="Please enter patient id"></div><a href="#" class="delete col-xs-2 col-sm-1" style="color:#333333; font-size:22px; padding:0; xmargin-top:-10px; margin-bottom: 10px; text-align:right" ><i class="fa fa-trash-o" aria-hidden="true" data-toggle="tooltip" data-placement="left" title="Delete" ></i></a></div>'); //add input box
			
			$('#count_current_med').val(x);
        } else {
            alert('You Reached the limits')
        }
    });

    $(wrapper).on("click", ".delete", function(e) {
        e.preventDefault();
        $(this).parent('div').remove();
        x--;
		$('#count_current_med').val(x);
    })
	

	
});


 </script>  
 
 
 
 <script>
$(document).ready(function(){
  $('[data-toggle="tooltip"]').tooltip(); 
});
</script>
</body>

</html>