<?php 
session_start();
include_once '../config.php';
$user_id = $_SESSION['Admin']['id'];
if($_REQUEST['action'] == 'Save'){
$Treatment = addslashes(trim($_REQUEST['Treatment']));
$TreatChk1 = addslashes(trim($_REQUEST['TreatChk1']));
if($TreatChk1==1){
$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 = addslashes(trim($_REQUEST['TreatChk2']));
if($TreatChk2==1){
$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 = addslashes(trim($_REQUEST['TreatChk3']));
if($TreatChk3==1){
$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 = addslashes(trim($_REQUEST['TreatChk4']));
if($TreatChk4==1){
$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 = addslashes(trim($_REQUEST['TreatChk5']));
if($TreatChk5==1){
$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 = addslashes(trim($_REQUEST['TreatChk6']));
if($TreatChk6==1){
$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 = addslashes(trim($_REQUEST['TreatChk7']));
if($TreatChk7==1){
$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 = addslashes(trim($_REQUEST['TreatChk8']));
if($TreatChk8==1){
$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 = addslashes(trim($_REQUEST['TreatChk9']));
if($TreatChk9==1){
$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 = addslashes(trim($_REQUEST['TreatChk10']));
if($TreatChk10==1){
$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 = addslashes(trim($_REQUEST['TreatChk11']));
if($TreatChk11==1){
$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 = addslashes(trim($_REQUEST['TreatChk12']));
if($TreatChk12==1){
$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 = addslashes(trim($_REQUEST['TreatChk13']));
if($TreatChk13==1){
$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']));
}

$IpdNo = addslashes(trim($_REQUEST['IpdNo']));
$MrdNo = addslashes(trim($_REQUEST['MrdNo']));
$PatientName = addslashes(trim($_REQUEST['PatientName']));
$AgeGender = addslashes(trim($_REQUEST['AgeGender']));
$OperationDate = addslashes(trim($_REQUEST['OperationDate']));
$OperationTime = addslashes(trim($_REQUEST['OperationTime']));
$AdmissionDate = addslashes(trim($_REQUEST['AdmissionDate']));
$AdmissionTime = addslashes(trim($_REQUEST['AdmissionTime']));
$DischargeDate = addslashes(trim($_REQUEST['DischargeDate']));
$DischargeTime = addslashes(trim($_REQUEST['DischargeTime']));
$FollowUpDate1 = addslashes(trim($_REQUEST['FollowUpDate1']));
//$FollowUpDate2 = addslashes(trim($_REQUEST['FollowUpDate2']));
//$FollowUpDate3 = addslashes(trim($_REQUEST['FollowUpDate3']));
$FollowUpDate2 = null;
$FollowUpDate3 = null;
$FollowUpTime1 = addslashes(trim($_REQUEST['FollowUpTime1']));

$Consultant = addslashes(trim($_REQUEST['Consultant']));
$Surgeon = addslashes(trim($_REQUEST['Surgeon']));
$Anaesthetist = addslashes(trim($_REQUEST['Anaesthetist']));

$Diagnosis = addslashes(trim($_REQUEST['Diagnosis']));
$Procedures = addslashes(trim($_REQUEST['Procedures']));

$VA = addslashes(trim($_REQUEST['VA']));
$BloodSugar = addslashes(trim($_REQUEST['BloodSugar']));
$UrineSugar = addslashes(trim($_REQUEST['UrineSugar']));
$BP = addslashes(trim($_REQUEST['BP']));
$IopRe = addslashes(trim($_REQUEST['IopRe']));
$IopLe = addslashes(trim($_REQUEST['IopLe']));

$Ecg = addslashes(trim($_REQUEST['Ecg']));
$Syringing = addslashes(trim($_REQUEST['Syringing']));
$K1 = addslashes(trim($_REQUEST['K1']));
$K2 = addslashes(trim($_REQUEST['K2']));
$Axl = addslashes(trim($_REQUEST['Axl']));

$IolPower = addslashes(trim($_REQUEST['IolPower']));
$CylToric = addslashes(trim($_REQUEST['CylToric']));
$Multifocal = addslashes(trim($_REQUEST['Multifocal']));

$VA2 = addslashes(trim($_REQUEST['VA2']));
$Conjunctiva = addslashes(trim($_REQUEST['Conjunctiva']));
$Cornea = addslashes(trim($_REQUEST['Cornea']));
$AC = addslashes(trim($_REQUEST['AC']));
$Pupil = addslashes(trim($_REQUEST['Pupil']));
$Pciol = addslashes(trim($_REQUEST['Pciol']));
$Fundus = addslashes(trim($_REQUEST['Fundus']));
$CondDischarge = addslashes(trim($_REQUEST['CondDischarge']));
$SurgeryType = addslashes(trim($_REQUEST['SurgeryType']));

$CreatedDate = date('Y-m-d');
$Status = 1;
$ModifiedBy = 0;
$ModifiedDate = null;
$id = $_REQUEST['id'];
if($id == ''){
/*$sql = "INSERT INTO tbl_dischargecards SET IpdNo='$IpdNo',MrdNo='$MrdNo',PatientName='$PatientName',AgeGender='$AgeGender',OperationDate='$OperationDate',OperationTime='$OperationTime',AdmissionDate='$AdmissionDate',AdmissionTime='$AdmissionTime',DischargeDate='$DischargeDate',DischargeTime='$DischargeTime',FollowUpDate1='$FollowUpDate1',FollowUpDate2='$FollowUpDate2',FollowUpDate3='$FollowUpDate3',FollowUpTime1='$FollowUpTime1',Consultant='$Consultant',Surgeon='$Surgeon',Anaesthetist='$Anaesthetist',Diagnosis='$Diagnosis',Procedures='$Procedures',VA='$VA',BloodSugar='$BloodSugar',UrineSugar='$UrineSugar',BP='$BP',IopRe='$IopRe',IopLe='$IopLe',Ecg='$Ecg',Syringing='$Syringing',K1='$K1',K2='$K2',Axl='$Axl',IolPower='$IolPower',VA2='$VA2',Conjunctiva='$Conjunctiva',Cornea='$Cornea',AC='$AC',Pupil='$Pupil',Pciol='$Pciol',Fundus='$Fundus',CondDischarge='$CondDischarge',SurgeryType='$SurgeryType',CylToric='$CylToric',Multifocal='$Multifocal',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',CreatedBy='$user_id',CreatedDate='$CreatedDate'";
$conn->query($sql);*/

try {
   $sql = "INSERT INTO tbl_dischargecards (IpdNo,MrdNo,PatientName,AgeGender,Department,BedNo,AdmissionDate,AdmissionTime,OperationDate,OperationTime,DischargeDate,DischargeTime,FollowUpDate1,FollowUpDate2,FollowUpDate3,FollowUpTime1,Consultant,Surgeon,Anaesthetist,Diagnosis,Procedures,VA,BloodSugar,UrineSugar,BP,IopRe,IopLe,Ecg,Syringing,K1,K2,Axl,IolPower,VA2,Conjunctiva,Cornea,AC,Pupil,Pciol,Fundus,CondDischarge,SurgeryType,CylToric,Multifocal,Pulse,Cns,Cvs,Rs,LabInvest,RadiologicalInvest,SurgeryPerformed,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,Status,CreatedBy,CreatedDate,ModifiedBy,ModifiedDate) VALUES (:IpdNo,:MrdNo,:PatientName,:AgeGender,:Department,:BedNo,:AdmissionDate,:AdmissionTime,:OperationDate,:OperationTime,:DischargeDate,:DischargeTime,:FollowUpDate1,:FollowUpDate2,:FollowUpDate3,:FollowUpTime1,:Consultant,:Surgeon,:Anaesthetist,:Diagnosis,:Procedures,:VA,:BloodSugar,:UrineSugar,:BP,:IopRe,:IopLe,:Ecg,:Syringing,:K1,:K2,:Axl,:IolPower,:VA2,:Conjunctiva,:Cornea,:AC,:Pupil,:Pciol,:Fundus,:CondDischarge,:SurgeryType,:CylToric,:Multifocal,:Pulse,:Cns,:Cvs,:Rs,:LabInvest,:RadiologicalInvest,:SurgeryPerformed,: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,:Status,:CreatedBy,:CreatedDate,:ModifiedBy,:ModifiedDate)";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':IpdNo', $IpdNo);
$stmt->bindParam(':MrdNo', $MrdNo);
$stmt->bindParam(':PatientName', $PatientName);
$stmt->bindParam(':AgeGender', $AgeGender);
$stmt->bindParam(':Department', $Department);
$stmt->bindParam(':BedNo', $BedNo);
$stmt->bindParam(':AdmissionDate', $AdmissionDate);
$stmt->bindParam(':AdmissionTime', $AdmissionTime);
$stmt->bindParam(':OperationDate', $OperationDate);
$stmt->bindParam(':OperationTime', $OperationTime);
$stmt->bindParam(':DischargeDate', $DischargeDate);
$stmt->bindParam(':DischargeTime', $DischargeTime);
$stmt->bindParam(':FollowUpDate1', $FollowUpDate1);
$stmt->bindParam(':FollowUpDate2', $FollowUpDate2);
$stmt->bindParam(':FollowUpDate3', $FollowUpDate3);
$stmt->bindParam(':FollowUpTime1', $FollowUpTime1);
$stmt->bindParam(':Consultant', $Consultant);
$stmt->bindParam(':Surgeon', $Surgeon);
$stmt->bindParam(':Anaesthetist', $Anaesthetist);
$stmt->bindParam(':Diagnosis', $Diagnosis);
$stmt->bindParam(':Procedures', $Procedures);
$stmt->bindParam(':VA', $VA);
$stmt->bindParam(':BloodSugar', $BloodSugar);
$stmt->bindParam(':UrineSugar', $UrineSugar);
$stmt->bindParam(':BP', $BP);
$stmt->bindParam(':IopRe', $IopRe);
$stmt->bindParam(':IopLe', $IopLe);
$stmt->bindParam(':Ecg', $Ecg);
$stmt->bindParam(':Syringing', $Syringing);
$stmt->bindParam(':K1', $K1);
$stmt->bindParam(':K2', $K2);
$stmt->bindParam(':Axl', $Axl);
$stmt->bindParam(':IolPower', $IolPower);
$stmt->bindParam(':VA2', $VA2);
$stmt->bindParam(':Conjunctiva', $Conjunctiva);
$stmt->bindParam(':Cornea', $Cornea);
$stmt->bindParam(':AC', $AC);
$stmt->bindParam(':Pupil', $Pupil);
$stmt->bindParam(':Pciol', $Pciol);
$stmt->bindParam(':Fundus', $Fundus);
$stmt->bindParam(':CondDischarge', $CondDischarge);
$stmt->bindParam(':SurgeryType', $SurgeryType);
$stmt->bindParam(':CylToric', $CylToric);
$stmt->bindParam(':Multifocal', $Multifocal);
$stmt->bindParam(':Pulse', $Pulse);
$stmt->bindParam(':Cns', $Cns);
$stmt->bindParam(':Cvs', $Cvs);
$stmt->bindParam(':Rs', $Rs);
$stmt->bindParam(':LabInvest', $LabInvest);
$stmt->bindParam(':RadiologicalInvest', $RadiologicalInvest);
$stmt->bindParam(':SurgeryPerformed', $SurgeryPerformed);
$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(':Status', $Status);
$stmt->bindParam(':CreatedBy', $user_id);
$stmt->bindParam(':CreatedDate', $CreatedDate);
$stmt->bindParam(':ModifiedBy', $ModifiedBy);
$stmt->bindParam(':ModifiedDate', $ModifiedDate);
if ($stmt->execute()) {
?>
<script>
  window.location.href="../view-dischargecard.php";
    setTimeout(function () {
       window.open(
        '../print-discharge-card.php?ipdno=<?php echo $IpdNo;?>', 'name', 'toolbar=1, scrollbars=1, location=1,statusbar=0, menubar=1, resizable=1, width=800, height=600'
    );
}, 1);
</script>
<?php
  }
}
catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}
}
else{
  try{
    $FollowUpDate2 = '0000-00-00';
$FollowUpDate3 = '0000-00-00';
 $sql = "UPDATE tbl_dischargecards SET OperationDate='$OperationDate',OperationTime='$OperationTime',AdmissionDate='$AdmissionDate',AdmissionTime='$AdmissionTime',DischargeDate='$DischargeDate',DischargeTime='$DischargeTime',FollowUpDate1='$FollowUpDate1',FollowUpDate2='$FollowUpDate2',FollowUpDate3='$FollowUpDate3',FollowUpTime1='$FollowUpTime1',Consultant='$Consultant',Surgeon='$Surgeon',Anaesthetist='$Anaesthetist',Diagnosis='$Diagnosis',Procedures='$Procedures',VA='$VA',BloodSugar='$BloodSugar',UrineSugar='$UrineSugar',BP='$BP',IopRe='$IopRe',IopLe='$IopLe',Ecg='$Ecg',Syringing='$Syringing',K1='$K1',K2='$K2',Axl='$Axl',IolPower='$IolPower',VA2='$VA2',Conjunctiva='$Conjunctiva',Cornea='$Cornea',AC='$AC',Pupil='$Pupil',Pciol='$Pciol',Fundus='$Fundus',CondDischarge='$CondDischarge',SurgeryType='$SurgeryType',CylToric='$CylToric',Multifocal='$Multifocal',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',ModifiedBy='$user_id',ModifiedDate='$CreatedDate' WHERE IpdNo='$id'";
$conn->query($sql);	
?>
<script>
  window.location.href="../view-dischargecard.php";
    setTimeout(function () {
       window.open(
        '../print-discharge-card.php?ipdno=<?php echo $IpdNo;?>', 'name', 'toolbar=1, scrollbars=1, location=1,statusbar=0, menubar=1, resizable=1, width=800, height=600'
    );
}, 1);
</script>
<?php }
catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
} }
?>

	<?php 
//echo "<script>alert('Discharge Card Generated Successfully!');window.location.href='../view-dischargecard.php';</script>";
}
?>