Mr.Fn4ticHz Shell
Server IP : 162.240.98.243  /  Your IP : 3.145.92.54
Web Server : Apache
System : Linux server.bti.yaw.mybluehostin.me 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : btiyawmy ( 1003)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/btiyawmy/public_html/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/btiyawmy/public_html/patientmanager_old.php
	      <?PHP
session_start();
require_once("../dbconnection.php");
require_once('../DBManager.php');
require_once('../LoginManager.php');
?>

<?php 
date_default_timezone_set('Asia/Kolkata');
require_once("LoginManager.php");
class PatientManager
{	
public static $userhomepage="welcome.php",$loginpage="login.php",$adminhomepage="price.php",$drhomepage="drprofile.php",$patienthomepage="patient_basic.php";

public static function setActivityLog($userno,$prescriptionid,$discription,$link,$enteredby)
{
	$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	$sql="INSERT INTO save_activity(srno,userno,prescriptionid,discription,entered_by,link,created_at,updated_at) VALUES (NULL, '$userno','$prescriptionid','$discription<br>Doc.no-','$enteredby','$link',' $created_at','$updated_at')";
	$link=DBManager::connect();

	$result=mysqli_query($link,$sql);
	if($result)
		$insid= mysqli_insert_id($link);
			$srid= $insid;
		$link=DBManager::close($link);
	}
	
	
public static function setActivitybillsave($invetory_id,$vendor_billid,$date_time,$price_pay,$status,$mode,$entered_by)
{
	$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	$sql="INSERT INTO part_vendor_billing(part_vendor_billid,invetory_id,vendor_billid,date_time,price_pay,status,mode,entered_by,created_at,updated_at) VALUES (NULL,'$invetory_id','$vendor_billid','$date_time','$price_pay','$status','$mode','$entered_by','$created_at','$updated_at')";
	
	$link=DBManager::connect();
	$result=mysqli_query($link,$sql);
	
	if($result)
		$insid= mysqli_insert_id($link);
			$srid= $insid;
		$link=DBManager::close($link);
	}	
	
	
public static function setActivitybill($invetory_id,$medicine_id,$date_of_purchase,$vendor,$date_invoice,$Cmrp,$cost_gst,$Batch_number,$mrp,$gst,$entered_by)
{
	$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	$sql="INSERT INTO vendor_billing(vendor_billid,invetory_id,medicine_id,date_of_purchase,vendor,date_invoice,Cmrp,cost_gst,Batch_number,mrp,gst,entered_by,created_at,updated_at) VALUES (NULL,'$invetory_id','$medicine_id','$date_of_purchase','$vendor','$date_invoice','$Cmrp','$cost_gst','$Batch_number','$mrp','$gst','$entered_by','$created_at','$updated_at')";
			$link=DBManager::connect();
	$result=mysqli_query($link,$sql);
	{
  	$insid= mysqli_insert_id($link);
			$vendor_billid= $insid;
			
	PatientManager::setActivitybillsave($invetory_id,"$vendor_billid","$date_of_purchase","$Cmrp","status","mode","$entered_by");
    }
	if($result)
		$link=DBManager::close($link);
	}
	
	
	
public static function transferbedpatient($prescriptionid,$towords,$datetime)
{
   $datetime=date("F d, Y / h:i:s A");
	$sql="INSERT INTO transferbed(srno,prescriptionid,towords,datetime) VALUES (NULL, '$prescriptionid','$towords','$datetime')";
	$link=DBManager::connect();

	$result=mysqli_query($link,$sql);
	if($result)
		$insid= mysqli_insert_id($link);
			$srid= $insid;
		$link=DBManager::close($link);
	}


public static function billingLog($patientid,$prescriptionid,$discription,$pagetype,$link,$pricetotal,$discount,$grand_total,$paymentmode,$status,$enteredby)
{
    date_default_timezone_set('Asia/Kolkata');
    $created_at=date('Y/m/d H:i:s');
	$sql="INSERT INTO patient_invace(invaceid,patientid,prescriptionid,discription,pagetype,link,pricetotal,discount,grand_total,paymentmode,status,entered_by,created_at,updated_at) VALUES (NULL, '$patientid','$prescriptionid','$discription','$pagetype','$link','$pricetotal','$discount','$grand_total','$paymentmode','$status','$enteredby','$created_at',now())";
	$link=DBManager::connect();
	$result=mysqli_query($link,$sql);
	if($result)
		$link=DBManager::close($link);
	}

//START BOOK APPOIMENT//



//START TAT LOG//
public static function tatLog($patientid,$prescriptionid,$discription,$pagetype,$hospital_id,$start_date,$stop_date,$start_time,$stop_time,$solution,$entered_by,$currenctive_by)
{
 date_default_timezone_set('Asia/Kolkata');
$timeva=time();
$pavam=date( "H:i:s","$timeva");
$start_date=date('Y/m/d H:i:s');

$narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
include("dbconnection.php");
$sql1 ="SELECT * FROM site_users WHERE userno='$entered_by'";
		$qsql1 = mysqli_query($con,$sql1);
		if($rh1 = mysqli_fetch_array($qsql1))
		

	$sql="INSERT INTO tat(tatid,patientid,prescriptionid,discription,pagetype,hospital_id,start_date,stop_date,start_time,stop_time,solution,entered_by,reported_at,currenctive_at,currenctive_by,updated_at) VALUES (NULL, '$patientid','$prescriptionid','$discription','$pagetype','$rh1[entered_by]','$start_date','$stop_date','$pavam','$stop_time','$solution','$entered_by',now(),'$currenctive_at','$currenctive_by',now())";
	$link=DBManager::connect();
	$result=mysqli_query($link,$sql);
	if($result)
		$link=DBManager::close($link);
	}



//END TAT LOG//

// Start investigation Update Status//
public static function updatetatLogvitals($patientid,$prescriptionid,$discription,$pagetype,$hospital_id,$start_date,$stop_date,$start_time,$stop_time,$solution,$entered_by,$currenctive_by)
{
	$link=DBManager::connect();
	 date_default_timezone_set('Asia/Kolkata');
$timeva=time();
$pavam=date( "H:i:s","$timeva");
$sjdjs=date('Y/m/d H:i:s');
$sql ="UPDATE tat SET stop_date='$sjdjs',stop_time='$pavam'  WHERE prescriptionid='$_GET[prescriptionid]' AND 	pagetype='Vitals'";
$result=mysqli_query($link,$sql);
if($result)
echo "";
else 
	echo "";
	$link=DBManager::close($link);
}

//END investigation update Status//

// Start investigation Update Status//
public static function updatetatLog($patientid,$prescriptionid,$discription,$pagetype,$hospital_id,$start_date,$stop_date,$start_time,$stop_time,$solution,$entered_by,$currenctive_by)
{
	$link=DBManager::connect();
	 date_default_timezone_set('Asia/Kolkata');
$timeva=time();
$pavam=date( "H:i:s","$timeva");
$sjdjs=date('Y/m/d H:i:s');
$sql ="UPDATE tat SET stop_date='$sjdjs',stop_time='$pavam'  WHERE prescriptionid='$_GET[prescriptionid]' AND 	pagetype='Add_As_Patient_Page'";
$result=mysqli_query($link,$sql);
if($result)
echo "";
else 
	echo "";
	$link=DBManager::close($link);
}

//END investigation update Status//

//Start on Glass Advices -Near//


public static function opdGlassnear($prescriptionid,$patientid,$occuid,$Examination_type,$SPH,$SPH_right,$SPH_left,$CYL,$CYL_right,$CYL_left,$AXIS,$AXIS_right,$AXIS_left,$VISION,$VISION_right,$VISION_left,$entered_by)
{
	echo "Patient admission new";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Examination <br>Glass Advices $Examination_type","show_GlassAdvices_near.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO Glass_Advices(id,prescriptionid,patientid,occuid,Examination_type,SPH,SPH_right,SPH_left,CYL,CYL_right,CYL_left,AXIS,AXIS_right,AXIS_left,VISION,VISION_right,VISION_left,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$occuid','$Examination_type','$SPH','$SPH_right','$SPH_left','$CYL','$CYL_right','$CYL_left','$AXIS','$AXIS_right','$AXIS_left','$VISION','$VISION_right','$VISION_left','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Glass Advices-Near add successfully..');</script><script>window.location='onexamnaton.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//End on Glass Advices -near//
// START ON Glass Advices -Distance//
public static function opdGlassAdvices($prescriptionid,$patientid,$occuid,$Examination_type,$SPH,$SPH_right,$SPH_left,$CYL,$CYL_right,$CYL_left,$AXIS,$AXIS_right,$AXIS_left,$VISION,$VISION_right,$VISION_left,$entered_by)
{
	echo "Patient admission new";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Examination <br>Glass Advices $Examination_type","show_GlassAdvices.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO Glass_Advices(id,prescriptionid,patientid,occuid,Examination_type,SPH,SPH_right,SPH_left,CYL,CYL_right,CYL_left,AXIS,AXIS_right,AXIS_left,VISION,VISION_right,VISION_left,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$occuid','$Examination_type','$SPH','$SPH_right','$SPH_left','$CYL','$CYL_right','$CYL_left','$AXIS','$AXIS_right','$AXIS_left','$VISION','$VISION_right','$VISION_left','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Glass Advices-Distance add successfully..');</script><script>window.location='onexamnaton.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

// END ON Glass Advices -Distance//


// START on visual acuity test //
public static function opdonevisualexam($prescriptionid,$patientid,$occuid,$Un_right,$Un_left,$Aided_right,$Aided_left,$entered_by)
{
	echo "";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Examination <br> Visual Acuity Test","show_Visual_Acuity_Test.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO visual(id,prescriptionid,patientid,occuid,Un_right,Un_left,Aided_right,Aided_left,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$occuid','$Un_right','$Un_left','$Aided_right','$Aided_left','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Visual Acuity Test add successfully..');</script><script>window.location='onexamnaton.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

// END ON visual acuity test//




// Start investigation Update Status//
public static function updatetatLogopd($patientid,$prescriptionid,$discription,$pagetype,$hospital_id,$start_date,$stop_date,$start_time,$stop_time,$solution,$entered_by,$currenctive_by)
{
	$link=DBManager::connect();
	 date_default_timezone_set('Asia/Kolkata');
$timeva=time();
$pavam=date( "H:i:s","$timeva");
$sjdjs=date('Y/m/d H:i:s');
$sql ="UPDATE tat SET stop_date='$sjdjs',stop_time='$pavam'  WHERE prescriptionid='$_GET[prescriptionid]' AND 	pagetype='OPD_Consultation'";
$result=mysqli_query($link,$sql);
if($result)
echo "";
else 
	echo "";
	$link=DBManager::close($link);
}

//END investigation update Status//

//START MEDICATION BILLING //

public static function billingmedication($patientid,$prescriptionid,$discription,$pagetype,$link,$pricetotal,$discount,$grand_total,$paymentmode,$status,$enteredby)
{
    $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	$sql="INSERT INTO patient_invace(invaceid,patientid,prescriptionid,discription,pagetype,link,pricetotal,discount,grand_total,paymentmode,status,entered_by,created_at,updated_at) VALUES (NULL, '$patientid','$prescriptionid','$discription','$pagetype','$link','$pricetotal','$discount','$grand_total','$paymentmode','$status','$enteredby',now(),now())";
	$link=DBManager::connect();
	
	$result=mysqli_query($link,$sql);
	if($result)
	echo "<script>window.location='patient_medicine_invacefinal.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
		$link=DBManager::close($link);
	}



//END MEDICATION BILLING//
public static function appoimentbook($patientid,$adminid,$patientname,$VisitConsultant,$Specialty,$Selectstate,$Selectdistrict,$hospitalname,$drid,$Payment,$selectdate,$SelectTime,$statusva)
{
	$sql="INSERT INTO bookap(srno,patientid,adminid,patientname,VisitConsultant,Specialty,Selectstate,Selectdistrict,hospitalname,drid,Payment,selectdate,SelectTime,statusva) VALUES (NULL, '$patientid','$adminid','$patientname','$VisitConsultant','$Specialty','$Selectstate','$Selectdistrict','$hospitalname','$drid','$Payment','$selectdate','$SelectTime','$statusva')";
	$link=DBManager::connect();
	
	$result=mysqli_query($link,$sql);
	if($result)
		echo "OK";
	else 
		echo "Fail";
		$link=DBManager::close($link);
	}

//END BOOK APPOIMNET//



// START FOLLOW UP BOOKING SYSTEM//
public static function appoimentbookopd($patientid,$adminid,$patientname,$VisitConsultant,$Specialty,$Selectstate,$Selectdistrict,$hospitalname,$drid,$Payment,$selectdate,$SelectTime,$statusva)
{
	$sql="INSERT INTO bookap(srno,patientid,adminid,patientname,VisitConsultant,Specialty,Selectstate,Selectdistrict,hospitalname,drid,Payment,selectdate,SelectTime,statusva) VALUES (NULL, '$patientid','$adminid','$patientname','$VisitConsultant','$Specialty','$Selectstate','$Selectdistrict','$hospitalname','$drid','$Payment','$selectdate','$SelectTime','$statusva')";
		$link=DBManager::connect();
	$result=mysqli_query($link,$sql);
	if($result)
echo "<script>alert('Booking add successfully..');</script><script>window.location='patient_basic.php?patientid=$patientid'</script>;</script>";
	else 
		echo "Fail";
		$link=DBManager::close($link);
	}

// END FOLLOW UP BOOKING SYSTEM//




//START VITALS//
public static function vilalslog($prescriptionid,$patientid,$Wt,$bmi,$BP,$BP2,$Temp,$RBS,$Spo2,$HR,$Pulse,$poa,$entered_by)
{
	$sql="INSERT INTO vitals_final(id,prescriptionid,patientid,Wt,bmi,BP,BP2,Temp,RBS,Spo2,HR,Pulse,poa,entered_by,created_at,updated_at) VALUES (NULL, '$prescriptionid','$patientid','$Wt','$bmi','$BP','$BP2','$Temp','$RBS','$Spo2','$HR','$Pulse','$poa','$entered_by',now(),now())";
	$link=DBManager::connect();
	$sql1 ="UPDATE patient SET Weight='$Wt' WHERE patientid='$patientid'";
$result=mysqli_query($link,$sql1);
	$result=mysqli_query($link,$sql);

if($result)



	if($result)
		echo "<div class='alert alert-success'>
  <strong>Success!</strong> Add vital a successful.
</div>";
	else 
		echo "Fail";
		$link=DBManager::close($link);
	}

//END VITALS//

//START VITALS//
public static function vilalsloging($prescriptionid,$patientid,$Wt,$bmi,$BP,$BP2,$Temp,$RBS,$Spo2,$HR,$Pulse,$poa,$entered_by)
{
    $link=DBManager::connect();
$narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;

$sql="INSERT INTO vitals_final(id,prescriptionid,patientid,Wt,bmi,BP,BP2,Temp,RBS,Spo2,HR,Pulse,poa,entered_by,created_at,updated_at) VALUES (NULL, '$prescriptionid','$patientid','$Wt','$bmi','$BP','$BP2','$Temp','$RBS','$Spo2','$HR','$Pulse','$poa','$entered_by',now(),now())";
	$sql1 ="UPDATE patient SET Weight='$Wt' WHERE patientid='$patientid'";
$result=mysqli_query($link,$sql1);
	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from vitals_final";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
PatientManager::setActivityLog($patientid,"$prescriptionid","Nursing Assessment<br>Vitals","showpageipd_vitals.php?prescriptionid=$prescriptionid&patientid=$patientid&id=$id&srno=","$entered_by");
	$result=mysqli_query($link,$sql);
		
if($result)
echo "<script>alert('Vitals add successfully..');</script><script>window.location='nursingset.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END VITALS//


//Start DR Note VITALS//
public static function vilalslogingdrnote($prescriptionid,$patientid,$Wt,$bmi,$BP,$BP2,$Temp,$RBS,$Spo2,$HR,$Pulse,$poa,$entered_by)
{
    $link=DBManager::connect();
$narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
$admissiondate=date("Y/m/d");
$sql="INSERT INTO vitals_final(id,prescriptionid,patientid,Wt,bmi,BP,BP2,Temp,RBS,Spo2,HR,Pulse,poa,entered_by,created_at,updated_at) VALUES (NULL, '$prescriptionid','$patientid','$Wt','$bmi','$BP','$BP2','$Temp','$RBS','$Spo2','$HR','$Pulse','$poa','$entered_by',now(),'$admissiondate')";
	$sql1 ="UPDATE patient SET Weight='$Wt' WHERE patientid='$patientid'";
$result=mysqli_query($link,$sql1);
	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from vitals_final";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
PatientManager::setActivityLog($patientid,"$prescriptionid","Doctor Note<br>Vitals","showpageipd_vitals.php?prescriptionid=$prescriptionid&patientid=$patientid&id=$id&srno=","$entered_by");
	$result=mysqli_query($link,$sql);
		
if($result)
echo "<script>alert('Vitals add successfully..');</script><script>window.location='vitals_drnote.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}




//END DR NOTE VITALS//





//BLood trainfusion start vitals//

public static function vilalsblooadtr($prescriptionid,$patientid,$Bmi,$Wt,$SPo2,$RBS,$Temp,$Pulse,$BP,$BP2,$stopid,$entered_by)
{
    $link=DBManager::connect();
$narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
$sttime=date("H:i:s");

PatientManager::vilalslog("$prescriptionid","$patientid","$Wt","$Bmi","$BP","$BP2","$Temp","$RBS","$SPo2","unknown","$Pulse","Blood Transfusion Stop","$entered_by");
$sql="INSERT INTO Medical_vitals(id,prescriptionid,patientid,Bmi,Wt,SPo2,RBS,Temp,Pulse,BP,BP2,stopid,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Bmi','$Wt','$SPo2','$RBS','$Temp','$Pulse','$BP','$BP2','$stopid','$entered_by','$created_at','$updated_at')";
		$sql6="UPDATE bloodtransfusion SET blood='',blood_stop='$sttime' WHERE patientid='$patientid' AND prescriptionid='$prescriptionid'  AND blood='on'";
$result=mysqli_query($link,$sql6);
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Blood Transfusion Stop successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//Blood trainfusion end vital//


//START VITALS//
public static function vilalslog2($prescriptionid,$patientid,$Wt,$bmi,$BP,$BP2,$Temp,$RBS,$Spo2,$HR,$Pulse,$poa,$entered_by)
{
    	$link=DBManager::connect();
$narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;

	$sql="INSERT INTO vitals_final(id,prescriptionid,patientid,Wt,bmi,BP,BP2,Temp,RBS,Spo2,HR,Pulse,poa,entered_by,created_at,updated_at) VALUES (NULL, '$prescriptionid','$patientid','$Wt','$bmi','$BP','$BP2','$Temp','$RBS','$Spo2','$HR','$Pulse','$poa','$entered_by',now(),now())";
	$sql1 ="UPDATE patient SET Weight='$Wt' WHERE patientid='$patientid'";
$result=mysqli_query($link,$sql1);

$result=mysqli_query($link,$sql1);
	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from vitals_final";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];


PatientManager::setActivityLog($patientid,"$prescriptionid","Progress Chart<br>$poa","showpageipd_vitals.php?prescriptionid=$prescriptionid&patientid=$patientid&id=$id&srno=","$entered_by");
	$result=mysqli_query($link,$sql);
		
if($result)
echo "<script>alert('Vitals add successfully..');</script><script>window.location='vitals_chart.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

	
//END VITALS//


//START VITALS//
public static function medicineslotgive($prescriptionid,$patientid,$medicine_id	,$admin_id,$linkfor,$quantitygiven,$slot_id,$price,$pricetotal,$discount,$paymentmode,$action,$batchno,$entered_by)
{
$narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	$link=DBManager::connect();
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	$sql="INSERT INTO medicine_slot(srno,prescriptionid,patientid,medicine_id	,admin_id,linkfor,quantitygiven,slot_id,price,pricetotal,discount,paymentmode,action,batchno,entered_by,created_at,updated_at) VALUES (NULL, '$prescriptionid','$patientid','$medicine_id','$admin_id','$linkfor','$quantitygiven','$slot_id','$price','$pricetotal','$discount','$paymentmode','$action','$batchno','$entered_by','$created_at','$updated_at')";
 $link=DBManager::connect();
	$result=mysqli_query($link,$sql);
	if($result)
		$link=DBManager::close($link);
	}
	
//END VITALS//


//Start Output //
public static function outputva($prescriptionid,$patientid,$output_datetime,$Intake,$Amount,$Output,$output_Amount,$entered_by)
{
      $link=DBManager::connect();
$narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;

	$sql="INSERT INTO output_patient(id,prescriptionid,patientid,output_datetime,Intake,Amount,Output,output_Amount,entered_by,created_at,updated_at) VALUES (NULL, '$prescriptionid','$patientid','$output_datetime','$Intake','$Amount','$Output','$output_Amount','$entered_by',now(),now())";
$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from output_patient";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
PatientManager::setActivityLog($patientid,"$prescriptionid","Nursing Assessment<br>Input & Output Timeline","showpage_Input_Output_Timeline.php?prescriptionid=$prescriptionid&patientid=$patientid&id=$id&srno=","$entered_by");
	$result=mysqli_query($link,$sql);
		
if($result)
echo "<script>alert('Add successfully..');</script><script>window.location='nursingset.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END OUTPUT //

//Start Output //
public static function outputvatimiline($prescriptionid,$patientid,$output_datetime,$Intake,$Amount,$Output,$output_Amount,$entered_by)
{
      $link=DBManager::connect();
$narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;

	$sql="INSERT INTO output_patient(id,prescriptionid,patientid,output_datetime,Intake,Amount,Output,output_Amount,entered_by,created_at,updated_at) VALUES (NULL, '$prescriptionid','$patientid','$output_datetime','$Intake','$Amount','$Output','$output_Amount','$entered_by',now(),now())";
$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from output_patient";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
PatientManager::setActivityLog($patientid,"$prescriptionid","Nursing Assessment<br>Input & Output Timeline","showpage_Input_Output_Timeline.php?prescriptionid=$prescriptionid&patientid=$patientid&id=$id&srno=","$entered_by");
	$result=mysqli_query($link,$sql);
		
if($result)
echo "<script>alert('Add successfully..');</script><script>window.location='timiline_inputandoutput.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END OUTPUT //



//START NURSING PLAN//

public static function narayanharilal($prescriptionid,$patientid,$Assessment_note,$Nursing_diagnosis_note,$Plan_of_Action,$Implementation,$Evaluation,$entered_by)
{
    	$link=DBManager::connect();
  
$narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;

	$sql="INSERT INTO nurse_note(id,prescriptionid,patientid,Assessment_note,Nursing_diagnosis_note,Plan_of_Action,Implementation,Evaluation,entered_by,created_at,updated_at) VALUES (NULL, '$prescriptionid','$patientid','$Assessment_note','$Nursing_diagnosis_note','$Plan_of_Action','$Implementation','$Evaluation','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from nurse_note";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];

PatientManager::setActivityLog($patientid,"$prescriptionid","Nursing Assessment<br>Plan Of care","showpage_Plan_Of_care.php?prescriptionid=$prescriptionid&patientid=$patientid&id=$id&srno=","$entered_by");
if($result)
echo "<script>alert('Nursing Plan Of care add successfully..');</script><script>window.location='nursingset.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//END NURSING PLAN//
public static function getRandomkey()
{
		$length=16;
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $string = '';

    for ($i = 0; $i < $length; $i++) {
        $string .= $characters[mt_rand(0, strlen($characters) - 1)];
    }

    return $string;

	
}

public static function getpassword()
{
		$length=13;
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $string = '';

    for ($i = 0; $i < $length; $i++) {
        $string .= $characters[mt_rand(0, strlen($characters) - 1)];
    }

    return $string;

	
}
//Registerd Patient Start //

public static function registerpatient($familyid,$headnumber,$pic,$fr,$patientname,$gendor,$HusbandName,$Email,$numbers,$dob,$age_type,$Weight,$Height,$bloodgroup,$Nationality,$Marital,$Religion,$Occupation,$Familyinc,$Education,$Passportnm,$AadharNu,$Referred,$Country,$State,$city,$pincode,$bloc,$nameofinc,$Policynm,$entered_by)
{
    date_default_timezone_set('Asia/Kolkata');
	$narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
		$patientuser = rand(1000, 9999);
$userno=PatientManager::registerUser("Patient$patientuser",$patientname,$numbers,"Patient",$password,"Active","$entered_by");
	echo "<br>Userno=$userno<br>";
	$link=DBManager::connect();
	$username = "ventexint@gmail.com";
     $apikey = "eebcced9-0ca1-4a6f-940b-c616276e2ec9";
    $sendername = "EASNUP";
	$user_otp = rand(100000, 999999);
	$user_activation_code = md5(rand());
$patientid=$userno;
$narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
$Referred=$harilal;
	$sql="INSERT INTO patient(srno,patientid,familyid,headnumber,pic,fr,patientname,gendor,HusbandName,Email,numbers,dob,age_type,Weight,Height,bloodgroup,Nationality,Marital,Religion,Occupation,Familyinc,Education, Passportnm,AadharNu,Referred,Country,State,city,pincode,bloc,nameofinc,Policynm,user_otp,numbers_status,user_activation_code,entered_by, created_at,updated_at) VALUES (NULL, '$userno','$familyid','$headnumber','$pic','$fr','$patientname','$gendor','$HusbandName','$Email','$numbers','$dob','$age_type','$Weight','$Height','$bloodgroup','$Nationality','$Marital','$Religion','$Occupation','$Familyinc','$Education','$Passportnm','$AadharNu','$Referred','$Country','$State','$city','$pincode','$bloc','$nameofinc','$Policynm','$user_otp','Not Verified','$user_activation_code','$entered_by',now(),now())";
		$message="Hello $patientname, Your OTP to complete the Registration with Ease'n'Up is $user_otp Regards, HAND Corp";
	$message=urlencode($message);
$sms ="http://login.aquasms.com/sendSMS?username=ventexint@gmail.com&message=$message&sendername=EASNUP&smstype=TRANS&numbers=$numbers&apikey=eebcced9-0ca1-4a6f-940b-c616276e2ec9";
	//$sms=urlencode($sms);
	$result=file_get_contents($sms);
	//echo $sql;
$result=mysqli_query($link,$sql);
if($result)
echo "<script>window.location='patient_verify.php?code=$user_activation_code';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//Registerd Patient END //
//ADD PATIENT IF ADDED FAMILY//
public static function registerfamilya($familyid,$pic,$fr,$patientname,$gendor,$HusbandName,$Email,$numbers,$dob,$Weight,$Height,$bloodgroup,$Nationality,$Marital,$Religion,$Occupation,$Familyinc,$Education,$Passportnm,$AadharNu,$Referred,$Country,$State,$city,$Tahsil,$locality,$bloc,$Street,$pincode,$nameofinc,$Policynm,$Dailyact,$adNone,$Alcohol,$Smoking,$Tobacco,$fmNone,$fmDiabetes,$fmThyroid,$fmHeart,$fmHypertension,$fmDepression,$fmAnemia,$fmThalassemia,$fmHIV,$None,$Diabetes,$Diabetesst,$Thyroid,$Thyroidst,$PCOD,$PCODst,$Cholesterol,$Cholesterolst,$PhysicalInjury,$PhysicalInjuryst,$HeartCondition,$HeartConditionst,$Depression,$Depressionst,$Physicallychallenged,$Physicallychallengedst,$Mentallychallenged,$Mentallychallengedst,$TerminallyIll,$TerminallyIllst,$Dependency,$Modn,$Level,$entered_by)
{
	echo "called Patient";
$userno=PatientManager::registerUser($numbers,$patientname,$numbers,"Patient","$password","Active","12345");

	echo "<br>Userno=$userno<br>";
	$link=DBManager::connect();
	$user_otp = rand(100000, 999999);
	$user_activation_code = md5(rand());
	    $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$familyid=$harilal;
	$sql="INSERT INTO patient(srno,patientid,familyid,pic,fr,patientname,gendor,HusbandName,Email,numbers,dob,Weight,Height,bloodgroup,Nationality,Marital,Religion,Occupation,Familyinc,Education, Passportnm,AadharNu,Referred,Country,State,city,Tahsil,locality,bloc,Street,pincode,nameofinc,Policynm, Dailyact,adNone,Alcohol,Smoking,Tobacco,fmNone,fmDiabetes,fmThyroid,fmHeart,fmHypertension,fmDepression, fmAnemia,fmThalassemia,fmHIV,None,Diabetes,Diabetesst,Thyroid,Thyroidst,PCOD,PCODst,Cholesterol, Cholesterolst,PhysicalInjury,PhysicalInjuryst,HeartCondition,HeartConditionst,Depression,Depressionst,Physicallychallenged,Physicallychallengedst,Mentallychallenged,Mentallychallengedst,TerminallyIll,TerminallyIllst,Dependency,Modn,Level,pin,user_otp,numbers_status,user_activation_code,entered_by, created_at,updated_at) VALUES (NULL, '$userno','$familyid','$pic','$fr','$patientname','$gendor','$HusbandName','$Email','$numbers','$dob','$Weight','$Height','$bloodgroup','$Nationality','$Marital','$Religion','$Occupation','$Familyinc','$Education','$Passportnm','$AadharNu','$Referred','$Country','$State','$city','$Tahsil','$locality','$bloc','$Street','$pincode','$nameofinc','$Policynm','$Dailyact','$adNone','$Alcohol','$Smoking','$Tobacco','$fmNone','$fmDiabetes','$fmThyroid','$fmHeart','$fmHypertension','$fmDepression','$fmAnemia','$fmThalassemia','$fmHIV','$None','$Diabetes','$Diabetesst','$Thyroid','$Thyroidst','$PCOD','$PCODst','$Cholesterol','$Cholesterolst','$PhysicalInjury','$PhysicalInjuryst','$HeartCondition','$HeartConditionst','$Depression','$Depressionst','$Physicallychallenged','$Physicallychallengedst','$Mentallychallenged','$Mentallychallengedst','$TerminallyIll','$TerminallyIllst','$Dependency','$Modn','$Level','$pin','$user_otp','Not Verified','$user_activation_code','$entered_by',now(),now())";
$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Member Add successfully');</script><script>window.location='signin.php'</script>;</script>";

else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END PATIENT AFTER ADD FAMILY ID//

//Star New Patient testing//
//ADD PATIENT IF ADDED FAMILY//
public static function registernaw($familyid,$headnumber,$pic,$fr,$patientname,$gendor,$HusbandName,$Email,$numbers,$dob,$Weight,$Height,$bloodgroup,$Nationality,$Marital,$Religion,$Occupation,$Familyinc,$Education,$Passportnm,$AadharNu,$Referred,$Country,$State,$city,$pincode,$bloc,$nameofinc,$Policynm,$entered_by)
{
	   $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	$patientuser = rand(1000, 9999);
$userno=PatientManager::registerUser("Patient$patientuser",$patientname,$numbers,"Patient",$password,"Active","$entered_by");
	$link=DBManager::connect();
	$user_otp = rand(100000, 999999);
	$user_activation_code = md5(rand());
   $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$familyid=$harilal;
	$sql="INSERT INTO patient(srno,patientid,familyid,headnumber,pic,fr,patientname,gendor,HusbandName,Email,numbers,dob,Weight,Height,bloodgroup,Nationality,Marital,Religion,Occupation,Familyinc,Education, Passportnm,AadharNu,Referred,Country,State,city,pincode,bloc,nameofinc,Policynm,user_otp,numbers_status,user_activation_code,entered_by, created_at,updated_at) VALUES (NULL, '$userno','$familyid','$headnumber','$pic','$fr','$patientname','$gendor','$HusbandName','$Email','$numbers','$dob','$Weight','$Height','$bloodgroup','$Nationality','$Marital','$Religion','$Occupation','$Familyinc','$Education','$Passportnm','$AadharNu','$Referred','$Country','$State','$city','$pincode','$bloc','$nameofinc','$Policynm','$user_otp','Not Verified','$user_activation_code','$entered_by',now(),now())";
$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Member Add successfully');</script><script>window.location='medication2.php?patientid=$userno'</script>;</script>";

else 
	echo "Fail";
	$link=DBManager::close($link);
}



//End New Patient testing//
//Start Patient testing 2//

//ADD PATIENT IF ADDED FAMILY//
public static function registerfamilya2($familyid,$patientid,$Country,$State,$city,$pincode,$bloc,$nameofinc,$Policynm,$entered_by)
{
	$link=DBManager::connect();
	    $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$familyid=$harilal;
	$sql="INSERT INTO patient2(srno,familyid,patientid,Country,State,city,pincode,bloc,nameofinc,Policynm,entered_by, created_at,updated_at) VALUES (NULL, '$familyid','$patientid','$Country','$State','$city','$pincode','$bloc','$nameofinc','$Policynm','$entered_by',now(),now())";
$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Personal Details Add successfully');</script><script>window.location='signin.php'</script>;</script>";

else 
	echo "Fail";
	$link=DBManager::close($link);
}
//END Patient Testing 2//



//ADD PATIENT IF ADDED FAMILY//
public static function ObstetricHistory($prescriptionid,$patientid,$hs_years,$hs_of,$mode,$outcome,$incident,$Gender,$wt,$conducted,$complication,$entered_by)
{
	$link=DBManager::connect();
	    $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	$sql="INSERT INTO Obstetric_History(id,prescriptionid,patientid,hs_years,hs_of,mode,outcome,incident,Gender,wt,conducted,complication,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$hs_years','$hs_of','$mode','$outcome','$incident','$Gender','$wt','$conducted','$complication','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Obstetric History add successfully..');</script><script>window.location='RequestforAdmissionset.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//
public static function admissionpatient($prescriptionid,$patientid,$pagetype,$typepage,$Ward,$Bed,$Type_of_Admission,$Reason_for_Admission,$MLC,$MLC_No,$Upload_MLC_Slip,$Trauma,$further,$Pneumo_Haemothorax,$Fluids_Started,$iv_fluids_started,$Full_Survey,$Perineum,$Back,$Pelvic_Fracture,$Internal_Bleeding,$Ultrasound,$CT,$Peritoneal,$Spinal_Immobilization,$Neurovascular_Status,$Hypothermic,$contraindication,$Nasogastric_Tube,$Chest_Drain,$None_Indicated,$leaves_patient,$Analgesics,$Antibiotics,$None_Indicated2,$tests_imaging,$Examinations,$Abdominal,$vascular,$care_discussed,$Receiving_Unit,$Primary_team,$Other_Specialists,$Trauma_Chart,$Trauma_Slip,$Safe_childbirth_checklist,$mother_need_referral,$Partograph_started,$start_Antibiotics,$antihypertensive_treatment,$vaginal_exam,$present_at_birth,$labour_needed,$Information_Obtained_from,$General_Consent_Signed,$Upload_Consent,$ID_Band_tied,$Rights_Responsibilities,$surroundings_safety,$Insulin_dependent,$Insulin_specify,$Last_menstrual_period,$Gravida,$Para,$Abortion,$Cesarean,$Child_alive,$Death,$Level_Consciousness,$Eye_Opening_Response,$Best_Verbal_Response,$Best_Motor_Response,$Dependency,$Modn,$Vulnevilty_Assessment,$Wt,$SPo2,$RBS,$Temp,$Pulse,$BP,$BP2,$Pain_Assessment,$Pain_Location,$fall_risk,$Addiction,$Alcohol,$Smoking,$Tobacco,$Chief_Complain,$Covid,$Fever,$smell,$Diarrhoea,$Deformity,$Cough,$Taste,$Weakness,$Breathlessness,$Appetite,$Limbs,$Throat,$Vomitting,$Slurred_Voice,$Nausea,$Loss_Appetite,$Delusion,$Fits_Anger,$Depression,$Memory_Loss,$Bleeding_Disorder,$Migraine,$Frequent_Urination,$Swollen_Join,$Weight_Gain,$weight_loss,$Body_pain,$Physical_Injury,$Other_Symptoms,$RED_EYE,$Swollen_Eye,$Conjunctiva,$Itchiness,$Dislocated,$Blur_Vision,$Partial_Blindness,$Blindness,$Admitted_Under,$Attending_Nurse,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	PatientManager::setActivityLog($patientid,"$prescriptionid","$pagetype","showrequestforadmission.php?prescriptionid=$prescriptionid&patientid=$patientid","$entered_by");
			PatientManager::vilalslog("$prescriptionid","$patientid","$Wt","$bmi","$BP","$BP2","$Temp","$RBS","$SPo2","unknown","$Pulse","$pagetype","$entered_by");
	$sql="INSERT INTO request_for_admission(id,prescriptionid,patientid,pagetype,typepage,Ward,Bed,Type_of_Admission,Reason_for_Admission,MLC,MLC_No,Upload_MLC_Slip,Trauma,further,Pneumo_Haemothorax,Fluids_Started,iv_fluids_started,Full_Survey,Perineum,Back,Pelvic_Fracture,Internal_Bleeding,Ultrasound,CT,Peritoneal,Spinal_Immobilization,Neurovascular_Status,Hypothermic,contraindication,Nasogastric_Tube,Chest_Drain,None_Indicated,leaves_patient,Analgesics,Antibiotics,None_Indicated2,tests_imaging,Examinations,Abdominal,vascular,care_discussed,Receiving_Unit,Primary_team,Other_Specialists,Trauma_Chart,Trauma_Slip,Safe_childbirth_checklist,mother_need_referral,Partograph_started,start_Antibiotics,antihypertensive_treatment,vaginal_exam,present_at_birth,labour_needed,Information_Obtained_from,General_Consent_Signed,Upload_Consent,ID_Band_tied,Rights_Responsibilities,surroundings_safety,Insulin_dependent,Insulin_specify,Last_menstrual_period,Gravida,Para,Abortion,Cesarean,Child_alive,Death,Level_Consciousness,Eye_Opening_Response,Best_Verbal_Response,Best_Motor_Response,Dependency,Modn,Vulnevilty_Assessment,Wt,SPo2,RBS,Temp,Pulse,BP,BP2,Pain_Assessment,Pain_Location,fall_risk,Addiction,Alcohol,Smoking,Tobacco,Chief_Complain,covid,Fever,smell,Diarrhoea,Deformity,Cough,Taste,Weakness,Breathlessness,Appetite,Limbs,Throat,Vomitting,Slurred_Voice,Nausea,Loss_Appetite,Delusion,Fits_Anger,Depression,Memory_Loss,Bleeding_Disorder,Migraine,Frequent_Urination,Swollen_Join,Weight_Gain,weight_loss,Body_pain,Physical_Injury,Other_Symptoms,RED_EYE,Swollen_Eye,Conjunctiva,Itchiness,Dislocated,Blur_Vision,Partial_Blindness,Blindness,Admitted_Under,Attending_Nurse,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$pagetype','$typepage','$Ward','$Bed','$Type_of_Admission','$Reason_for_Admission','$MLC','$MLC_No','$Upload_MLC_Slip','$Trauma','$further','$Pneumo_Haemothorax','$Fluids_Started','$iv_fluids_started','$Full_Survey','$Perineum','$Back','$Pelvic_Fracture','$Internal_Bleeding','$Ultrasound','$CT','$Peritoneal','$Spinal_Immobilization','$Neurovascular_Status','$Hypothermic','$contraindication','$Nasogastric_Tube','$Chest_Drain','$None_Indicated','$leaves_patient','$Analgesics','$Antibiotics','$None_Indicated2','$tests_imaging','$Examinations','$Abdominal','$vascular','$care_discussed','$Receiving_Unit','$Primary_team','$Other_Specialists','$Trauma_Chart','$Trauma_Slip','$Safe_childbirth_checklist','$mother_need_referral','$Partograph_started','$start_Antibiotics','$antihypertensive_treatment','$vaginal_exam','$present_at_birth','$labour_needed','$Information_Obtained_from','$General_Consent_Signed','$Upload_Consent','$ID_Band_tied','$Rights_Responsibilities','$surroundings_safety','$Insulin_dependent','$Insulin_specify','$Last_menstrual_period','$Gravida','$Para','$Abortion','$Cesarean','$Child_alive','$Death','$Level_Consciousness','$Eye_Opening_Response','$Best_Verbal_Response','$Best_Motor_Response','$Dependency','$Modn','$Vulnevilty_Assessment','$Wt','$SPo2','$RBS','$Temp','$Pulse','$BP','$BP2','$Pain_Assessment','$Pain_Location','$fall_risk','$Addiction','$Alcohol','$Smoking','$Tobacco','$Chief_Complain','$covid','$Fever','$smell','$Diarrhoea','$Deformity','$Cough','$Taste','$Weakness','$Breathlessness','$Appetite','$Limbs','$Throat','$Vomitting','$Slurred_Voice','$Nausea','$Loss_Appetite','$Delusion','$Fits_Anger','$Depression','$Memory_Loss','$Bleeding_Disorder','$Migraine','$Frequent_Urination','$Swollen_Join','$Weight_Gain','$weight_loss','$Body_pain','$Physical_Injury','$Other_Symptoms','$RED_EYE','$Swollen_Eye','$Conjunctiva','$Itchiness','$Dislocated','$Blur_Vision','$Partial_Blindness','$Blindness','$Admitted_Under','$Attending_Nurse','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('$pagetype add successfully..');</script><script>window.location='treatment_timline.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//End Patient  In Pregancy admission//



//Start Covid Chekclist //

public static function covidchecklist($prescriptionid,$patientid,$symptoms_fever,$difficulty_breathing,$country_days,$other_cities,$two_weeks,$health_facility,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	$updated_at=date("Y/m/d");
   $created_at=date("F d, Y / h:i:s A");
	$sql="INSERT INTO CovidChecklist(id,prescriptionid,patientid,symptoms_fever,difficulty_breathing,country_days,other_cities,two_weeks,health_facility,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$symptoms_fever','$difficulty_breathing','$country_days','$other_cities','$two_weeks','$health_facility','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
{
	$insid= mysqli_insert_id($link);
			$docid= $insid;
	PatientManager::setActivityLog($patientid,"$prescriptionid","Intial Assessment<br>Covid 19 Checklist","showpage_CovidChecklist.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
echo "<script>alert('Covid 19 Checklist add successfully..');</script><script>window.location='RequestforAdmissionset.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
}
else 
{
	echo "Fail";
	$link=DBManager::close($link);
}
}


//END COVID CHECKLIST//

// Start Patient Refferal//


public static function patientreferral($prescriptionid,$patientid,$hs_referral,$location,$Phone,$Email,$Accompanied,$Primary_Diagnosis,$Treatments_initiated,$Types_Patient,$Transportation_needs,$Follow_up_requirements,$Mobility,$Self_care,$Cognitive_impairment,$Assistive_devices_provide,$Assistive_required,$Nurse_Name,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
$updated_at=date("Y/m/d");
   $created_at=date("F d, Y / h:i:s A");
	$sql="INSERT INTO patient_referral(id,prescriptionid,patientid,hs_referral,location,Phone,Email,Accompanied,Primary_Diagnosis,Treatments_initiated,Types_Patient,Transportation_needs,Follow_up_requirements,Mobility,Self_care,Cognitive_impairment,Assistive_devices_provide,Assistive_required,Nurse_Name,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$hs_referral','$location','$Phone','$Email','$Accompanied','$Primary_Diagnosis','$Treatments_initiated','$Types_Patient','$Transportation_needs','$Follow_up_requirements','$Mobility','$Self_care','$Cognitive_impairment','$Assistive_devices_provide','$Assistive_required','$Nurse_Name','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
{
	$insid= mysqli_insert_id($link);
			$docid= $insid;
	PatientManager::setActivityLog($patientid,"$prescriptionid","Patient Referral","showpage_patient_referral.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
echo "<script>alert('Patient Referral add successfully..');</script><script>window.location='patient_referral.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
}
else 
{
	echo "Fail";
	$link=DBManager::close($link);
}
}




//End Patient Refferal//




//START WARD//



//Start Covid Chekclist //

public static function addward($ward_department,$ward_name,$ward_type,$adminid)
{

	$link=DBManager::connect();
	
	$sql="INSERT INTO ward(wardid,ward_department,ward_name,ward_type,adminid) VALUES (NULL,'$ward_department','$ward_name','$ward_type','$adminid')";
	$result=mysqli_query($link,$sql);
if($result)
{
  
	$insid= mysqli_insert_id($link);
			$docid= $insid;
		  PatientManager::updateaddbedward("$docid","1","P","Active","$prescriptionid");
echo "<script>alert('Ward add successfully..');</script><script>window.location='addbedindex.php?wardid=$docid'</script>;</script>";
}
else 
{
	echo "Fail";
	$link=DBManager::close($link);
}
}



//END WARD//



//start bed//

public static function addbedwardinsert($wardid,$bedname,$price,$status,	$prescriptionid)
{

	$link=DBManager::connect();
	
	$sql="INSERT INTO bedindex(bedid,wardid,bedname,price,status,prescriptionid) VALUES (NULL,'$wardid','$bedname','$price','$status','$prescriptionid')";
	$result=mysqli_query($link,$sql);
if($result)
{
}
else 
{

	$link=DBManager::close($link);
}
}


//end bed//





// NEW TRY//

public static function updateaddbedward($wardid,$bedname,$price,$status,$prescriptionid)
{

	$link=DBManager::connect();
	
	$sql="INSERT INTO bedindex(bedid,wardid,bedname,price,status,prescriptionid) VALUES (NULL,'$wardid','$bedname','$price','$status','$prescriptionid')";
	$result=mysqli_query($link,$sql);
if($result)
{
}
else 
{
	echo "Fail";
	$link=DBManager::close($link);
}
}


//NEW TRY//


public static function updatebedindex($wardid,$bedname,$price,$status,$prescriptionid)
{

	$link=DBManager::connect();
	$sql ="UPDATE bedindex SET status='Inactive',prescriptionid='$prescriptionid'  WHERE  bedid='$_POST[Bed]'";
	$result=mysqli_query($link,$sql);
if($result)
{
}
else 
{
	echo "Fail";
	$link=DBManager::close($link);
}
}




//Start Patient Information //


//start bed index //



public static function updatebedindexdext($wardid,$bedname,$price,$status,$prescriptionid)
{

	$link=DBManager::connect();
	$sql ="UPDATE bedindex SET status='Active',prescriptionid='' WHERE  prescriptionid='$prescriptionid'";
	$result=mysqli_query($link,$sql);
if($result)
{
}
else 
{
	echo "Fail";
	$link=DBManager::close($link);
}
}

//end bed index//

public static function PatientInformation($prescriptionid,$patientid,$Diagnosis,$Investigation,$Duration_hospital,$Estimatedexpenses,$Possible_outcome,$Invited_patient,$Explained_importance,$Discussed_essential,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Counselor Sheet<br>Patient Information","showpage_PatientInformation.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	$sql="INSERT INTO PatientInformation(id,prescriptionid,patientid,Diagnosis,Investigation,Duration_hospital,Estimatedexpenses,Possible_outcome,Invited_patient,Explained_importance,Discussed_essential,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Diagnosis','$Investigation','$Duration_hospital','$Estimatedexpenses','$Possible_outcome','$Invited_patient','$Explained_importance','$Discussed_essential','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Patient Information add successfully..');</script><script>window.location='CounselorSheet.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//End Patient Information //



//Start Decision making //

public static function Decisionmaking($prescriptionid,$patientid,$Presented_all,$Discussed_risks,$Asked_patient,$patient_teach,$Patient_demonstrated,$Encouraged_patient,$Listened_actively,$decision_might,$Acknowledged,$preferred,$additional,$consult,$Treating_Doctor,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Counselor Sheet<br>Decision Making","showpage_Decision_making.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	$sql="INSERT INTO Decision_making(id,prescriptionid,patientid,Presented_all,Discussed_risks,Asked_patient,patient_teach,Patient_demonstrated,Encouraged_patient,Listened_actively,decision_might,Acknowledged,preferred,additional,consult,Treating_Doctor,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Presented_all','$Discussed_risks','$Asked_patient','$patient_teach','$Patient_demonstrated','$Encouraged_patient','$Listened_actively','$decision_might','$Acknowledged','$preferred','$additional','$consult','$Treating_Doctor','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Patient Information add successfully..');</script><script>window.location='CounselorSheet.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//End Patient Information //


//Start Decision making //

public static function Evaluatepatient($prescriptionid,$patientid,$Hospital_plans,$implementing_decision,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
PatientManager::setActivityLog($patientid,"$prescriptionid","Counselor Sheet<br>Evaluate Patient","showpage_Evaluate_patient.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	$sql="INSERT INTO Evaluate_patient(id,prescriptionid,patientid,Hospital_plans,implementing_decision,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Hospital_plans','$implementing_decision','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Evaluate Patient add successfully..');</script><script>window.location='CounselorSheet.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//End Patient Information //



public static function SharedDecisionAid($prescriptionid,$patientid,$Investigation,$Pros,$Cons,$entered_by)
{
    	$link=DBManager::connect();
    		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
    	include("dbconnection.php");

$DisplayForm=True;
$sql1 ="SELECT * FROM SharedDecision WHERE prescriptionid='$_GET[prescriptionid]'";
		$qsql1 = mysqli_query($con,$sql1);
		while($rh1 = mysqli_fetch_array($qsql1))
		{
	$DisplayForm=False;
echo "";
}
if($DisplayForm)
{
PatientManager::setActivityLog($patientid,"$prescriptionid","Counselor Sheet<br>Shared Decision Aid","showpage_SharedDecisionAid.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
} else{
  
}


	
 $sql="INSERT INTO SharedDecision(id,prescriptionid,patientid,Investigation,Pros,Cons,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Investigation','$Pros','$Cons','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)

echo "<script>alert('Shared Decision add successfully..');</script><script>window.location='CounselorSheet.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";

else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END COVID CHECKLIST//


public static function GeneralConsent($prescriptionid,$patientid,$towords,$Upload_Consent,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	PatientManager::setActivityLog($patientid,"$prescriptionid","Intial Assessment<br>GENERAL CONSENT","showpage_GeneralConsentSigned.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	$sql="INSERT INTO GeneralConsent(id,prescriptionid,patientid,towords,Upload_Consent,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$towords','$Upload_Consent','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('General Consent Signed Upload  successfully..');</script><script>window.location='RequestforAdmissionset.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END GENERAL CONSENT SIGNUD//


//Start Anesthesia CONSENT SIGNUD//
public static function Anesthesiapavam($prescriptionid,$patientid,$surgeryid,$Patient_not_accepted,$Patient_accepted,$Anesthesia_procedure,$Upload_Consent,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	PatientManager::setActivityLog($patientid,"$prescriptionid","Pre-Assessment Sheet<br>Anesthesia Consent","showpage_Anesthesia_Consent.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid&srno=","$entered_by");
	$sql="INSERT INTO AnesthesiaConsent(id,prescriptionid,patientid,surgeryid,Patient_not_accepted,Patient_accepted,Anesthesia_procedure,Upload_Consent,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$surgeryid','$Patient_not_accepted','$Patient_accepted','$Anesthesia_procedure','$Upload_Consent','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Anesthesia Consent  Upload  successfully..');</script><script>window.location='PreOperativeAssessmentSheet.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END Anesthesia CONSENT SIGNUD//



//Start Anesthesia Note//
public static function Anesthesianote($prescriptionid,$patientid,$surgeryid,$Name_Anesthetist,$Name_of_Surgeon,$member_1,$member_2,$Proposed_Surgery,$Duration,$Duration_time,$Pre_Operative_Diagnosis,$Anesthesia_Type,$Procedure_Executed,$Procedure_performed,$Surgeon_Note,$Anesthetic_Note,$Patient_Status,$Expected_Outcome,$Record_time_Death,$Revesalr,$Post_Op_advice,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	PatientManager::setActivityLog($patientid,"$prescriptionid","Pre-Assessment Sheet<br>Anesthesia Note","showpage_Anesthesia_note.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid&srno=","$entered_by");
	$sql="INSERT INTO Anesthesia_note(id,prescriptionid,patientid,surgeryid,Name_Anesthetist,Name_of_Surgeon,member_1,member_2,Proposed_Surgery,Duration,Duration_time,Pre_Operative_Diagnosis,Anesthesia_Type,Procedure_Executed,Procedure_performed,Surgeon_Note,Anesthetic_Note,Patient_Status,Expected_Outcome,Record_time_Death,Revesalr,Post_Op_advice,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$surgeryid','$Name_Anesthetist','$Name_of_Surgeon','$member_1','$member_2','$Proposed_Surgery','$Duration','$Duration_time','$Pre_Operative_Diagnosis','$Anesthesia_Type','$Procedure_Executed','$Procedure_performed','$Surgeon_Note','$Anesthetic_Note','$Patient_Status','$Expected_Outcome','$Record_time_Death','$Revesalr','$Post_Op_advice','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Anesthesia Note Add  successfully..');</script><script>window.location='Anesthesia_Note.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END Anesthesia Note //


//Patient Request for Admission//

public static function RequestConsultation($prescriptionid,$patientid,$pagetype,$typepage,$Ward,$Bed,$Type_of_Admission,$Reason_for_Admission,$MLC,$MLC_No,$Upload_MLC_Slip,$Trauma,$further,$Pneumo_Haemothorax,$Fluids_Started,$iv_fluids_started,$Full_Survey,$Perineum,$Back,$Pelvic_Fracture,$Internal_Bleeding,$Ultrasound,$CT,$Peritoneal,$Spinal_Immobilization,$Neurovascular_Status,$Hypothermic,$contraindication,$Nasogastric_Tube,$Chest_Drain,$None_Indicated,$leaves_patient,$Analgesics,$Antibiotics,$None_Indicated2,$tests_imaging,$Examinations,$Abdominal,$vascular,$care_discussed,$Receiving_Unit,$Primary_team,$Other_Specialists,$Trauma_Chart,$Trauma_Slip,$Code_Blue,$Subjective,$First_Responder,$Establishes_unresponsiveness,$Drills_code,$Lower_Bed,$Universal_Precautions,$initiate_compressions,$Airway_Assess,$Carotid_femoral,$Breathing_Bag,$Airway_placement,$Second_Responder,$Crash_cart,$Sick_board,$Applies_multifunction,$Monitor_PROMPTS,$Proceed_defibrillation,$ACLS_qualified,$Interprets_rhythm,$Third_Responder_BLS,$suction_equipment,$intubation_tray,$Establishes_Access,$Contain_patient,$med_tray,$Fourth_fifth_responders,$Verbalizes_Method,$Communicates_Family,$Complete_CodeBlue,$Secure_codestatement,$cov,$symptoms_fever,$difficulty_breathing,$country_days,$other_cities,$two_weeks,$health_facility,$Safe_childbirth_checklist,$mother_need_referral,$Partograph_started,$start_Antibiotics,$antihypertensive_treatment,$vaginal_exam,$present_at_birth,$labour_needed,$Information_Obtained_from,$General_Consent_Signed,$Upload_Consent,$referred_by,$ID_Band_tied,$Rights_Responsibilities,$surroundings_safety,$entered_by)
{

	$link=DBManager::connect();
		include("dbconnection.php");
   $narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='5' AND hospitalid='$re[entered_by]' AND wardid='$Ward' OR wardid!='$Ward'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
	$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	PatientManager::tatLog("$patientid","$prescriptionid","$casetype","opd_Consultation","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_visit_fee]","discount","grand_total","","","","$Admitted_Under"); 
	PatientManager::setActivityLog($patientid,"$prescriptionid","Intial Assessment<br>Request for Consultation","showpage_Request_for_Consultation.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	 if(is_numeric($Bed))
	 {
	 PatientManager::billingLog("$patientid","$prescriptionid","Admission_fees","$casetype","admissioninvoice.php?prescriptionid=$prescriptionid&patientid=$patientid","$rs112[rate]","discount","grand_total","paymentmode","status","$entered_by");
	 PatientManager::updatebedindex("$wardid","$bedname","$price","$status","$prescriptionid");
	 }
	 if(is_numeric($Bed))
	 {
	 PatientManager::transferbedpatient("$prescriptionid","$Bed","$datetime");
	 }
}
}
	$sql="INSERT INTO request_for_admission(id,prescriptionid,patientid,pagetype,typepage,Ward,Bed,Type_of_Admission,Reason_for_Admission,MLC,MLC_No,Upload_MLC_Slip,Trauma,further,Pneumo_Haemothorax,Fluids_Started,iv_fluids_started,Full_Survey,Perineum,Back,Pelvic_Fracture,Internal_Bleeding,Ultrasound,CT,Peritoneal,Spinal_Immobilization,Neurovascular_Status,Hypothermic,contraindication,Nasogastric_Tube,Chest_Drain,None_Indicated,leaves_patient,Analgesics,Antibiotics,None_Indicated2,tests_imaging,Examinations,Abdominal,vascular,care_discussed,Receiving_Unit,Primary_team,Other_Specialists,Trauma_Chart,Trauma_Slip,Code_Blue,Subjective,First_Responder,Establishes_unresponsiveness,Drills_code,Lower_Bed,Universal_Precautions,initiate_compressions,Airway_Assess,Carotid_femoral,Breathing_Bag,Airway_placement,Second_Responder,Crash_cart,Sick_board,Applies_multifunction,Monitor_PROMPTS,Proceed_defibrillation,ACLS_qualified,Interprets_rhythm,Third_Responder_BLS,suction_equipment,intubation_tray,Establishes_Access,Contain_patient,med_tray,Fourth_fifth_responders,Verbalizes_Method,Communicates_Family,Complete_CodeBlue,Secure_codestatement,cov,symptoms_fever,difficulty_breathing,country_days,other_cities,two_weeks,health_facility,Safe_childbirth_checklist,mother_need_referral,Partograph_started,start_Antibiotics,antihypertensive_treatment,vaginal_exam,present_at_birth,labour_needed,Information_Obtained_from,General_Consent_Signed,Upload_Consent,referred_by,ID_Band_tied,Rights_Responsibilities,surroundings_safety,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$pagetype','$typepage','$Ward','$Bed','$Type_of_Admission','$Reason_for_Admission','$MLC','$MLC_No','$Upload_MLC_Slip','$Trauma','$further','$Pneumo_Haemothorax','$Fluids_Started','$iv_fluids_started','$Full_Survey','$Perineum','$Back','$Pelvic_Fracture','$Internal_Bleeding','$Ultrasound','$CT','$Peritoneal','$Spinal_Immobilization','$Neurovascular_Status','$Hypothermic','$contraindication','$Nasogastric_Tube','$Chest_Drain','$None_Indicated','$leaves_patient','$Analgesics','$Antibiotics','$None_Indicated2','$tests_imaging','$Examinations','$Abdominal','$vascular','$care_discussed','$Receiving_Unit','$Primary_team','$Other_Specialists','$Trauma_Chart','$Trauma_Slip','$Code_Blue','$Subjective','$First_Responder','$Establishes_unresponsiveness','$Drills_code','$Lower_Bed','$Universal_Precautions','$initiate_compressions','$Airway_Assess','$Carotid_femoral','$Breathing_Bag','$Airway_placement','$Second_Responder','$Crash_cart','$Sick_board','$Applies_multifunction','$Monitor_PROMPTS','$Proceed_defibrillation','$ACLS_qualified','$Interprets_rhythm','$Third_Responder_BLS','$suction_equipment','$intubation_tray','$Establishes_Access','$Contain_patient','$med_tray','$Fourth_fifth_responders','$Verbalizes_Method','$Communicates_Family','$Complete_CodeBlue','$Secure_codestatement','$cov','$symptoms_fever','$difficulty_breathing','$country_days','$other_cities','$two_weeks','$health_facility','$Safe_childbirth_checklist','$mother_need_referral','$Partograph_started','$start_Antibiotics','$antihypertensive_treatment','$vaginal_exam','$present_at_birth','$labour_needed','$Information_Obtained_from','$General_Consent_Signed','$Upload_Consent','$referred_by','$ID_Band_tied','$Rights_Responsibilities','$surroundings_safety','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Request for Consultation add successfully..');</script><script>window.location='RequestforAdmissionset.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


// Start Code Blue //


public static function Requestcodeblue($prescriptionid,$patientid,$status,$adminid,$Subjective,$First_Responder,$Establishes_unresponsiveness,$Drills_code,$Lower_Bed,$Universal_Precautions,$initiate_compressions,$Airway_Assess,$Carotid_femoral,$Breathing_Bag,$Airway_placement,$Second_Responder,$Crash_cart,$Sick_board,$Applies_multifunction,$Monitor_PROMPTS,$Proceed_defibrillation,$ACLS_qualified,$Interprets_rhythm,$Third_Responder_BLS,$suction_equipment,$intubation_tray,$Establishes_Access,$Contain_patient,$med_tray,$Fourth_fifth_responders,$Verbalizes_Method,$Communicates_Family,$Complete_CodeBlue,$Secure_codestatement,$entered_by)
{

	$link=DBManager::connect();

		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("Y/m/d");
	PatientManager::setActivityLog($patientid,"$prescriptionid","Code Blue","showpage_showpage_codeblue.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	$sql="INSERT INTO code_blue(id,prescriptionid,patientid,status,adminid,Subjective,First_Responder,Establishes_unresponsiveness,Drills_code,Lower_Bed,Universal_Precautions,initiate_compressions,Airway_Assess,Carotid_femoral,Breathing_Bag,Airway_placement,Second_Responder,Crash_cart,Sick_board,Applies_multifunction,Monitor_PROMPTS,Proceed_defibrillation,ACLS_qualified,Interprets_rhythm,Third_Responder_BLS,suction_equipment,intubation_tray,Establishes_Access,Contain_patient,med_tray,Fourth_fifth_responders,Verbalizes_Method,Communicates_Family,Complete_CodeBlue,Secure_codestatement,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$status','$adminid','$Subjective','$First_Responder','$Establishes_unresponsiveness','$Drills_code','$Lower_Bed','$Universal_Precautions','$initiate_compressions','$Airway_Assess','$Carotid_femoral','$Breathing_Bag','$Airway_placement','$Second_Responder','$Crash_cart','$Sick_board','$Applies_multifunction','$Monitor_PROMPTS','$Proceed_defibrillation','$ACLS_qualified','$Interprets_rhythm','$Third_Responder_BLS','$suction_equipment','$intubation_tray','$Establishes_Access','$Contain_patient','$med_tray','$Fourth_fifth_responders','$Verbalizes_Method','$Communicates_Family','$Complete_CodeBlue','$Secure_codestatement','$entered_by',now(),'$updated_at')";
	$result=mysqli_query($link,$sql);
		$insid= mysqli_insert_id($link);
			$id= $insid;
if($result)
echo "<script>alert('Code Blue add successfully..');</script><script>window.location='codeblue.php?prescriptionid=$prescriptionid&patientid=$patientid&id=" . $insid . "'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//End Code blue//



//Star mlc//
public static function Requestmlc($prescriptionid,$patientid,$MLC_No,$Upload_MLC_Slip,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	PatientManager::setActivityLog($patientid,"$prescriptionid","Intial Assessment<br>MLC Checklist","showpage_mlc.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	$sql="INSERT INTO mlc(id,prescriptionid,patientid,MLC_No,Upload_MLC_Slip,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$MLC_No','$Upload_MLC_Slip','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('MLC Records add successfully..');</script><script>window.location='RequestforAdmissionset.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//end Mlc//



// START Trauma//

public static function Requesttraumachecklist($prescriptionid,$patientid,$further,$Pneumo_Haemothorax,$Fluids_Started,$iv_fluids_started,$Full_Survey,$Perineum,$Back,$Pelvic_Fracture,$Internal_Bleeding,$Ultrasound,$CT,$Peritoneal,$Spinal_Immobilization,$Neurovascular_Status,$Hypothermic,$contraindication,$Nasogastric_Tube,$Chest_Drain,$None_Indicated,$leaves_patient,$Analgesics,$Antibiotics,$None_Indicated2,$tests_imaging,$Examinations,$Abdominal,$vascular,$care_discussed,$Receiving_Unit,$Primary_team,$Other_Specialists,$Trauma_Chart,$Trauma_Slip,$entered_by)
{

	$link=DBManager::connect();
			$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	PatientManager::setActivityLog($patientid,"$prescriptionid","Intial Assessment<br>Trauma Checklist","showpage_traumachecklist.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	$sql="INSERT INTO trauma_checklist(id,prescriptionid,patientid,further,Pneumo_Haemothorax,Fluids_Started,iv_fluids_started,Full_Survey,Perineum,Back,Pelvic_Fracture,Internal_Bleeding,Ultrasound,CT,Peritoneal,Spinal_Immobilization,Neurovascular_Status,Hypothermic,contraindication,Nasogastric_Tube,Chest_Drain,None_Indicated,leaves_patient,Analgesics,Antibiotics,None_Indicated2,tests_imaging,Examinations,Abdominal,vascular,care_discussed,Receiving_Unit,Primary_team,Other_Specialists,Trauma_Chart,Trauma_Slip,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$further','$Pneumo_Haemothorax','$Fluids_Started','$iv_fluids_started','$Full_Survey','$Perineum','$Back','$Pelvic_Fracture','$Internal_Bleeding','$Ultrasound','$CT','$Peritoneal','$Spinal_Immobilization','$Neurovascular_Status','$Hypothermic','$contraindication','$Nasogastric_Tube','$Chest_Drain','$None_Indicated','$leaves_patient','$Analgesics','$Antibiotics','$None_Indicated2','$tests_imaging','$Examinations','$Abdominal','$vascular','$care_discussed','$Receiving_Unit','$Primary_team','$Other_Specialists','$Trauma_Chart','$Trauma_Slip','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Trauma Checklist add successfully..');</script><script>window.location='RequestforAdmissionset.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}





//END TRAUMA//



//START NUTRITION SCREEENIG//

public static function NutritionalScreening($prescriptionid,$patientid,$weight_loss,$BMI,$patient_look,$last_2_weeks,$enteral_tube,$parenteral_tube,$Pattern_Followed,$Appetite,$entered_by)
{

	$link=DBManager::connect();
			$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	PatientManager::setActivityLog($patientid,"$prescriptionid","Intial Assessment<br>Nutritional Screening","showpage_NutritionalScreening.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	$sql="INSERT INTO Nutritional_Screening(id,prescriptionid,patientid,weight_loss,BMI,patient_look,last_2_weeks,enteral_tube,parenteral_tube,Pattern_Followed,Appetite,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$weight_loss','$BMI','$patient_look','$last_2_weeks','$enteral_tube','$parenteral_tube','$Pattern_Followed','$Appetite','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Nutritional Screening add successfully..');</script><script>window.location='RequestforAdmissionset.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}






//END NUTRITION SCREENIG//



//Medical Surgical History START//

public static function Medicalsurgical($prescriptionid,$patientid,$Information_Obtained_from,$specify,$relation,$Addiction,$Alcohol,$Smoking,$Tobacco,$entered_by)
{

	$link=DBManager::connect();
			$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	PatientManager::setActivityLog($patientid,"$prescriptionid","Intial Assessment<br>Medical and surgical History","showpage_Medical_surgical_History.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	$sql="INSERT INTO Medical_surgical(id,prescriptionid,patientid,Information_Obtained_from,specify,relation,Addiction,Alcohol,Smoking,Tobacco,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Information_Obtained_from','$specify','$relation','$Addiction','$Alcohol','$Smoking','$Tobacco','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Medical and surgical History add successfully..');</script><script>window.location='RequestforAdmissionset.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


// start Brief History //



public static function BriefHistory($prescriptionid,$patientid,$surgeryid,$Family_History,$entered_by)
{

	$link=DBManager::connect();
			$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	PatientManager::setActivityLog($patientid,"$prescriptionid","Pre-Assessment Sheet<br>Brief History","showpage_Brief_History_Patient.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid&srno=","$entered_by");
	$sql="INSERT INTO Brief_History_Patient(Briefid,prescriptionid,patientid,	surgeryid,Family_History,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$surgeryid','$Family_History','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Brief History add successfully..');</script><script>window.location='PreOperativeAssessmentSheet.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END BRIEF HISTORY//




//Medical Surgical History END//
//Vulnerability_Assessment Start//
public static function Vulnerability($prescriptionid,$patientid,$Insulin_dependent,$Insulin_specify,$Last_menstrual_period,$Gravida,$Para,$Abortion,$Cesarean,$Child_alive,$Death,$Level_Consciousness,$Eye_Opening_Response,$Best_Verbal_Response,$Best_Motor_Response,$Dependency,$Modn,$Vulnevilty_Assessment,$Pain_Assessment,$Pain_Location,$Pain_Location1,$Pain_Location2,$Pain_Location3,$Pain_Location4,$Pain_Location5,$other_pain_location,$fall_risk,$low_fall_risk,$high_fall_risk,$implement_low,$Complete_paralysis,$History_more,$Patient_experienced,$deemed_high,$entered_by)
{

	$link=DBManager::connect();
			$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	PatientManager::setActivityLog($patientid,"$prescriptionid","Intial Assessment<br>Vulnerability Assessment","showpage_Vulnerability_Assessment.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	$sql="INSERT INTO Vulnerability(id,prescriptionid,patientid,Insulin_dependent,Insulin_specify,Last_menstrual_period,Gravida,Para,Abortion,Cesarean,Child_alive,Death,Level_Consciousness,Eye_Opening_Response,Best_Verbal_Response,Best_Motor_Response,Dependency,Modn,Vulnevilty_Assessment,Pain_Assessment,Pain_Location,Pain_Location1,Pain_Location2,Pain_Location3,Pain_Location4,Pain_Location5,other_pain_location,fall_risk,low_fall_risk,high_fall_risk,implement_low,Complete_paralysis,History_more,Patient_experienced,deemed_high,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Insulin_dependent','$Insulin_specify','$Last_menstrual_period','$Gravida','$Para','$Abortion','$Cesarean','$Child_alive','$Death','$Level_Consciousness','$Eye_Opening_Response','$Best_Verbal_Response','$Best_Motor_Response','$Dependency','$Modn','$Vulnevilty_Assessment','$Pain_Assessment','$Pain_Location','$Pain_Location1','$Pain_Location2','$Pain_Location3','$Pain_Location4','$Pain_Location5','$other_pain_location','$fall_risk','$low_fall_risk','$high_fall_risk','$implement_low','$Complete_paralysis','$History_more','$Patient_experienced','$deemed_high','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Vulnerability Assessment add successfully..');</script><script>window.location='RequestforAdmissionset.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//Vulnerability_Assessment END//



//Medical Assistment START//



public static function MedicalAssessment($prescriptionid,$patientid,$Chief_Complain,$Covid,$Fever,$Fever_note,$smell,$smell_note,$Diarrhoea,$Diarrhoea_note,$Deformity,$Deformity_note,$Cough,$Cough_note,$Taste,$Taste_note,$Weakness,$Weakness_note,$Breathlessness,$Breathlessness_note,$Appetite,$Appetite_note,$Limbs,$Limbs_note,$Throat,$Throat_note,$Vomitting,$Vomitting_note,$Slurred_Voice,$Slurred_Voice_note,$Nausea,$Nausea_note,$Loss_Appetite,$Loss_Appetite_note,$Delusion,$Delusion_note,$Fits_Anger,$Fits_Anger_note,$Depression,$Depression_note,$Memory_Loss,$Memory_Loss_note,$Bleeding_Disorder,$Bleeding_Disorder_note,$Migraine,$Migraine_note,$Frequent_Urination,$Frequent_Urination_note,$Swollen_Join,$Swollen_Join_note,$Weight_Gain,$Weight_Gain_note,$weight_loss,$weight_loss_note,$Body_pain,$Body_pain_note,$Physical_Injury,$Physical_Injury_note,$Other_Symptoms,$Other_Symptoms_note,$RED_EYE,$RED_EYE_note,$Swollen_Eye,$Swollen_Eye_note,$Conjunctiva,$Conjunctiva_note,$Itchiness,$Itchiness_note,$Dislocated,$Dislocated_note,$Blur_Vision,$Blur_Vision_note,$Partial_Blindness,$Partial_Blindness_note,$Blindness,$Blindness_note,$entered_by)
{
	echo "";
	$link=DBManager::connect();
			$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	PatientManager::setActivityLog($patientid,"$prescriptionid","Intial Assessment<br>Medical Assessment","showpage_Medical_Assessment.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
		
	$sql="INSERT INTO Medical_Assessment(id,prescriptionid,patientid,Chief_Complain,covid,Fever,Fever_note,smell,smell_note,Diarrhoea,Diarrhoea_note,Deformity,Deformity_note,Cough,Cough_note,Taste,Taste_note,Weakness,Weakness_note,Breathlessness,Breathlessness_note,Appetite,Appetite_note,Limbs,Limbs_note,Throat,Throat_note,Vomitting,Vomitting_note,Slurred_Voice,Slurred_Voice_note,Nausea,Nausea_note,Loss_Appetite,Loss_Appetite_note,Delusion,Delusion_note,Fits_Anger,Fits_Anger_note,Depression,Depression_note,Memory_Loss,Memory_Loss_note,Bleeding_Disorder,Bleeding_Disorder_note,Migraine,Migraine_note,Frequent_Urination,Frequent_Urination_note,Swollen_Join,Swollen_Join_note,Weight_Gain,Weight_Gain_note,weight_loss,weight_loss_note,Body_pain,Body_pain_note,Physical_Injury,Physical_Injury_note,Other_Symptoms,Other_Symptoms_note,RED_EYE,RED_EYE_note,Swollen_Eye,Swollen_Eye_note,Conjunctiva,Conjunctiva_note,Itchiness,Itchiness_note,Dislocated,Dislocated_note,Blur_Vision,Blur_Vision_note,Partial_Blindness,Partial_Blindness_note,Blindness,Blindness_note,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Chief_Complain','$covid','$Fever','$Fever_note','$smell','$smell_note','$Diarrhoea','$Diarrhoea_note','$Deformity','$Deformity_note','$Cough','$Cough_note','$Taste','$Taste_note','$Weakness','$Weakness_note','$Breathlessness','$Breathlessness_note','$Appetite','$Appetite_note','$Limbs','$Limbs_note','$Throat','$Throat_note','$Vomitting','$Vomitting_note','$Slurred_Voice','$Slurred_Voice_note','$Nausea','$Nausea_note','$Loss_Appetite','$Loss_Appetite_note','$Delusion','$Delusion_note','$Fits_Anger','$Fits_Anger_note','$Depression','$Depression_note','$Memory_Loss','$Memory_Loss_note','$Bleeding_Disorder','$Bleeding_Disorder_note','$Migraine','$Migraine_note','$Frequent_Urination','$Frequent_Urination_note','$Swollen_Join','$Swollen_Join_note','$Weight_Gain','$Weight_Gain_note','$weight_loss','$weight_loss_note','$Body_pain','$Body_pain_note','$Physical_Injury','$Physical_Injury_note','$Other_Symptoms','$Other_Symptoms_note','$RED_EYE','$RED_EYE_note','$Swollen_Eye','$Swollen_Eye_note','$Conjunctiva','$Conjunctiva_note','$Itchiness','$Itchiness_note','$Dislocated','$Dislocated_note','$Blur_Vision','$Blur_Vision_note','$Partial_Blindness','$Partial_Blindness_note','$Blindness','$Blindness_note','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Medical Assessment add successfully..');</script><script>window.location='RequestforAdmissionset.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//ON EXAMANATION//






// Medical Assesment//

public static function Medicalvitals($prescriptionid,$patientid,$Bmi,$Wt,$SPo2,$RBS,$Temp,$Pulse,$BP,$BP2,$stopid,$entered_by)
{
	echo "";
	$link=DBManager::connect();
			$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	PatientManager::setActivityLog($patientid,"$prescriptionid","Intial Assessment<br>Vitals","showpage_vitals.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
			PatientManager::vilalslog("$prescriptionid","$patientid","$Wt","$Bmi","$BP","$BP2","$Temp","$RBS","$SPo2","unknown","$Pulse","Medical Assessment","$entered_by");
				PatientManager::updatetatLogvitals("$patientid","$prescriptionid","Consultant_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_visit_fee]","grand_total","q","w","ee","$Admitted_Under",""); 
	$sql="INSERT INTO Medical_vitals(id,prescriptionid,patientid,Bmi,Wt,SPo2,RBS,Temp,Pulse,BP,BP2,stopid,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Bmi','$Wt','$SPo2','$RBS','$Temp','$Pulse','$BP','$BP2','$stopid','$entered_by','$created_at','$updated_at')";
	$sql1 ="UPDATE patient SET Weight='$Wt' WHERE patientid='$patientid'";
$result=mysqli_query($link,$sql1);
	$result=mysqli_query($link,$sql);
	
if($result)

echo "<script>alert('Vitals add successfully..');</script><script>window.location='RequestforAdmissionset.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//MEDICAL ASSESMENT//


public static function examnaton($prescriptionid,$patientid,$On_Examination,$Right_eye,$right_nct,$right_DCLY,$right_at,$right_BASE_LINE_IOP,$right_CCT,$right_UCVA,$right_DSPH,$right_Axis,$right_PGVA,$right_PHVA,$right_Vision,$right_Without_Glasses,$right_Vision_lens,$right_CSL,$right_Retinoscopy,$right_Squint,$right_fundus,$right_Top_con,$right_Auto_ref,$right_Specular,$right_A_Scan,$right_B_Scan,$right_Adnexa,$right_Ant_Segment,$right_Pachy,$right_Pupil,$right_Gonioscop,$Left_eye,$left_nct,$left_at,$left_BASE_LINE_IOP,$left_CCT,$left_UCVA,$left_DSPH,$left_DCLY,$left_Axis,$left_PGVA,$left_PHVA,$left_Vision,$left_Without_Glasses,$left_Vision_lens,$left_CSL,$left_Retinoscopy,$left_Squint,$left_fundus,$left_Top_con,$left_Auto_ref,$left_Specular,$left_A_Scan,$left_B_Scan,$left_Adnexa,$left_Ant_Segment,$left_Pachy,$left_Pupil,$left_Gonioscop,$entered_by)
{
	echo "";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","On Examination","showrequestforadmission.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	$sql="INSERT INTO Examination(id,prescriptionid,patientid,On_Examination,Right_eye,right_nct,right_DCLY,right_at,right_BASE_LINE_IOP,right_CCT,right_UCVA,right_DSPH,right_Axis,right_PGVA,right_PHVA,right_Vision,right_Without_Glasses,right_Vision_lens,right_CSL,right_Retinoscopy,right_Squint,right_fundus,right_Top_con,right_Auto_ref,right_Specular,right_A_Scan,right_B_Scan,right_Adnexa,right_Ant_Segment,right_Pachy,right_Pupil,right_Gonioscop,Left_eye,left_nct,left_at,left_BASE_LINE_IOP,left_CCT,left_UCVA,left_DSPH,left_DCLY,left_Axis,left_PGVA,left_PHVA,left_Vision,left_Without_Glasses,left_Vision_lens,left_CSL,left_Retinoscopy,left_Squint,left_fundus,left_Top_con,left_Auto_ref,left_Specular,left_A_Scan,left_B_Scan,left_Adnexa,left_Ant_Segment,left_Pachy,left_Pupil,left_Gonioscop,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$On_Examination','$Right_eye','$right_nct','$right_DCLY','$right_at','$right_BASE_LINE_IOP','$right_CCT','$right_UCVA','$right_DSPH','$right_Axis','$right_PGVA','$right_PHVA','$right_Vision','$right_Without_Glasses','$right_Vision_lens','$right_CSL','$right_Retinoscopy','$right_Squint','$right_fundus','$right_Top_con','$right_Auto_ref','$right_Specular','$right_A_Scan','$right_B_Scan','$right_Adnexa','$right_Ant_Segment','$right_Pachy','$right_Pupil','$right_Gonioscop','$Left_eye','$left_nct','$left_at','$left_BASE_LINE_IOP','$left_CCT','$left_UCVA','$left_DSPH','$left_DCLY','$left_Axis','$left_PGVA','$left_PHVA','$left_Vision','$left_Without_Glasses','$left_Vision_lens','$left_CSL','$left_Retinoscopy','$left_Squint','$left_fundus','$left_Top_con','$left_Auto_ref','$left_Specular','$left_A_Scan','$left_B_Scan','$left_Adnexa','$left_Ant_Segment','$left_Pachy','$left_Pupil','$left_Gonioscop','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('$pagetype add successfully..');</script><script>window.location='treatment_timline.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//End Patient  In Pregancy admission//


//END EXAMANATION//



//S
//Start IPD Requiest For Admission//
public static function admissionpatientipd($prescriptionid,$patientid,$Ward,$Bed,$Type_of_Admission,$Reason_for_Admission,$MLC,$MLC_No,$Upload_MLC_Slip,$Trauma,$further,$Pneumo_Haemothorax,$Fluids_Started,$iv_fluids_started,$Full_Survey,$Perineum,$Back,$Pelvic_Fracture,$Internal_Bleeding,$Ultrasound,$Spinal_Immobilization,$Neurovascular_Status,$Hypothermic,$contraindication,$Nasogastric_Tube,$Chest_Drain,$None_Indicated,$leaves_patient,$Analgesics,$Antibiotics,$None_Indicated2,$tests_imaging,$Examinations,$care_discussed,$Receiving_Unit,$Primary_team,$Other_Specialists,$Trauma_Chart,$Trauma_Slip,$Information_Obtained_from,$General_Consent_Signed,$Upload_Consent,$ID_Band_tied,$Rights_Responsibilities,$surroundings_safety,$Level_Consciousness,$Dependency,$Modn,$Vulnevilty_Assessment,$Wt,$SPo2,$RBS,$Temp,$Pulse,$BP,$BP2,$Pain_Assessment,$Pain_Location,$fall_risk,$Addiction,$Alcohol,$Smoking,$Tobacco,$Chief_Complain,$Covid,$Fever,$smell,$Diarrhoea,$Deformity,$Cough,$Taste,$Weakness,$Breathlessness,$Appetite,$Limbs,$Throat,$Vomitting,$Slurred_Voice,$Admitted_Under,$entered_by)
{
	echo "";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		PatientManager::setActivityLog($patientid,"$prescriptionid","Request for admissions","showrequestforadmissionipd.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
			PatientManager::vilalslog("$prescriptionid","$patientid","$Wt","$bmi","$BP","$BP2","$Temp","$RBS","$SPo2","unknown","$Pulse","request_for_admission","$entered_by");
	$sql="INSERT INTO request_for_admission_ipd(id,prescriptionid,patientid,Ward,Bed,Type_of_Admission,Reason_for_Admission,MLC,MLC_No,Upload_MLC_Slip,Trauma,further,Pneumo_Haemothorax,Fluids_Started,iv_fluids_started,Full_Survey,Perineum,Back,Pelvic_Fracture,Internal_Bleeding,Ultrasound,Spinal_Immobilization,Neurovascular_Status,Hypothermic,contraindication,Nasogastric_Tube,Chest_Drain,None_Indicated,leaves_patient,Analgesics,Antibiotics,None_Indicated2,tests_imaging,Examinations,care_discussed,Receiving_Unit,Primary_team,Other_Specialists,Trauma_Chart,Trauma_Slip,Information_Obtained_from,General_Consent_Signed,Upload_Consent,ID_Band_tied,Rights_Responsibilities,surroundings_safety,Level_Consciousness,Dependency,Modn,Vulnevilty_Assessment,Wt,SPo2,RBS,Temp,Pulse,BP,BP2,Pain_Assessment,Pain_Location,fall_risk,Addiction,Alcohol,Smoking,Tobacco,Chief_Complain,covid,Fever,smell,Diarrhoea,Deformity,Cough,Taste,Weakness,Breathlessness,Appetite,Limbs,Throat,Vomitting,Slurred_Voice,Admitted_Under,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Ward','$Bed','$Type_of_Admission','$Reason_for_Admission','$MLC','$MLC_No','$Upload_MLC_Slip','$Trauma','$further','$Pneumo_Haemothorax','$Fluids_Started','$iv_fluids_started','$Full_Survey','$Perineum','$Back','$Pelvic_Fracture','$Internal_Bleeding','$Ultrasound','$Spinal_Immobilization','$Neurovascular_Status','$Hypothermic','$contraindication','$Nasogastric_Tube','$Chest_Drain','$None_Indicated','$leaves_patient','$Analgesics','$Antibiotics','$None_Indicated2','$tests_imaging','$Examinations','$care_discussed','$Receiving_Unit','$Primary_team','$Other_Specialists','$Trauma_Chart','$Trauma_Slip','$Information_Obtained_from','$General_Consent_Signed','$Upload_Consent','$ID_Band_tied','$Rights_Responsibilities','$surroundings_safety','$Level_Consciousness','$Dependency','$Modn','$Vulnevilty_Assessment','$Wt','$SPo2','$RBS','$Temp','$Pulse','$BP','$BP2','$Pain_Assessment','$Pain_Location','$fall_risk','$Addiction','$Alcohol','$Smoking','$Tobacco','$Chief_Complain','$covid','$Fever','$smell','$Diarrhoea','$Deformity','$Cough','$Taste','$Weakness','$Breathlessness','$Appetite','$Limbs','$Throat','$Vomitting','$Slurred_Voice','$Admitted_Under','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Initial Assessment add successfully..');</script><script>window.location='treatment_timline.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//End IPD Admission//
//Start investigation//


public static function nwinvestigation($prescriptionid,$patientid,$Investigation,$Result,$Evidence,$entered_by)
{
	echo "";
	$link=DBManager::connect();

$sql="INSERT INTO investigation(id,prescriptionid,patientid,Investigation,Result,Evidence,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid', '$patientid','$Investigation','$Result','$Evidence','$entered_by',now(),now())";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Initial Assessment -ROI","showinvestigation.php?id=$id","$entered_by");
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('$Investigation add successfully..');</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//End Investigation//

//Start investigation//


public static function drinvestigation($prescriptionid,$patientid,$Investigation,$Result,$Evidence,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	PatientManager::setActivityLog($patientid,"$prescriptionid","Doctor Note-ROI","showinvestigation.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO investigation(id,prescriptionid,patientid,Investigation,Result,Evidence,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid', '$patientid','$Investigation','$Result','$Evidence','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('$Investigation add successfully..');</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
// Start investigation Update Status//
public static function updatenayainvestigation($prescriptionid,$patientid,$Raised_at,$Investigation_type,$Category,$Sub_Category,$Priority_slip,$Investigation,$ivid,$Result,$Evidence,$entered_by)
{
	$link=DBManager::connect();
$sql ="UPDATE investigation SET Result='$_POST[Container_Number]' WHERE id='$_POST[Container_Number]'";
$result=mysqli_query($link,$sql);
if($result)
echo "";
else 
	echo "";
	$link=DBManager::close($link);
}

//END investigation update Status//



// Start investigation Update Status//
public static function updatenayainvestigationreport($prescriptionid,$patientid,$Raised_at,$Investigation_type,$Category,$Sub_Category,$Priority_slip,$Investigation,$ivid,$Result,$Evidence,$entered_by)
{
	$link=DBManager::connect();
$sql ="UPDATE investigation SET Result='Done' WHERE prescriptionid='$_GET[prescriptionid]' AND patientid='$_GET[patientid]' AND id='$_POST[requesttestid]'";
$result=mysqli_query($link,$sql);
if($result)
echo "";
else 
	echo "";
	$link=DBManager::close($link);
}

//END investigation update Status//

//End Investigation//


//Start new Investigation//
public static function nayainvestigation($prescriptionid,$patientid,$hospital_id,$Raised_at,$Investigation_type,$Category,$Sub_Category,$Priority_slip,$Investigation,$ivid,$Result,$Evidence,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	include("dbconnection.php");
$sql1 ="SELECT * FROM create_inhouse WHERE ivid='$ivid' AND hospitalid='$hospital_id' OR ivid='$Investigation' AND hospitalid='$hospital_id'";
		$qsql1 = mysqli_query($con,$sql1);
		if($rh1 = mysqli_fetch_array($qsql1))
		    	$pricetotal=$rh1[rate];
		    	$ivname=$rh1[ivid];
		    		PatientManager::billingLog("$patientid","$prescriptionid","Investigation_charge","$ivid$Investigation","patient_invtitation_invace.php?prescriptionid=$prescriptionid&patientid=$patientid","$pricetotal","","","$paymentmode","$status","$entered_by");
		    	
$DisplayForm=True;
$sql1 ="SELECT * FROM investigation WHERE prescriptionid='$_GET[prescriptionid]'";
		$qsql1 = mysqli_query($con,$sql1);
		while($rh1 = mysqli_fetch_array($qsql1))
		{
	$DisplayForm=False;
echo "";
}
if($DisplayForm)
{
PatientManager::setActivityLog($patientid,"$prescriptionid","Opd Slip<br>Request for investigation","showpage_investigation.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
} else{
  
}
$sql="INSERT INTO investigation(id,prescriptionid,patientid,hospital_id,Raised_at,Investigation_type,Category,Sub_Category,Priority_slip,Investigation,ivid,Result,Evidence,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid', '$patientid','$hospital_id','$Raised_at','$Investigation_type','$Category','$Sub_Category','$Priority_slip','$Investigation','$ivid','$Result','$Evidence','$entered_by',now(),now())";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$sql ="select last_insert_id() from investigation";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
	$result=mysqli_query($link,$sql);
		
if($result)
echo "<script>alert('$Investigation add successfully..');</script><script>window.location='testopdslip2.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}




// START Investigation IPD//


//STAR Investigation DR NOTE IPD//

public static function nayainvestigationdr($prescriptionid,$patientid,$hospital_id,$Raised_at,$Investigation_type,$Category,$Sub_Category,$Priority_slip,$Investigation,$ivid,$Result,$Evidence,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	$admissiondate=date("Y/m/d");
	include("dbconnection.php");
$sql1 ="SELECT * FROM create_inhouse WHERE ivid='$ivid' OR ivid='$Investigation'";
		$qsql1 = mysqli_query($con,$sql1);
		if($rh1 = mysqli_fetch_array($qsql1))
		    	$pricetotal=$rh1[rate];
		    	$ivname=$rh1[ivid];
		    		PatientManager::billingLog("$patientid","$prescriptionid","Investigation_charge","$ivid$Investigation","patient_invtitation_invace.php?prescriptionid=$prescriptionid&patientid=$patientid","$pricetotal","","","$paymentmode","$status","$entered_by");
		    	
$DisplayForm=True;
$sql1 ="SELECT * FROM investigation WHERE prescriptionid='$_GET[prescriptionid]'";
		$qsql1 = mysqli_query($con,$sql1);
		while($rh1 = mysqli_fetch_array($qsql1))
		{
	$DisplayForm=False;
echo "";
}
if($DisplayForm)
{
PatientManager::setActivityLog($patientid,"$prescriptionid","Doctor Note<br>Request for investigation","showpage_investigation.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
} else{
  
}
$sql="INSERT INTO investigation(id,prescriptionid,patientid,hospital_id,Raised_at,Investigation_type,Category,Sub_Category,Priority_slip,Investigation,ivid,Result,Evidence,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid', '$patientid','$hospital_id','$Raised_at','$Investigation_type','$Category','$Sub_Category','$Priority_slip','$Investigation','$ivid','$Result','$Evidence','$entered_by',now(),'$admissiondate')";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$sql ="select last_insert_id() from investigation";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
	$result=mysqli_query($link,$sql);
		
if($result)
echo "<script>alert('$Investigation add successfully..');</script><script>window.location='drnoteinvestigation.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//END DR NOTE Investigation IPD//

public static function nayainvestigationIPD($prescriptionid,$patientid,$hospital_id,$Raised_at,$Investigation_type,$Category,$Sub_Category,$Priority_slip,$Investigation,$ivid,$Result,$Evidence,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	include("dbconnection.php");
$sql1 ="SELECT * FROM create_inhouse WHERE ivid='$ivid' OR ivid='$Investigation'";
		$qsql1 = mysqli_query($con,$sql1);
		if($rh1 = mysqli_fetch_array($qsql1))
		    	$pricetotal=$rh1[rate];
		    	$ivname=$rh1[ivid];
		    		PatientManager::billingLog("$patientid","$prescriptionid","Investigation_charge","$ivid$Investigation","patient_invtitation_invace.php?prescriptionid=$prescriptionid&patientid=$patientid","$pricetotal","","","$paymentmode","$status","$entered_by");
		    	
$DisplayForm=True;
$sql1 ="SELECT * FROM investigation WHERE prescriptionid='$_GET[prescriptionid]'";
		$qsql1 = mysqli_query($con,$sql1);
		while($rh1 = mysqli_fetch_array($qsql1))
		{
	$DisplayForm=False;
echo "";
}
if($DisplayForm)
{
PatientManager::setActivityLog($patientid,"$prescriptionid","Initial Assessment<br>Request for investigation","showpage_investigation.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
} else{
  
}
$sql="INSERT INTO investigation(id,prescriptionid,patientid,hospital_id,Raised_at,Investigation_type,Category,Sub_Category,Priority_slip,Investigation,ivid,Result,Evidence,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid', '$patientid','$hospital_id','$Raised_at','$Investigation_type','$Category','$Sub_Category','$Priority_slip','$Investigation','$ivid','$Result','$Evidence','$entered_by',now(),now())";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$sql ="select last_insert_id() from investigation";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
	$result=mysqli_query($link,$sql);
		
if($result)
echo "<script>alert('$Investigation add successfully..');</script><script>window.location='Requestforinvestigationipd.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//END INVESTIGATION IPD//



//End New Investigation//

// START SAMPLE COLLECTION//
public static function CollectSample($ivid,$prescriptionid,$patientid,$patientname,$Investigation_des,$Specimen_type,$Specimen_type1,$Specimen_type2,$Specimen_type3,$Container_Number,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	PatientManager::updatenayainvestigation($prescriptionid,$patientid,$hospital_id,$Raised_at,$Investigation_type,$Category,$Sub_Category,$Priority_slip,$Investigation,$ivid,"$Container_Number",$Evidence,$entered_by);
$sql="INSERT INTO Collect_Sample(Collectid,ivid,prescriptionid,patientid,patientname,Investigation_des,Specimen_type,Specimen_type1,Specimen_type2,Specimen_type3,Container_Number,entered_by,created_at) VALUES (NULL,'$ivid','$prescriptionid','$patientid','$patientname','$Investigation_des','$Specimen_type','$Specimen_type1','$Specimen_type2','$Specimen_type3','$Container_Number','$entered_by',now())";

	$result=mysqli_query($link,$sql);
	
if($result)

echo "<script>alert('Sample Collect successfully..');</script><script> window.history.go(-2)</script>;</script>";

else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END SAMPLE COLLECTION//


// START REPORT//
public static function REPORTGenerated($prescriptionid,$patientid,$requesttestid,$Impression,$Study_Reveals,$Interpretation,$marks_critical,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	PatientManager::updatenayainvestigationreport($prescriptionid,$patientid,$hospital_id,$Raised_at,$Investigation_type,$Category,$Sub_Category,$Priority_slip,$Investigation,$ivid,"$requesttestid",$Evidence,$entered_by);
$sql="INSERT INTO labreports(labreportid,prescriptionid,patientid,requesttestid,Impression,Study_Reveals,Interpretation,marks_critical,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$requesttestid','$Impression','$Study_Reveals','$Interpretation','$marks_critical','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('REPORT Generated successfully..');</script><script> window.history.go(-2)</script>;</script>";

else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END REPORT//


//START REDIOLOGY REPORT//
public static function Radioreports($rivid,$prescriptionid,$patientid,$Study_Reveals,$Impression,$Suggested,$entered_by)
{
	echo "";
	$link=DBManager::connect();

$sql="INSERT INTO radioreport(radioid,rivid,prescriptionid,patientid,Study_Reveals,Impression,Suggested,entered_by,created_at) VALUES (NULL,'$rivid','$prescriptionid','$patientid','$Study_Reveals','$Impression','$Suggested','$entered_by',now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Report Create  successfully..');</script><script> window.history.go(-1)</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END RADIOLOGY REPORT//


//START PATHOLOGY REPORT//
public static function labreports($Collectid,$ivid,$prescriptionid,$patientid,$Test_Description,$Result,$Units,$True_Value,$entered_by)
{
	echo "";
	$link=DBManager::connect();

$sql="INSERT INTO labreports(labreportid,Collectid,ivid,prescriptionid,patientid,Test_Description,Result,Units,True_Value,entered_by,created_at) VALUES (NULL,'$Collectid','$ivid','$prescriptionid','$patientid','$Test_Description','$Result','$Units','$True_Value','$entered_by',now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Pathlogy Report Create  successfully..');</script><script> window.history.go(-1)</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END PATHLOGY REPORT//



//START NEW TEST DESCRIPTION//


public static function testdesciption($ivid,$methodid,$parametersid,$Test_Description,$Unit,$gender,$same_to_all,$all_min,$all_max,$mNewborn_min,$mNewborn_max,$mChild_min,$mChild_max,$mAdult_min,$mAdult_max,$mSenior_Citizen_min,$mSenior_Citizen_max,$mold_min,$mold_max,$fNewborn_min,$fNewborn_max,$fChild_min,$fChild_max,$fAdult_min,$fAdult_max,$fSenior_Citizen_min,$fSenior_Citizen_max,$fold_min,$fold_max,$entered_by)
{
	echo "";
	$link=DBManager::connect();

$sql="INSERT INTO Test_Description_final(testdesid,ivid,methodid,parametersid,Test_Description,Unit,gender,same_to_all,all_min,all_max,mNewborn_min,mNewborn_max,mChild_min,mChild_max,mAdult_min,mAdult_max,mSenior_Citizen_min,mSenior_Citizen_max,mold_min,mold_max,fNewborn_min,fNewborn_max,fChild_min,fChild_max,fAdult_min,fAdult_max,fSenior_Citizen_min,fSenior_Citizen_max,fold_min,fold_max,entered_by,created_at) VALUES (NULL,'$ivid','$methodid','$parametersid','$Test_Description','$Unit','$gender','$same_to_all','$all_min','$all_max','$mNewborn_min','$mNewborn_max','$mChild_min','$mChild_max','$mAdult_min','$mAdult_max','$mSenior_Citizen_min','$mSenior_Citizen_max','$mold_min','$mold_max','$fNewborn_min','$fNewborn_max','$fChild_min','$fChild_max','$fAdult_min','$fAdult_max','$fSenior_Citizen_min','$fSenior_Citizen_max','$fold_min','$fold_max','$entered_by',now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Test Description Create  successfully..');</script><script> window.history.go(-1)</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//END TEST DESCRIPTION//





//Start list of invitation//

public static function listinvestigation($Investigation,$labdepartmentid,$radiobodypartid,$adminid)
{
	echo "";
	$link=DBManager::connect();

$sql="INSERT INTO list_Investigation(ivid,Investigation,labdepartmentid	,radiobodypartid,adminid) VALUES (NULL,'$Investigation','$labdepartmentid','$radiobodypartid','$adminid')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Investigation Create  successfully..');</script><script> window.history.go(-1)</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END START OF INVITATION//


//Start list of invitation//

public static function listtreatment($tratment,$labdepartmentid)
{
	echo "";
	$link=DBManager::connect();

$sql="INSERT INTO list_tretment(trid,tratment,labdepartmentid) VALUES (NULL,'$tratment','$labdepartmentid')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Treatment Create  successfully..');</script><script> window.history.go(-1)</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END START OF INVITATION//


//Start Dressing//
public static function Dressinglarge($prescriptionid,$patientid,$done,$entered_by)
{
	echo "";
	include("dbconnection.php");
		$narayan=LoginManager::currentUser();
		$link=DBManager::connect();
$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
$sql="INSERT INTO Dressing(id,prescriptionid,patientid,done,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$done','$entered_by','$created_at','$updated_at')";
$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$prescriptionid' AND patientid='$patientid'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='13' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
    
	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from Dressing";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","Dressing Large","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Dressing add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//STOP Dressing//


//Start Dressing//
public static function Dressingmedium($prescriptionid,$patientid,$done,$entered_by)
{
	echo "";
	include("dbconnection.php");
		$narayan=LoginManager::currentUser();
		$link=DBManager::connect();
$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
$sql="INSERT INTO Dressing(id,prescriptionid,patientid,done,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$done','$entered_by','$created_at','$updated_at')";
$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$prescriptionid' AND patientid='$patientid'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='14' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
    
	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from Dressing";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","Dressing Medium","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}

	$result=mysqli_query($link,$sql);
		
if($result)
echo "<script>alert('Dressing add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//STOP Dressing//



//Start Dressing//
public static function Dressingsmall($prescriptionid,$patientid,$done,$entered_by)
{
	echo "";
	include("dbconnection.php");
		$narayan=LoginManager::currentUser();
		$link=DBManager::connect();
$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
$sql="INSERT INTO Dressing(id,prescriptionid,patientid,done,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$done','$entered_by','$created_at','$updated_at')";
$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$prescriptionid' AND patientid='$patientid'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='15' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
    
	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from Dressing";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","Dressing Small","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}

	$result=mysqli_query($link,$sql);
		
if($result)
echo "<script>alert('Dressing add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//STOP Dressing//

//Start Dressing//
public static function medimgnt($prescriptionid,$patientid,$medicine_id,$DRUGS,$timeslot,$admissiondate,$status,$entered_by)
{
	echo "";
		$narayan=LoginManager::currentUser();
		$link=DBManager::connect();
$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	$admissiondate=date("Y/m/d");
	PatientManager::setActivityLog($patientid,"$prescriptionid","Request for investigation","showinvestigation.php?prescriptionid=$prescriptionid&patientid=$patientid","$entered_by");
$sql="INSERT INTO medication_mng(id,prescriptionid,patientid,medicine_id,DRUGS,timeslot,admissiondate,status,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$medicine_id','$DRUGS','$timeslot','$admissiondate','$status','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('$status successfully..');</script>;<script>window.location='testmedifinal.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//STOP Dressing//





// START NEBULIZER//
public static function Nebulization($prescriptionid,$patientid,$Nebulization_done,$entered_by)
{
	echo "";
	include("dbconnection.php");
		$narayan=LoginManager::currentUser();
		$link=DBManager::connect();
$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		PatientManager::setActivityLog($patientid,"$prescriptionid","Record sheet<br>Nebulization","showNebulization.php?prescriptionid=$prescriptionid&patientid=$patientid","$entered_by");
$sql="INSERT INTO Nebulization(id,prescriptionid,patientid,Nebulization_done,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Nebulization_done','$entered_by',now(),now())";

$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$prescriptionid' AND patientid='$patientid'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='26' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
    
	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from Nebulization";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","Nebulization","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Nebulization add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//STOP Dressing//
//END NEBULIZER//




// START NEBULIZER//
public static function ivpcentralline($prescriptionid,$patientid,$Nebulization_done,$entered_by)
{
	echo "";
	include("dbconnection.php");
		$narayan=LoginManager::currentUser();
		$link=DBManager::connect();
$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	$sql="INSERT INTO ivpcentralline(id,prescriptionid,patientid,ivp_done,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$ivp_done','$entered_by',now(),now())";

$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$prescriptionid' AND patientid='$patientid'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='41' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
    
	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from ivpcentralline";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","IVP","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('IVP Central Line add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//STOP Dressing//
//END NEBULIZER//


//START DELAY IN//

public static function DelayIn($prescriptionid,$patientid,$DelayIn,$DelayIn_Native,$DelayIn_Corrective,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
PatientManager::setActivityLog($patientid,"$prescriptionid","Incident Report<br>Delayin","showDietician.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO DelayIn(id,prescriptionid,patientid,DelayIn,DelayIn_Native,DelayIn_Corrective,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$DelayIn','$DelayIn_Native','$DelayIn_Corrective','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('DelayIn add successfully..');</script><script>window.location='incidentreport.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//STOP DELAY IN//


//START DELAY IN//

public static function frequency($type,$typeid,$frq,$route,$duration,$potential,$adminid,$drid,$surgeryid,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
$sql="INSERT INTO frequency(id,type,typeid,frq,route,duration,potential,adminid,drid,surgeryid,entered_by,created_at,updated_at) VALUES (NULL,'$type','$typeid','$frq','$route','$duration','$potential','$adminid','$drid','$surgeryid','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('frequency add successfully..');</script><script>window.location='frequency_add.php?drid=$drid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//STOP DELAY IN//

//START DELAY IN//

public static function frequencyiv($type,$typeid,$frq,$route,$duration,$potential,$adminid,$drid,$surgeryid,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
$sql="INSERT INTO frequency(id,type,typeid,frq,route,duration,potential,adminid,drid,surgeryid,entered_by,created_at,updated_at) VALUES (NULL,'$type','$typeid','$frq','$route','$duration','$potential','$adminid','$drid','$surgeryid','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('frequency add successfully..');</script><script>window.location='frequencyinvestigation_add.php?drid=$drid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//STOP DELAY IN//






//START DelayFrom //

public static function DelayFrom($prescriptionid,$patientid,$DelayFrom,$DelayFrom_Native,$DelayFrom_Corrective,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Incident Report<br>Delayfrom","showdelayFrom.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO DelayFrom(id,prescriptionid,patientid,DelayFrom,DelayFrom_Native,DelayFrom_Corrective,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$DelayFrom','$DelayFrom_Native','$DelayFrom_Corrective','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('DelayFrom add successfully..');</script><script>window.location='incidentreport.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//STOP Delay From//


//START REPORT ERROR//
public static function ReportingError($prescriptionid,$patientid,$ReportingError,$ReportingError_Native,$ReportingError_Corrective,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Incident Report<br>Reporting Error","show_Reporting_Error.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO ReportingError(id,prescriptionid,patientid,ReportingError,ReportingError_Native,ReportingError_Corrective,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$ReportingError','$ReportingError_Native','$ReportingError_Corrective','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Reporting Error add successfully..');</script><script>window.location='incidentreport.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END REPORT ERROR//


//START Administrative Related //
public static function AdministrativeRelated($prescriptionid,$patientid,$AdministrativeRelated,$AdministrativeRelated_Native,$AdministrativeRelated_Corrective,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Incident Report<br>Administrative Related","show_AdministrativeRelated.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO AdministrativeRelated(id,prescriptionid,patientid,AdministrativeRelated,AdministrativeRelated_Native,AdministrativeRelated_Corrective,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$AdministrativeRelated','$AdministrativeRelated_Native','$AdministrativeRelated_Corrective','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Administrative Related Error add successfully..');</script><script>window.location='incidentreport.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END Administrative Related //


//START CLINICAL//

public static function Clinicalcarerelated($prescriptionid,$patientid,$Clinicalcarerelated,$Clinicalcarerelated_Native,$Clinicalcarerelated_Corrective,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		PatientManager::setActivityLog($patientid,"$prescriptionid","Incident Report<br>Clinical care Related","show_Clinical_care_Related.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO Clinicalcarerelated(id,prescriptionid,patientid,Clinicalcarerelated,Clinicalcarerelated_Native,Clinicalcarerelated_Corrective,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Clinicalcarerelated','$Clinicalcarerelated_Native','$Clinicalcarerelated_Corrective','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Clinical Care Related Error add successfully..');</script><script>window.location='incidentreport.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//END CLINICAL//


//START CONSENT//
public static function Consentrelated($prescriptionid,$patientid,$Consentrelated,$Consentrelated_Native,$Consentrelated_Corrective,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Incident Report<br>Consent Related","show_Consent_Related.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO Consentrelated(id,prescriptionid,patientid,Consentrelated,Consentrelated_Native,Consentrelated_Corrective,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Consentrelated','$Consentrelated_Native','$Consentrelated_Corrective','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Consent Related add successfully..');</script><script>window.location='incidentreport.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//END CONSENT //


// START EQUIPMENT//
public static function Equipmentrelated($prescriptionid,$patientid,$Equipmentrelated,$Equipmentrelated_Native,$Equipmentrelated_Corrective,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Incident Report<br>Equipment Related","show_Equipment.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO Equipmentrelated(id,prescriptionid,patientid,Equipmentrelated,Equipmentrelated_Native,Equipmentrelated_Corrective,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Equipmentrelated','$Equipmentrelated_Native','$Equipmentrelated_Corrective','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Equipment Related add successfully..');</script><script>window.location='incidentreport.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END EQUIPMENT//

// START Medicationrelated//
public static function Medicationrelated($prescriptionid,$patientid,$Medicationrelated,$Medicationrelated_Native,$Medicationrelated_Corrective,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Incident Report<br>Medication Related","show_Medication_related.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO Medicationrelated(id,prescriptionid,patientid,Medicationrelated,Medicationrelated_Native,Medicationrelated_Corrective,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Medicationrelated','$Medicationrelated_Native','$Medicationrelated_Corrective','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Medication Related add successfully..');</script><script>window.location='incidentreport.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END Medicationrelated//

// START Medicationrelated//
public static function Needlesharpsinjury($prescriptionid,$patientid,$Needlesharpsinjury,$Needlesharpsinjury_Native,$Needlesharpsinjury_Corrective,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Incident Report<br>Needle stick for sharps injury","show_Needle_stick_injury.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO Needlesharpsinjury(id,prescriptionid,patientid,Needlesharpsinjury,Needlesharpsinjury_Native,Needlesharpsinjury_Corrective,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Needlesharpsinjury','$Needlesharpsinjury_Native','$Needlesharpsinjury_Corrective','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Needle stick for sharps injury add successfully..');</script><script>window.location='incidentreport.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END Medicationrelated//


// START Software_hardwarerelated//
public static function Software_hardwarerelated($prescriptionid,$patientid,$Software_hardwarerelated,$Software_hardwarerelated_Native,$Software_hardwarerelated_Corrective,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Incident Report<br>Software or hardware related","show_Software_hardware_related.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO Software_hardwarerelated(id,prescriptionid,patientid,Software_hardwarerelated,Software_hardwarerelated_Native,Software_hardwarerelated_Corrective,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Software_hardwarerelated','$Software_hardwarerelated_Native','$Software_hardwarerelated_Corrective','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Software or hardware related add successfully..');</script><script>window.location='incidentreport.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END Medicationrelated//

// START Laboratory specimen related//
public static function Laboratoryspecimenrelated($prescriptionid,$patientid,$Laboratoryspecimenrelated,$Laboratoryspecimenrelated_Native,$Laboratoryspecimenrelated_Corrective,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Incident Report<br>Laboratory specimen related","show_Laboratory_specimen_related.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO Laboratoryspecimenrelated(id,prescriptionid,patientid,Laboratoryspecimenrelated,Laboratoryspecimenrelated_Native,Laboratoryspecimenrelated_Corrective,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Laboratoryspecimenrelated','$Laboratoryspecimenrelated_Native','$Laboratoryspecimenrelated_Corrective','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Laboratory specimen related add successfully..');</script><script>window.location='incidentreport.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END Laboratory specimen related//

// START Surgery procedure related//
public static function Surgeryprocedurerelated($prescriptionid,$patientid,$Surgeryprocedurerelated,$Surgeryprocedurerelated_Native,$Surgeryprocedurerelated_Corrective,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Incident Report<br>Surgery Procedure Related","show_Surgery_Procedure_related.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO Surgeryprocedurerelated(id,prescriptionid,patientid,Surgeryprocedurerelated,Surgeryprocedurerelated_Native,Surgeryprocedurerelated_Corrective,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Surgeryprocedurerelated','$Surgeryprocedurerelated_Native','$Surgeryprocedurerelated_Corrective','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Surgery procedure related add successfully..');</script><script>window.location='incidentreport.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END Surgery procedure related//

// START Facility related//
public static function Facilityrelated($prescriptionid,$patientid,$Facilityrelated,$Facilityrelated_Native,$Facilityrelated_Corrective,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Incident Report<br>Facility Related","show_Surgery_Facility_related.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO Facilityrelated(id,prescriptionid,patientid,Facilityrelated,Facilityrelated_Native,Facilityrelated_Corrective,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Facilityrelated','$Facilityrelated_Native','$Facilityrelated_Corrective','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Facility related add successfully..');</script><script>window.location='incidentreport.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END Facility related//


// START Security related//
public static function Securityrelated($prescriptionid,$patientid,$Securityrelated,$Securityrelated_Native,$Securityrelated_Corrective,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Incident Report<br>Security Related","show_Security_related.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO Securityrelated(id,prescriptionid,patientid,Securityrelated,Securityrelated_Native,Securityrelated_Corrective,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Securityrelated','$Securityrelated_Native','$Securityrelated_Corrective','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Security related add successfully..');</script><script>window.location='incidentreport.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END Security related//



// START Report Disaster //
public static function ReportDisaster($prescriptionid,$patientid,$ReportDisaster,$ReportDisaster_Incidence,$ReportDisaster_Native,$ReportDisaster_Corrective,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Incident Report<br>Report Disaster","show_Report_Disaster.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO ReportDisaster(id,prescriptionid,patientid,ReportDisaster,ReportDisaster_Incidence,ReportDisaster_Native,ReportDisaster_Corrective,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$ReportDisaster','$ReportDisaster_Incidence','$ReportDisaster_Native','$ReportDisaster_Corrective','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Report Disaster  add successfully..');</script><script>window.location='incidentreport.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END Report Disaster //


// START Classification of Incidence  //
public static function Classification_Incidence($prescriptionid,$patientid,$Classification_Incidence,$Minor_Reaction,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		PatientManager::setActivityLog($patientid,"$prescriptionid","Incident Report<br>Classification Incidence","show_Classification_Incidence.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");

$sql="INSERT INTO Classification_Incidence(id,prescriptionid,patientid,Classification_Incidence,Minor_Reaction,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Classification_Incidence','$Minor_Reaction','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Classification of Incidence   add successfully..');</script><script>window.location='incidentreport.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END Classification of Incidence  //


//Start Oxygen//
public static function Oxygen($prescriptionid,$patientid,$Oxygen,$Oxygen_start,$Oxygen_stop,$entered_by)
{

	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
$sql="INSERT INTO Oxygen(id,prescriptionid,patientid,Oxygen,Oxygen_start,Oxygen_stop,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Oxygen','$Oxygen_start','$Oxygen_stop','$entered_by',now(),now())";

	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from Oxygen";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
	PatientManager::setActivityLog($patientid,"$prescriptionid","Record sheet<br>Oxygen","showDialysis.php?prescriptionid=$prescriptionid&patientid=$patientid&id=$id&srno=","$entered_by");

	$result=mysqli_query($link,$sql);
		
if($result)
echo "<script>alert('Oxygen Start successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//STOP Dressing//



// START ON EXAMNATION//
public static function onevisualexam($prescriptionid,$patientid,$occuid,$Un_right,$Un_left,$Aided_right,$Aided_left,$entered_by)
{
	echo "";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Examination <br> Visual Acuity Test","show_Visual_Acuity_Test.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO visual(id,prescriptionid,patientid,occuid,Un_right,Un_left,Aided_right,Aided_left,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$occuid','$Un_right','$Un_left','$Aided_right','$Aided_left','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Examination add successfully..');</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

// END ON EXAMNATION//



// START ON EXAMNATION//
public static function oneexamnation($prescriptionid,$patientid,$occuid,$Examination,$eye,$Result,$left_result,$entered_by)
{
	echo "Eye Examination";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Examination <br>Eye Examination","show_oneexamnation.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO onexamnation(id,prescriptionid,patientid,occuid,Examination,eye,Result,left_result,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$occuid','$Examination','$eye','$Result','$left_result','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Eye Examination add successfully..');</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

// END ON EXAMNATION//


// START ON EXAMNATION//
public static function GlassAdvices($prescriptionid,$patientid,$occuid,$Examination_type,$SPH,$SPH_right,$SPH_left,$CYL,$CYL_right,$CYL_left,$AXIS,$AXIS_right,$AXIS_left,$VISION,$VISION_right,$VISION_left,$entered_by)
{
	echo "Patient admission new";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Examination <br>Glass Advices $Examination_type","show_GlassAdvices.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO Glass_Advices(id,prescriptionid,patientid,occuid,Examination_type,SPH,SPH_right,SPH_left,CYL,CYL_right,CYL_left,AXIS,AXIS_right,AXIS_left,VISION,VISION_right,VISION_left,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$occuid','$Examination_type','$SPH','$SPH_right','$SPH_left','$CYL','$CYL_right','$CYL_left','$AXIS','$AXIS_right','$AXIS_left','$VISION','$VISION_right','$VISION_left','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Examination add successfully..');</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

// END ON EXAMNATION//



public static function Glassnear($prescriptionid,$patientid,$occuid,$Examination_type,$SPH,$SPH_right,$SPH_left,$CYL,$CYL_right,$CYL_left,$AXIS,$AXIS_right,$AXIS_left,$VISION,$VISION_right,$VISION_left,$entered_by)
{
	echo "Patient admission new";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	PatientManager::setActivityLog($patientid,"$prescriptionid","Examination <br>Glass Advices $Examination_type","show_GlassAdvices_near.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO Glass_Advices(id,prescriptionid,patientid,occuid,Examination_type,SPH,SPH_right,SPH_left,CYL,CYL_right,CYL_left,AXIS,AXIS_right,AXIS_left,VISION,VISION_right,VISION_left,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$occuid','$Examination_type','$SPH','$SPH_right','$SPH_left','$CYL','$CYL_right','$CYL_left','$AXIS','$AXIS_right','$AXIS_left','$VISION','$VISION_right','$VISION_left','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Examination add successfully..');</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}





//Start Suction//

public static function Suction($prescriptionid,$patientid,$Suction,$entered_by)
{
	echo "Patient admission new";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
$sql="INSERT INTO Suction(id,prescriptionid,patientid,Suction,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Suction','$entered_by',now(),now())";

	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from Suction";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
	$result=mysqli_query($link,$sql);
		
if($result)
echo "<script>alert('Suction Start successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//END SUCTION//

//START BIPAP//
public static function BIPAP($prescriptionid,$patientid,$BIPAP,$BIPAP_start,$BIPAP_stop,$duration,$entered_by)
{ 
echo "";
	include("dbconnection.php");
		$narayan=LoginManager::currentUser();
		$link=DBManager::connect();
$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$prescriptionid' AND patientid='$patientid'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='7' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
     $subbill=$rs112[rate];
   
$sql="INSERT INTO BIPAP(id,prescriptionid,patientid,BIPAP,BIPAP_start,BIPAP_stop,rate,duration,ward_id,bed_id,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$BIPAP','$BIPAP_start','$BIPAP_stop','$subbill','$duration','$rs56[Ward]','$rs56[Bed]','$entered_by','$created_at','$updated_at')";
    
	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from BIPAP";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
$duration=$row[7];
$ward_id=$row[8];
$bed_id=$row[9];
PatientManager::billingLog("$patientid","$prescriptionid","BIPAP","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","","$ward_id","$bed_id","$subbill","discount","grand_total","paymentmode","status","$entered_by");
PatientManager::setActivityLog($patientid,"$prescriptionid","Record sheet<br>BIPAP","showBIPAP.php?prescriptionid=$prescriptionid&patientid=$patientid&id=$id&srno=","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('BIPAP add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END BIPAP//



//START CPAP//
public static function CPAP($prescriptionid,$patientid,$CPAP,$CPAP_start,$CPAP_stop,$entered_by)
{
	echo "Patient admission new";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
$sql="INSERT INTO CPAP(id,prescriptionid,patientid,CPAP,CPAP_start,CPAP_stop,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$CPAP','$CPAP_start','$CPAP_stop','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from CPAP";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
		$result=mysqli_query($link,$sql);
		
if($result)
echo "<script>alert('CPAP add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END CPAP//




//START Ventilator//
public static function Ventilator($prescriptionid,$patientid,$Ventilator,$Ventilator_start,$Ventilator_stop,$entered_by)
{
	echo "Patient admission new";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";

$sql="INSERT INTO Ventilator(id,prescriptionid,patientid,Ventilator,Ventilator_start,Ventilator_stop,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Ventilator','$Ventilator_start','$Ventilator_stop','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from Ventilator";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
	$result=mysqli_query($link,$sql);
		
if($result)
echo "<script>alert('Ventilator add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//END Ventilator//

//Catheterization Done//
public static function Catheterization($prescriptionid,$patientid,$Catheterization,$entered_by)
{
	echo "";
	include("dbconnection.php");
			$link=DBManager::connect();
	$narayan=LoginManager::currentUser();
$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");

$sql="INSERT INTO Catheterization(id,prescriptionid,patientid,Catheterization,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Catheterization','$entered_by','$created_at','$updated_at')";
		$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$_GET[prescriptionid]' AND patientid='$_GET[patientid]'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='9' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from Catheterization";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","Catheterization","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Catheterization add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//Catheterization Stop//



//Intubation Done//
public static function Intubation($prescriptionid,$patientid,$Intubation,$entered_by)
{
	echo "";
	include("dbconnection.php");
	$link=DBManager::connect();
	$narayan=LoginManager::currentUser();
    $anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
    $updated_at=date("F d, Y / h:i:s A");
    $created_at=date("F d, Y / h:i:s A");
$sql="INSERT INTO Intubation(id,prescriptionid,patientid,Intubation,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Intubation','$entered_by',now(),now())";
		$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$_GET[prescriptionid]' AND patientid='$_GET[patientid]'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='25' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from Intubation";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","Intubation","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Intubation add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//Intubation Stop//




//PAC Done//
public static function PACrecords($prescriptionid,$patientid,$pac,$entered_by)
{
	echo "";
	include("dbconnection.php");
	$link=DBManager::connect();
	$narayan=LoginManager::currentUser();
    $anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
    $updated_at=date("F d, Y / h:i:s A");
    $created_at=date("F d, Y / h:i:s A");
$sql="INSERT INTO pac(id,prescriptionid,patientid,pac,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$pac','$entered_by',now(),now())";
		$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$_GET[prescriptionid]' AND patientid='$_GET[patientid]'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='28' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from pac";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","PAC","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('PAC add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//PAC Stop//


//RBS Done//
public static function RBSrecords($prescriptionid,$patientid,$RBS,$entered_by)
{
	echo "";
	include("dbconnection.php");
	$link=DBManager::connect();
	$narayan=LoginManager::currentUser();
    $anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
    $updated_at=date("F d, Y / h:i:s A");
    $created_at=date("F d, Y / h:i:s A");
$sql="INSERT INTO RBS(id,prescriptionid,patientid,RBS,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$RBS','$entered_by',now(),now())";
		$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$_GET[prescriptionid]' AND patientid='$_GET[patientid]'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='32' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from RBS";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","RBS","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('RBS add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//RBS Stop//





//CSF Done//
public static function csfline($prescriptionid,$patientid,$csf,$entered_by)
{
	echo "";
	include("dbconnection.php");
			$link=DBManager::connect();
	$narayan=LoginManager::currentUser();
$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");

$sql="INSERT INTO csf(id,prescriptionid,patientid,csf,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$csf','$entered_by',now(),now())";
		$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$_GET[prescriptionid]' AND patientid='$_GET[patientid]'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='11' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from csf";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","Catheterization","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('CSF add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//CSF Stop//

//Echo Charge Done//
public static function Echoc($prescriptionid,$patientid,$echoc,$entered_by)
{
	echo "";
	include("dbconnection.php");
			$link=DBManager::connect();
	$narayan=LoginManager::currentUser();
$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");

$sql="INSERT INTO echoc(id,prescriptionid,patientid,echoc,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$echoc','$entered_by',now(),now())";
		$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$_GET[prescriptionid]' AND patientid='$_GET[patientid]'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='18' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from echoc";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","Echo Charges","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Echo add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//Echo Charge Stop//


//Echo Charge Done//
public static function ect($prescriptionid,$patientid,$ect,$entered_by)
{
	echo "";
	include("dbconnection.php");
			$link=DBManager::connect();
	$narayan=LoginManager::currentUser();
$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");

$sql="INSERT INTO ect(id,prescriptionid,patientid,ect,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$ect','$entered_by',now(),now())";
		$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$_GET[prescriptionid]' AND patientid='$_GET[patientid]'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='19' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from echoc";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","ECT","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('ECT add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//Echo Charge Stop//


//Echo Charge Done//
public static function Electrotherapy($prescriptionid,$patientid,$Electrotherapy,$entered_by)
{
	echo "";
	include("dbconnection.php");
			$link=DBManager::connect();
	$narayan=LoginManager::currentUser();
$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");

$sql="INSERT INTO Electrotherapy(id,prescriptionid,patientid,Electrotherapy,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Electrotherapy','$entered_by',now(),now())";
		$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$_GET[prescriptionid]' AND patientid='$_GET[patientid]'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='20' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from echoc";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","Electrotherapy","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Electrotherapy add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//Echo Charge Stop//

//Echo Charge Done//
public static function Electrotherapylaser($prescriptionid,$patientid,$Electrotherapylaser,$entered_by)
{
	echo "";
	include("dbconnection.php");
			$link=DBManager::connect();
	$narayan=LoginManager::currentUser();
$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");

$sql="INSERT INTO Electrotherapylaser(id,prescriptionid,patientid,Electrotherapylaser,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Electrotherapylaser','$entered_by',now(),now())";
		$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$_GET[prescriptionid]' AND patientid='$_GET[patientid]'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='21' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from Electrotherapylaser";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","Electrotherapy","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Electrotherapy Laser add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//Echo Charge Stop//


//Echo Charge Done//
public static function FFPTransfusion($prescriptionid,$patientid,$FFPTransfusion,$entered_by)
{
	echo "";
	include("dbconnection.php");
			$link=DBManager::connect();
	$narayan=LoginManager::currentUser();
$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");

$sql="INSERT INTO FFPTransfusion(id,prescriptionid,patientid,FFPTransfusion,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$FFPTransfusion','$entered_by',now(),now())";

		$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$_GET[prescriptionid]' AND patientid='$_GET[patientid]'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='22' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from FFPTransfusion";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","FFP Transfusion","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('FFP Transfusion add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//Echo Charge Stop//



//Physiotherapy Start//
public static function Physiotherapy($prescriptionid,$patientid,$Physiotherapy,$entered_by)
{
	echo "";
		include("dbconnection.php");
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");

$sql="INSERT INTO Physiotherapy(id,prescriptionid,patientid,Physiotherapy,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Physiotherapy','$entered_by','$created_at','$updated_at')";
$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$prescriptionid' AND patientid='$patientid'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='30' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
    
	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from Physiotherapy";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","Physiotherapy","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Physiotherapy add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//Physiotherapy Stop//


//START Dietician//
public static function Dietician($prescriptionid,$patientid,$Dietician,$entered_by)
{
	echo "";
	include("dbconnection.php");
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
$sql="INSERT INTO Dietician(id,prescriptionid,patientid,Dietician,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Dietician','$entered_by','$created_at','$updated_at')";
$sql1 ="SELECT * FROM site_users WHERE userno='$anilka'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$prescriptionid' AND patientid='$patientid'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='46' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
    
	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from Dressing";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","Dietician","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Dietician add successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//STOP Dietician//


//Start Potensial Side Effect//
public static function potential($prescriptionid,$patientid,$operative_date,$Mode_Treatment,$Plan_Of_Care,$Follow_Up_Care,$treatment_Facility,$enteredby)
{
	echo "";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
		PatientManager::updatetatLog("$patientid","$prescriptionid","Consultant_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_visit_fee]","grand_total","q","w","ee","$Admitted_Under",""); 
	PatientManager::setActivityLog($patientid,"$prescriptionid","Opd Slip<br>Assessment","opdslip5.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	   PatientManager::dischargetry($prescriptionid,"$patientid","$hospitalid","","Opdslip","","","","","$entered_by");
	   	PatientManager::updatetatLogopd("$patientid","$prescriptionid","Consultant_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_visit_fee]","grand_total","q","w","ee","$Admitted_Under",""); 
$sql="INSERT INTO potential(id,prescriptionid,patientid,operative_date,Mode_Treatment,Plan_Of_Care,Follow_Up_Care,treatment_Facility,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$operative_date','$Mode_Treatment','$Plan_Of_Care','$Follow_Up_Care','$treatment_Facility','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Add successfully..');</script><script>window.location='opdset.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END Potensial Side Effect//





//START IPD POTENSIAL//

public static function potentialipd($prescriptionid,$patientid,$operative_date,$Mode_Treatment,$Plan_Of_Care,$Follow_Up_Care,$treatment_Facility,$enteredby)
{
	echo "";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
		PatientManager::updatetatLog("$patientid","$prescriptionid","Consultant_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_visit_fee]","grand_total","q","w","ee","$Admitted_Under",""); 
	PatientManager::setActivityLog($patientid,"$prescriptionid","Initial Assessment<br>Assessment","showpage_Assessment.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO potential(id,prescriptionid,patientid,operative_date,Mode_Treatment,Plan_Of_Care,Follow_Up_Care,treatment_Facility,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$operative_date','$Mode_Treatment','$Plan_Of_Care','$Follow_Up_Care','$treatment_Facility','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Add successfully..');</script><script>window.location='admission4.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//END IPD POTENTIAL//



//Start Nutrionn//

//Start Potensial Side Effect//
public static function NutritionRecommendation($prescriptionid,$patientid,$weight,$Present_Nutritional,$Nutritional_Status,$Maintain_BP,$Blood_Sugar,$Reduce_Cholesterol,$Energy,$Protein,$Fat,$note,$enteredby)
{
	echo "";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	PatientManager::setActivityLog($patientid,"$prescriptionid","Opd Slip<br>Nutrition Recommendation","showpage_Nutrition_Recommendation.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
$sql="INSERT INTO Nutrition_Recommendation(id,prescriptionid,patientid,weight,Present_Nutritional,Nutritional_Status,Maintain_BP,Blood_Sugar,Reduce_Cholesterol,Energy,Protein,Fat,note,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$weight','$Present_Nutritional','$Nutritional_Status','$Maintain_BP','$Blood_Sugar','$Reduce_Cholesterol','$Energy','$Protein','$Fat','$note','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Add successfully..');</script><script>window.location='test_Nutrition_Recommendation.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END Potensial Side Effect//


//end nutresion//



//Start Potensial2 Side Effect//
public static function potential2($prescriptionid,$patientid,$Potential_Side_Effects,$Mode_Treatment,$follow_up,$treatment_Facility,$transfer_IPD,$Second_Opinious,$Referral_Higher_Center,$nameofhospital,$Name_Consultant,$enteredby)
{
	echo "";
	$link=DBManager::connect();
	PatientManager::setActivityLog($patientid,"$prescriptionid","Initial Assessment","admissionshow.php?prescriptionid=$prescriptionid&patientid=$patientid","$entered_by");

$sql="INSERT INTO potential(id,prescriptionid,patientid,Potential_Side_Effects,Mode_Treatment,follow_up,treatment_Facility,transfer_IPD,Second_Opinious,Referral_Higher_Center,nameofhospital,Name_Consultant,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Potential_Side_Effects','$Mode_Treatment','$follow_up','$treatment_Facility','$transfer_IPD','$Second_Opinious','$Referral_Higher_Center','$nameofhospital','$Name_Consultant','$enteredby',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Add successfully..');</script><script>window.location='treatment_timline.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END Potensial Side Effect//

//Start Meidication//

public static function medication($patientid,$first_name,$last_name,$Route,$Frequency,$enteredby)
{
	echo "";
	$link=DBManager::connect();
$sql="INSERT INTO medication(id,patientid,first_name,last_name,Route,Frequency,entered_by,created_at,updated_at) VALUES (NULL, '$patientid','$Investigation','$Result','$Evidence','$enteredby',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>window.location='patient_verify.php?code=$user_activation_code';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//End Medication//

//Start Opd Slip//
public static function opdslip($prescriptionid,$patientid,$significate,$Admission_diagnosis,$other_Admission_diagnosis,$tratment,$Nutritional_Diagnosis,$eyetype,$note,$entered_by)
{
	echo "";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
		PatientManager::setActivityLog($patientid,"$prescriptionid","Opd Slip<br>Initial Diagnosis","showpage_Diagnosis.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
		  PatientManager::diagnosistimiline("$prescriptionid","$patientid","$Admission_diagnosis","$tratment","$entered_by");
$sql="INSERT INTO opdslip(Srno,prescriptionid,patientid,significate,Admission_diagnosis,other_Admission_diagnosis,tratment,Nutritional_Diagnosis,eyetype,note,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$significate','$Admission_diagnosis','$other_Admission_diagnosis','$tratment','$Nutritional_Diagnosis','$eyetype','$note','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>window.location='testopdslip1.php?prescriptionid=$prescriptionid&patientid=$patientid';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//End OPD Slip//

//Start DR Note//

public static function drnote($prescriptionid,$patientid,$Potential_side_effect,$Nursing_Instruction,$Status_of_Patient,$Response_to_Treatment,$Intensive_unit,$Shift_Ward,$Expected_Outcome,$Risk_Involved,$Mode_Treatment,$treatment_Facility,$Assurances_Guarantee,$Second_Opinious,$Referral_Higher_Center,$nameofhospital,$Name_Consultant,$Prognosis_Explained,$Diagnosis,$Detail_Note,$entered_by)
{
	$link=DBManager::connect();
	include("dbconnection.php");
	$sql12 ="SELECT * FROM addaspatient WHERE prescriptionid='$prescriptionid'";
		$qsql12 = mysqli_query($con,$sql12);
		if($rh12 = mysqli_fetch_array($qsql12))
	
$sql1 ="SELECT * FROM dr WHERE drid='$rh12[Admitted_Under]'";
		$qsql1 = mysqli_query($con,$sql1);
		if($rh1 = mysqli_fetch_array($qsql1))
	
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("Y/m/d");
   $created_at=date("F d, Y / h:i:s A");
$sql="INSERT INTO drnote(id,prescriptionid,patientid,Potential_side_effect,Nursing_Instruction,Status_of_Patient,Response_to_Treatment,Intensive_unit,Shift_Ward,Expected_Outcome,Risk_Involved,Mode_Treatment,treatment_Facility,Assurances_Guarantee,Second_Opinious,Referral_Higher_Center,nameofhospital,Name_Consultant,Prognosis_Explained,Diagnosis,Detail_Note,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Potential_side_effect','$Nursing_Instruction','$Status_of_Patient','$Response_to_Treatment','$Intensive_unit','$Shift_Ward','$Expected_Outcome','$Risk_Involved','$Mode_Treatment','$treatment_Facility','$Assurances_Guarantee','$Second_Opinious','$Referral_Higher_Center','$nameofhospital','$Name_Consultant','$Prognosis_Explained','$Diagnosis','$Detail_Note','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from drnote";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];

if($rh12[typevisit] == 'Ipd_Emergency'){
   PatientManager::billingLog("$patientid","$prescriptionid","visit_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_EMG_fee]","discount","grand_total","paymentmode","status","$Admitted_Under");
}
else{
   PatientManager::billingLog("$patientid","$prescriptionid","visit_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_visit_fee]","discount","grand_total","paymentmode","status","$Admitted_Under");
}
	
PatientManager::setActivityLog($patientid,"$prescriptionid","Doctor Note<br>Assessment","showpage_drnote.php?prescriptionid=$prescriptionid&patientid=$patientid&id=$id&srno=","$entered_by");
	$result=mysqli_query($link,$sql);
		PatientManager::diagnosistimiline("$prescriptionid","$patientid","$Diagnosis","$Surgery","$entered_by");
if($result)
echo "<script>alert('Assessment add successfully..');</script><script>window.location='drnote.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


// start Handower //


public static function handover($prescriptionid,$patientid,$Nursinggivern_Instruction,$entered_by)
{
	echo "";
	$link=DBManager::connect();
		$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
  
$sql="INSERT INTO handover(id,prescriptionid,patientid,Nursinggivern_Instruction,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Nursinggivern_Instruction','$entered_by','$created_at','$updated_at')";

	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from handover";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
PatientManager::setActivityLog($patientid,"$prescriptionid","Nursing Assessment<br>Handover","showpage_Handover.php?prescriptionid=$prescriptionid&patientid=$patientid&id=$id&srno=","$entered_by");
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Nursing Handover add successfully..');</script><script>window.location='nursingset.php?prescriptionid=$prescriptionid&patientid=$patientid';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//End Handower//



public static function admissionipd($prescriptionid,$patientid,$significate,$Admission_diagnosis,$other_Admission_diagnosis,$tratment,$Nutritional_Diagnosis,$eyetype,$note,$entered_by)
{
	echo "";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
		PatientManager::setActivityLog($patientid,"$prescriptionid","Intial Assessment<br>Initial Diagnosis","showpage_Diagnosis.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
		  PatientManager::diagnosistimiline("$prescriptionid","$patientid","$Admission_diagnosis","$tratment","$entered_by");
$sql="INSERT INTO opdslip(Srno,prescriptionid,patientid,significate,Admission_diagnosis,other_Admission_diagnosis,tratment,Nutritional_Diagnosis,eyetype,note,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$significate','$Admission_diagnosis','$other_Admission_diagnosis','$tratment','$Nutritional_Diagnosis','$eyetype','$note','$entered_by','$created_at','$updated_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Initial Diagnosis add successfully..');</script><script>window.location='admission1.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}




// Start Vitals//
public static function vitalsva($patientid,$vitals_name,$range_status,$enteredby)
{
	echo "";
	$link=DBManager::connect();
$sql="INSERT INTO vitals(srno,patientid,vitals_name,range_status,entered_by,created_at,updated_at) VALUES (NULL, '$patientid','$vitals_name','$range_status','$enteredby',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>window.location='patient_verify.php?code=$user_activation_code';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//End Vitals//
//Start Investigation Report//
public static function reportinvestigation($patientid,$Investigation,$Result,$Evidence,$enteredby)
{
	echo "";
	$link=DBManager::connect();
	   PatientManager::setActivityLog($patientid,"$prescriptionid","Report Investigation","showinvestigation.php?prescriptionid=$prescriptionid&patientid=$patientid","$entered_by");
	$sql="UPDATE investigation SET Result = $Result, Evidence = $Evidence
	Where Id='$id'";
	//$sql="INSERT INTO investigation(id,patientid,Investigation,Result,Evidence,entered_by,created_at,updated_at) VALUES (NULL, '$patientid','$Investigation','$Result','$Evidence','$enteredby',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>window.location='patient_verify.php?code=$user_activation_code';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//End Investigation Report//
public static function registerot($otid,$Name,$user_id,$numbers,$user_otp,$numbers_status,$user_activation_code,$entered_by)


{
	echo "called Ot";
	$link=DBManager::connect();
	$sql="INSERT INTO ot(srno,otid,Name,user_id,numbers,user_otp,numbers_status,user_activation_code,entered_by,created_at,updated_at) VALUES (NULL,'12345','$Name','$user_id','$numbers','$user_otp','Not Verified','$user_activation_code','$entered_by',now(),now())";
		$result=mysqli_query($link,$sql);
if($result)
echo "<script>window.location='patient_verify.php?code=$user_activation_code';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//End Ot Registerd//

// Start OPD//
public static function opd($patientid,$Investigation,$Result,$Evidence,$enteredby)
{
	echo "";
	$link=DBManager::connect();


$sql="INSERT INTO investigation(id,patientid,Investigation,Result,Evidence,entered_by,created_at,updated_at) VALUES (NULL, '$patientid','$Investigation','$Result','$Evidence','$enteredby',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>window.location='patient_verify.php?code=$user_activation_code';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//End opd//

//Start Medicine//

public static function Medicine($prescriptionid,$patientid,$DRUGS,$Dose,$Route,$Frequency,$duration,$potential,$poa,$status,$Action_med,$availability,$batchno,$st0,$st1,$st2,$st3,$st4,$st5,$drid,$treatmentid,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	$narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
include("dbconnection.php");

$DisplayForm=True;
$sql1 ="SELECT * FROM medicinede WHERE prescriptionid='$_GET[prescriptionid]'";
		$qsql1 = mysqli_query($con,$sql1);
		while($rh1 = mysqli_fetch_array($qsql1))
		{
	$DisplayForm=False;
echo "";
}
if($DisplayForm)
{
PatientManager::setActivityLog($patientid,"$prescriptionid","Opd Slip<br>Medicine Prescription","showmedicine.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
} else{
  
}

$narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
$sql1 ="SELECT * FROM site_users WHERE userno='$entered_by'";
		$qsql1 = mysqli_query($con,$sql1);
		while($re = mysqli_fetch_array($qsql1))
		$admin_id=$re[entered_by];
   $sql="SELECT  count('id') FROM medicinede WHERE prescriptionid='$_GET[prescriptionid]'";
$result=mysqli_query($con,$sql);
$row=mysqli_fetch_array($result);
    $slot=$row[0]+1;
    $durationselect='1';
		     $x=$durationselect; $y=$duration; $w=$Frequency; 
		  $a=$x*$y;
		  $z=$a*$w;
$sql2 ="SELECT * FROM medicine_stok WHERE medicine_id='$DRUGS'";
$qsql2 = mysqli_query($con,$sql2);
while($re2 = mysqli_fetch_array($qsql2))
  $price=$re2[mrp]/$re2[size];
           $price = number_format($price, 2, '.', ''); 
           $product=$price;
            $product1=$price*$z;
if (is_numeric($DRUGS))
{
$availability='Available';
PatientManager::medicineslotgive("$prescriptionid","$patientid","$DRUGS","$admin_id","medicinein","$z","$slot","$product","$product1","discount","process","batchno","paymentmode","$entered_by");
}
else
{
$availability='Not Available';
PatientManager::medicineslotgive("$prescriptionid","$patientid","$DRUGS","$admin_id","medicinein","$z","$slot","$product","$product1","discount","process","batchno","paymentmode","$entered_by");
}

$Action_med='process';
	$sql="INSERT INTO medicinede(id,prescriptionid,patientid,DRUGS,Dose,Route,Frequency,duration,potential,poa,status,Action_med,availability,batchno,st0,st1,st2,st3,st4,st5,drid,treatmentid,entered_by,created_at,updated_at) VALUES (NULL, '$prescriptionid','$patientid','$DRUGS','$Dose','$Route','$Frequency','$duration','$potential','$poa','$status','$Action_med','$availability','$batchno','$st0','$st1','$st2','$st3','$st4','$st5','$drid','$treatmentid','$entered_by',now(),now())";
    $result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Medicine add successfully..');</script><script>
 window.history.go(-1)</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
	
}

//End Medicine//




//OPD MEDICINE START//


public static function MedicineOPD($prescriptionid,$patientid,$DRUGS,$Dose,$Route,$Frequency,$duration,$potential,$poa,$status,$Action_med,$availability,$batchno,$st0,$st1,$st2,$st3,$st4,$st5,$drid,$treatmentid,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	$narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
include("dbconnection.php");

$DisplayForm=True;
$sql1 ="SELECT * FROM medicinede WHERE prescriptionid='$_GET[prescriptionid]'";
		$qsql1 = mysqli_query($con,$sql1);
		while($rh1 = mysqli_fetch_array($qsql1))
		{
	$DisplayForm=False;
echo "";
}
if($DisplayForm)
{
PatientManager::setActivityLog($patientid,"$prescriptionid","Opd Slip<br>Medicine Prescription","showmedicine.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
} else{
  
}


$sql1 ="SELECT * FROM site_users WHERE userno='$entered_by'";
		$qsql1 = mysqli_query($con,$sql1);
		while($re = mysqli_fetch_array($qsql1))
		$admin_id=$re[entered_by];
   $sql="SELECT  count('id') FROM medicinede WHERE prescriptionid='$_GET[prescriptionid]'";
$result=mysqli_query($con,$sql);
$row=mysqli_fetch_array($result);
    $slot=$row[0]+1;
    $durationselect='1';
		     $x=$durationselect; $y=$duration; $w=$Frequency; 
		  $a=$x*$y;
		  $z=$a*$w;
$sql2 ="SELECT * FROM medicine_stok WHERE medicine_id='$DRUGS'";
$qsql2 = mysqli_query($con,$sql2);
while($re2 = mysqli_fetch_array($qsql2))
  $price=$re2[mrp]/$re2[size];
           $price = number_format($price, 2, '.', ''); 
           $product=$price;
            $product1=$price*$z;
if (is_numeric($DRUGS))
{
$availability='Available';
PatientManager::medicineslotgive("$prescriptionid","$patientid","$DRUGS","$admin_id","medicinein","$z","$slot","$product","$product1","discount","process","batchno","paymentmode","$entered_by");
}
else
{
$availability='Not Available';
PatientManager::medicineslotgive("$prescriptionid","$patientid","$DRUGS","$admin_id","medicinein","$z","$slot","$product","$product1","discount","process","batchno","paymentmode","$entered_by");
}

$Action_med='process';
	$sql="INSERT INTO medicinede(id,prescriptionid,patientid,DRUGS,Dose,Route,Frequency,duration,potential,poa,status,Action_med,availability,batchno,st0,st1,st2,st3,st4,st5,drid,treatmentid,entered_by,created_at,updated_at) VALUES (NULL, '$prescriptionid','$patientid','$DRUGS','$Dose','$Route','$Frequency','$duration','$potential','$poa','$status','$Action_med','$availability','$batchno','$st0','$st1','$st2','$st3','$st4','$st5','$drid','$treatmentid','$entered_by',now(),now())";
    $result=mysqli_query($link,$sql);
if($result)
echo "<script>window.location='testopdslip3.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
	
}
// OPD MEDICINE END//






//Start Medicine Inventory//


public static function Medicinestokinventory($medicine_id,$invoice_no,$date_of_purchase,$vendor,$date_invoice,$Cmrp,$cost_gst,$Batch_number,$HSN_No,$mrp,$gst,$Quantity,$Expiry_Date,$entered_by)
{
	//echo "";
	$link=DBManager::connect();
$narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	 
	$sql="INSERT INTO medicine_inventory(inventory_id,medicine_id,invoice_no,date_of_purchase,vendor,date_invoice,Cmrp,cost_gst,Batch_number,HSN_No,mrp,gst,Quantity,Expiry_Date,entered_by,created_at,updated_at) VALUES (NULL,'$medicine_id','$invoice_no','$date_of_purchase','$vendor','$date_invoice','$Cmrp','$cost_gst','$Batch_number','$HSN_No','$mrp','$gst','$Quantity','$Expiry_Date','$entered_by',now(),now())";
	
    $result=mysqli_query($link,$sql);
    {
  	$insid= mysqli_insert_id($link);
			$invetory_id= $insid;
			
	PatientManager::setActivitybill($invetory_id,"$medicine_id","$date_of_purchase","$vendor","$date_invoice","$Cmrp","$cost_gst","$Batch_number","$mrp","$gst","$entered_by");
    }
if($result)

echo "<script>alert('Medicine add successfully..');</script><script>window.location='Add_inventory.php?medicine_id=$medicine_id'</script>;</script>";

else 
	echo "Fail";
	$link=DBManager::close($link);
	
}


//Start Medicine Stok//

public static function Medicinestok($admin_id,$Category,$DRUGS_name,$Contain,$Dose,$dose_value,$mrp,$size,$Name_brand,$vendorname)
{
	//echo "";
	$link=DBManager::connect();
$narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	$sql="INSERT INTO medicine_stok(medicine_id,admin_id,Category,DRUGS_name,Contain,Dose,dose_value,mrp,size,Name_brand,vendorname,created_at,updated_at) VALUES (NULL, '$admin_id','$Category','$DRUGS_name','$Contain','$Dose','$dose_value','$mrp','$size','$Name_brand','$vendorname',now(),now())";
    $result=mysqli_query($link,$sql);
    if(!$result)
	return false;
$sql ="select last_insert_medicine_id() from medicine_stok";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$medicine_id=$row[0];
	$result=mysqli_query($link,$sql);
		PatientManager::setActivityLog($patientid,"$prescriptionid","medicine Prescription","show_medicine.php?medicine_id=$medicine_id","$entered_by");
if($result)
echo "<script>alert('Medicine add successfully..');</script><script>
window.location='StockInventory.php';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//End Medicine Stock//

//Start Medicine Stok//

public static function Medicinestoknurse($admin_id,$Category,$DRUGS_name,$Contain,$Dose,$dose_value,$mrp,$size,$Name_brand)
{
	//echo "";
	$link=DBManager::connect();
$narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	$sql="INSERT INTO medicine_stok(medicine_id,admin_id,Category,DRUGS_name,Contain,Dose,dose_value,mrp,size,Name_brand,created_at,updated_at) VALUES (NULL, '$admin_id','$Category','$DRUGS_name','$Contain','$Dose','$dose_value','$mrp','$size','$Name_brand',now(),now())";
	$result=mysqli_query($link,$sql);
		
if(!$result)
	return false;
$sql ="select last_insert_id() from medicine_stok";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$medicine_id=$row[0];
 PatientManager::medicineupdatefianl("$prescriptionid","$patientid","$medicine_id","$Category","$Dose","$Route","$Frequency","$duration","$durationselect","$potential","$poa","$status","$action","$availability","$batchno","$entered_by");
if($result)

echo "<script>alert('Medicine add successfully..');</script><script>
window.location='Add_inventory_ontime.php?medicine_id=$medicine_id'</script>";

else 
	echo "Fail";
	$link=DBManager::close($link);
}
//End Medicine Stock//


//Start Medicine order//
public static function Medicineorder($prescriptionid,$patientid,$DRUGS,$Dose,$Frequency,$days,$status,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	$sql="INSERT INTO medicineorder(id,prescriptionid,patientid,DRUGS,Dose,Frequency,days,status,entered_by,created_at,updated_at) VALUES (NULL, '$prescriptionid','$patientid','$DRUGS','$Dose','$Frequency','$days','pending','$entered_by',now(),now())";
    $result=mysqli_query($link,$sql);
if($result)
echo "<script>
 window.history.go(-2)</script>";
   
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//End Medicine order//

// START MEDICATION ACTION//
//Start Medicine//

public static function Medicineaction($prescriptionid,$patientid,$shift,$drugsid,$Action_med,$entered_by)
{

	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	$sql="INSERT INTO medicinedeaction(srno,prescriptionid,patientid,shift,drugsid,Action_med,entered_by,created_at,updated_at) VALUES (NULL, '$prescriptionid','$patientid','$shift','$drugsid','$Action_med','$entered_by',now(),now())";
    $result=mysqli_query($link,$sql);
	$link=DBManager::close($link);
}

//End Medicine//

//END MEDICATION ACTION//

//Start TRANSFER And Referal //

public static function transferreferal($prescriptionid,$patientid,$Transfer_IPD,$Word,$Bed,$Referred_To,$Name_Hospital,$Name_of_Consultant,$followup,$followup_date,$enteredby)
{
	echo "";
	$link=DBManager::connect();
		   PatientManager::setActivityLog($patientid,"$prescriptionid","Transfer Referal","showtransferandreferal.php?prescriptionid=$prescriptionid&patientid=$patientid","$entered_by");
	$sql="INSERT INTO transferreferal(srno,prescriptionid,patientid,Transfer_IPD,Word,Bed,Referred_To,Name_Hospital,Name_of_Consultant,followup,followup_date,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Transfer_IPD','$Word','$Bed','$Referred_To','$Name_Hospital','$Name_of_Consultant','$followup','$followup_date','$enteredby',now(),now())";
		$result=mysqli_query($link,$sql);
			PatientManager::appoimentbook("$patientid","$Name_Hospital","$patientname","$VisitConsultant","$Specialty","$Selectstate","$Selectdistrict","$hospitalname","$Name_of_Consultant","$Payment","$followup_date","$SelectTime","new");
if($result)

echo "<script>window.location='treatment_timline.php?prescriptionid=$prescriptionid&patientid=$patientid';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//End Transfer And Referal//

//Discharge Cheacklist//
public static function dischargechecklist($prescriptionid,$patientid,$Pharmacy_Replacement,$Billing_Completed,$summary_handed,$Prescription_explained,$Report_handed,$iv_cannula_removed,$Hospital_Dress_Changed,$Hospital_belonging,$Pending_report_informed,$Admission_Consent,$Transfusion_Consent,$Cost_Consent,$Procedure_Consent,$High_Risk_Consent,$Anesthesia_Consent,$LAMA_DOR_Consent,$Discharge_Consent,$check_date,$Nurse_Name,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
		   PatientManager::setActivityLog($patientid,"$prescriptionid","Discharge Summery<br>Discharge Checklist","showpage_dischargechecklist.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	$sql="INSERT INTO dischargechecklist(id,prescriptionid,patientid,Pharmacy_Replacement,Billing_Completed,summary_handed,Prescription_explained,Report_handed,iv_cannula_removed,Hospital_Dress_Changed,Hospital_belonging,Pending_report_informed,Admission_Consent,Transfusion_Consent,Cost_Consent,Procedure_Consent,High_Risk_Consent,Anesthesia_Consent,LAMA_DOR_Consent,Discharge_Consent,check_date,Nurse_Name,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Pharmacy_Replacement','$Billing_Completed','$summary_handed','$Prescription_explained','$Report_handed','$iv_cannula_removed','$Hospital_Dress_Changed','$Hospital_belonging','$Pending_report_informed','$Admission_Consent','$Transfusion_Consent','$Cost_Consent','$Procedure_Consent','$High_Risk_Consent','$Anesthesia_Consent','$LAMA_DOR_Consent','$Discharge_Consent','$check_date','$Nurse_Name','$entered_by',now(),now())";
		$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Add successfully..');</script>;<script>window.location='Dischargesummery.php?prescriptionid=$prescriptionid&patientid=$patientid';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//End Discharge Cheaklist//



//End Discharge Cheaklist//



//  START REQUEST FOR TRANSPORT//

public static function RequestTransport($prescriptionid,$patientid,$Type_Ambulance,$Departure,$Arrival,$EN_Route,$Loading_Startup,$Duration,$Inspection_Report,$Duration2,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
		   PatientManager::setActivityLog($patientid,"$prescriptionid","Discharge Summery<br>Request Transport","showpage_RequestTransport.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	$sql="INSERT INTO Request_Transport(id,prescriptionid,patientid,Type_Ambulance,Departure,Arrival,EN_Route,Loading_Startup,Duration,Inspection_Report,Duration2,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Type_Ambulance','$Departure','$Arrival','$EN_Route','$Loading_Startup','$Duration','$Inspection_Report','$Duration2','$entered_by',now(),now())";
		$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('add successfully..');</script><script>window.location='Dischargesummery.php?prescriptionid=$prescriptionid&patientid=$patientid';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}




// END REQUEST FOR TRANSPORT//



//  START REQUEST FOR TRANSPORT//

public static function followupd($prescriptionid,$patientid,$Food_Intake,$Kindly_Avoid,$Kindly_Follow,$Follow_Visit,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
		   PatientManager::setActivityLog($patientid,"$prescriptionid","Discharge Summery<br>Follow Up","showpage_followupdischarge.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	$sql="INSERT INTO followdis(id,prescriptionid,patientid,Food_Intake,Kindly_Avoid,Kindly_Follow,Follow_Visit,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Food_Intake','$Kindly_Avoid','$Kindly_Follow','$Follow_Visit','$entered_by',now(),now())";
		$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('add successfully..');</script><script>window.location='Dischargesummery.php?prescriptionid=$prescriptionid&patientid=$patientid';</script>;</script>";
//echo "<script>window.location='treatment_timline.php?prescriptionid=$prescriptionid&patientid=$patientid';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}




// END REQUEST FOR TRANSPORT//


// Start CREATE GET PASS//



public static function Gatepassfinal($prescriptionid,$patientid,$Checklist_Filed,$Ambulance_Required,$Discharge_Handover,$Time_Exit,$Follow_Visit,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
		   PatientManager::setActivityLog($patientid,"$prescriptionid","Discharge Summery<br>Gate Pass","showpage_Create_Gate_pass.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	$sql="INSERT INTO Gatepass(id,prescriptionid,patientid,Checklist_Filed,Ambulance_Required,Discharge_Handover,Time_Exit,Follow_Visit,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Checklist_Filed','$Ambulance_Required','$Discharge_Handover','$Time_Exit','$Follow_Visit','$entered_by',now(),now())";
		$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('add successfully..');</script><script>window.location='Dischargesummery.php?prescriptionid=$prescriptionid&patientid=$patientid';</script>;</script>";
//echo "<script>window.location='treatment_timline.php?prescriptionid=$prescriptionid&patientid=$patientid';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END CREATE GET PASS//


//START MEDICATION SLOT UPDATE QUIRY//

// Start Final Discharge//


public static function medicineupdate($prescriptionid,$patientid,$DRUGS,$Category,$Dose,$Route,$Frequency,$duration,$durationselect,$potential,$poa,$status,$Action_med,$availability,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
$sql ="UPDATE medicinede SET Action_med='$_POST[action]' WHERE prescriptionid='$_GET[prescriptionid]' AND patientid='$_GET[patientid]' AND DRUGS='$_POST[DRUGS]'";
		$result=mysqli_query($link,$sql);
if($result)
echo "";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//Discharge Try//


// Start Final Discharge//


public static function medicineupdatefianl($prescriptionid,$patientid,$medicine_id,$Category,$Dose,$Route,$Frequency,$duration,$durationselect,$potential,$poa,$status,$Action_med,$availability,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
$sql ="UPDATE medicinede SET DRUGS='$medicine_id',  availability='Available' WHERE id='$_GET[id]'";
		$result=mysqli_query($link,$sql);
if($result)
echo "";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//Discharge Try//


//END MEDICTION SLOT UPDATE QUIRY//

//START UPDATE MEDICINE STATUS//


public static function medicineslotupdate($prescriptionid,$patientid,$medicine_id,$admin_id,$quantitygiven,$slot_id,$price,$pricetotal,$action,$batchno,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
$sql ="UPDATE medicine_slot SET action='$_POST[action]', quantitygiven='$_POST[quantitygiven]', batchno='$_POST[batchno]' WHERE prescriptionid='$_GET[prescriptionid]' AND patientid='$_GET[patientid]' AND srno='$_POST[srno]'";
		$result=mysqli_query($link,$sql);
		 PatientManager::medicineupdate("$prescriptionid","$patientid","$DRUGS","$Category","$Dose","$Route","$Frequency","$duration","$durationselect","$potential","$poa","$status","$action","$availability","$batchno","$entered_by");
		 	PatientManager::billingLog("$patientid","$prescriptionid","Medicine_charge","$_POST[srno]","patient_invtitation_invace.php?prescriptionid=$prescriptionid&patientid=$patientid","$pricetotal","","","$paymentmode","$status","$entered_by");
if($result)
echo "";
else 
	echo "";
	$link=DBManager::close($link);
}


//END UPDATE MEDICINE STATUS//


// Start Final Discharge//

public static function discharge($prescriptionid,$patientid,$hospital_id,$status,$COdischarge,$Advice_Discharge,$created_by,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
		   PatientManager::setActivityLog($patientid,"$prescriptionid","Discharge","showinvestigation.php?prescriptionid=$prescriptionid&patientid=$patientid","$entered_by");
		  		 PatientManager::updatebedindexdext("$wardid","$bedname","$price","$status","$prescriptionid");
$sql ="UPDATE discharge SET status='$status',  COdischarge='$COdischarge', Advice_Discharge='$Advice_Discharge', created_by='$created_by' WHERE patientid='$_GET[patientid]'";
		$result=mysqli_query($link,$sql);
if($result)
// echo "<script>window.location='patient_basic.php?patientid=$patientid';</script>;</script>";
echo "<script>window.location='show_discharge_summery.php?prescriptionid=$prescriptionid&patientid=$patientid';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//Discharge Try//
// Start Final Discharge//




//Transfer TO IPD//
public static function tripd($prescriptionid,$patientid,$hospital_id,$status,$COdischarge,$Advice_Discharge,$created_by,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
		   PatientManager::setActivityLog($patientid,"$prescriptionid","Discharge","showinvestigation.php?prescriptionid=$prescriptionid&patientid=$patientid","$entered_by");
$sql ="UPDATE discharge SET status='$status',  COdischarge='$COdischarge', Advice_Discharge='$Advice_Discharge', created_by='$created_by' WHERE patientid='$_GET[patientid]'";
		$result=mysqli_query($link,$sql);
if($result)
echo "<script>window.location='addpatientrecodsipd.php?patientid=$patientid';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//Transfer to IPD//

public static function dischargetry($prescriptionid,$patientid,$hospital_id,$typevisit,$status,$COdischarge,$Advice_Discharge,$admissiondate,$created_by,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
$admissiondate=date("Y/m/d");
		  	$sql="INSERT INTO discharge(id,prescriptionid,patientid,hospital_id,typevisit,status,COdischarge,Advice_Discharge,admissiondate,created_by,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$hospital_id','$typevisit','$status','$COdischarge','$Advice_Discharge','$admissiondate','$created_by','$entered_by',now(),now())";
		$result=mysqli_query($link,$sql);
if($result)
	$link=DBManager::close($link);
}




//END DISCHARGE TRY//



// Timiline Diagnosis start//

public static function diagnosistimiline($prescriptionid,$patientid,$diagnosis,$Surgery,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
$admissiondate=date("Y/m/d");
		  	$sql="INSERT INTO diagnosis_timiline(id,prescriptionid,patientid,diagnosis,Surgery,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$diagnosis','$Surgery','$entered_by',now(),now())";
		$result=mysqli_query($link,$sql);
if($result)
	$link=DBManager::close($link);
}

//timiline diagnosis end//


// Timiline Diagnosis start//

public static function diagnosistimilinetest($prescriptionid,$patientid,$diagnosis,$Surgery,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
$admissiondate=date("Y/m/d");
		  	$sql="INSERT INTO diagnosis_timiline(id,prescriptionid,patientid,diagnosis,Surgery,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$diagnosis','$Surgery','$entered_by','$admissiondate',now())";
		$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Add successfully..');</script><script> window.history.go(-2)</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//timiline diagnosis end//


//END FINAL DISCHARGE//


//FORCE TO DISCHARGE//

public static function dischargeforce($prescriptionid,$patientid,$status,$COdischarge,$Advice_Discharge,$created_by,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
		   PatientManager::setActivityLog($patientid,"$prescriptionid","Force To Discharge","showinvestigation.php?prescriptionid=$prescriptionid&patientid=$patientid","$entered_by");
	$sql="INSERT INTO discharge(id,prescriptionid,patientid,status,COdischarge,Advice_Discharge,created_by,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$status','$COdischarge','$Advice_Discharge','$created_by','$entered_by',now(),now())";
		$result=mysqli_query($link,$sql);
if($result)
echo "<script>window.location='treatment_timline.php?prescriptionid=$prescriptionid&patientid=$patientid';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END FORCE TO DISCHARGE//


//START NEW  ADD AS PATIENT//

public static function Addaspatient($patientid,$hospitalid,$typevisit,$casetype,$Admitted_Under,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	include("dbconnection.php");
$sql1 ="SELECT * FROM dr WHERE drid='$Admitted_Under'";
		$qsql1 = mysqli_query($con,$sql1);
		if($rh1 = mysqli_fetch_array($qsql1))
		
		
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
			$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	$sql="INSERT INTO addaspatient(prescriptionid,patientid,hospitalid,typevisit,casetype,Admitted_Under,entered_by, created_at,updated_at) VALUES (NULL,'$patientid','$hospitalid','$typevisit','$casetype','$Admitted_Under','$entered_by','$created_at','$updated_at')";
		if($qsql = mysqli_query($link,$sql))
		{
			$insid= mysqli_insert_id($link);
			$prescriptionid= $insid;
		   PatientManager::dischargetry($prescriptionid,"$patientid","$hospitalid","$typevisit","Admission","","","","$admissiondate","$entered_by");
		   if($typevisit == 'OPD'){
	 PatientManager::billingLog("$patientid","$prescriptionid","Consultant_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[Visit_fee]","discount","grand_total","paymentmode","status","$Admitted_Under");
} elseif($typevisit == 'Opd_Emergency'){
   PatientManager::billingLog("$patientid","$prescriptionid","Consultant_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[opd_EMG_fee]","discount","grand_total","paymentmode","status","$Admitted_Under");
}
elseif($typevisit == 'Ipd_Emergency'){
   PatientManager::billingLog("$patientid","$prescriptionid","Consultant_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_EMG_fee]","discount","grand_total","paymentmode","status","$Admitted_Under");
}
else{
   PatientManager::billingLog("$patientid","$prescriptionid","Consultant_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_visit_fee]","discount","grand_total","paymentmode","status","$Admitted_Under");
}
	echo "<script>window.location='document_verify.php?prescriptionid=" . $insid . "&patientid=$_GET[patientid]';</script>";
		}
		else
		{
			echo mysqli_error($link);
		}
	$link=DBManager::close($link);
}





//END NEW ADD AS PATIENT//


//START NEW  ADD AS PATIENT//

public static function testpatientfinal($patientid,$hospitalid,$typevisit,$casetype,$Admitted_Under,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	include("dbconnection.php");
$sql1 ="SELECT * FROM dr WHERE drid='$Admitted_Under'";
		$qsql1 = mysqli_query($con,$sql1);
		if($rh1 = mysqli_fetch_array($qsql1))
		
		
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
			$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
		
	$sql="INSERT INTO addaspatient(prescriptionid,patientid,hospitalid,typevisit,casetype,Admitted_Under,entered_by, created_at,updated_at) VALUES (NULL,'$patientid','$hospitalid','$typevisit','$casetype','$Admitted_Under','$entered_by','$created_at','$updated_at')";
		if($qsql = mysqli_query($link,$sql))
		{
			$insid= mysqli_insert_id($link);
			$prescriptionid= $insid;
		   PatientManager::dischargetry($prescriptionid,"$patientid","$hospitalid","$typevisit","Admission","","","","$admissiondate","$entered_by");
		   if($typevisit == 'OPD'){
  PatientManager::billingLog("$patientid","$prescriptionid","Consultant_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[Visit_fee]","discount","grand_total","paymentmode","status","$Admitted_Under");
} elseif($typevisit == 'Opd_Emergency'){
   PatientManager::billingLog("$patientid","$prescriptionid","Consultant_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[opd_EMG_fee]","discount","grand_total","paymentmode","status","$Admitted_Under");
}
elseif($typevisit == 'Ipd_Emergency'){
   PatientManager::billingLog("$patientid","$prescriptionid","Consultant_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_EMG_fee]","discount","grand_total","paymentmode","status","$Admitted_Under");
}
else{
   PatientManager::billingLog("$patientid","$prescriptionid","Consultant_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_visit_fee]","discount","grand_total","paymentmode","status","$Admitted_Under");
}
		   
		   
		   		echo "<script>window.location='document_verify.php?prescriptionid=" . $insid . "&patientid=$_GET[patientid]';</script>";
		}
		else
		{
			echo mysqli_error($link);
		}
	$link=DBManager::close($link);
}



//END NEW ADD AS PATIENT//




//TEST NEW TRIAE//




//start patient surgury records//


//START NEW  ADD AS PATIENT//

public static function testsurgury($prescriptionid,$patientid,$hospitalid,$surgery,$case_status,$Admitted_Under,$status,$entered_by)
{
    echo "";
    $link=DBManager::connect();
    include("dbconnection.php");
    $sql12 ="SELECT * FROM create_inhouse WHERE ivid='$surgery' AND hospitalid='$hospitalid'";
    $qsql12 = mysqli_query($con,$sql12);
    if($rh12 = mysqli_fetch_array($qsql12))
    {
    	$narayan=LoginManager::currentUser();
    	$anilka=LoginManager::getUserTypeByuname("$narayan");
    	$entered_by="$anilka";
    	$updated_at=date("Y/m/d");
    	$created_at=date("F d, Y / h:i:s A");
    	$sql="INSERT INTO surgerytracker(surgeryid,prescriptionid,patientid,hospitalid,surgery,case_status,Admitted_Under,status,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$hospitalid','$surgery','$case_status','$Admitted_Under','$status','$entered_by','$created_at','$updated_at')";
    	 PatientManager::billingLog("$patientid","$prescriptionid","surgury_fees","$surgery","show_testsurgury.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh12[rate]","discount","grand_total","paymentmode","status","$Admitted_Under");
    	 $result=mysqli_query($link,$sql);
    	if($result)
    	{
    		$surgeryid=mysqli_insert_id($link);
    
    		echo "<script>alert('Operative Process start successfully');</script><script>window.location='operativemenu.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid'</script>;</script>";
    	}
    	else{
    		echo "<script>alert('Selected treatment and surgery not created.');</script>";
    		$link=DBManager::close($link);
    	} 	
    }else{
    	echo "<script>alert('Selected treatment and surgery not created.');</script>";
    	$link=DBManager::close($link);
    } 	


}

	
// END TRIAE FINAL//

//START OCCULAR EXAMNATION//
//START NEW  ADD AS PATIENT//

public static function testoccu($prescriptionid,$patientid,$hospitalid,$occu,$Admitted_Under,$status,$entered_by)
{
	echo "";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
   $updated_at=date("Y/m/d");
   $created_at=date("F d, Y / h:i:s A");
	$sql="INSERT INTO occutracker(occuid,prescriptionid,patientid,hospitalid,occu,Admitted_Under,status,entered_by, created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$hospitalid','$occu','$Admitted_Under','$status','$entered_by','$created_at','$updated_at')";
     $result=mysqli_query($link,$sql);
if($result)
{
    	$occuid=mysqli_insert_id($link);

echo "<script>alert('Occular Process start successfully');</script><script>window.location='occumenu.php?prescriptionid=$prescriptionid&patientid=$patientid&occuid=$occuid'</script>;</script>";
}
else 
	echo "Fail";
	$link=DBManager::close($link);
}

	
// END TRIAE FINAL//





//END OCCULAR EXAMNATION//





// Start FREQUENCY PRESCRIBE MEDICATION//
public static function frqsurguryinv($hospitalid,$surgery,$drid,$entered_by)
{
	echo "";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
   $updated_at=date("Y/m/d");
   $created_at=date("F d, Y / h:i:s A");
	$sql="INSERT INTO frquencytracker(surgeryid,hospitalid,surgery,drid,entered_by,created_at,updated_at) VALUES (NULL,'$hospitalid','$surgery','$drid','$entered_by','$created_at','$updated_at')";
     $result=mysqli_query($link,$sql);
if($result)
{
    	$surgeryid=mysqli_insert_id($link);

echo "<script>alert('FPM Add successfully');</script><script>window.location='frequencyinvestigation_add.php?drid=$drid&surgeryid=$surgeryid'</script>;</script>";
}
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//START NEW  ADD AS PATIENT//

public static function frqsurgury($hospitalid,$surgery,$drid,$entered_by)
{
	echo "";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
   $updated_at=date("Y/m/d");
   $created_at=date("F d, Y / h:i:s A");
	$sql="INSERT INTO frquencytracker(surgeryid,hospitalid,surgery,drid,entered_by,created_at,updated_at) VALUES (NULL,'$hospitalid','$surgery','$drid','$entered_by','$created_at','$updated_at')";
     $result=mysqli_query($link,$sql);
if($result)
{
    	$surgeryid=mysqli_insert_id($link);

echo "<script>alert('FPM Add successfully');</script><script>window.location='frequency_add.php?drid=$drid&surgeryid=$surgeryid'</script>;</script>";
}
else 
	echo "Fail";
	$link=DBManager::close($link);
}

	
// END TRIAE FINAL//




//END FREQUENCY P MEDICATION//







//END PATIENT SURERY RECORDS//


//START NEW  ADD AS PATIENT//

public static function testpatientfinal26MARC($patientid,$hospitalid,$typevisit,$casetype,$Admitted_Under,$triage,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	include("dbconnection.php");
$sql1 ="SELECT * FROM dr WHERE drid='$Admitted_Under'";
		$qsql1 = mysqli_query($con,$sql1);
		if($rh1 = mysqli_fetch_array($qsql1))
		
		
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
			$updated_at=date("Y/m/d");
   $created_at=date("F d, Y / h:i:s A");
		
	$sql="INSERT INTO addaspatient(prescriptionid,patientid,hospitalid,typevisit,casetype,Admitted_Under,triage,entered_by, created_at,updated_at) VALUES (NULL,'$patientid','$hospitalid','$typevisit','$casetype','$Admitted_Under','$triage','$entered_by','$created_at','$updated_at')";
		if($qsql = mysqli_query($link,$sql))
		{
			$insid= mysqli_insert_id($link);
			$prescriptionid= $insid;
		   PatientManager::dischargetry($prescriptionid,"$patientid","$hospitalid","$typevisit","Admission","","","","$admissiondate","$entered_by");
		   if($typevisit == 'OPD'){
  PatientManager::billingLog("$patientid","$prescriptionid","Consultant_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[Visit_fee]","discount","grand_total","paymentmode","status","$Admitted_Under");
	PatientManager::tatLog("$patientid","$prescriptionid","$casetype","OPD_Consultation","showtatlog.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_visit_fee]","discount","grand_total","","","","$Admitted_Under");
} elseif($typevisit == 'Opd_Emergency'){
   PatientManager::billingLog("$patientid","$prescriptionid","Consultant_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[opd_EMG_fee]","discount","grand_total","paymentmode","status","$Admitted_Under");
  
	PatientManager::tatLog("$patientid","$prescriptionid","$casetype","OPD_Consultation","showtatlog.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_visit_fee]","discount","grand_total","","","","$Admitted_Under");
}
elseif($typevisit == 'OPD_Routine'){
   PatientManager::billingLog("$patientid","$prescriptionid","Consultant_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[routin_fee]","discount","grand_total","paymentmode","status","$Admitted_Under");
  
	PatientManager::tatLog("$patientid","$prescriptionid","$casetype","OPD_Consultation","showtatlog.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_visit_fee]","discount","grand_total","","","","$Admitted_Under");
}
elseif($typevisit == 'Ipd_Emergency'){
   PatientManager::billingLog("$patientid","$prescriptionid","Consultant_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_EMG_fee]","discount","grand_total","paymentmode","status","$Admitted_Under");
	PatientManager::tatLog("$patientid","$prescriptionid","$casetype","Emergency_care","showtatlog.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_visit_fee]","discount","grand_total","","","","$Admitted_Under");
		PatientManager::tatLog("$patientid","$prescriptionid","$casetype","Bed_Allotment","showtatlog.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_visit_fee]","discount","grand_total","","","","$Admitted_Under");
}
else{
   PatientManager::billingLog("$patientid","$prescriptionid","Consultant_fees","$casetype","drinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_visit_fee]","discount","grand_total","paymentmode","status","$Admitted_Under");
   PatientManager::tatLog("$patientid","$prescriptionid","$casetype","Bed_Allotment","showtatlog.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_visit_fee]","discount","grand_total","","","","$Admitted_Under");
}
 	PatientManager::tatLog("$patientid","$prescriptionid","$casetype","Add_As_Patient_Page","showtatlog.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_visit_fee]","discount","grand_total","","","","$Admitted_Under");
	PatientManager::tatLog("$patientid","$prescriptionid","$casetype","Vitals","showtatlog.php?prescriptionid=$prescriptionid&patientid=$patientid","$rh1[ipd_visit_fee]","discount","grand_total","","","","$Admitted_Under");

	
		   
		   
		   		echo "<script>window.location='document_verify.php?prescriptionid=" . $insid . "&patientid=$_GET[patientid]';</script>";
		}
		else
		{
			echo mysqli_error($link);
		}
	$link=DBManager::close($link);
}

// END TRIAE FINAL//


//START RECORDS ACCESS WITOUT PATIENT PERMISSION//
public static function patientAccess($prescriptionid,$patientid,$adminid,$typevisit,$casetype,$note,$entered_by)
{
	$link=DBManager::connect();
	$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	$sql="INSERT INTO accesspatient(accessid,prescriptionid,patientid,adminid,typevisit,casetype,note,entered_by,created_at) VALUES (NULL,'$prescriptionid','$patientid','$adminid','$typevisit','$casetype','$note','$entered_by',now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Member Add successfully');</script><script>window.location='medication2.php?patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}





//END RECORDS ACCESS WITOUT PATIENT PERMISSION//

//START TWO RECORDS ACCESS WITOUT PATIENT PERMISSION//
public static function patientAccessTWO($prescriptionid,$patientid,$adminid,$typevisit,$casetype,$note,$entered_by)
{
	$link=DBManager::connect();
	$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
		$created_at=date("Y/m/d");
	$sql="INSERT INTO accesspatient(accessid,prescriptionid,patientid,adminid,typevisit,casetype,note,entered_by,created_at) VALUES (NULL,'$prescriptionid','$patientid','$adminid','$typevisit','$casetype','$note','$entered_by','$created_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>window.location='profile.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}





//END TWO RECORDS ACCESS WITOUT PATIENT PERMISSION//




//START NEW  ADD AS PATIENT//

public static function createinhouse($ivid,$hospitalid,$scope,$sample_urgent,$sample_urgent_duration,$sample_normal,$sample_normal_duration,$report_urgent,$report_urgent_duration,$report_normal,$report_normal_duration,$rate,$entered_by)
{
	echo "";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	$sql="INSERT INTO create_inhouse(srno,ivid,hospitalid,scope,sample_urgent,sample_urgent_duration,sample_normal,sample_normal_duration,report_urgent,report_urgent_duration,report_normal,report_normal_duration,rate,entered_by,created_at,updated_at) VALUES (NULL,'$ivid','$hospitalid','$scope','$sample_urgent','$sample_urgent_duration','$sample_normal','$sample_normal_duration','$report_urgent','$report_urgent_duration','$report_normal','$report_normal_duration','$rate','$entered_by',now(),now())";
		$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Add successfully..');</script><script> window.history.go(-2)</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END NEW ADD AS PATIENT//


//START NEW  ADD AS PATIENT//

public static function createdailyinhouse($reportid,$admin_id,$frq,$report_to,$report_by,$entered_by)
{
	echo "";
	$link=DBManager::connect();
		$narayan=LoginManager::currentUser();
	$anilka=LoginManager::getUserTypeByuname("$narayan");
	$entered_by="$anilka";
	$sql="INSERT INTO dailyreport_inhouse(reportinhouseid,reportid,admin_id,frq,report_to,report_by,entered_by,created_at,updated_at) VALUES (NULL,'$reportid','$admin_id','$frq','$report_to','$report_by','$entered_by',now(),now())";
		$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Add successfully..');</script><script> window.history.go(-2)</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END NEW ADD AS PATIENT//


//Blood Requisition Form//



public static function bloodrequisition($prescriptionid,$patientid,$abo_rh,$units,$blgroup,$Address,$Ref_Dr,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
		   PatientManager::setActivityLog($patientid,"$prescriptionid","Blood Requisition","showinvestigation.php?prescriptionid=$prescriptionid&patientid=$patientid","$entered_by");
	$sql="INSERT INTO bloodrequisition(id,prescriptionid,patientid,abo_rh,units,blgroup,Address,Ref_Dr,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$abo_rh','$units','$blgroup','$Address','$Ref_Dr','$entered_by',now(),now())";
		$result=mysqli_query($link,$sql);
if($result)
echo "<script>window.location='treatment_timline.php?prescriptionid=$prescriptionid&patientid=$patientid';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//End Blood Requisition Form//


// START Histopathology//

public static function histopathology($prescriptionid,$patientid,$surgeryid,$Diagnosis,$specimen,$investigation,$Ref_Dr,$Containerno,$specimen_wt,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
		   PatientManager::setActivityLog($patientid,"$prescriptionid","Post-Operative Checklist<br>Histopathology","showpage_histopathology.php?prescriptionid=$prescriptionid&patientid=$patientid&srno=","$entered_by");
	$sql="INSERT INTO histopathology(id,prescriptionid,patientid,surgeryid,Diagnosis,specimen,investigation,Ref_Dr,Containerno,specimen_wt,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$surgeryid','$Diagnosis','$specimen','$investigation','$Ref_Dr','$Containerno','$specimen_wt','$entered_by',now(),now())";
		$result=mysqli_query($link,$sql);
if($result)
echo "<script>window.location='PostOperativeChecklistset.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END Histopathology//





// START Histopathology//

public static function SuspectedReaction($prescriptionid,$patientid,$surgeryid,$Minor,$Major,$Minor_Reaction,$Major_Reaction,$Specify,$otherAnswer,$otherAnswer_date,$Name_Medicine,$Treatment_Given,$Outcome,$Corrective_action,$Recovery_time,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
		   PatientManager::setActivityLog($patientid,$prescriptionid,"Post-Operative Checklist<br>Suspected Reaction","showpage_Suspected_Reaction.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid&srno=","$entered_by");
	$sql="INSERT INTO Suspected_Reaction(id,prescriptionid,patientid,surgeryid,Minor,Major,Minor_Reaction,Major_Reaction,Specify,otherAnswer,otherAnswer_date,Name_Medicine,Treatment_Given,Outcome,Corrective_action,Recovery_time,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$surgeryid','$Minor','$Major','$Minor_Reaction','$Major_Reaction','$Specify','$otherAnswer','$otherAnswer_date','$Name_Medicine','$Treatment_Given','$Outcome','$Corrective_action','$Recovery_time','$entered_by',now(),now())";
		$result=mysqli_query($link,$sql);
		
if($result)
echo "<script>window.location='PostOperativeChecklistset.php?prescriptionid=$prescriptionid&patientid=$patientid'&surgeryid='$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END Histopathology//

//Start Surgical Site Infection//
public static function surgicalsite($prescriptionid,$patientid,$Operation,$dateoperation,$Wound_Class,$Duration_Operation,$Starting_Date,$duration,$surgical_site_infection,$Infection_Site,$Sample_Collection,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
		   PatientManager::setActivityLog($patientid,"$prescriptionid","Surgical Site Infection","showinvestigation.php?prescriptionid=$prescriptionid&patientid=$patientid","$entered_by");
	$sql="INSERT INTO surgicalsite_infection(id,prescriptionid,patientid,Operation,dateoperation,Wound_Class,Duration_Operation,Starting_Date,duration,surgical_site_infection,Infection_Site,Sample_Collection,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Operation','$dateoperation','$Wound_Class','$Duration_Operation','$Starting_Date','$duration','$surgical_site_infection','$Infection_Site','$Sample_Collection','$entered_by',now(),now())";
		$result=mysqli_query($link,$sql);
if($result)
echo "<script>window.location='treatment_timline.php?prescriptionid=$prescriptionid&patientid=$patientid';</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//END Surgical Site Infection//


//Start Blood transfusion//
public static function bloodtransfusion($prescriptionid,$patientid,$blood,$Diagnosis,$Indications_Transfusion,$blood_group,$advers_reaction,$Blood_Bag_Number,$Products_Blood_Group,$product_name,$blood_bank_name,$date_of_expiry,$Blood_Checked_Doctor,$doctor_id_no,$Nurse_name,$Nurse_Id_No,$blood_start,$blood_stop,$Wt,$BP,$BP2,$Temp,$RBS,$Spo2,$HR,$Pulse,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	include("dbconnection.php");
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
		$updated_at=date("F d, Y / h:i:s A");
   $created_at=date("F d, Y / h:i:s A");
	
				PatientManager::vilalslog("$prescriptionid","$patientid","$Wt","$bmi","$BP","$BP2","$Temp","$RBS","$SPo2","unknown","$Pulse","Blood Transfusion Start","$entered_by");
	$sql="INSERT INTO bloodtransfusion(id,prescriptionid,patientid,blood,Diagnosis,Indications_Transfusion,blood_group,advers_reaction,Blood_Bag_Number,Products_Blood_Group,product_name,blood_bank_name,date_of_expiry,Blood_Checked_Doctor,doctor_id_no,Nurse_name,Nurse_Id_No,blood_start,blood_stop,Wt,BP,BP2,Temp,RBS,Spo2,HR,Pulse,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$blood','$Diagnosis','$Indications_Transfusion','$blood_group','$advers_reaction','$Blood_Bag_Number','$products_Blood_Group','$product_name','$blood_bank_name','$date_of_expiry','$Blood_Checked_Doctor','$doctor_id_no','$Nurse_name','$Nurse_Id_No','$blood_start','$blood_stop','$Wt','$BP','$BP2','$Temp','$RBS','$Spo2','$HR','$Pulse','$entered_by',now(),now())";
	$sql1 ="SELECT * FROM site_users WHERE userno='$harilal'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$prescriptionid' AND patientid='$patientid'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='8' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
    
	$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from bloodtransfusion";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","Tranfusion","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Blood Transfusion Start successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//Stop blood Transfusion//


//Start DIALYSIS//
public static function Dialysis($prescriptionid,$patientid,$Dialysis,$type,$Blood_Bag_Number,$Products_Blood_Group,$blood_bank_name,$date_of_expiry,$Blood_Checked_Doctor,$Nurse_name,$Dialysis_start,$Dialysis_stop,$Wt,$BP,$BP2,$Temp,$RBS,$Spo2,$HR,$Pulse,$Wtu,$BPu,$BP2u,$Tempu,$RBSu,$Spo2u,$HRu,$Pulseu,$entered_by)
{
	echo "";
	include("dbconnection.php");
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
$updated_at=date("F d, Y / h:i:s A");
$created_at=date("F d, Y / h:i:s A");
	PatientManager::vilalslog("$prescriptionid","$patientid","$Wt","$bmi","$BP","$BP2","$Temp","$RBS","$Spo2","$HR","$Pulse","Dialysis Start","$entered_by");
	$sql="INSERT INTO Dialysis(id,prescriptionid,patientid,Dialysis,type,Blood_Bag_Number,Products_Blood_Group,blood_bank_name,date_of_expiry,Blood_Checked_Doctor,Nurse_name,Dialysis_start,Dialysis_stop,Wt,BP,BP2,Temp,RBS,Spo2,HR,Pulse,Wtu,BPu,BP2u,Tempu,RBSu,Spo2u,HRu,Pulseu,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$Dialysis','$type','$Blood_Bag_Number','$products_Blood_Group','$blood_bank_name','$date_of_expiry','$Blood_Checked_Doctor','$Nurse_name','$Dialysis_start','$Dialysis_stop','$Wt','$BP','$BP2','$Temp','$RBS','$Spo2','$HR','$Pulse','$Wtu','$BPu','$BP2u','$Tempu','$RBSu','$Spo2u','$HRu','$Pulseu','$entered_by',now(),now())";
	$sql1 ="SELECT * FROM site_users WHERE userno='$harilal'";
		$qsql1 = mysqli_query($con,$sql1);
		if($re = mysqli_fetch_array($qsql1))
{
$sql56 ="SELECT * FROM request_for_admission WHERE prescriptionid='$_GET[prescriptionid]' AND patientid='$_GET[patientid]'";
		$qsql56 = mysqli_query($con,$sql56);
		while($rs56 = mysqli_fetch_array($qsql56))
		{
	$sql212 ="SELECT * FROM tarifrate WHERE tarifid='47' AND hospitalid='$re[entered_by]' AND wardid='$rs56[Ward]'";
$qsql212 = mysqli_query($con,$sql212);
if($rs112 = mysqli_fetch_array($qsql212))
{
    $subbill=$rs112[rate];
$result=mysqli_query($link,$sql);
	if(!$result)
	return false;
$sql ="select last_insert_id() from Dialysis";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$id=$row[0];
   PatientManager::billingLog("$patientid","$prescriptionid","Dialysis","$id","recordsinvace.php?prescriptionid=$prescriptionid&patientid=$patientid","$subbill","discount","grand_total","paymentmode","status","$entered_by");
}
}
}
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Dialysis Start successfully..');</script><script>window.location='nursingrecodstest.php?prescriptionid=$prescriptionid&patientid=$patientid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}

//END DIALYSIS//

// DOctors Visit//

public static function drvisit($Drname,$enteredby)
{
	echo "";
	$link=DBManager::connect();
	
	$sql="INSERT INTO drvisit(srno,Drname,entered_by,created_at,updated_at) VALUES (NULL, '$Drname','$enteredby',now(),now())";
    $result=mysqli_query($link,$sql);
	$link=DBManager::close($link);
}

//Doctars Visit//
//Add Vitals //

public static function vitals($patientid,$bp,$temp,$rr,$spo2,$hr,$rbs,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	$sql="INSERT INTO vitals(srno,patientid,bp,temp,rr,spo2,hr,rbs,entered_by,created_at,updated_at) VALUES (NULL, '$patientid','$bp','$temp','$rr','$spo2','$hr','$rbs','$entered_by',now(),now())";
    $result=mysqli_query($link,$sql);
	$link=DBManager::close($link);
}


//End Vitals//
//Start//
public static function preAssessmentSheet($prescriptionid,$patientid,$surgeryid,$Cough,$Wheezing,$Hypertension,$Diabetes,$Liverproblem,$Previous_Operation, $Smoking,$Migraine,$Pregnancy,$Bleeding_Disorder,$SOB,$Palpitation,$Chest_Pain,$Renal_Disease,$Allergies,$Alcohol,$Anesthesia_Problem,$Urination,$Back_Neck_Pain,$Arthritis,$Blackouts,$Muscie,$Weight_Loss_Gain,$hernia,$Pacemaker,$Artificial,$Resp_System,$Resp_System_note,$CVS_status,$CVS_status_note,$Dentures_status,$Dentures_status_note, $Dentures_status_lower,$Dentures_lower_note,$Mouth_Opening,$Mouth_Opening_note,$Neck_Mobility,$Neck_Mobility_note,$Venous_Access,$Venous_Access_note,$Nervous_System,$Nervous_System_note,$Abdomen_System,$Intubation_Difficulty,$Intubation_Difficulty_note,$Special_Anesthesia_Problems,$Special_Anesthesia_Problems_note,$PALLOR,$ICTERUS,$CYANOSIS,$LYMPHNODES,$JVP_RAISED,$TM_JOINT,$DENTAL_REACTION,$Abdomen_note,$Neck,$Neck_note,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	  PatientManager::setActivityLog($patientid,"$prescriptionid","Pre-Assessment Sheet<br>Routine Examination","showpage_Routine_Examination.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid&srno=","$entered_by");
	$sql="INSERT INTO Pre_Operative_Assessment_Sheet(srno,prescriptionid,patientid,surgeryid,Cough,Wheezing, Hypertension,Diabetes,Liverproblem,Previous_Operation, Smoking,Migraine,Pregnancy,Bleeding_Disorder,SOB, Palpitation,Chest_Pain,Renal_Disease,Allergies,Alcohol, Anesthesia_Problem,Urination,Back_Neck_Pain,Arthritis,Blackouts,Muscie,Weight_Loss_Gain,hernia,Pacemaker, Artificial,Resp_System,Resp_System_note,CVS_status,CVS_status_note,Dentures_status,Dentures_status_note, Dentures_status_lower,Dentures_lower_note,Mouth_Opening,Mouth_Opening_note, Neck_Mobility,Neck_Mobility_note,Venous_Access, Venous_Access_note,Nervous_System,Nervous_System_note, Abdomen_System,Intubation_Difficulty,Intubation_Difficulty_note, Special_Anesthesia_Problems,Special_Anesthesia_Problems_note,PALLOR,ICTERUS,CYANOSIS,LYMPHNODES,JVP_RAISED,TM_JOINT,DENTAL_REACTION,Abdomen_note,Neck,Neck_note,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid', '$patientid','$surgeryid','$Cough', '$Wheezing', '$Hypertension', '$Diabetes', '$Liverproblem', '$Previous_Operation', '$Smoking', '$Migraine', '$Pregnancy', '$Bleeding_Disorder', '$SOB', '$Palpitation', '$Chest_Pain', '$Renal_Disease', '$Allergies', '$Alcohol', '$Anesthesia_Problem', '$Urination', '$Back_Neck_Pain', '$Arthritis','$Blackouts', '$Muscie', '$Weight_Loss_Gain','$hernia', '$Pacemaker', '$Artificial', '$Resp_System','$Resp_System_note', '$CVS_status','$CVS_status_note', '$Dentures_status','$Dentures_status_note', '$Dentures_status_lower', '$Dentures_lower_note', '$Mouth_Opening', '$Mouth_Opening_note','$Neck_Mobility', '$Neck_Mobility_note', '$Venous_Access','$Venous_Access_note','$Nervous_System', '$Nervous_System_note','$Abdomen_System','$Intubation_Difficulty', '$Intubation_Difficulty_note','$Special_Anesthesia_Problems', '$Special_Anesthesia_Problems_note','$PALLOR','$ICTERUS','$CYANOSIS','$LYMPHNODES','$JVP_RAISED','$TM_JOINT','$DENTAL_REACTION','$Abdomen_note','$Neck','$Neck_note','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);

if($result)
echo "<script>alert('Routine Examination Add successfully');</script><script>window.location='PreOperativeAssessmentSheet.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//end//
//Start Login with OTP//

//Start Routine Information//
public static function RoutineInformation($prescriptionid,$patientid,$surgeryid,$Information_Obtained_from,$Date_of_Operative_procedure,$Time_of_Operative_procedure,$name_Surgeon,$Name_of_Anesthetist,$Pre_Operative_Diagnosis,$Systemic_Disease,$Systemic_Disease_note,$Anesthesia_Events,$Anesthesia_Events_note,$ho_Operations,$ho_Operations_note,$Adverse_Drugs_Reaction,$Adverse_Drugs_Reaction_note,$DRUG_THERAPY,$DRUG_THERAPY_note,$Duration_Surgery,$WRITTEN_CONSENT,$Ward,$Bed,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	  PatientManager::setActivityLog($patientid,"$prescriptionid","Pre-Assessment Sheet<br>Routine Information","showpage_Routine_Information.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid&srno=","$entered_by");
	 PatientManager::transferbedpatient("$prescriptionid","$Bed","$datetime");
	$sql="INSERT INTO Routine_Information(srno,prescriptionid,patientid,surgeryid,Information_Obtained_from,Date_of_Operative_procedure, Time_of_Operative_procedure,name_Surgeon,Name_of_Anesthetist, Pre_Operative_Diagnosis,Systemic_Disease,Systemic_Disease_note,Anesthesia_Events,Anesthesia_Events_note,ho_Operations,ho_Operations_note,Adverse_Drugs_Reaction,Adverse_Drugs_Reaction_note,DRUG_THERAPY,DRUG_THERAPY_note,Duration_Surgery,WRITTEN_CONSENT,Ward,Bed,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid', '$patientid','$surgeryid', '$Information_Obtained_from', '$Date_of_Operative_procedure', '$Time_of_Operative_procedure','$name_Surgeon', '$Name_of_Anesthetist','$Pre_Operative_Diagnosis','$Systemic_Disease','$Systemic_Disease_note','$Anesthesia_Events','$Anesthesia_Events_note','$ho_Operations','$ho_Operations_note','$Adverse_Drugs_Reaction','$Adverse_Drugs_Reaction_note','$DRUG_THERAPY','$DRUG_THERAPY_note','$Duration_Surgery','$WRITTEN_CONSENT','$Ward','$Bed','$entered_by',now(),now())";
	
		$result=mysqli_query($link,$sql);
	//	echo "$sql";
if($result)
//echo "save";
echo "<script>alert('Routine Information Add successfully');</script><script>window.location='PreOperativeAssessmentSheet.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//End Routine Information //



//Start Risk Assessment Status//
public static function RiskStatus($prescriptionid,$patientid,$surgeryid,$Fitness_Procedure,$Risk_Factors_Present,$Arranged_units_blood,$RequisitionForm,$abo_rh,$units,$group_name,$address,$Ref_Dr,$Nurse_Name,$Blood_Bag_Number,$Products_Blood_Group,$product_name,$blood_bank_name,$date_of_expiry,$Blood_Checked_Doctor,$doctor_id_no,$Plan_Action,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	  PatientManager::setActivityLog($patientid,"$prescriptionid","Pre-Assessment Sheet<br>Risk Assessment Status","showpage_Risk_Assessment_Status.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid&srno=","$entered_by");
	$sql="INSERT INTO Risk_Assessment_Status(srno,prescriptionid,patientid,surgeryid,Fitness_Procedure,Risk_Factors_Present,Arranged_units_blood, RequisitionForm,abo_rh,units,group_name,address,Ref_Dr,Nurse_Name ,Blood_Bag_Number,Products_Blood_Group,product_name,blood_bank_name ,date_of_expiry,Blood_Checked_Doctor,doctor_id_no,Plan_Action,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$surgeryid','$Fitness_Procedure','$Risk_Factors_Present','$Arranged_units_blood', '$RequisitionForm','$abo_rh','$units','$group_name','$address','$Ref_Dr','$Nurse_Name','$Blood_Bag_Number','$Products_Blood_Group','$product_name','$blood_bank_name','$date_of_expiry','$Blood_Checked_Doctor','$doctor_id_no','$Plan_Action','$entered_by',now(),now())";
		$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Risk Assessment Status Add successfully');</script><script>window.location='PreOperativeAssessmentSheet.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//End Risk Assessment Status//


//STAR PHYSICAL ASSEMENT//
//Start Routine Information//
public static function PhysicalAssessment($prescriptionid,$patientid,$surgeryid,$XYLOCAINE_SENSITIVITY,$Food_Intake,$PHYSICAL_STATUS,$Mallampati_Score,$Thyromental_Distance,$Metabolic_Score,$entered_by)
{
	echo "";
	$link=DBManager::connect();
$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;



	  PatientManager::setActivityLog($patientid,"$prescriptionid","Pre-Assessment Sheet<br>Pre Anesthesia evaluation","showpage_Physical_Assessment.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid&srno=","$entered_by");
	$sql="INSERT INTO Physical_Assessment(srno,prescriptionid,patientid,surgeryid,XYLOCAINE_SENSITIVITY,Food_Intake,PHYSICAL_STATUS,Mallampati_Score,Thyromental_Distance,Metabolic_Score,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid', '$patientid','$surgeryid','$XYLOCAINE_SENSITIVITY','$Food_Intake','$PHYSICAL_STATUS','$Mallampati_Score','$Thyromental_Distance','$Metabolic_Score','$entered_by',now(),now())";

	$result=mysqli_query($link,$sql);
if($result)

echo "<script>alert('Physical Assessment Add successfully');</script><script>window.location='PreOperativeAssessmentSheet.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//End Routine Information //



//Start Instruction Sheet Information//
public static function InstructionSheet($prescriptionid,$patientid,$surgeryid,$foodtake,$Anesthesia_Note,$entered_by)
{
	echo "";
	$link=DBManager::connect();
$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	  PatientManager::setActivityLog($patientid,"$prescriptionid","Pre-Assessment Sheet<br>Nursing Instruction","showpage_Nursing_Instruction_Sheet.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid&srno=","$entered_by");
	$sql="INSERT INTO Instruction_Sheet(srno,prescriptionid,patientid,surgeryid,foodtake,Anesthesia_Note,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid', '$patientid','$surgeryid','$foodtake','$Anesthesia_Note','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Nursing Instruction Sheet Add successfully');</script><script>window.location='PreOperativeAssessmentSheet.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//END Instruction Sheet//

//START CONFIRAMTION Post//

public static function PostConfirmationSheet($prescriptionid,$patientid,$surgeryid,$verify_pt_identity,$name_tag,$consent_form_signed,$Operation_consent,$operative_assessment,$Medical_fitness,$Last_meal,$Allergy_noted,$reports_checked,$entered_by)
{
	echo "";
	$link=DBManager::connect();
$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	  PatientManager::setActivityLog($patientid,"$prescriptionid","Post-Operative Checklist<br>Assessment","showpage_Postoperative_Confirmation_Sheet.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid&srno=","$entered_by");
	$sql="INSERT INTO post_Confirmation_Sheet(srno,prescriptionid,patientid,surgeryid,verify_pt_identity,name_tag,consent_form_signed,Operation_consent,operative_assessment,Medical_fitness,Last_meal,Allergy_noted,reports_checked,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$surgeryid','$verify_pt_identity','$name_tag','$consent_form_signed','$Operation_consent','$operative_assessment','$Medical_fitness','$Last_meal','$Allergy_noted','$reports_checked','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Post-Operative Checklist Add successfully');</script><script>window.location='PostOperativeChecklistset.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//END PRE CONFORMATION//



//START CONFIRAMTION PRE//

public static function ConfirmationSheet($prescriptionid,$patientid,$surgeryid,$verify_pt_identity,$time_surgery,$name_tag,$site_marked,$Operation_consent,$operative_assessment,$Medical_fitness,$Last_meal,$Bladder_voided,$topical_antibiotics,$Lab_investigation,$General_systematic,$infection_present,$Xylocaine_sensitivity,$Hospital_dress,$jewelry_removed,$Dentures_removed,$Hair_clips,$Allergy_noted,$Operation_site_marked,$reports_checked,$entered_by)
{
	echo "";
	$link=DBManager::connect();
$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	  PatientManager::setActivityLog($patientid,"$prescriptionid","Pre-Assessment Sheet<br>Confirmation Sheet","showpage_Preoperative_Confirmation_Sheet.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid&srno=","$entered_by");
	$sql="INSERT INTO Confirmation_Sheet(srno,prescriptionid,patientid,surgeryid,verify_pt_identity,time_surgery,name_tag,site_marked,Operation_consent,operative_assessment,Medical_fitness,Last_meal,Bladder_voided,topical_antibiotics,Lab_investigation,General_systematic,infection_present,Xylocaine_sensitivity,Hospital_dress,jewelry_removed,Dentures_removed,Hair_clips,Allergy_noted,Operation_site_marked,reports_checked,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$surgeryid','$verify_pt_identity','$time_surgery','$name_tag','$site_marked','$Operation_consent','$operative_assessment','$Medical_fitness','$Last_meal','$Bladder_voided','$topical_antibiotics','$Lab_investigation','$General_systematic','$infection_present','$Xylocaine_sensitivity','$Hospital_dress','$jewelry_removed','$Dentures_removed','$Hair_clips','$Allergy_noted','$Operation_site_marked','$reports_checked','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Pre-Operative Checklist Add successfully');</script><script>window.location='preoperativechecklist.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//END PRE CONFORMATION//


//START CONFIRAMTION PRE//

public static function BeforeConduction($prescriptionid,$patientid,$surgeryid,$Anesthesia_Safety,$Pulse_Oximeter,$Known_Allergy,$Difficult_Airways,$Risk_500,$entered_by)
{
	echo "";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	  PatientManager::setActivityLog($patientid,"$prescriptionid","Pre-Assessment Sheet<br>Before Conduction","showpage_Before_Conduction.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid&srno=","$entered_by");
	$sql="INSERT INTO Before_Conduction(srno,prescriptionid,patientid,surgeryid,Anesthesia_Safety,Pulse_Oximeter,Known_Allergy,Difficult_Airways,Risk_500,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$surgeryid','$Anesthesia_Safety','$Pulse_Oximeter','$Known_Allergy','$Difficult_Airways','$Risk_500','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Before Conduction Of Sign-In Add successfully');</script><script>window.location='preoperativechecklist.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//END PRE CONFORMATION//


//START OR Tray PRE//

public static function Ortrayce($prescriptionid,$patientid,$surgeryid,$sponege,$Sponge_Holder,$Gauge_and_Bandage,$Antiseptic,$BP_Handle,$Mop,$Towel,$Towel_Clip,$Long_forceps,$Small_Forceps,$Allis_forceps,$Mayo_Scissors,$Suture,$Cutting,$Needle_Holder,$Tooth_Forceps,$Doyens_Retractors,$Suction_Tube,$Cautery_pencil,$Right_angle_Forceps,$Tenaculum,$Kocher_Forceps,$Babcock,$Absorb_Suture,$Suture_V1,$Suture_V2,$Non_Absorb_Suture,$entered_by)
{
	echo "iuiuiuiouioui";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	  PatientManager::setActivityLog($patientid,"$prescriptionid","Pre-Assessment Sheet<br>Or Tray","showpage_ortraychecklist.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid&srno=","$entered_by");
	$sql="INSERT INTO ortray(srno,prescriptionid,patientid,surgeryid,sponege,Sponge_Holder,Gauge_and_Bandage,Antiseptic,BP_Handle,Mop,Towel,Towel_Clip,Long_forceps,Small_Forceps,Allis_forceps,Mayo_Scissors,Suture,Cutting,Needle_Holder,Tooth_Forceps,Doyens_Retractors,Suction_Tube,Cautery_pencil,Right_angle_Forceps,Tenaculum,Kocher_Forceps,Babcock,Absorb_Suture,Suture_V1,Suture_V2,Non_Absorb_Suture,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$surgeryid','$sponege','$Sponge_Holder','$Gauge_and_Bandage','$Antiseptic','$BP_Handle','$Mop','$Towel','$Towel_Clip','$Long_forceps','$Small_Forceps','$Allis_forceps','$Mayo_Scissors','$Suture','$Cutting','$Needle_Holder','$Tooth_Forceps','$Doyens_Retractors','$Suction_Tube','$Cautery_pencil','$Right_angle_Forceps','$Tenaculum','$Kocher_Forceps','$Babcock','$Absorb_Suture','$Suture_V1','$Suture_V2','$Non_Absorb_Suture','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('OR tray Checklist Add successfully');</script><script>window.location='preoperativechecklist.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//END PRE OR TRAY //




//START OR Tray PRE//

public static function Ortrayceout($prescriptionid,$patientid,$surgeryid,$sponege_out,$Sponge_Holder_out,$Gauge_and_Bandage_out,$Antiseptic_out,$BP_Handle_out,$Mop_out,$Towel_out,$Towel_Clip_out,$Long_forceps_out,$Small_Forceps_out,$Allis_forceps_out,$Mayo_Scissors_out,$Suture_out,$Cutting_out,$Needle_Holder_out,$Tooth_Forceps_out,$Doyens_Retractors_out,$Suction_Tube_out,$Cautery_pencil_out,$Right_angle_Forceps_out,$Tenaculum_out,$Kocher_Forceps_out,$Babcock_out,$Absorb_Suture_out,$Suture_V1_out,$Suture_V2_out,$Non_Absorb_Suture_out,$entered_by)
{
	echo "iuiuiuiouioui";
	$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	  PatientManager::setActivityLog($patientid,"$prescriptionid","Post-Operative Checklist<br>Or Tray Out","showpage_outortraychecklist.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid&srno=","$entered_by");
	$sql="INSERT INTO ortray_out(srno,prescriptionid,patientid,surgeryid,sponege_out,Sponge_Holder_out,Gauge_and_Bandage_out,Antiseptic_out,BP_Handle_out,Mop_out,Towel_out,Towel_Clip_out,Long_forceps_out,Small_Forceps_out,Allis_forceps_out,Mayo_Scissors_out,Suture_out,Cutting_out,Needle_Holder_out,Tooth_Forceps_out,Doyens_Retractors_out,Suction_Tube_out,Cautery_pencil_out,Right_angle_Forceps_out,Tenaculum_out,Kocher_Forceps_out,Babcock_out,Absorb_Suture_out,Suture_V1_out,Suture_V2_out,Non_Absorb_Suture_out,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$surgeryid','$sponege_out','$Sponge_Holder_out','$Gauge_and_Bandage_out','$Antiseptic_out','$BP_Handle_out','$Mop_out','$Towel_out','$Towel_Clip_out','$Long_forceps_out','$Small_Forceps_out','$Allis_forceps_out','$Mayo_Scissors_out','$Suture_out','$Cutting_out','$Needle_Holder_out','$Tooth_Forceps_out','$Doyens_Retractors_out','$Suction_Tube_out','$Cautery_pencil_out','$Right_angle_Forceps_out','$Tenaculum_out','$Kocher_Forceps_out','$Babcock_out','$Absorb_Suture_out','$Suture_V1_out','$Suture_V2_out','$Non_Absorb_Suture_out','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('OR tray Out Add successfully');</script><script>window.location='PostOperativeChecklistset.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}



//END PRE OR TRAY //






//Start Instruction Sheet Information//
public static function OperationCare($prescriptionid,$patientid,$surgeryid,$Analgesia_Plan,$Analgesia_Plan_Note,$entered_by)
{
	echo "";
	$link=DBManager::connect();
$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;

 PatientManager::setActivityLog($patientid,"$prescriptionid","Pre-Assessment Sheet<br>OperationCare","showpage_Operation_Care.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid&srno=","$entered_by");
	$sql="INSERT INTO Operation_Plan(srno,prescriptionid,patientid,surgeryid,Analgesia_Plan,Analgesia_Plan_Note,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid', '$patientid','$surgeryid','$Analgesia_Plan','$Analgesia_Plan_Note','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Operation Plan Add successfully');</script><script>window.location='PreOperativeAssessmentSheet.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//END Instruction Sheet//



//Start Instruction Sheet Information//
public static function dailyreport($Reporting_By,$Query,$Reply,$entered_by)
{
	echo "";
	$link=DBManager::connect();
$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	$sql="INSERT INTO daily_report(id,Reporting_By,Query,Reply,entered_by,created_at) VALUES (NULL,'$Reporting_By','$Query','$Reply','$entered_by','$created_at')";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Daily Report Add successfully');</script><script>window.location='daily_report.php'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//END Instruction Sheet//




//Start Patient Leaves //
public static function PatientLeaves($prescriptionid,$patientid,$surgeryid,$Verbally_Confirmed,$Procedure_Recorded,$Specimen_Labeled,$infection_present,$Equipment_Problems,$Detail,$Review_Key,$Prognosis_Explained,$entered_by)
{
	echo "";
	$link=DBManager::connect();
$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;

 PatientManager::setActivityLog($patientid,"$prescriptionid","Post-Operative Checklist<br>Patient Leaves","showpage_Patient_Leaves.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid&srno=","$entered_by");
	$sql="INSERT INTO Patient_Leaves(srno,prescriptionid,patientid,surgeryid,Verbally_Confirmed,Procedure_Recorded,Specimen_Labeled,infection_present,Equipment_Problems,Detail,Review_Key,Prognosis_Explained,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid','$patientid','$surgeryid','$Verbally_Confirmed','$Procedure_Recorded','$Specimen_Labeled','$infection_present','$Equipment_Problems','$Detail','$Review_Key','$Prognosis_Explained','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Before Patient Leaves Add successfully');</script><script>window.location='PostOperativeChecklistset.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}
//END Patient Leaves//




//Start Systemic Examination Information//
public static function SystemicExamination($prescriptionid,$patientid,$surgeryid,$Systemic_Disease,$Systemic_Disease_note,$Anesthesia_Events,$Anesthesia_Events_note,$ho_Operations,$ho_Operations_note,$Adverse_Drugs_Reaction,$Adverse_Drugs_Reaction_note,$DRUG_THERAPY,$DRUG_THERAPY_note,$HISTORY_CHEST_PAIN,$HISTORY_PALPITATION,$HISTORY_HYPERTENTION,$S1_S2,$MURMUR,$ECG_REPORT,$ENTER_LUNGS,$CREPITATIONS_WHEEZ,$HISTORY_COUGH,$HISTORY_BRONCHIAL,$HISTORY_REPAIRATORY,$PULMONARY_TEST,$CARDIAO_VASCULAR_note,$HISTORY_CONVULSION,$HISTORY_TREMOR,$HISTORY_GI_BLEEDING,$NEUROLOGICAL_DISEASE,$CENTRAL_NERVOUS_note,$HEART_BURN,$OTHER_DISEASE,$LIVER_FUNCTION_TEST,$GASTRO_INTESTINAL_note,$HISTORY_DM,$HISTORY_HYPER,$HARMONAL_ABNORMALITY,$ENDOCRINE_SYSTEM_note,$HISTORY_HAEMATURIA,$HISTORY_UTI,$HISTORY_STD,$RENAL_PROBLEM,$GENITO_URINARY_note,$respiratory_system_note,$entered_by)
{
	echo "";
	$link=DBManager::connect();
$link=DBManager::connect();
	  $narayan=LoginManager::currentUser();
$harilal=LoginManager::getUserTypeByuname("$narayan");
$entered_by=$harilal;
	  PatientManager::setActivityLog($patientid,"$prescriptionid","Pre-Assessment Sheet<br>Systemic Examination","showpage_Systemic_Examination.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid&srno=","$entered_by");
	$sql="INSERT INTO Systemic_Examination(srno,prescriptionid,patientid,surgeryid,Systemic_Disease,Systemic_Disease_note,Anesthesia_Events,Anesthesia_Events_note,ho_Operations,ho_Operations_note,Adverse_Drugs_Reaction,Adverse_Drugs_Reaction_note,DRUG_THERAPY,DRUG_THERAPY_note,HISTORY_CHEST_PAIN,HISTORY_PALPITATION,HISTORY_HYPERTENTION,S1_S2,MURMUR,ECG_REPORT,ENTER_LUNGS,CREPITATIONS_WHEEZ,HISTORY_COUGH,HISTORY_BRONCHIAL,HISTORY_REPAIRATORY,PULMONARY_TEST,CARDIAO_VASCULAR_note,HISTORY_CONVULSION,HISTORY_TREMOR,HISTORY_GI_BLEEDING,NEUROLOGICAL_DISEASE,CENTRAL_NERVOUS_note,HEART_BURN,OTHER_DISEASE,LIVER_FUNCTION_TEST,GASTRO_INTESTINAL_note,HISTORY_DM,HISTORY_HYPER,HARMONAL_ABNORMALITY,ENDOCRINE_SYSTEM_note,HISTORY_HAEMATURIA,HISTORY_UTI,HISTORY_STD,RENAL_PROBLEM,GENITO_URINARY_note,respiratory_system_note,entered_by,created_at,updated_at) VALUES (NULL,'$prescriptionid', '$patientid','$surgeryid','$Systemic_Disease','$Systemic_Disease_note','$Anesthesia_Events','$Anesthesia_Events_note','$ho_Operations','$ho_Operations_note','$Adverse_Drugs_Reaction','$Adverse_Drugs_Reaction_note','$DRUG_THERAPY','$DRUG_THERAPY_note','$HISTORY_CHEST_PAIN','$HISTORY_PALPITATION','$HISTORY_HYPERTENTION','$S1_S2','$MURMUR','$ECG_REPORT','$ENTER_LUNGS','$CREPITATIONS_WHEEZ','$HISTORY_COUGH','$HISTORY_BRONCHIAL','$HISTORY_REPAIRATORY','$PULMONARY_TEST','$CARDIAO_VASCULAR_note','$HISTORY_CONVULSION','$HISTORY_TREMOR','$HISTORY_GI_BLEEDING','$NEUROLOGICAL_DISEASE','$CENTRAL_NERVOUS_note','$HEART_BURN','$OTHER_DISEASE','$LIVER_FUNCTION_TEST','$GASTRO_INTESTINAL_note','$HISTORY_DM','$HISTORY_HYPER','$HARMONAL_ABNORMALITY','$ENDOCRINE_SYSTEM_note','$HISTORY_HAEMATURIA','$HISTORY_UTI','$HISTORY_STD','$RENAL_PROBLEM','$GENITO_URINARY_note','$respiratory_system_note','$entered_by',now(),now())";
	$result=mysqli_query($link,$sql);
if($result)
echo "<script>alert('Systemic Examination Add successfully');</script><script>window.location='PreOperativeAssessmentSheet.php?prescriptionid=$prescriptionid&patientid=$patientid&surgeryid=$surgeryid'</script>;</script>";
else 
	echo "Fail";
	$link=DBManager::close($link);
}


//End Systemic_Examination Information //


public function Familylogin($uname,$password)
{
$verifyresult=LoginManager::checkdrunameandpassword($uname,$password);
if(!$verifyresult)
	return false;
$_SESSION['uname']=$uname;
$_SESSION['userno']=$userno;
$usertype=LoginManager::getUserTypeByuname($uname);
$_SESSION['usertype']=$usertype;
$userhomepage=LoginManager::$userhomepage;
header("location: $userhomepage");
return true;
}	

public function checkdrunameandpassword($uname,$password)
{
$link=DBManager::connect();
$sql = "SELECT * FROM site_users WHERE uname='$uname' AND password='$password' AND usertype='Family'";
	$qsql = mysqli_query($link,$sql);
	if(mysqli_num_rows($qsql) == 1)
	{
		return true;
	}
else
	return false;

}
// END Login With OTP//


//Registation Site User//

public static function registerUser($uname,$name,$numbers,$usertype,$password,$status,$entered_by)
{
	
$link=DBManager::connect();
$userkey=PatientManager::getRandomkey();
$password=rand(10000, 99999);
$user_otp = rand(100000, 999999);
$user_activation_code = md5(rand());
$sql="INSERT INTO site_users(userno,uname,name,numbers,usertype,status,password,userkey,user_otp,user_activation_code,entered_by,created_at,updated_at) VALUES (NULL, '$uname', '$name', '$numbers', '$usertype', '$status','$password', '$userkey','$user_otp','$user_activation_code','$entered_by', now(), now());";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$sql ="select last_insert_id() from site_users";
$result=mysqli_query($link,$sql);
if(!$result)
	return false;
$row=mysqli_fetch_row($result);
$userno=$row[0];
  PatientManager::setActivityLog($userno,"$noknow","User registered","showinvestigation.php?prescriptionid=$prescriptionid&patientid=$patientid","$entered_by");
return $userno;
}
public static function getUserTypeByuname($uname)
{

$link=DBManager::connect();
$sql="select usertype from site_users where uname='$uname'";
$result=mysqli_query($link,$sql);
$row=mysqli_fetch_row($result);

return $row[0];

	
}

public static function protectAdminPage()
{
	if(PatientManager::isAdminLoggedIn())
		return true;
	else
	{
		$loginpage=PatientManager::$loginpage;
		header("location: $loginpage");
return false;		
	}
}

public static function protectPage()
{
	if(PatientManager::isUserLoggedIn())
		return true;
	else
	{
		$adminhomepage=PatientManager::$adminhomepage;
		header("location: $adminhomepage");
return false;		
	}
}



public static function currentUser()
{
	if(isset($_SESSION['uname']))
		return $_SESSION['uname'];
	else
		return "";
	//header("location: index.php");
}

public static function logout()
{
	unset($_SESSION['uname']);
	//header("location: index.php");
}

public static function isAdminLoggedIn()
{
	if(!PatientManager::isUserLoggedIn())
	return false;
$usertype=$_SESSION['usertype'];
if($usertype="admin");
return true;
return false;
}

public static function isUserLoggedIn()
{
	if(isset($_SESSION['uname']))
		return true;
	return false;
}

public function doLogin($uname,$password)
{
$verifyresult=PatientManager::checkunameAndPassword($uname,$password);
if(!$verifyresult)
	return false;
$_SESSION['uname']=$uname;
$usertype=PatientManager::getUserTypeByuname($uname);
$_SESSION['usertype']=$usertype;
$userhomepage=PatientManager::$userhomepage;
header("location: $userhomepage");
return true;
}	

public function checkunameAndPassword($uname,$password)
{
$link=DBManager::connect();
$sql = "SELECT * FROM site_users WHERE uname='$uname' AND password='$password'";
	$qsql = mysqli_query($link,$sql);
	if(mysqli_num_rows($qsql) == 1)
	{
		return true;
	}
else
	return false;

}


//Login with otp//

public function otplogin($uname,$password)
{
$verifyresult=PatientManager::checkotp($user_otp,$user_activation_code);
if(!$verifyresult)
	return false;
$_SESSION['uname']=$uname;
$usertype=PatientManager::getUserTypeByuname($user_otp);
$_SESSION['usertype']=$usertype;
$userhomepage=PatientManager::$userhomepage;
header("location: $userhomepage");
return true;
}	

public function checkotp($user_otp,$user_activation_code)
{
$link=DBManager::connect();
$sql = "SELECT * FROM site_users WHERE user_otp='$user_otp' AND user_activation_code='$user_activation_code'";
	$qsql = mysqli_query($link,$sql);
	if(mysqli_num_rows($qsql) == 1)
	{
		return true;
	}
else
	return false;

}


}
//Eng Login With OTP//


?>

Anon7 - 2022
AnonSec Team