<!-- 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
                $id = $this->uri->segment(4);
                $db = $this->db->query("SELECT c.Description,e.diagnosa_primer FROM Cases c join erm_pemeriksaan_fisik e on c.[Case ID] = e.case_id 
                    where c.PatientCode = '$id' ")->row_array();
                ?>
                <?php if ($db['diagnosa_primer'] == 'B20') { ?>
                    <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 Diagnosis HIV AIDS
                    </div>
                <?php } elseif ($db['diagnosa_primer'] == 'B20.0') { ?>
                    <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 Diagnosis HIV AIDS
                    </div>
                <?php } elseif ($db['diagnosa_primer'] == 'B20.1') { ?>
                    <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 Diagnosis HIV AIDS
                    </div>
                <?php } elseif ($db['diagnosa_primer'] == 'B20.2') { ?>
                    <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 Diagnosis HIV AIDS
                    </div>
                <?php } elseif ($db['diagnosa_primer'] == 'B20.3') { ?>
                    <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 Diagnosis HIV AIDS
                    </div>
                <?php } elseif ($db['diagnosa_primer'] == 'B20.4') { ?>
                    <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 Diagnosis HIV AIDS
                    </div>
                <?php } elseif ($db['diagnosa_primer'] == 'B20.5') { ?>
                    <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 Diagnosis HIV AIDS
                    </div>
                <?php } elseif ($db['diagnosa_primer'] == 'B20.6') { ?>
                    <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 Diagnosis HIV AIDS
                    </div>
                <?php } elseif ($db['diagnosa_primer'] == 'B20.7') { ?>
                    <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 Diagnosis HIV AIDS
                    </div>
                <?php } elseif ($db['diagnosa_primer'] == 'B20.8') { ?>
                    <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 Diagnosis HIV AIDS
                    </div>
                <?php } elseif ($db['diagnosa_primer'] == 'B20.9') { ?>
                    <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 Diagnosis HIV AIDS
                    </div>
                <?php } elseif ($db['diagnosa_primer'] == '098.7') { ?>
                    <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 Diagnosis HIV AIDS 098.7
                    </div>
                <?php } elseif ($db['diagnosa_primer'] == '098.4') { ?>
                    <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 Diagnosis HEPATITIS 098.4
                    </div>
                <?php } elseif ($db['diagnosa_primer'] == '098.1') { ?>
                    <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 Diagnosis Syphilis complicating 098.1
                    </div>
                <?php } elseif ($db['diagnosa_primer'] == 'B18') { ?>
                    <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 Diagnosis Chronic viral hepatitis B.18
                    </div>
                <?php } elseif ($db['diagnosa_primer'] == 'A16') { ?>
                    <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 Diagnosis Respiratory tuberculosis
                    </div>
                <?php } elseif ($db['diagnosa_primer'] == 'Z20.1') { ?>
                <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 Diagnosis TB
                </div>
                <?php } else { ?>

                <?php } ?>

                <?php
                        $mr = $case['PatientCode'];
                        $alergi = $this->db->query("Select alergi_obat,alergiobat,PenyakitKeluarga 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['alergi_obat'] . ' - ' . $alergi['alergiobat']; ?>
                            </div>
                <?php } ?>
                <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="No Kunjungan">
                                            <small><i class="fa fa-fw fa-sort-numeric-asc"></i>
                                                <?= $case['Case ID']; ?>
                                            </small>
                                        </a>
                                    </li>
                                    <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="Kode PPK Peserta">
                                            <small>
                                                <i class="fa fa-fw fa-user"></i>
                                                <?= $kodePpkPeserta; ?>
                                            </small>
                                        </a>
                                    </li>

                                    <li>
                                        <a title="Kode PPK Klinik">
                                            <small>
                                                <i class="fa fa-fw fa-user"></i>
                                                <?= $kodePpkRs; ?>
                                            </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">
                        <form onsubmit="return validate(this);" action="<?= base_url('anamnesa/prosesAnamnesisJKN'); ?>" method="post">
                            <div class="row">
                                <div class="col-md-6">
                                    <label for="">Poli Tujuan <small style="color: red;">isi*</small></label>
                                    <select name="Unit" class="form-control unit" id="" required>
                                        <option value="">- Pilih -</option>
                                        <?php
                                        foreach ($antrian as $klinik) :
                                        ?>
                                            <option value="<?= $klinik['Jenis']; ?>"><?= $klinik['Jenis']; ?></option>
                                        <?php
                                        endforeach;
                                        ?>
                                    </select>
                                </div>
                                <div class="col-md-6">
                                    <label for="">Dokter Tujuan <small style="color: red;">isi*</small></label> <br>
                                    <select name="DoctorID" class="form-control" id="dokter" required>
                                    </select>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-4" style="margin-top: 10px;">
                                    <label for="">Kesadaran E <small style="color: red;">isi*</small></label>
                                    <input type="text" name="case_id" hidden value="<?= $case['Case ID']; ?>">
                                    <input type="text" name="nomorkartu" hidden value="<?= $case['nokartu']; ?>">
                                    <input type="text" name="kodePPKRs" hidden value="<?= $kodePpkRs; ?>">
                                    <input type="text" name="KodePPKPst" hidden value="<?= $kodePpkPeserta; ?>">
                                    <select name="Kesadaran_E" class="form-control" required>
                                        <option value=""></option>
                                        <option value="1">1</option>
                                        <option value="2">2</option>
                                        <option value="3">3</option>
                                        <option value="4">4</option>
                                    </select>
                                </div>
                                <div class="col-md-4" style="margin-top: 10px;">
                                    <label for="">Kesadaran M <small style="color: red;">isi*</small></label>
                                    <!-- <input type="text" autocomplete="off" class="form-control" name="Kesadaran_M"> -->
                                    <select name="Kesadaran_M" class="form-control" required>
                                        <option value=""></option>
                                        <option value="1">1</option>
                                        <option value="2">2</option>
                                        <option value="3">3</option>
                                        <option value="4">4</option>
                                        <option value="5">5</option>
                                        <option value="6">6</option>
                                    </select>
                                </div>
                                <div class="col-md-4" style="margin-top: 10px;">
                                    <label for="">Kesadaran V <small style="color: red;">isi*</small></label>
                                    <!-- <input type="text" autocomplete="off" class="form-control" name="Kesadaran_V"> -->
                                    <select name="Kesadaran_V" class="form-control" required>
                                        <option value=""></option>
                                        <option value="1">1</option>
                                        <option value="2">2</option>
                                        <option value="3">3</option>
                                        <option value="4">4</option>
                                        <option value="5">5</option>
                                        <!-- <option value="6">6</option> -->
                                    </select>
                                </div>
                            </div>
                            <div class="row">
                                <?php
                                if ($y > 10) {
                                ?>
                                    <div class="col-md-4" style="margin-top: 10px;">
                                        <label for="">Tekanan Darah <small>*mmHg</small> <small style="color: red;">isi*</small></label>
                                        <input type="number" min="40" max="250" autocomplete="off" class="form-control" name="Tensi" required placeholder="Min 40 - 250 Max">
                                    </div>
                                    <div class="col-md-4" style="margin-top: 10px;">
                                        <label for="">Tekanan Darah Per /<small style="color: red;">isi*</small></label>
                                        <input type="number"  min="30" max="180" autocomplete="off" class="form-control" name="TensiPer" placeholder="Min 30 - 180 Max" required>
                                    </div>
                                <?php
                                } else {
                                ?>
                                    <div class="col-md-4" style="margin-top: 10px;">
                                        <label for="">Tekanan Darah <small>*mmHg</small></label>
                                        <input type="number" min="40" max="250" autocomplete="off" class="form-control" name="Tensi" placeholder="Min 40 - 250 Max>
                                    </div>
                                    <div class="col-md-4" style="margin-top: 10px;">
                                        <label for="">Tekanan Darah Per /<small style="color: red;">isi*</small></label>
                                        <input type="number" min="30" max="180" autocomplete="off" class="form-control" name="TensiPer"  placeholder="Min 30 - 180 Max" required>
                                    </div>
                                <?php
                                }
                                ?>

                                <div class="col-md-4" style="margin-top: 10px;">
                                    <label for="">Frekuensi Nadi <small>*x/mnt</small> <small style="color: red;">isi*</small></label>
                                    <input type="text" autocomplete="off" class="form-control" name="FrekuensiNadi"  placeholder="Min 30 - 160 Max" required>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6" style="margin-top: 10px;">
                                    <label for="">Frekuensi Nafas <small>*x/mnt</small> <small style="color: red;">isi*</small></label>
                                    <input type="text" autocomplete="off" class="form-control" name="FrekuensiNafas" placeholder="Min 5 - 70 Max" required>
                                </div>
                                <div class="col-md-6" style="margin-top: 10px;">
                                    <label for="">Suhu <small>*<sup>o</sup>C</small> <small style="color: red;">isi*</small></label>
                                    <input type="text" autocomplete="off" class="form-control" name="Suhu" required>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6" style="margin-top: 10px;">
                                    <label for="">Tinggi Badan <small>*m</small></label>
                                    <input type="text" placeholder="exp: 1.65 Max 30-250 cm" maxlength="5" autocomplete="off" class="form-control" name="TB" id="txt1" onkeyup="sum();" onkeydown="return disableKoma(event)">
                                </div>
                                <div class="col-md-6" style="margin-top: 10px;">
                                    <label for="">Berat Badan <small>*kg.</small></label>
                                    <input type="text" maxlength="3" autocomplete="off" class="form-control" name="BB" id="txt2" onkeyup="sum();" onkeydown="return disableKoma(event)" placeholder="Min 2 - 300 Max">
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-6" style="margin-top: 10px;">
                                    <label for="">IMT</label>
                                    <input type="text" name="IMT" readonly id="txt3" class="form-control">
                                </div>
                                <div class="col-md-6" style="margin-top: 10px;">
                                    <label for="">Klasifikasi IMT</label>
                                    <input type="text" name="klasifikasiIMT" readonly id="klasifikasiIMT" class="form-control">
                                </div>
                                <div class="col-md-6" style="margin-top: 10px;">
                                    <?php
                                    if ($y >= 3) {
                                    ?>
                                        <label style="display: none;" for="">Lingkar Kepala Bayi <small>*cm</small></label>
                                        <input type="text" style="display: none;" maxlength="3" name="LingkarKepala" class="form-control">
                                    <?php
                                    } else {
                                    ?>
                                        <label for="">Lingkar Kepala Bayi <small>*cm</small></label>
                                        <input type="text" maxlength="3" name="LingkarKepala" class="form-control">
                                    <?php
                                    }
                                    ?>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6" style="margin-top: 10px;">
                                    <label for="">Lingkar Perut*</label>
                                    <input type="text" name="lingkarperut" required class="form-control">
                                </div>
                            </div>
                            <div class="row" hidden>
                                <div class="col-md-12" style="display: block;">
                                    <label for="">Status Gizi</small></label>
                                    <select name="statusgizi" id="displaygizi" class="form-control" id="">
                                        <option value="">Pilih Status Gizi</option>
                                        <option value="-" selected>-</option>
                                        <option value="Balita">Balita</option>
                                        <option value="Ibu Hamil">Ibu Hamil</option>
                                    </select>
                                </div>
                            </div>
                            <hr>
                            <div class="row">
                                <div class="col-md-12" style="display: none;" id="PanelGizi">
                                    <label for="">Panjang Badan Balita</label>
                                    <textarea name="panjangbalita" class="form-control"></textarea>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12" style="display: none;" id="Panelibuhamil">
                                    <label for="">Lila</label>
                                    <textarea name="lila" class="form-control"></textarea>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12" style="display: block;">
                                    <label for="">Keluhan <small style="color: red;">isi*</small></label>
                                    <textarea name="Keluhan" class="form-control" required></textarea>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12" style="display: block;">
                                    <label for="">Pisikososial <small style="color: red;">isi*</small></label>
                                    <textarea name="Pisikososial" class="form-control" required></textarea>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12" style="display: block;">
                                    <label for="">Spiritual <small style="color: red;">isi*</small></label>
                                    <textarea name="Spiritual" class="form-control" required></textarea>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12" style="display: block;">
                                    <label for="">Penilaian Tingkat Nyeri <small style="color: red;">isi*</small></label>
                                    <select class="form-control" name="tingkat_nyeri" required>
                                        <option value=""></option>
                                        <?php
                                        foreach ($tingkatnyeri as $nyeri) :
                                        ?>
                                            <option value="<?= $nyeri['nilai']; ?> - <?= $nyeri['deskripsi']; ?>"><?= $nyeri['nilai']; ?> - <?= $nyeri['deskripsi']; ?></option>
                                        <?php
                                        endforeach;
                                        ?>
                                    </select>
                                </div>
                            </div>
                            <div class="row" style="margin-bottom: 5px;">
                                <div class="col-md-12" style="display: block;">
                                    <label for="">Riwayat Penyakit Pasien<small style="color: red;"> isi*</small></label>
                                    <select name="riwayatpenyakit" class="form-control Riwayatpasien" required>
                                        <?php
                                        foreach ($riwayatPenyakit as $sRiwayatPenyakit) :
                                        ?>
                                            <option value="<?= $sRiwayatPenyakit['RiwayatPenyakit']; ?>">
                                                <?= $sRiwayatPenyakit['RiwayatPenyakit']; ?></option>
                                        <?php
                                        endforeach;
                                        ?>
                                    </select>
                                    <input type="text" style="display: none; margin-top:10px" id="Riwayatlainya" name="Riwayatlainya" class="form-control" placeholder="Riwayat lainnya ...">
                                </div>
                            </div>


                            <br>

                            <!-- name : resikojatuh  -->
                            <label for="">Pasien Resiko Jatuh</label> <br>
                            <div class="row">
                                <div class="col-md-8">

                                    <b>Cara Berjalan Pasien<br>
                                        1. Tidak seimbang/Sempoyongan/limbung<br>
                                        2. Jalan menggunakan alat bantu (keruk,tripot,kursi roda,oranglain)</b>
                                </div>
                                <div class="col-md-4">
                                    <select name="resiko_a" id="resiko1" class="form-control" required>
                                        <option value="">- Pilih -</option>
                                        <option value="YA">YA</option>
                                        <option value="TIDAK">TIDAK</option>
                                    </select>
                                </div>
                            </div>

                            <div class="row" style="margin-top: 15px;">

                                <div class="col-md-8">
                                    <b> Menopang saat akan duduk : tampak memegang<br>
                                        Pingggiran kursi atau meja / benda lain <br>
                                        sebagai penopang saat akan duduk</b>
                                </div>
                                <div class="col-md-4">

                                    <select name="resiko_b" id="resiko2" class="form-control" required>
                                        <option value="">- Pilih -</option>
                                        <option value="YA">YA</option>
                                        <option value="TIDAK">TIDAK</option>
                                    </select><br>

                                </div>
                            </div>

                            <br>

                            <!-- <form class="sidebar-form"> -->
                            <div class="input-group">
                                <input readonly type="text" name="hasilresiko" id="valueResiko" class="form-control">
                                <span class="input-group-btn">
                                    <button type="button" name="" id="resetResiko" class="btn btn-flat btn-warning">Reset Resiko
                                    </button>
                                </span>
                            </div>
                            <!-- </form> -->

                            <br>
                            <input type="text" name="tindakanresiko" class="form-control" placeholder="Tindakan Resiko">

                            <hr>
                            <div class="row" style="margin-top: 10px;">

                                <div class="col-md-3">
                                    <b>Pernah Dirawat Sebelumnya</b>
                                </div>
                                <div class="col-md-9">
                                    <input type="radio" name="pernahDirawat" value="YA" class="pernahDirawat" id="pernahDirawat1"> <label style="font-weight: normal;cursor: pointer;" for="pernahDirawat1">YA</label> &nbsp; &nbsp;
                                    <input type="radio" name="pernahDirawat" value="TIDAK" checked class="pernahDirawat" id="pernahDirawat2">
                                    <label style="font-weight: normal;cursor: pointer;" for="pernahDirawat2">TIDAK</label>

                                    <input type="text" style="display: none; margin-top:10px" id="KapanDirawat" name="KapanDirawat" class="form-control" placeholder="Kapan dirawat ...">

                                    <input type="text" style="display: none; margin-top:10px" id="DimanaDirawat" name="DimanaDirawat" class="form-control" placeholder="Dimana dirawat ...">
                                </div>
                            </div>

                            <div class="row" style="margin-top: 10px;">

                                <div class="col-md-3">
                                    <b>Apakah dengan sakit yang sama</b>
                                </div>
                                <div class="col-md-9">
                                    <input type="radio" name="SakitYangSama" value="YA" id="SakitYangSama1">
                                    <label style="font-weight: normal;cursor: pointer;" for="SakitYangSama1">YA</label> &nbsp; &nbsp;
                                    <input type="radio" name="SakitYangSama" value="TIDAK" class="SakitYangSama" id="SakitYangSama2" checked>
                                    <label style="font-weight: normal;cursor: pointer;" for="SakitYangSama2">TIDAK</label>
                                </div>
                            </div>

                            <div class="row" style="margin-top: 10px;">

                                <div class="col-md-3">
                                    <b>Riwayat Operasi</b>
                                </div>
                                <div class="col-md-9">

                                    <input type="radio" name="Operasi" value="YA" class="RiwayatOperasi" id="RiwayatOperasi1"> <label style="font-weight: normal;cursor: pointer;" for="RiwayatOperasi1">YA</label> &nbsp; &nbsp;
                                    <input type="radio" name="Operasi" value="TIDAK" checked class="RiwayatOperasi" id="RiwayatOperasi2">
                                    <label style="font-weight: normal;cursor: pointer;" for="RiwayatOperasi2">TIDAK</label>

                                    <textarea style="display: none; margin-top:10px" id="CeritaOperasi" name="RiwayatOperasi" class="form-control" placeholder="Riwayat operasi ..."></textarea>
                                </div>
                            </div>

                            <div class="row" style="margin-top: 10px;">

                                <div class="col-md-3">
                                    <b>Riwayat Penyakit Keluarga</b>
                                </div>
                                <div class="col-md-9">
                                    <select name="PenyakitKeluarga" class="form-control riwayatKeluarga" required>
                                    <?php
                                         foreach ($riwayatPenyakit as $sRiwayatPenyakit) :
                                            if ($sRiwayatPenyakit['RiwayatPenyakit'] == $alergi['PenyakitKeluarga']) {
                                        ?>
                                                <option selected value="<?= $alergi['PenyakitKeluarga']; ?>"><?= $sRiwayatPenyakit['RiwayatPenyakit']; ?></option>
                                            <?php
                                            } else {
                                            ?>
                                                <option selected value="<?= $sRiwayatPenyakit['RiwayatPenyakit']; ?>"><?= $sRiwayatPenyakit['RiwayatPenyakit']; ?></option>
                                        <?php
                                            }

                                        endforeach;
                                        ?>

                                    <input type="text" style="display: none; margin-top:10px" id="RiwayatPenyakitKeluarga" name="RiwayatPenyakitKeluarga" class="form-control" placeholder="Riwayat lainnya ...">
                                </div>
                            </div>

                            <div class="row" style="margin-top: 10px;">
                                <div class="col-md-3">
                                    <b>Riwayat Obat yang diminum / Obat Rutin</b>
                                </div>
                                <div class="col-md-9">
                                    <textarea class="form-control" name="RiwayatObatDiminum" rows="3" cols="80">TIDAK ADA</textarea>
                                </div>
                            </div>

                            <!-- <hr> -->

                            <div class="row" style="margin-top: 10px;">
                                <div class="col-md-3">
                                    <b>Alergi Obat </b><small style="color: red;"> wajib diisi*</small>
                                </div>
                                <?php
                                    if($alergi['alergi_obat'] == 'Tidak' || $alergi['alergi_obat'] == NULL){
                                ?>
                               <div class="col-md-9">
                                    <select name="alergi_obat" id="alergi_obat"  class="form-control Alergi" >
                                        <option value="">Pilih Alergi</option>
                                        <option value="YA" selected>YA</option>
                                        <option value="Tidak">Tidak</option>
                                    </select>
                                </div>
                                <?php  }else{ ?>
                                    <div class="col-md-9">
                                    <select name="alergi_obat" id="alergi_obat" class="form-control Alergi">
                                        <option value="">Pilih Alergi</option>
                                        <option value="YA" selected>YA</option>
                                        <option value="Tidak">Tidak</option>
                                    </select>
                                </div>
                                <?php } ?>
                                
                            </div>

                            <div class="row" style="margin-top: 10px;" id="Alergi">
                                <div class="col-md-3">
                                    <b>Ketik Alergi</b>
                                </div>
                                <div class="col-md-9">
                                    <textarea name="alergi_obat1" id="Alergi" class="form-control"><?= $alergi['alergiobat']; ?></textarea>
                                </div>
                            </div>

                            <input hidden type="text" name="usia_kunjungan" value="<?= $y; ?>">

                            <div class="row">
                                <div class="col-md-3"></div>
                                <div class="col-md-9">
                                    <button type="submit" class="btn bg-green-gradient btn-info" style="outline-style: none;border-style: none;margin-top:10px"><i class="fa fa-fw fa-save"></i> Simpan</button>
                                </div>
                            </div>

                        </form>
                    </div>

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

    </section><!-- /.content -->
</div><!-- /.content-wrapper -->
<script src="<?= base_url('assets/'); ?>jquery-3.3.1.min.js"></script>
<script src="<?= base_url('assets/'); ?>jquery-migrate-1.4.1.min.js"></script>
<script>


    var isAlergiObat = "<?php echo $alergi['alergi_obat']; ?>";   
    if(isAlergiObat.toLowerCase() == 'ya'){
        document.getElementById("alergi_obat").disabled = true;
    }                             


    $(document).ready(function() {
        $('#tindakLanjut').change(function() {
            if ($(this).val() == "Kontrol") {
                $("#tanggalKontrol").show();
                $("#alasanrujuk").hide();
                $("#rujukke").hide();
                $("#atasdasar").hide();
                $("#meninggal").hide();
            } else if ($(this).val() == "Dirujuk") {
                $("#tanggalKontrol").hide();
                $("#alasanrujuk").show();
                $("#rujukke").show();
                $("#atasdasar").show();
                $("#meninggal").hide();
            } else if ($(this).val() == "Meninggal") {
                $("#tanggalKontrol").hide();
                $("#alasanrujuk").hide();
                $("#rujukke").hide();
                $("#atasdasar").hide();
                $("#meninggal").show();
            } else {
                $("#tanggalKontrol").hide();
                $("#alasanrujuk").hide();
                $("#rujukke").hide();
                $("#atasdasar").hide();
                $("#meninggal").hide();
            }
        });

        $('.riwayat').change(function() {
            if ($(this).val() == "Lainnya") {
                $("#RiwayatDahuluLainnya").show();
            } else {
                $("#RiwayatDahuluLainnya").hide();
            }
        });

        $('.pernahDirawat').change(function() {
            if ($(this).val() == "YA") {
                $("#KapanDirawat").show();
                $("#DimanaDirawat").show();
            } else {
                $("#KapanDirawat").hide();
                $("#DimanaDirawat").hide();
            }
        });

        $('.riwayatKeluarga').change(function() {
            if ($(this).val() == "LAINNYA") {
                $("#RiwayatPenyakitKeluarga").show();
            } else {
                $("#RiwayatPenyakitKeluarga").hide();
            }
        });

        $('.Riwayatpasien').change(function() {
            if ($(this).val() == "LAINNYA") {
                $("#Riwayatlainya").show();
            } else {
                $("#Riwayatlainya").hide();
            }
        });

        $('.RiwayatOperasi').change(function() {
            if ($(this).val() == "YA") {
                $("#CeritaOperasi").show();
            } else {
                $("#CeritaOperasi").hide();
            }
        });

        $('.Alergi').change(function() {
            if ($(this).val() == "YA") {
                $("#Alergi").show();
            } else {
                $("#Alergi").hide();
            }
        });

        $('#displaygizi').change(function() {
            if ($(this).val() == "Balita") {
                $("#PanelGizi").show();
                $("#Panelibuhamil").hide();
            } else if ($(this).val() == "Ibu Hamil") {
                $("#Panelibuhamil").show();
                $("#PanelGizi").hide();
            } else {
                $("#PanelGizi").hide();
                $("#Panelibuhamil").hide();
            }
        });
    });
</script>

<script>
    function disableKoma(e) {
        if (e.keyCode == 188) {
            return false;
        }
        return true;
    }

    function sum() {
        var txtFirstNumberValue = document.getElementById('txt1').value;
        var txtSecondNumberValue = document.getElementById('txt2').value;
        var tinggibadan = txtFirstNumberValue ** 2;
        var result = parseFloat(txtSecondNumberValue) / parseFloat(tinggibadan);

        if (result >= 30) {
            var deskripsi = "Obesitas II";
        } else if (result >= 25) {
            var deskripsi = "Obesitas I";
        } else if (result >= 23) {
            var deskripsi = "Kelebihan berat badan normal (Overweight) dengan risiko";
        } else if (result >= 18.5) {
            var deskripsi = "Berat badan normal";
        } else if (result < 18.5) {
            var deskripsi = "Berat badan kurang (Underweight)";
        }
        // alert(deskripsi);
        if (!isNaN(result)) {
            document.getElementById('txt3').value = result.toFixed(2);
        }
        document.getElementById('klasifikasiIMT').value = deskripsi;
    }
</script>

<script>
    $('.unit').change(function() {
        var _layanan = $(this).val();
        $.ajax({
            url: "<?= base_url('rekamMedis/getDokter'); ?>",
            method: "POST",
            data: {
                layanan: _layanan
            },
            async: true,
            dataType: 'json',
            success: function(data) {
                var html = '';
                var i;

                for (i = 0; i < data.length; i++) {
                    html += '<option value=' + data[i].DoctInCharge + '>' + data[i].FirstName + '-'
                    data[i].LastName + '</option>';
                }
                $('#dokter').html(html);
            }
        });
        return false;
    });
</script>
<!-- pilihan resiko jatuh -->

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://code.jquery.com/jquery-migrate-1.4.1.min.js"></script>

<script type="text/javascript">
    $(document).ready(function() {
        $('#resiko1').change(function() {
            var res1 = $(this).val();
        });

        $("#resetResiko").click(function() {
            // Here the value is stored in variable. 
            var text = '';
            document.getElementById("valueResiko").value = text;
            document.getElementById("resiko1").value = text;
            document.getElementById("resiko2").value = text;
        });

        $('#resiko2').change(function() {
            var res1 = document.getElementById("resiko1").value;
            var res2 = $(this).val();

            if (res1 == 'YA' && res2 == 'YA') {
                var deskripsiResiko = 'Resiko Tinggi';
            } else if (res1 == 'YA' && res2 == 'TIDAK') {
                var deskripsiResiko = 'Resiko Rendah';
            } else if (res1 == 'TIDAK' && res2 == 'TIDAK') {
                var deskripsiResiko = 'Tidak Beresiko';
            } else if (res1 == 'TIDAK' && res2 == 'YA') {
                var deskripsiResiko = 'Resiko Rendah';
            }
            document.getElementById('valueResiko').value = deskripsiResiko;
        });
    });



    function validate(form) {

        var isKodePPkPesertaEqualRs = '<?php echo $IsKodePPKPesertaEqualRs; ?>';

        // validation code here ...
        if(isKodePPkPesertaEqualRs) {
            return confirm('Kode Rujukan Peserta Berbeda, apakah akan tetap lanjut?');
        }else{
            return true;
        }
    }

</script>