<?php 
   session_start();
   require_once 'config.php';
   require_once 'auth.php';
   ?>
<!DOCTYPE>
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">


body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
}
.style1 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 16px;
	font-weight: bold;
}
.style4 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; }
.style10 {font-family: Arial, Helvetica, sans-serif; font-size: 12; }
.style11 {font-size: 12}

 @media print {
        @page {
            margin-top: 10px;
            margin-left: 50px;
            margin-right: 0px;
            margin-bottom: 0px;
        }

        @page :footer {
            display: none
        }

        .noPrint {
            display: none;
        }

        @page :header {
            display: none
        }
    }
</style></head>

<?php 
$sql = "SELECT * FROM tbl_patients WHERE MrdNo='".$_GET['mrdno']."'";
$row = getRecord($sql);
 ?>
<body>
   <tr class="noPrint" align="center">
            <td style="text-align: center;" align="center"><button align="center" style="text-align:center;font-size: 18px;width: 100px;"
                    onclick="window.print();" class="noPrint">Print</button>
            </td>
        </tr>

        <table width="700" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="left" valign="top"><table width="100%" border="0" cellspacing="2" cellpadding="2">

      <tr>
        <td><div align="center"><span class="style1">Dr. Jayant Deshmukh OPD Notes </span></div></td>
      </tr>
      <tr>
        <td align="left" valign="top"><table width="100%" border="0" cellspacing="3" cellpadding="3">
          <tr>
            <td width="9%"><span class="style4">MRD No : <?php echo $row['MrdNo'];?></span></td>
         
            <td colspan="2"><span class="style4">Name : <?php echo $row['PatientName'];?></span></td>
            <td class="style4"><span class="style10">Gender : <?php echo $row['Gender'];?></span></td>
             <td width="13%" class="style4"><span class="style10">Age : <?php echo $row['Age'];?></span></td>
          </tr>
          <tr>
            
           
            <td width="33%" class="style4">Mobile : <?php echo $row['Phone'];?></td>
            <td class="style4"><span class="style10" style="font-size: 11px;">Address : <?php echo $row['Address'];?></span></td>
          </tr>
        </table>
        </td>
      </tr>
    </td>
     </tr>
    </table><br>
  <?php 

  if($_REQUEST["action"]=="delete")
{
  $id = $_REQUEST["id"];
  $mrdno = $_REQUEST['mrdno'];
  $visitdate = $_REQUEST['visitdate'];
  $sql11 = "DELETE FROM tbl_consultant WHERE id = '$id'";
  $conn->query($sql11);
  $sql11 = "DELETE FROM tbl_consultant_treatments WHERE MrdNo='$mrd' AND VisitDate='$visitdate'";
  $conn->query($sql11);
  $sql11 = "DELETE FROM tbl_visits WHERE MrdNo='$mrd' AND VisitDate='$visitdate'";
  $conn->query($sql11);
  
  ?>
    <script type="text/javascript">
      alert("Deleted Successfully!");
      window.location.href="view-patient-summary.php?mrdno=<?php echo $mrdno;?>";
    </script>
<?php } 

$mrd = $_REQUEST['mrdno'];
$sql7_1 = "SELECT * FROM tbl_consultant WHERE MrdNo='$mrd' AND DeleteFlag=0";
$row7 = getList($sql7_1);
foreach($row7 as $result){

  $sql2 = "SELECT * FROM tbl_visits WHERE MrdNo='$mrd' AND VisitDate='".$result['VisitDate']."'";
$row2 = getRecord($sql2);
?>
<table width="700" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td align="left" valign="top"><table width="100%" border="0" cellspacing="2" cellpadding="2">

     
      <tr>
        <td align="left" valign="top">
          <tr>
          
            
            <td width="40%" style="float:right;"><span class="style4">Date / Visit No : <?php echo date("d/m/Y", strtotime(str_replace('-', '/',$result['VisitDate'])));?> / <?php echo $row2['VisitNo'];?> </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <a onClick="return confirm('Are you sure you want delete this record?');" href="<?php echo $_SERVER['PHP_SELF']; ?>?mrdno=<?php echo $mrd; ?>&action=delete&id=<?php echo $result['id'];?>&visitdate=<?php echo $result['VisitDate'];?>" style="color:red;" class="noPrint">Delete</a>
            </td>
          </tr>
      <tr>
        <td align="left" valign="top" class="style4">OD : <?php echo strtoupper($result['Relationship']); ?> - <?php echo strtoupper($result['RelativeName']); ?></td>
      </tr>
      
      <tr>
        <td>
           <?php if($result['DM'] == 1 || $result['HT'] == 1 || $result['IHD'] == 1 || $result['PILES'] == 1 || $result['Thyroid'] == 1 || $result['Other'] == 1){?>
          <span class="style4">Comorbodities : Know case of - <?php if($result['DM'] == 1){?>
             DM   <?php } if($result['HT'] == 1){?>
             HT <?php } if($result['IHD'] == 1){?>
             IHD  <?php } if($result['PILES'] == 1){?>
             PILES <?php } if($result['Thyroid'] == 1){?>
             Thyroid <?php } if($result['Other'] == 1){?>
              Other - <?php echo $result['OtherTxt']; }?></span>
            <?php } ?>
            </td>
      </tr>
      <?php if($result['Prognosis'] == 1 || $result['DSH'] == 1 || $result['Admission'] == 1 || $result['FollowUp'] == 1 || $result['Irregular'] == 1 || $result['Medication'] == 1 || $result['StrictSupervision'] == 1){?>
      <tr>
        <td align="left" valign="top" class="style4">Instructions :   <?php if($result['Prognosis'] == 1){?>
             - Poor Prognosis   <?php } if($result['DSH'] == 1){?>
             - DSH Risk Informed to OD <?php } if($result['Admission'] == 1){?>
              - Admission / Relatives not willing at present
               <?php } if($result['FollowUp'] == 1){?>
            - Follow up with responsible relative  <?php } if($result['Irregular'] == 1){?>
             - Irregular Treatment <?php } if($result['Medication'] == 1){?>
              - Self Medication <?php } if($result['StrictSupervision'] == 1){?>
      - Maintain strict supervision on patients
              <?php } ?></td>
      </tr>
       <?php } ?>

       <?php if($result['Notes'] != ''){?>
      <tr>
        <td align="left" valign="top" class="style4">Detail Notes : <?php echo $result['Notes']; ?></td>
      </tr>
      <?php } ?>
       <?php if($result['ChkBlood'] == 1 || $result['Eeg'] == 1 || $result['ChkCT'] == 1 || $result['ChkMRI'] == 1 || $result['ChkUSG'] == 1 || $result['ChkOthers'] == 1){?>
      <tr>
        <td align="left" valign="top"><div align="left" class="style4"><strong>Investigations : </strong></div></td>
      </tr>
      <?php if($result['ChkBlood'] == 1){?>
      <tr>
        <td align="left" valign="top" class="style4">Blood : <?php echo $result['TxtBlood'];?></td>
      </tr>
    <?php } if($result['Eeg'] == 1){?>
      <tr>
        <td align="left" valign="top" class="style4">EEG : <?php echo $result['TxtEeg'];?></td>
      </tr>
       <?php } if($result['ChkCT'] == 1){?>
      <tr>
        <td align="left" valign="top" background="Brain" class="style4">CT Brain : <?php echo $result['TxtCT'];?></td>
      </tr>
       <?php } if($result['ChkMRI'] == 1){?>
      <tr>
        <td align="left" valign="top" background="Brain" class="style4">MRI Brain : <?php echo $result['TxtMRI'];?></td>
      </tr>
       <?php } if($result['ChkUSG'] == 1){?>
      <tr>
        <td align="left" valign="top" background="Brain" class="style4">USG : <?php echo $result['TxtUSG'];?></td>
      </tr>
       <?php } if($result['ChkOthers'] == 1){?>
      <tr>
        <td align="left" valign="top" background="Brain" class="style4">Others : <?php echo $result['TxtOthers'];?></td>
      </tr>
       <?php }} ?>
    </table>
    <br />
    <table width="100%" border="0" cellspacing="2" cellpadding="2">
      <?php if($result['ChkDiagnosis'] == 1){?>
      <tr>
        <td class="style4">Diagnosis : <?php echo $result['Diagnosis'];?></td>
      </tr>
      <?php } if($result['ChkAdvice'] == 1){?>
      <tr>
        <td class="style4">Advised : <?php echo $result['Remark'];?></td>
      </tr>
      <?php } if($result['ChkPrevTreat'] == 1){?>
      <tr>
        <td class="style4">Previous Treatment : <?php echo $result['PrevTreatment'];?></td>
      </tr>
      <?php } if($result['ChkSpecialNote'] == 1){?>
      <tr>
        <td class="style4"><p>Special Notes : <?php echo $result['SpecialNote'];?></p>          </td>
      </tr>
    <?php } ?>
      <tr>
        <td class="style4">फेर तपासणी दिनांक : <?php echo date("d/m/Y", strtotime(str_replace('-', '/',$result['FollowUpDate']))); ?></td>
      </tr>
    </table>
    <table width="100%" border="0" cellspacing="2" cellpadding="2">

      <tr>
        <td align="left" valign="top" width="30%"><div align="center" class="style4"><strong>Treatment</strong></div></td>
      </tr>
      <tr>
        <td align="left" width="30%" valign="top"><div align="left" class="style4"><strong>Rx,</strong></div></td>
            <td width="7%" align="center" valign="top" class="style67">Mor</td>
              <td width="7%" align="center" valign="top" class="style67">Aft</td>
              <td width="7%" align="center" valign="top" class="style67">Eve</td>
              <td width="49%" align="center" valign="top" class="style67">&nbsp;</td>
      </tr>

 <?php  
            $sql7_2 = "SELECT * FROM tbl_consultant_treatments WHERE MrdNo='$mrd' AND VisitDate='".$result['VisitDate']."'";
            $row7_2 = getList($sql7_2);
            foreach($row7_2 as $result){
              $sql88 = "SELECT * FROM tbl_freq WHERE FreqName='".$result['TreatFreq1']."'";
              $row88 = getRecord($sql88);
              $Morning = $row88['Morning'];
              $Afternoon = $row88['Afternoon'];
              $Evening = $row88['Evening'];
            ?>
                  <tr>
             <!--  <td align="center" valign="top" class="style67">&nbsp;</td> -->
              <td align="left" valign="top" class="style67" style="font-size: 9px;">&nbsp;<?php echo strtoupper($result['TreatName1']);?></td>
              <td align="center" valign="top" class="style67">&nbsp;<?php echo $Morning;?></td>
              <td align="center" valign="top" class="style67">&nbsp;<?php echo $Afternoon;?></td>
              <td align="center" valign="top" class="style67">&nbsp;<?php echo $Evening;?></td>
              <td align="center" valign="top" class="style67">&nbsp;</td>
            </tr>
              <?php } ?>
                       
</table>    
    </td>
  </tr>
</table>
     
    </td>
  </tr>
</table>

<br>
<?php } ?>
</body>
</html>
