<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            Pemeriksaan Fisik

        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Vclaim</a></li>
            <li class="active">Anamnesa</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">

        <!-- Default box -->
        <div class="box">
            <div class="box-header with-border">
                <div class="box-tools pull-right">
                    <button class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse"><i class="fa fa-minus"></i></button>
                    <button class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove"><i class="fa fa-times"></i></button>
                </div>
            </div>
            <div class="box-body">
                <?php if ($this->session->flashdata('success')): ?>
                    <div class="alert alert-success">
                        <?= $this->session->flashdata('success'); ?>
                    </div>
                <?php elseif ($this->session->flashdata('error')): ?>
                    <div class="alert alert-danger">
                        <?= $this->session->flashdata('error'); ?>
                    </div>
                <?php endif; ?>
                <div class="row">
                    <div class="col-md-3">
                        <div class="box box-solid box-success">
                            <div class="box-header with-border">
                                <span><small><i class="fa fa-user"> Peserta</i></small> </span>
                                <div class="box-tools">
                                    <button type="button" class="btn btn-box-tool" data-widget="collapse">
                                        <i class="fa fa-minus"></i>
                                    </button>
                                </div>
                            </div>
                            <div class="box-body no-padding">
                                <ul class="nav nav-pills nav-stacked">
                                    <li>
                                        <a title="Kode MR">
                                            <small><i class="fa fa-fw fa-sort-numeric-asc"></i>
                                                <?= $case['PatientCode']; ?>
                                            </small>
                                        </a>
                                    </li>
                                    <li>
                                        <a title="Nama Pasien">
                                            <small>
                                                <i class="fa fa-fw fa-user"></i>
                                                <?= $case['Description']; ?>
                                            </small>
                                        </a>
                                    </li>

                                    <li>
                                        <a title="Tanggal Lahir Pasien">
                                            <small>
                                                <i class="fa fa-fw fa-calendar-o"></i>
                                                <?php
                                                $pass = $case['PatientCode'];
                                                $pas = $this->db->query("SELECT * FROM Patient WHERE PatientCode = '$pass'")->row_array();
                                                // tanggal lahir
                                                echo date('d F Y', strtotime($pas['DOB']));
                                                ?>
                                            </small>
                                        </a>
                                    </li>
                                    <li>
                                        <a title="Usia Pasien">
                                            <small>
                                                <i class="fa fa-fw fa-calendar-o"></i>
                                                <?php
                                                // tanggal lahir
                                                $dob = date('Y-m-d', strtotime($pas['DOB']));
                                                $tanggal = new DateTime($dob);

                                                // tanggal hari ini
                                                $today = new DateTime('today');

                                                // tahun
                                                $y = $today->diff($tanggal)->y;

                                                // bulan
                                                $m = $today->diff($tanggal)->m;

                                                // hari
                                                $d = $today->diff($tanggal)->d;
                                                echo  $y . " tahun " . $m . " bulan " . $d . " hari";
                                                ?>
                                            </small>
                                        </a>
                                    </li>

                                    <li>
                                        <a title="Tanggal Periksa">
                                            <small>
                                                <i class="fa fa-fw fa-calendar"></i>
                                                <?= $case['Intake Date']; ?>
                                            </small>
                                        </a>
                                    </li>
                                    <?php
                                    if ($case['NoSEP'] == '') {
                                    } else {
                                    ?>
                                        <li>
                                            <a title="Nomor SEP">
                                                <small>
                                                    <i class="fa fa-fw fa-book"></i>
                                                    <?= $case['NoSEP']; ?>
                                                </small>
                                            </a>
                                        </li>
                                    <?php
                                    }
                                    ?>
                                    <li>
                                        <a title="Antrian Poli">
                                            <small>
                                                <i class="fa fa-fw fa-desktop"></i>
                                                <?= $case['FRNo']; ?>
                                            </small>
                                        </a>
                                    </li>
                                    <li>
                                        <a title="Company">
                                            <small>
                                                <i class="fa fa-fw fa-desktop"></i>
                                                <?php
                                                $cm = $case['CompanyCode'];
                                                $cc = $this->db->query("SELECT * FROM Company WHERE CompanyCode = '$cm'")->row_array();
                                                ?>
                                                <?= $cc['CompanyCode'] . ' - ' . $cc['CompanyName']; ?>
                                            </small>
                                        </a>
                                    </li>

                                </ul>
                            </div>
                            <!-- /.box-body -->
                        </div>
                    </div>
                    <div class="col-md-9">
                        <?php
                        $mr = $case['PatientCode'];
                        $alergi = $this->db->query("Select alergi_obat,alergiobat from CaseDetail a JOIN Cases c on a.[Case ID] = c.[Case ID] where c.PatientCode = '$mr' Order by c.[Case ID] DESC")->row_array();
                        ?>
                        <?php
                        if ($alergi['alergi_obat'] == 'Tidak' || $alergi['alergi_obat'] == Null) {
                        ?>
                            <div class="alert alert-info alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                <h4>Tidak Ada Alergi</h4>Pasien Ini Tidak Memiliki Alergi
                            </div>
                        <?php } else { ?>
                            <div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                <h4><i class="icon fa fa-ban"></i> Alert !!!</h4>Pasien Ini Memiliki Alergi <?= $alergi['alergiobat']; ?>
                            </div>
                        <?php } ?>
                        <table class="table table-striped table-bordered table-hover">
                            <tr>
                                <th>Poli Tujuan</th>
                                <th>Dokter</th>
                            </tr>
                            <tr>
                                <?php
                                $dId = $listDetail['DoctorID'];
                                $sdId = $this->db->query("SELECT * FROM Doctor where DoctorID = '$dId'")->row_array();
                                ?>
                                <td><?= $listDetail['Unit']; ?></td>
                                <td><?= $listDetail['DoctorID']; ?> - <?= $sdId['FirstName'] . ', ' . $sdId['LastName']; ?></td>
                            </tr>
                        </table>

                        <table style="display: none;" class="table table-striped table-bordered table-hover">
                            <tr>
                                <th>Kesadaran E</th>
                                <th>Kesadaran M</th>
                                <th>Kesadaran V</th>
                            </tr>
                            <tr>
                                <td><?= $listDetail['Kesadaran_E']; ?></td>
                                <td><?= $listDetail['Kesadaran_M']; ?></td>
                                <td><?= $listDetail['Kesadaran_V']; ?></td>
                            </tr>
                        </table>

                        <table class="table table-striped table-bordered table-hover">
                            <tr>
                                <th>Tekanan Darah <small>mmHg</small></th>
                                <th>Frekuensi Nadi <small>x/mnt</small></th>
                                <th>Frekuensi Nafas <small>x/mnt</small></th>
                                <th>Suhu <small><sup>o</sup>C</small></th>
                                <?php
                                if ($listDetail['LingkarKepala'] != NULL) {
                                ?>
                                    <th>Lingkar Kepala Bayi</th>
                                <?php
                                }
                                ?>
                            </tr>
                            <tr>
                                <td><?= $listDetail['Tensi']; ?> </td>
                                <td><?= $listDetail['heartRate']; ?> </td>
                                <td><?= $listDetail['respRate']; ?> </td>
                                <td><?= $listDetail['Suhu']; ?></td>
                                <?php
                                if ($listDetail['LingkarKepala'] != NULL) {
                                ?>
                                    <td>
                                        <?= $listDetail['LingkarKepala']; ?>
                                    </td>
                                <?php
                                }
                                ?>
                            </tr>
                        </table>

                        <table class="table table-striped table-bordered table-hover">
                            <tr>
                                <th>TB <small>cm</small></th>
                                <th>BB <small>kg</small></th>
                                <th>IMT</th>
                                <th>Klasifikasi IMT</th>
                            </tr>
                            <tr>
                                <td><?= $listDetail['TinggiBadan']; ?></td>
                                <td><?= $listDetail['BeratBadan']; ?></td>
                                <td><?= $listDetail['IMT']; ?></td>
                                <td><?= $listDetail['KlasifikasiIMT']; ?></td>
                            </tr>
                        </table>

                        <table class="table table-striped table-bordered table-hover">
                            <tr>
                                <th width="15%">Usia Kunjungan</th>
                                <th width="20%">Tingkat Nyeri</th>

                            </tr>
                            <tr>
                                <td><?= $listDetail['usia_kunjungan']; ?> Th.</td>
                                <td>
                                    <?= $listDetail['tingkat_nyeri']; ?>
                                </td>

                            </tr>
                        </table>

                        <table class="table table-striped table-bordered table-hover">
                            <tr>
                                <td colspan="3"><b>Resiko Jatuh</b></td>
                            </tr>
                            <tr>
                                <td>
                                    <b>Cara Berjalan Pasien<br>
                                        1. Tidak seimbang/Sempoyongan/limbung<br>
                                        2. Jalan menggunakan alat bantu (keruk,tripot,kursi roda,oranglain)</b>
                                </td>
                                <td>
                                    <b> Menopang saat akan duduk : tampak memegang<br>
                                        Pingggiran kursi atau meja / benda lain <br>
                                        sebagai penopang saat akan duduk</b>
                                </td>
                            </tr>
                            <tr>
                                <td><?= $listDetail['resiko_a']; ?></td>
                                <td><?= $listDetail['resiko_b']; ?></td>
                            </tr>
                            <tr>
                                <td><b>Resiko Jatuh</b></td>
                                <td><b>Tindakan</b></td>
                            </tr>
                            <tr>
                                <td><?= $listDetail['hasilresiko']; ?></td>
                                <td><?= $listDetail['tindakanresiko']; ?></td>
                            </tr>
                        </table>

                        <table class="table table-striped table-bordered table-hover">
                            <tr>
                                <th>Pernah Dirawat</th>
                                <th>Sakit yang Sama</th>
                                <th>Pernah Operasi</th>
                                <th>Penyakit Keluarga</th>
                                <th>Riwayat Obat Diminum</th>
                            </tr>
                            <tr>
                                <td>
                                    <?= $listDetail['pernahDirawat']; ?>
                                    <?php
                                    if ($listDetail['pernahDirawat'] == 'YA') {
                                        echo "<br>Dirawat : " . $listDetail['KapanDirawat'] . "<br>";
                                        echo $listDetail['DimanaDirawat'] . "<br>";
                                    }
                                    ?>
                                </td>
                                <td><?= $listDetail['SakitYangSama']; ?></td>
                                <td>
                                    <?= $listDetail['Operasi']; ?>
                                    <?php
                                    if ($listDetail['Operasi'] == 'YA') {
                                        echo "<br>Riwayat : " . $listDetail['RiwayatOperasi'];
                                    }
                                    ?>
                                </td>
                                <td>
                                    <?= $listDetail['PenyakitKeluarga']; ?> <br>
                                    <?= $listDetail['RiwayatPenyakitKeluarga']; ?>
                                </td>
                                <td><?= $listDetail['RiwayatObatDiminum']; ?></td>
                            </tr>
                        </table>

                        <table class="table table-striped table-bordered table-hover">
                            <tr>
                                <th>Alergi Obat</th>
                            </tr>
                            <tr>
                                <td>
                                    <?= $listDetail['alergi_obat']; ?>
                                </td>

                            </tr>
                        </table>

                        <a href="<?= base_url('anamnesa/cetakantrian/' . $listDetail['Case ID']); ?>" target="_blank" class="btn btn-primary">Print Antrian</a>
                        <?php
                        if ($listDetail['Unit'] == 'MCU') {
                        ?>
                            <a href="<?= base_url('Mcu/cetakmcu/' . $listDetail['Case ID']); ?>" target="_blank" class="btn btn-default"><i class="fa fa-print"></i>Cetak Mcu</a>
                        <?php } else {
                        } ?>
                    </div>

                </div>
            </div><!-- /.box-body -->
            <div class="box-footer">
                <?= date('d F Y'); ?>
            </div><!-- /.box-footer-->
        </div><!-- /.box -->

    </section><!-- /.content -->
</div><!-- /.content-wrapper -->