<?php 
session_start();
include_once '../config.php';
$user_id = $_SESSION['Admin']['id'];
$CurrDate = date('dmY');
if($_REQUEST['action'] == 'Save'){
$MrdNo = addslashes(trim($_REQUEST['MrdNo']));
$VisitNo = addslashes(trim($_REQUEST['VisitNo']));
$VisitDate = addslashes(trim($_REQUEST['VisitDate']));
$PatientName = addslashes(trim($_REQUEST['PatientName']));
$ChkReNormal = $_REQUEST['ChkReNormal'];
$ChkLeNormal = $_REQUEST['ChkLeNormal'];
$ReOcMov = addslashes(trim($_REQUEST['ReOcMov']));
$LeOcMov = addslashes(trim($_REQUEST['LeOcMov']));
$ReLids = addslashes(trim($_REQUEST['ReLids']));
$LeLids = addslashes(trim($_REQUEST['LeLids']));
$ReConj = addslashes(trim($_REQUEST['ReConj']));
$LeConj = addslashes(trim($_REQUEST['LeConj']));
$ReCornea = addslashes(trim($_REQUEST['ReCornea']));
$LeCornea = addslashes(trim($_REQUEST['LeCornea']));
$ReCorneaRemark = addslashes(trim($_REQUEST['ReCorneaRemark']));
$LeCorneaRemark = addslashes(trim($_REQUEST['LeCorneaRemark']));
$ReAntChamber = addslashes(trim($_REQUEST['ReAntChamber']));
$LeAntChamber = addslashes(trim($_REQUEST['LeAntChamber']));
$ReIris = addslashes(trim($_REQUEST['ReIris']));
$LeIris = addslashes(trim($_REQUEST['LeIris']));
$RePupil = addslashes(trim($_REQUEST['RePupil']));
$LePupil = addslashes(trim($_REQUEST['LePupil']));
$ReIop = addslashes(trim($_REQUEST['ReIop']));
$LeIop = addslashes(trim($_REQUEST['LeIop']));
$ReLens = addslashes(trim($_REQUEST['ReLens']));
$LeLens = addslashes(trim($_REQUEST['LeLens']));
$ReLens2 = addslashes(trim($_REQUEST['ReLens2']));
$LeLens2 = addslashes(trim($_REQUEST['LeLens2']));
$ReNlp = addslashes(trim($_REQUEST['ReNlp']));
$LeNlp = addslashes(trim($_REQUEST['LeNlp']));
$ChkReHazy = addslashes(trim($_REQUEST['ChkReHazy']));
$ChkLeHazy = addslashes(trim($_REQUEST['ChkLeHazy']));
$ReMedia = addslashes(trim($_REQUEST['ReMedia']));
$LeMedia = addslashes(trim($_REQUEST['LeMedia']));
$ReOptDisc = addslashes(trim($_REQUEST['ReOptDisc']));
$LeOptDisc = addslashes(trim($_REQUEST['LeOptDisc']));
$ReMacBV = addslashes(trim($_REQUEST['ReMacBV']));
$LeMacBV = addslashes(trim($_REQUEST['LeMacBV']));
$ReMidPerPh = addslashes(trim($_REQUEST['ReMidPerPh']));
$LeMidPerPh = addslashes(trim($_REQUEST['LeMidPerPh']));
$InvStName = addslashes(trim($_REQUEST['InvStName']));
$InvStBy = addslashes(trim($_REQUEST['InvStBy']));
$CounCellingBy = addslashes(trim($_REQUEST['CounCellingBy']));
$Diagnosis = addslashes(trim($_REQUEST['Diagnosis']));
$Treatment = addslashes(trim($_REQUEST['Treatment']));
$TreatChk1 = $_REQUEST['TreatChk1'];
$TreatType1 = addslashes(trim($_REQUEST['TreatType1']));
$TreatName1 = addslashes(trim($_REQUEST['TreatName1']));
$TreatDose1 = addslashes(trim($_REQUEST['TreatDose1']));
$TreatFreq1 = addslashes(trim($_REQUEST['TreatFreq1']));
$TreatDur1 = addslashes(trim($_REQUEST['TreatDur1']));
$TreatEye1 = addslashes(trim($_REQUEST['TreatEye1']));

$TreatChk2 = $_REQUEST['TreatChk2'];
$TreatType2 = addslashes(trim($_REQUEST['TreatType2']));
$TreatName2 = addslashes(trim($_REQUEST['TreatName2']));
$TreatDose2 = addslashes(trim($_REQUEST['TreatDose2']));
$TreatFreq2 = addslashes(trim($_REQUEST['TreatFreq2']));
$TreatDur2 = addslashes(trim($_REQUEST['TreatDur2']));
$TreatEye2 = addslashes(trim($_REQUEST['TreatEye2']));

$TreatChk3 = $_REQUEST['TreatChk3'];
$TreatType3 = addslashes(trim($_REQUEST['TreatType3']));
$TreatName3 = addslashes(trim($_REQUEST['TreatName3']));
$TreatDose3 = addslashes(trim($_REQUEST['TreatDose3']));
$TreatFreq3 = addslashes(trim($_REQUEST['TreatFreq3']));
$TreatDur3 = addslashes(trim($_REQUEST['TreatDur3']));
$TreatEye3 = addslashes(trim($_REQUEST['TreatEye3']));

$TreatChk4 = $_REQUEST['TreatChk4'];
$TreatType4 = addslashes(trim($_REQUEST['TreatType4']));
$TreatName4 = addslashes(trim($_REQUEST['TreatName4']));
$TreatDose4 = addslashes(trim($_REQUEST['TreatDose4']));
$TreatFreq4 = addslashes(trim($_REQUEST['TreatFreq4']));
$TreatDur4 = addslashes(trim($_REQUEST['TreatDur4']));
$TreatEye4 = addslashes(trim($_REQUEST['TreatEye4']));

$TreatChk5 = $_REQUEST['TreatChk5'];
$TreatType5 = addslashes(trim($_REQUEST['TreatType5']));
$TreatName5 = addslashes(trim($_REQUEST['TreatName5']));
$TreatDose5 = addslashes(trim($_REQUEST['TreatDose5']));
$TreatFreq5 = addslashes(trim($_REQUEST['TreatFreq5']));
$TreatDur5 = addslashes(trim($_REQUEST['TreatDur5']));
$TreatEye5 = addslashes(trim($_REQUEST['TreatEye5']));

$TreatChk6 = $_REQUEST['TreatChk6'];
$TreatType6 = addslashes(trim($_REQUEST['TreatType6']));
$TreatName6 = addslashes(trim($_REQUEST['TreatName6']));
$TreatDose6 = addslashes(trim($_REQUEST['TreatDose6']));
$TreatFreq6 = addslashes(trim($_REQUEST['TreatFreq6']));
$TreatDur6 = addslashes(trim($_REQUEST['TreatDur6']));
$TreatEye6 = addslashes(trim($_REQUEST['TreatEye6']));

$TreatChk7 = $_REQUEST['TreatChk7'];
$TreatType7 = addslashes(trim($_REQUEST['TreatType7']));
$TreatName7 = addslashes(trim($_REQUEST['TreatName7']));
$TreatDose7 = addslashes(trim($_REQUEST['TreatDose7']));
$TreatFreq7 = addslashes(trim($_REQUEST['TreatFreq7']));
$TreatDur7 = addslashes(trim($_REQUEST['TreatDur7']));
$TreatEye7 = addslashes(trim($_REQUEST['TreatEye7']));

$TreatChk8 = $_REQUEST['TreatChk8'];
$TreatType8 = addslashes(trim($_REQUEST['TreatType8']));
$TreatName8 = addslashes(trim($_REQUEST['TreatName8']));
$TreatDose8 = addslashes(trim($_REQUEST['TreatDose8']));
$TreatFreq8 = addslashes(trim($_REQUEST['TreatFreq8']));
$TreatDur8 = addslashes(trim($_REQUEST['TreatDur8']));
$TreatEye8 = addslashes(trim($_REQUEST['TreatEye8']));

$TreatChk9 = $_REQUEST['TreatChk9'];
$TreatType9 = addslashes(trim($_REQUEST['TreatType9']));
$TreatName9 = addslashes(trim($_REQUEST['TreatName9']));
$TreatDose9 = addslashes(trim($_REQUEST['TreatDose9']));
$TreatFreq9 = addslashes(trim($_REQUEST['TreatFreq9']));
$TreatDur9 = addslashes(trim($_REQUEST['TreatDur9']));
$TreatEye9 = addslashes(trim($_REQUEST['TreatEye9']));

$TreatChk10 = $_REQUEST['TreatChk10'];
$TreatType10 = addslashes(trim($_REQUEST['TreatType10']));
$TreatName10 = addslashes(trim($_REQUEST['TreatName10']));
$TreatDose10 = addslashes(trim($_REQUEST['TreatDose10']));
$TreatFreq10 = addslashes(trim($_REQUEST['TreatFreq10']));
$TreatDur10 = addslashes(trim($_REQUEST['TreatDur10']));
$TreatEye10 = addslashes(trim($_REQUEST['TreatEye10']));

$TreatChk11 = $_REQUEST['TreatChk11'];
$TreatType11 = addslashes(trim($_REQUEST['TreatType11']));
$TreatName11 = addslashes(trim($_REQUEST['TreatName11']));
$TreatDose11 = addslashes(trim($_REQUEST['TreatDose11']));
$TreatFreq11 = addslashes(trim($_REQUEST['TreatFreq11']));
$TreatDur11 = addslashes(trim($_REQUEST['TreatDur11']));
$TreatEye11 = addslashes(trim($_REQUEST['TreatEye11']));

$TreatChk12 = $_REQUEST['TreatChk12'];
$TreatType12 = addslashes(trim($_REQUEST['TreatType12']));
$TreatName12 = addslashes(trim($_REQUEST['TreatName12']));
$TreatDose12 = addslashes(trim($_REQUEST['TreatDose12']));
$TreatFreq12 = addslashes(trim($_REQUEST['TreatFreq12']));
$TreatDur12 = addslashes(trim($_REQUEST['TreatDur12']));
$TreatEye12 = addslashes(trim($_REQUEST['TreatEye12']));

$TreatChk13 = $_REQUEST['TreatChk13'];
$TreatType13 = addslashes(trim($_REQUEST['TreatType13']));
$TreatName13 = addslashes(trim($_REQUEST['TreatName13']));
$TreatDose13 = addslashes(trim($_REQUEST['TreatDose13']));
$TreatFreq13 = addslashes(trim($_REQUEST['TreatFreq13']));
$TreatDur13 = addslashes(trim($_REQUEST['TreatDur13']));
$TreatEye13 = addslashes(trim($_REQUEST['TreatEye13']));

$Advice = addslashes(trim($_REQUEST['Advice']));
$Remark = addslashes(trim($_REQUEST['Remark']));
$ChkDilate = addslashes(trim($_REQUEST['ChkDilate']));
$ChkCatProfile = addslashes(trim($_REQUEST['ChkCatProfile']));
$ChkLasikProfile = addslashes(trim($_REQUEST['ChkLasikProfile']));

$Checked = $_REQUEST['Checked'];

$CreatedDate = date('Y-m-d');
$CreatedTime = date('H:i:s');
$VisitDate2 = date("d/m/Y", strtotime(str_replace('-', '/',$VisitDate)));
$Status = 1;
$ModifiedBy = 0;
$ModifiedDate = null;

$sql3 = "SELECT * FROM tbl_consultants WHERE MrdNo='$MrdNo' AND VisitDate='$VisitDate'";
$rncnt3 = getRow($sql3);
if($rncnt3 > 0){
	$sql = "UPDATE tbl_consultants SET ChkReNormal='$ChkReNormal',ChkLeNormal='$ChkLeNormal',ReOcMov='$ReOcMov',LeOcMov='$LeOcMov',ReLids='$ReLids',LeLids='$LeLids',ReConj='$ReConj',LeConj='$LeConj',ReCornea='$ReCornea',LeCornea='$LeCornea',ReCorneaRemark='$ReCorneaRemark',LeCorneaRemark='$LeCorneaRemark',ReAntChamber='$ReAntChamber',LeAntChamber='$LeAntChamber',ReIris='$ReIris',LeIris='$LeIris',RePupil='$RePupil',LePupil='$LePupil',ReIop='$ReIop',LeIop='$LeIop',ReLens='$ReLens',LeLens='$LeLens',ReLens2='$ReLens2',LeLens2='$LeLens2',ReNlp='$ReNlp',LeNlp='$LeNlp',ChkReHazy='$ChkReHazy',ChkLeHazy='$ChkLeHazy',ReMedia='$ReMedia',LeMedia='$LeMedia',ReOptDisc='$ReOptDisc',LeOptDisc='$LeOptDisc',ReMacBV='$ReMacBV',LeMacBV='$LeMacBV',ReMidPerPh='$ReMidPerPh',LeMidPerPh='$LeMidPerPh',InvStName='$InvStName',InvStBy='$InvStBy',CounCellingBy='$CounCellingBy',Diagnosis='$Diagnosis',Treatment='$Treatment',TreatChk1='$TreatChk1',TreatType1='$TreatType1',TreatName1='$TreatName1',TreatDose1='$TreatDose1',TreatFreq1='$TreatFreq1',TreatDur1='$TreatDur1',TreatEye1='$TreatEye1',TreatChk2='$TreatChk2',TreatType2='$TreatType2',TreatName2='$TreatName2',TreatDose2='$TreatDose2',TreatFreq2='$TreatFreq2',TreatDur2='$TreatDur2',TreatEye2='$TreatEye2',TreatChk3='$TreatChk3',TreatType3='$TreatType3',TreatName3='$TreatName3',TreatDose3='$TreatDose3',TreatFreq3='$TreatFreq3',TreatDur3='$TreatDur3',TreatEye3='$TreatEye3',TreatChk4='$TreatChk4',TreatType4='$TreatType4',TreatName4='$TreatName4',TreatDose4='$TreatDose4',TreatFreq4='$TreatFreq4',TreatDur4='$TreatDur4',TreatEye4='$TreatEye4',TreatChk5='$TreatChk5',TreatType5='$TreatType5',TreatName5='$TreatName5',TreatDose5='$TreatDose5',TreatFreq5='$TreatFreq5',TreatDur5='$TreatDur5',TreatEye5='$TreatEye5',TreatChk6='$TreatChk6',TreatType6='$TreatType6',TreatName6='$TreatName6',TreatDose6='$TreatDose6',TreatFreq6='$TreatFreq6',TreatDur6='$TreatDur6',TreatEye6='$TreatEye6',TreatChk7='$TreatChk7',TreatType7='$TreatType7',TreatName7='$TreatName7',TreatDose7='$TreatDose7',TreatFreq7='$TreatFreq7',TreatDur7='$TreatDur7',TreatEye7='$TreatEye7',TreatChk8='$TreatChk8',TreatType8='$TreatType8',TreatName8='$TreatName8',TreatDose8='$TreatDose8',TreatFreq8='$TreatFreq8',TreatDur8='$TreatDur8',TreatEye8='$TreatEye8',TreatChk9='$TreatChk9',TreatType9='$TreatType9',TreatName9='$TreatName9',TreatDose9='$TreatDose9',TreatFreq9='$TreatFreq9',TreatDur9='$TreatDur9',TreatEye9='$TreatEye9',TreatChk10='$TreatChk10',TreatType10='$TreatType10',TreatName10='$TreatName10',TreatDose10='$TreatDose10',TreatFreq10='$TreatFreq10',TreatDur10='$TreatDur10',TreatEye10='$TreatEye10',TreatChk11='$TreatChk11',TreatType11='$TreatType11',TreatName11='$TreatName11',TreatDose11='$TreatDose11',TreatFreq11='$TreatFreq11',TreatDur11='$TreatDur11',TreatEye11='$TreatEye11',TreatChk12='$TreatChk12',TreatType12='$TreatType12',TreatName12='$TreatName12',TreatDose12='$TreatDose12',TreatFreq12='$TreatFreq12',TreatDur12='$TreatDur12',TreatEye12='$TreatEye12',TreatChk13='$TreatChk13',TreatType13='$TreatType13',TreatName13='$TreatName13',TreatDose13='$TreatDose13',TreatFreq13='$TreatFreq13',TreatDur13='$TreatDur13',TreatEye13='$TreatEye13',Advice='$Advice',Remark='$Remark',ChkDilate='$ChkDilate',ChkCatProfile='$ChkCatProfile',ChkLasikProfile='$ChkLasikProfile',ModifiedBy='$user_id',ModifiedDate='$CreatedDate' WHERE MrdNo='$MrdNo' AND VisitDate='$VisitDate'";
$conn->query($sql);

$sql2 = "UPDATE tbl_queue_managements SET Checked='1',OutTime='$CreatedTime' WHERE MrdNo='$MrdNo' AND InDate='$VisitDate'";
$conn->query($sql2);
echo "<script>alert('Record Saved Successfully!');window.location.href='../consultantform.php?mrd=$MrdNo&visitdate=$VisitDate';</script>";
}
else{
/*$sql = "INSERT INTO tbl_consultants SET MrdNo='$MrdNo',VisitNo='$VisitNo',VisitDate='$VisitDate',PatientName='$PatientName',ChkReNormal='$ChkReNormal',ChkLeNormal='$ChkLeNormal',ReOcMov='$ReOcMov',LeOcMov='$LeOcMov',ReLids='$ReLids',LeLids='$LeLids',ReConj='$ReConj',LeConj='$LeConj',ReCornea='$ReCornea',LeCornea='$LeCornea',ReCorneaRemark='$ReCorneaRemark',LeCorneaRemark='$LeCorneaRemark',ReAntChamber='$ReAntChamber',LeAntChamber='$LeAntChamber',ReIris='$ReIris',LeIris='$LeIris',RePupil='$RePupil',LePupil='$LePupil',ReIop='$ReIop',LeIop='$LeIop',ReLens='$ReLens',LeLens='$LeLens',ReLens2='$ReLens2',LeLens2='$LeLens2',ReNlp='$ReNlp',LeNlp='$LeNlp',ChkReHazy='$ChkReHazy',ChkLeHazy='$ChkLeHazy',ReMedia='$ReMedia',LeMedia='$LeMedia',ReOptDisc='$ReOptDisc',LeOptDisc='$LeOptDisc',ReMacBV='$ReMacBV',LeMacBV='$LeMacBV',ReMidPerPh='$ReMidPerPh',LeMidPerPh='$LeMidPerPh',InvStName='$InvStName',InvStBy='$InvStBy',CounCellingBy='$CounCellingBy',Diagnosis='$Diagnosis',Treatment='$Treatment',TreatChk1='$TreatChk1',TreatType1='$TreatType1',TreatName1='$TreatName1',TreatDose1='$TreatDose1',TreatFreq1='$TreatFreq1',TreatDur1='$TreatDur1',TreatEye1='$TreatEye1',TreatChk2='$TreatChk2',TreatType2='$TreatType2',TreatName2='$TreatName2',TreatDose2='$TreatDose2',TreatFreq2='$TreatFreq2',TreatDur2='$TreatDur2',TreatEye2='$TreatEye2',TreatChk3='$TreatChk3',TreatType3='$TreatType3',TreatName3='$TreatName3',TreatDose3='$TreatDose3',TreatFreq3='$TreatFreq3',TreatDur3='$TreatDur3',TreatEye3='$TreatEye3',TreatChk4='$TreatChk4',TreatType4='$TreatType4',TreatName4='$TreatName4',TreatDose4='$TreatDose4',TreatFreq4='$TreatFreq4',TreatDur4='$TreatDur4',TreatEye4='$TreatEye4',TreatChk5='$TreatChk5',TreatType5='$TreatType5',TreatName5='$TreatName5',TreatDose5='$TreatDose5',TreatFreq5='$TreatFreq5',TreatDur5='$TreatDur5',TreatEye5='$TreatEye5',TreatChk6='$TreatChk6',TreatType6='$TreatType6',TreatName6='$TreatName6',TreatDose6='$TreatDose6',TreatFreq6='$TreatFreq6',TreatDur6='$TreatDur6',TreatEye6='$TreatEye6',TreatChk7='$TreatChk7',TreatType7='$TreatType7',TreatName7='$TreatName7',TreatDose7='$TreatDose7',TreatFreq7='$TreatFreq7',TreatDur7='$TreatDur7',TreatEye7='$TreatEye7',TreatChk8='$TreatChk8',TreatType8='$TreatType8',TreatName8='$TreatName8',TreatDose8='$TreatDose8',TreatFreq8='$TreatFreq8',TreatDur8='$TreatDur8',TreatEye8='$TreatEye8',TreatChk9='$TreatChk9',TreatType9='$TreatType9',TreatName9='$TreatName9',TreatDose9='$TreatDose9',TreatFreq9='$TreatFreq9',TreatDur9='$TreatDur9',TreatEye9='$TreatEye9',TreatChk10='$TreatChk10',TreatType10='$TreatType10',TreatName10='$TreatName10',TreatDose10='$TreatDose10',TreatFreq10='$TreatFreq10',TreatDur10='$TreatDur10',TreatEye10='$TreatEye10',TreatChk11='$TreatChk11',TreatType11='$TreatType11',TreatName11='$TreatName11',TreatDose11='$TreatDose11',TreatFreq11='$TreatFreq11',TreatDur11='$TreatDur11',TreatEye11='$TreatEye11',TreatChk12='$TreatChk12',TreatType12='$TreatType12',TreatName12='$TreatName12',TreatDose12='$TreatDose12',TreatFreq12='$TreatFreq12',TreatDur12='$TreatDur12',TreatEye12='$TreatEye12',TreatChk13='$TreatChk13',TreatType13='$TreatType13',TreatName13='$TreatName13',TreatDose13='$TreatDose13',TreatFreq13='$TreatFreq13',TreatDur13='$TreatDur13',TreatEye13='$TreatEye13',Advice='$Advice',Remark='$Remark',ChkDilate='$ChkDilate',ChkCatProfile='$ChkCatProfile',ChkLasikProfile='$ChkLasikProfile',CreatedBy='$user_id',CreatedDate='$CreatedDate'";
$conn->query($sql);*/

try {
   $sql = "INSERT INTO tbl_consultants (MrdNo,VisitNo,VisitDate,PatientName,ChkReNormal,ChkLeNormal,ReOcMov,LeOcMov,ReLids,LeLids,ReConj,LeConj,ReCornea,LeCornea,ReCorneaRemark,LeCorneaRemark,ReAntChamber,LeAntChamber,ReIris,LeIris,RePupil,LePupil,ReIop,LeIop,ReLens,LeLens,ReLens2,LeLens2,ReNlp,LeNlp,ChkReHazy,ChkLeHazy,ReMedia,LeMedia,ReOptDisc,LeOptDisc,ReMacBV,LeMacBV,ReMidPerPh,LeMidPerPh,InvStName,InvStBy,CounCellingBy,Diagnosis,Advice,Remark,ChkDilate,ChkCatProfile,ChkLasikProfile,Treatment,TreatChk1,TreatType1,TreatName1,TreatDose1,TreatFreq1,TreatDur1,TreatEye1,TreatChk2,TreatType2,TreatName2,TreatDose2,TreatFreq2,TreatDur2,TreatEye2,
   	   TreatChk3,TreatType3,TreatName3,TreatDose3,TreatFreq3,TreatDur3,TreatEye3,TreatChk4,TreatType4,TreatName4,TreatDose4,TreatFreq4,TreatDur4,TreatEye4,TreatChk5,TreatType5,TreatName5,TreatDose5,TreatFreq5,TreatDur5,TreatEye5,TreatChk6,TreatType6,TreatName6,TreatDose6,TreatFreq6,TreatDur6,TreatEye6,TreatChk7,TreatType7,TreatName7,TreatDose7,TreatFreq7,TreatDur7,TreatEye7,
   	   TreatChk8,TreatType8,TreatName8,TreatDose8,TreatFreq8,TreatDur8,TreatEye8,
   	   TreatChk9,TreatType9,TreatName9,TreatDose9,TreatFreq9,TreatDur9,TreatEye9,
   	   TreatChk10,TreatType10,TreatName10,TreatDose10,TreatFreq10,TreatDur10,TreatEye10,
   	   TreatChk11,TreatType11,TreatName11,TreatDose11,TreatFreq11,TreatDur11,TreatEye11,
   	   TreatChk12,TreatType12,TreatName12,TreatDose12,TreatFreq12,TreatDur12,TreatEye12,
   	   TreatChk13,TreatType13,TreatName13,TreatDose13,TreatFreq13,TreatDur13,TreatEye13,CreatedBy,CreatedDate,ModifiedBy,ModifiedDate) VALUES (:MrdNo,:VisitNo,:VisitDate,:PatientName,:ChkReNormal,:ChkLeNormal,:ReOcMov,:LeOcMov,:ReLids,:LeLids,:ReConj,:LeConj,:ReCornea,:LeCornea,:ReCorneaRemark,:LeCorneaRemark,:ReAntChamber,:LeAntChamber,:ReIris,:LeIris,:RePupil,:LePupil,:ReIop,:LeIop,:ReLens,:LeLens,:ReLens2,:LeLens2,:ReNlp,:LeNlp,:ChkReHazy,:ChkLeHazy,:ReMedia,:LeMedia,:ReOptDisc,:LeOptDisc,:ReMacBV,:LeMacBV,:ReMidPerPh,:LeMidPerPh,:InvStName,:InvStBy,:CounCellingBy,:Diagnosis,:Advice,:Remark,:ChkDilate,:ChkCatProfile,:ChkLasikProfile,:Treatment,:TreatChk1,:TreatType1,:TreatName1,:TreatDose1,:TreatFreq1,:TreatDur1,:TreatEye1,:TreatChk2,:TreatType2,:TreatName2,:TreatDose2,:TreatFreq2,:TreatDur2,:TreatEye2,
   	   :TreatChk3,:TreatType3,:TreatName3,:TreatDose3,:TreatFreq3,:TreatDur3,:TreatEye3,:TreatChk4,:TreatType4,:TreatName4,:TreatDose4,:TreatFreq4,:TreatDur4,:TreatEye4,:TreatChk5,:TreatType5,:TreatName5,:TreatDose5,:TreatFreq5,:TreatDur5,:TreatEye5,:TreatChk6,:TreatType6,:TreatName6,:TreatDose6,:TreatFreq6,:TreatDur6,:TreatEye6,:TreatChk7,:TreatType7,:TreatName7,:TreatDose7,:TreatFreq7,:TreatDur7,:TreatEye7,
   	   :TreatChk8,:TreatType8,:TreatName8,:TreatDose8,:TreatFreq8,:TreatDur8,:TreatEye8,
   	   :TreatChk9,:TreatType9,:TreatName9,:TreatDose9,:TreatFreq9,:TreatDur9,:TreatEye9,
   	   :TreatChk10,:TreatType10,:TreatName10,:TreatDose10,:TreatFreq10,:TreatDur10,:TreatEye10,
   	   :TreatChk11,:TreatType11,:TreatName11,:TreatDose11,:TreatFreq11,:TreatDur11,:TreatEye11,
   	   :TreatChk12,:TreatType12,:TreatName12,:TreatDose12,:TreatFreq12,:TreatDur12,:TreatEye12,
   	   :TreatChk13,:TreatType13,:TreatName13,:TreatDose13,:TreatFreq13,:TreatDur13,:TreatEye13,:CreatedBy,:CreatedDate,:ModifiedBy,:ModifiedDate)";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':MrdNo', $MrdNo);
$stmt->bindParam(':VisitNo', $VisitNo);
$stmt->bindParam(':VisitDate', $VisitDate);
$stmt->bindParam(':PatientName', $PatientName);
$stmt->bindParam(':ChkReNormal', $ChkReNormal);
$stmt->bindParam(':ChkLeNormal', $ChkLeNormal);
$stmt->bindParam(':ReOcMov', $ReOcMov);
$stmt->bindParam(':LeOcMov', $LeOcMov);
$stmt->bindParam(':ReLids', $ReLids);
$stmt->bindParam(':LeLids', $LeLids);
$stmt->bindParam(':ReConj', $ReConj);
$stmt->bindParam(':LeConj', $LeConj);
$stmt->bindParam(':ReCornea', $ReCornea);
$stmt->bindParam(':LeCornea', $LeCornea);
$stmt->bindParam(':ReCorneaRemark', $ReCorneaRemark);
$stmt->bindParam(':LeCorneaRemark', $LeCorneaRemark);
$stmt->bindParam(':ReAntChamber', $ReAntChamber);
$stmt->bindParam(':LeAntChamber', $LeAntChamber);
$stmt->bindParam(':ReIris', $ReIris);
$stmt->bindParam(':LeIris', $LeIris);
$stmt->bindParam(':RePupil', $RePupil);
$stmt->bindParam(':LePupil', $LePupil);
$stmt->bindParam(':ReIop', $ReIop);
$stmt->bindParam(':LeIop', $LeIop);
$stmt->bindParam(':ReLens', $ReLens);
$stmt->bindParam(':LeLens', $LeLens);
$stmt->bindParam(':ReLens2', $ReLens2);
$stmt->bindParam(':LeLens2', $LeLens2);
$stmt->bindParam(':ReNlp', $ReNlp);
$stmt->bindParam(':LeNlp', $LeNlp);
$stmt->bindParam(':ChkReHazy', $ChkReHazy);
$stmt->bindParam(':ChkLeHazy', $ChkLeHazy);
$stmt->bindParam(':ReMedia', $ReMedia);
$stmt->bindParam(':LeMedia', $LeMedia);
$stmt->bindParam(':ReOptDisc', $ReOptDisc);
$stmt->bindParam(':LeOptDisc', $LeOptDisc);
$stmt->bindParam(':ReMacBV', $ReMacBV);
$stmt->bindParam(':LeMacBV', $LeMacBV);
$stmt->bindParam(':ReMidPerPh', $ReMidPerPh);
$stmt->bindParam(':LeMidPerPh', $LeMidPerPh);
$stmt->bindParam(':InvStName', $InvStName);
$stmt->bindParam(':InvStBy', $InvStBy);
$stmt->bindParam(':CounCellingBy', $CounCellingBy);
$stmt->bindParam(':Diagnosis', $Diagnosis);
$stmt->bindParam(':Advice', $Advice);
$stmt->bindParam(':Remark', $Remark);
$stmt->bindParam(':ChkDilate', $ChkDilate);
$stmt->bindParam(':ChkCatProfile', $ChkCatProfile);
$stmt->bindParam(':ChkLasikProfile', $ChkLasikProfile);
$stmt->bindParam(':Treatment', $Treatment);
$stmt->bindParam(':TreatChk1', $TreatChk1);
$stmt->bindParam(':TreatType1', $TreatType1);
$stmt->bindParam(':TreatName1', $TreatName1);
$stmt->bindParam(':TreatDose1', $TreatDose1);
$stmt->bindParam(':TreatFreq1', $TreatFreq1);
$stmt->bindParam(':TreatDur1', $TreatDur1);
$stmt->bindParam(':TreatEye1', $TreatEye1);
$stmt->bindParam(':TreatChk2', $TreatChk2);
$stmt->bindParam(':TreatType2', $TreatType2);
$stmt->bindParam(':TreatName2', $TreatName2);
$stmt->bindParam(':TreatDose2', $TreatDose2);
$stmt->bindParam(':TreatFreq2', $TreatFreq2);
$stmt->bindParam(':TreatDur2', $TreatDur2);
$stmt->bindParam(':TreatEye2', $TreatEye2);
$stmt->bindParam(':TreatChk3', $TreatChk3);
$stmt->bindParam(':TreatType3', $TreatType3);
$stmt->bindParam(':TreatName3', $TreatName3);
$stmt->bindParam(':TreatDose3', $TreatDose3);
$stmt->bindParam(':TreatFreq3', $TreatFreq3);
$stmt->bindParam(':TreatDur3', $TreatDur3);
$stmt->bindParam(':TreatEye3', $TreatEye3);
$stmt->bindParam(':TreatChk4', $TreatChk4);
$stmt->bindParam(':TreatType4', $TreatType4);
$stmt->bindParam(':TreatName4', $TreatName4);
$stmt->bindParam(':TreatDose4', $TreatDose4);
$stmt->bindParam(':TreatFreq4', $TreatFreq4);
$stmt->bindParam(':TreatDur4', $TreatDur4);
$stmt->bindParam(':TreatEye4', $TreatEye4);
$stmt->bindParam(':TreatChk5', $TreatChk5);
$stmt->bindParam(':TreatType5', $TreatType5);
$stmt->bindParam(':TreatName5', $TreatName5);
$stmt->bindParam(':TreatDose5', $TreatDose5);
$stmt->bindParam(':TreatFreq5', $TreatFreq5);
$stmt->bindParam(':TreatDur5', $TreatDur5);
$stmt->bindParam(':TreatEye5', $TreatEye5);
$stmt->bindParam(':TreatChk6', $TreatChk6);
$stmt->bindParam(':TreatType6', $TreatType6);
$stmt->bindParam(':TreatName6', $TreatName6);
$stmt->bindParam(':TreatDose6', $TreatDose6);
$stmt->bindParam(':TreatFreq6', $TreatFreq6);
$stmt->bindParam(':TreatDur6', $TreatDur6);
$stmt->bindParam(':TreatEye6', $TreatEye6);
$stmt->bindParam(':TreatChk7', $TreatChk7);
$stmt->bindParam(':TreatType7', $TreatType7);
$stmt->bindParam(':TreatName7', $TreatName7);
$stmt->bindParam(':TreatDose7', $TreatDose7);
$stmt->bindParam(':TreatFreq7', $TreatFreq7);
$stmt->bindParam(':TreatDur7', $TreatDur7);
$stmt->bindParam(':TreatEye7', $TreatEye7);

$stmt->bindParam(':TreatChk8', $TreatChk8);
$stmt->bindParam(':TreatType8', $TreatType8);
$stmt->bindParam(':TreatName8', $TreatName8);
$stmt->bindParam(':TreatDose8', $TreatDose8);
$stmt->bindParam(':TreatFreq8', $TreatFreq8);
$stmt->bindParam(':TreatDur8', $TreatDur8);
$stmt->bindParam(':TreatEye8', $TreatEye8);

$stmt->bindParam(':TreatChk9', $TreatChk9);
$stmt->bindParam(':TreatType9', $TreatType9);
$stmt->bindParam(':TreatName9', $TreatName9);
$stmt->bindParam(':TreatDose9', $TreatDose9);
$stmt->bindParam(':TreatFreq9', $TreatFreq9);
$stmt->bindParam(':TreatDur9', $TreatDur9);
$stmt->bindParam(':TreatEye9', $TreatEye9);

$stmt->bindParam(':TreatChk10', $TreatChk10);
$stmt->bindParam(':TreatType10', $TreatType10);
$stmt->bindParam(':TreatName10', $TreatName10);
$stmt->bindParam(':TreatDose10', $TreatDose10);
$stmt->bindParam(':TreatFreq10', $TreatFreq10);
$stmt->bindParam(':TreatDur10', $TreatDur10);
$stmt->bindParam(':TreatEye10', $TreatEye10);

$stmt->bindParam(':TreatChk11', $TreatChk11);
$stmt->bindParam(':TreatType11', $TreatType11);
$stmt->bindParam(':TreatName11', $TreatName11);
$stmt->bindParam(':TreatDose11', $TreatDose11);
$stmt->bindParam(':TreatFreq11', $TreatFreq11);
$stmt->bindParam(':TreatDur11', $TreatDur11);
$stmt->bindParam(':TreatEye11', $TreatEye11);

$stmt->bindParam(':TreatChk12', $TreatChk12);
$stmt->bindParam(':TreatType12', $TreatType12);
$stmt->bindParam(':TreatName12', $TreatName12);
$stmt->bindParam(':TreatDose12', $TreatDose12);
$stmt->bindParam(':TreatFreq12', $TreatFreq12);
$stmt->bindParam(':TreatDur12', $TreatDur12);
$stmt->bindParam(':TreatEye12', $TreatEye12);

$stmt->bindParam(':TreatChk13', $TreatChk13);
$stmt->bindParam(':TreatType13', $TreatType13);
$stmt->bindParam(':TreatName13', $TreatName13);
$stmt->bindParam(':TreatDose13', $TreatDose13);
$stmt->bindParam(':TreatFreq13', $TreatFreq13);
$stmt->bindParam(':TreatDur13', $TreatDur13);
$stmt->bindParam(':TreatEye13', $TreatEye13);
$stmt->bindParam(':CreatedBy', $user_id);
$stmt->bindParam(':CreatedDate', $CreatedDate);
$stmt->bindParam(':ModifiedBy', $ModifiedBy);
$stmt->bindParam(':ModifiedDate', $ModifiedDate);
if ($stmt->execute()) {
$sql2 = "UPDATE tbl_queue_managements SET Checked='1',OutTime='$CreatedTime' WHERE MrdNo='$MrdNo' AND InDate='$VisitDate'";
$conn->query($sql2);
echo "<script>alert('Record Saved Successfully!');window.location.href='../consultantform.php?mrd=$MrdNo&visitdate=$VisitDate';</script>";
}
}
catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}


}
}