<?php
date_default_timezone_set("Asia/Jakarta");
$CaseID = $this->uri->segment(3);
$d = $this->db->query("Select * from Patient p join Cases c on p.PatientCode = c.PatientCode where c.[Case ID] = '$CaseID' ")->row_array();
$tgll = date('Y-m-d', strtotime(@$d['DOB']));
$tanggal_lahir = new DateTime($tgll);
$sekarang = new DateTime("today");
if ($tanggal_lahir > $sekarang) {
    $thn = "0";
    $bln = "0";
    $tgl = "0";
}
$thn = $sekarang->diff($tanggal_lahir)->y;
$bln = $sekarang->diff($tanggal_lahir)->m;
$tgl = $sekarang->diff($tanggal_lahir)->d;
?>
<table style="margin-top: -7px; width: 100%;">
    <tr>
        <td style="margin-top: -10px; width: 20%;"><img src="<?= base_url('images/logo.png'); ?>" width="70" height="50"></td>
        <td style="margin-top: -10px; width: 80%; text-align:center;">
            <b style='font-size:18px;'><?= $abdulradjak['NamaPerusahaan']; ?></b><br>
            <?= $abdulradjak['AlamatPerusahaan']; ?><br>
            <small>Telp. <?= $abdulradjak['TeleponPerusahaan']; ?>, Fax : <?= $abdulradjak['FaxPerusahaan']; ?></small>
        </td>
    </tr>
</table>
<hr>
<h3 style="text-align: center;"><u>FORM MONITORING TINDAKAN ANESTESI DAN BEDAH</u></h3>
<table class="table table-striped table-hover" id="example1" style="border-collapse: collapse; width:100mm;">
    <tr>
        <td>No.MR</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td><?= $d['PatientCode']; ?></td>
    </tr>
    <tr>
        <td>No.Reg</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td><?= $d['Case ID']; ?></td>
    </tr>
    <tr>
        <td>Nama</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td><?= $d['Description']; ?></td>
    </tr>
    <tr>
        <td>Kunjungan</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td><?= date('d-m-Y', strtotime($d['Intake Date'])); ?></td>
    </tr>
    <tr>
        <td>Jenis Kelamin</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <?php
            if($d['Sex'] == 1) {
                $Jenis = "Perempuan";
            }else{
                $Jenis = "Laki - Laki";
            }
        ?>
        <td><?= $Jenis; ?></td>
    </tr>
    <tr>
        <td>Tanggal Lahir</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td>
            <?php
            if ($d['DOB'] == '') {
            } else {
                echo date('d-m-Y', strtotime($d['DOB']));
            }
            ?>
        </td>
    </tr>
    <tr>
        <td>Umur</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td><?= $thn . ' th ' . $bln . ' bulan ' . $tgl . ' hari'; ?></td>
    </tr>
    <tr>
        <td>Alamat</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </td>
        <td><?= $d['HomeAddress1']; ?></td>
    </tr>
</table>
<h3 style="text-align: center;">ANESTESI</h3>
<table border="1" style="border-collapse: collapse;width:100%;text-align:center;">
<tr style="background-color: A9A9A9;">
    <td style="width:25%; text-align:center;">Pre Anestesi</td>
    <td style="width:25%; text-align:center;">Durante Anestesi</td>
    <td style="width:25%; text-align:center;">Jenis Pemberian Anastesi</td>
    <td style="width:25%; text-align:center;">Post Anestesi</td>
</tr>
<tr>
    <td>Gcs : <?= $data['Gcs']; ?></td>
    <td rowspan="7" style="text-align: center;">Durante Anestesi : <?= $data['Tindakan']; ?></td>
    <td rowspan="7" style="text-align: center;">Jenis Pemberian Anastesi : <?= $data['jenisanastesi'] ?></td>
    <td>Gcs : <?= $data['Gcsp']; ?></td>
</tr>
<tr>
    <td>TD : <?= $data['Td']; ?></td>
    <td>TD : <?= $data['Tdp']; ?></td>
</tr>
<tr>
    <td>N : <?= $data['N']; ?></td>
    <td>N : <?= $data['Np']; ?></td>
</tr>
<tr>
    <td>RR : <?= $data['RR']; ?></td>
    <td>RR : <?= $data['RRp']; ?></td>
</tr>
<tr>
    <td>Tax : <?= $data['Tax']; ?></td>
    <td>Tax : <?= $data['Taxp']; ?></td>
</tr>
<tr>
    <td>Nyeri : +/- <?= $data['Nyeri']; ?></td>
    <td>Nyeri : +/- <?= $data['Nyerip']; ?></td>
</tr>
<tr>
    <td>Lain - Lain : <?= $data['Lain2']; ?></td>
    <td>Lain - Lain : <?= $data['Lainlain']; ?></td>
</tr>
<tr>
</tr>
</table>
<h3 style="text-align: center;">PEMBEDAHAN</h3>
<table border="1" style="border-collapse: collapse;width:100%;">
<tr style="background-color: A9A9A9;">
    <td style="width:30%; text-align:center;">Pre Pembedahan</td>
    <td style="width:40%; text-align:center;">Durante Pembedahan</td>
    <td style="width:30%; text-align:center;">Post Pembedahan</td>
</tr>
<tr>
    <td style="text-align: center;"><?= $data['Tindakan1']; ?></td>
    <td style="text-align: center;"><?= $data['Tindakan2']; ?></td>
    <td style="text-align: center;"><?= $data['Tindakan3']; ?></td>
</tr>
</table><br><br><br>
<table style="float:right;">
                    <tr> 
                        <td style="text-align: center;"><p style="margin-top: 25px;">Dokter</p></td>
                    </tr>
                    <tr>
                    <td style="text-align: center;"><p style="margin-top: -1px;"><img src="<?= base_url('images/uploadsign/monitoring/' . $data['Ttd']); ?>.png" height="80px"> </p></td>
                    </tr>
                    <tr>
                        <td style="text-align: center;"><p>(<?= $data['Petugas']; ?>)</p></td>
                    </tr>
</table>
<script>
        window.onload = function() {
            window.print();
            setTimeout(window.close, 500);
        };
</script>
<!-- <label for=""><small style="aligen-text:right;"><i>**cetak <?= date('d-m-Y H:i:s'); ?></i></small></label> -->