<div class="row" id="info-content" style="display:block">
    <div class="col-md-12">
        <div class="portlet box green-haze" style="position:relative">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-user"></i> Informasi Pasien
                </div>
            </div>

            <div class="portlet-body form">
                <form class="form-horizontal form-bordered form-row-stripped" role="form">
                    <div class="form-body">
                        <div class="form-group">
                            <div class="col-md-6">
                                <div class="row">
                                    <label class="form-control-static col-md-4">Nomor Rekam Medis </label>
                                    <p class="form-control-static col-md-8">
                                        : &nbsp; BBMC-<?=$this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'nrm')?> 
                                    </p>
                                </div>
                                <div class="row">
                                    <label class="form-control-static col-md-4">Nama Pasien </label>
                                    <p class="form-control-static col-md-8">
                                        : &nbsp; <?=strtoupper($this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'nama_pasien'))?>  / <?=$this->Content_m->get_tipe_pasien($id_re_pasien)?>
                                    </p>
                                </div>
                                <div class="row">
                                    <label class="form-control-static col-md-4">Umur  </label>
                                    <p class="form-control-static col-md-8">
                                        : &nbsp; <?=strtoupper($this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'umur_tahun'))?> TAHUN <?=strtoupper($this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'umur_bulan'))?> BULAN
                                    </p>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="row">
                                    <label class="form-control-static col-md-4">Pendidikan  </label>
                                    <p class="form-control-static col-md-8">
                                        <?php $id_pendidikan = $this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'id_pendidikan');
                                        $pendidikan = $this->Content_m->get_value('bbmc_re_jenjang_pendidikan','id_jenj_didik',$id_pendidikan,'nm_jenj_didik');
                                        ?>
                                        : &nbsp; <?=strtoupper($pendidikan)?> 
                                    </p>
                                </div>
                                <div class="row">
                                    <label class="form-control-static col-md-4">Pekerjaan  </label>
                                    <p class="form-control-static col-md-8">
                                        <?php $id_pekerjaan = $this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'id_pekerjaan');
                                        $pendidikan = $this->Content_m->get_value('bbmc_re_pekerjaan','id_pekerjaan',$id_pekerjaan,'nm_pekerjaan');
                                        ?>
                                        : &nbsp; <?=strtoupper($pendidikan)?> 
                                    </p>
                                </div>
                                <div class="row">
                                    <label class="form-control-static col-md-4">Alamat  </label>
                                    <p class="form-control-static col-md-8">
                                        : &nbsp; <?=strtoupper($this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'alamat'))?> 
                                    </p>
                                </div>
                            </div>
                            
                        </div>                                    
                    </div>
                </form>
                
            </div>
            
        </div>
    </div>
</div>

<div class="row" id="portlet-content">
    <div class="col-md-12">
        <div class="portlet light" style="position:relative">           
            <div class="portlet-body form" id="page-content" style="display:none">
              <form action="<?= site_url('front_office/'.$controller_dir.$controller.'/update_data_kunjungan') ?>" method="post" id="<?=$controller?>" enctype="multipart/form-data" class="horizontal-form">
                <input type="hidden" name="id_re_kunjungan" value="<?=$id_re_kunjungan?>">

                <div class="form-body">
                  <div class="alert alert-danger display-hide" style="display:none;" id="error">
                    <button class="close" data-close="alert"></button>
                    <span id="error-text"></span>
                  </div>

                  <h4 class="form-section" style="margin-top:0px !important; padding-bottom:0px !important"><i class="fa fa-stethoscope"></i><strong> Data Pemeriksaan Awal</strong><hr style="margin-top:10px !important"> </h4>
                  <div class="row" style="margin-top:0px !important;">
                    
                    <div class="col-md-6">
                      <div class="form-group" id="form_id_t">
                        <label for="id_t" class="control-label">Keluhan Utama </label>
                        <input required type="text" id="id_t" name="keluhan_utama" class="form-control" placeholder="" value="<?=$get_kunjungan->keluhan_utama?>">
                        <span id="error_id_t" class="help-block"></span>
                      </div>
                    </div>  
                     <div class="col-md-6">
                      <div class="form-group requireds alergi" id="form_alergi">
                        <label for="alergi" class="control-label">Alergi</label>
                        <select required id="alergi" name="alergi" class="form-control sel2">
                          <option value=""></option>
                           <option value="Ada" <?=$get_kunjungan->alergi=='Ada'?'selected':''?>>Ada</option>      
                           <option value="Tidak" <?=$get_kunjungan->alergi=='Tidak'?'selected':''?>>Tidak</option>                
                        </select>
                        <span id="error_alergi" class="help-block requireds_error"></span>
                      </div>
                    </div>

                    <script type="text/javascript">
                      $('#alergi').change(function(){
                          var valu = $(this).val();
                          if(valu == 'Ada'){
                            $('.deskripsi_alergi').css('display','block');
                          }else{
                            $('.deskripsi_alergi').css('display','none');
                          }
                      });
                    </script>
                    
                    <div class="col-md-12 deskripsi_alergi" style="<?=$get_kunjungan->deskripsi_alergi!=''?'display: block':'display: none'?>">
                      <div class="form-group" id="form_id_t">
                        <label for="id_t" class="control-label">Deskripsi Alergi</label>
                        <input type="text" id="id_t" name="deskripsi_alergi" class="form-control" placeholder="" value="<?=$get_kunjungan->deskripsi_alergi?>">
                        <span id="error_id_t" class="help-block"></span>
                      </div>
                    </div>  
                   
                  </div>                 
                 
                  <h4 class="form-section" style="margin:10px 0px 0px 0px !important; padding-bottom:0px !important; font-size:13px !important"><strong> VITAL SIGN </strong><hr style="margin-top:10px !important"> </h4>

                  <div class="row">
                    
                    <div class="col-md-6">
                      <div class="form-group" id="form_id_t">
                        <label for="id_t" class="control-label">Tensi</label>
                        <input required type="text" name="tensi" class="form-control" placeholder="" value="<?=$get_kunjungan->tensi?>">
                        <span id="error_id_t" class="help-block"></span>
                      </div>
                    </div>  
                    <div class="col-md-6">
                      <div class="form-group" id="form_id_t">
                        <label for="id_t" class="control-label">Temperature</label>
                        <input required type="text" name="temperature" class="form-control" placeholder="" value="<?=$get_kunjungan->temperature?>">
                        <span id="error_id_t" class="help-block"></span>
                      </div>
                    </div>  
                    <div class="col-md-6">
                      <div class="form-group" id="form_id_t">
                        <label for="id_t" class="control-label">Pulse</label>
                        <input required type="text" name="pulse" class="form-control" placeholder="" value="<?=$get_kunjungan->pulse?>">
                        <span id="error_id_t" class="help-block"></span>
                      </div>
                    </div>  
                    <div class="col-md-6">
                      <div class="form-group" id="form_id_t">
                        <label for="id_t" class="control-label">Tinggi Badan</label>
                        <input required type="text" name="tinggi_badan" class="form-control" placeholder="" value="<?=$get_kunjungan->tinggi_badan?>">
                        <span id="error_id_t" class="help-block"></span>
                      </div>
                    </div>  
                    <div class="col-md-6">
                      <div class="form-group" id="form_id_t">
                        <label for="id_t" class="control-label">Berat Badan</label>
                        <input required type="text" name="berat_badan" class="form-control" placeholder="" value="<?=$get_kunjungan->berat_badan?>">
                        <span id="error_id_t" class="help-block"></span>
                      </div>
                    </div>  
                            
                  </div>

                   <h4 class="form-section" style="margin:10px 0px 0px 0px !important; padding-bottom:0px !important; font-size:13px !important"><strong> MEDICAL HISTORY </strong><hr style="margin-top:10px !important"> </h4>
                   <div class="row">
                    <div class="col-md-6">
                      <div class="form-group requireds alergi" id="form_alergi">
                        <label for="alergi" class="control-label">Riwayat Pengobatan</label>
                        <select required id="riwayat_pengobatan" name="riwayat_pengobatan" class="form-control sel2">
                          <option value=""></option>
                           <option value="Ada" <?=$get_kunjungan->riwayat_pengobatan=='Ada'?'selected':''?>>Ada</option>      
                           <option value="Tidak Ada" <?=$get_kunjungan->riwayat_pengobatan=='Tidak Ada'?'selected':''?>>Tidak Ada</option>                
                        </select>
                        <span id="error_alergi" class="help-block requireds_error"></span>
                      </div>
                    </div>

                    <div class="col-md-6 deskripsi_riwayat_pengobatan" style="<?=$get_kunjungan->deskripsi_riwayat_pengobatan!=''?'display: block':'display: none'?>">
                      <div class="form-group" id="form_id_t">
                        <label for="id_t" class="control-label">Deskripsi Riwayat Pengobatan</label>
                        <input type="text" id="id_t" name="deskripsi_riwayat_pengobatan" class="form-control" placeholder="" value="<?=$get_kunjungan->deskripsi_riwayat_pengobatan?>">
                        <span id="error_id_t" class="help-block"></span>
                      </div>
                    </div>  

                    <div class="col-md-6">
                      <div class="form-group requireds alergi" id="form_alergi">
                        <label for="alergi" class="control-label">Tekanan Darah Tinggi</label>
                        <select required id="tekanan_darah_tinggi" name="tekanan_darah_tinggi" class="form-control sel2">
                          <option value=""></option>
                           <option value="Ada" <?=$get_kunjungan->tekanan_darah_tinggi=='Ada'?'selected':''?>>Ada</option>      
                           <option value="Tidak Ada" <?=$get_kunjungan->tekanan_darah_tinggi=='Tidak Ada'?'selected':''?>>Tidak Ada</option>                
                        </select>
                        <span id="error_alergi" class="help-block requireds_error"></span>
                      </div>
                    </div>

                    <div class="col-md-6 terakhir_check" style="<?=$get_kunjungan->terakhir_check!=''?'display: block':'display: none'?>">
                      <div class="form-group" id="form_id_t">
                        <label for="id_t" class="control-label">Terakhir Check</label>
                       

                        <div class="input-group">
                           <input type="text" id="id_t" name="terakhir_check" class="form-control" placeholder="" value="<?=$get_kunjungan->terakhir_check?>">
                          <span class="input-group-addon"> mmHg </span>  
                        </div> 

                        <span id="error_id_t" class="help-block"></span>
                      </div>
                    </div>  

                    <div class="col-md-6">
                      <div class="form-group requireds alergi" id="form_alergi">
                        <label for="alergi" class="control-label">Hamil</label>
                        <select required id="hamil" name="hamil" class="form-control sel2">
                          <option value=""></option>
                           <option value="Sedang Hamil" <?=$get_kunjungan->hamil=='Sedang Hamil'?'selected':''?>>Sedang Hamil</option>      
                           <option value="Tidak Hamil" <?=$get_kunjungan->hamil=='Tidak Hamil'?'selected':''?>>Tidak Hamil</option>                
                        </select>
                        <span id="error_alergi" class="help-block requireds_error"></span>
                      </div>
                    </div>

                  </div>

                    <script type="text/javascript">
                      $('#riwayat_pengobatan').change(function(){
                          var valu = $(this).val();
                          if(valu == 'Ada'){
                            $('.deskripsi_riwayat_pengobatan').css('display','block');
                          }else{
                            $('.deskripsi_riwayat_pengobatan').css('display','none');
                          }
                      });
                      $('#tekanan_darah_tinggi').change(function(){
                          var valu = $(this).val();
                          if(valu == 'Ada'){
                            $('.terakhir_check').css('display','block');
                          }else{
                            $('.terakhir_check').css('display','none');
                          }
                      });
                    </script>
                    
             
                 

                  <h4 class="form-section" style="margin:10px 0px 0px 0px !important; padding-bottom:0px !important; font-size:13px !important"><strong> APAKAH PASIEN MEMILIKI </strong><hr style="margin-top:10px !important"> </h4>
                  <div class="row">  
                   <div class="col-md-6">
                      <div class="form-group requireds alergi" id="form_alergi">
                        <label for="alergi" class="control-label">Hemofilia</label>
                        <select required id="hemofilia" name="hemofilia" class="form-control sel2">
                          <option value=""></option>
                           <option value="Ya" <?=$get_kunjungan->hemofilia=='Ya'?'selected':''?>>Ya</option>      
                           <option value="Tidak" <?=$get_kunjungan->hemofilia=='Tidak'?'selected':''?>>Tidak</option>                
                        </select>
                        <span id="error_alergi" class="help-block requireds_error"></span>
                      </div>
                    </div>
                    <div class="col-md-6">
                      <div class="form-group requireds alergi" id="form_alergi">
                        <label for="alergi" class="control-label">Penyakit Jantung</label>
                        <select required id="penyakit_jangunt" name="penyakit_jantung" class="form-control sel2">
                          <option value=""></option>
                           <option value="Ya" <?=$get_kunjungan->penyakit_jantung=='Ya'?'selected':''?>>Ya</option>      
                           <option value="Tidak" <?=$get_kunjungan->penyakit_jantung=='Tidak'?'selected':''?>>Tidak</option>                
                        </select>
                        <span id="error_alergi" class="help-block requireds_error"></span>
                      </div>
                    </div>
                    <div class="col-md-6">
                      <div class="form-group requireds alergi" id="form_alergi">
                        <label for="alergi" class="control-label">HIV / AIDS</label>
                        <select required id="hiv_aids" name="hiv_aids" class="form-control sel2">
                          <option value=""></option>
                           <option value="Ya" <?=$get_kunjungan->hiv_aids=='Ya'?'selected':''?>>Ya</option>      
                           <option value="Tidak" <?=$get_kunjungan->hiv_aids=='Tidak'?'selected':''?>>Tidak</option>                
                        </select>
                        <span id="error_alergi" class="help-block requireds_error"></span>
                      </div>
                    </div>
                    <div class="col-md-6">
                      <div class="form-group requireds alergi" id="form_alergi">
                        <label for="alergi" class="control-label">Epilepsi</label>
                        <select required id="epilepsi" name="epilepsi" class="form-control sel2">
                          <option value=""></option>
                           <option value="Ya" <?=$get_kunjungan->epilepsi=='Ya'?'selected':''?>>Ya</option>      
                           <option value="Tidak" <?=$get_kunjungan->epilepsi=='Tidak'?'selected':''?>>Tidak</option>                
                        </select>
                        <span id="error_alergi" class="help-block requireds_error"></span>
                      </div>
                    </div>
                    <div class="col-md-6">
                      <div class="form-group requireds alergi" id="form_alergi">
                        <label for="alergi" class="control-label">Diabetes</label>
                        <select required id="diabetes" name="diabetes" class="form-control sel2">
                          <option value=""></option>
                           <option value="Ya" <?=$get_kunjungan->diabetes=='Ya'?'selected':''?>>Ya</option>      
                           <option value="Tidak" <?=$get_kunjungan->diabetes=='Tidak'?'selected':''?>>Tidak</option>                
                        </select>
                        <span id="error_alergi" class="help-block requireds_error"></span>
                      </div>
                    </div>
                    <div class="col-md-6">
                      <div class="form-group requireds alergi" id="form_alergi">
                        <label for="alergi" class="control-label">Asma</label>
                        <select required id="asma" name="asma" class="form-control sel2">
                          <option value=""></option>
                           <option value="Ya" <?=$get_kunjungan->asma=='Ya'?'selected':''?>>Ya</option>      
                           <option value="Tidak" <?=$get_kunjungan->asma=='Tidak'?'selected':''?>>Tidak</option>                
                        </select>
                        <span id="error_alergi" class="help-block requireds_error"></span>
                      </div>
                    </div>
                    <div class="col-md-6">
                      <div class="form-group requireds alergi" id="form_alergi">
                        <label for="alergi" class="control-label">Stroke</label>
                        <select required id="stroke" name="stroke" class="form-control sel2">
                          <option value=""></option>
                           <option value="Ya" <?=$get_kunjungan->stroke=='Ya'?'selected':''?>>Ya</option>      
                           <option value="Tidak" <?=$get_kunjungan->stroke=='Tidak'?'selected':''?>>Tidak</option>                
                        </select>
                        <span id="error_alergi" class="help-block requireds_error"></span>
                      </div>
                    </div>
                    <div class="col-md-6">
                      <div class="form-group requireds alergi" id="form_alergi">
                        <label for="alergi" class="control-label">Gangguan Ginjal</label>
                        <select required id="gangguan_ginjal" name="gangguan_ginjal" class="form-control sel2">
                          <option value=""></option>
                           <option value="Ya" <?=$get_kunjungan->gangguan_ginjal=='Ya'?'selected':''?>>Ya</option>      
                           <option value="Tidak" <?=$get_kunjungan->gangguan_ginjal=='Tidak'?'selected':''?>>Tidak</option>                
                        </select>
                        <span id="error_alergi" class="help-block requireds_error"></span>
                      </div>
                    </div>
                    <div class="col-md-6">
                      <div class="form-group requireds alergi" id="form_alergi">
                        <label for="alergi" class="control-label">Keluhan Rahang</label>
                        <select required id="keluhan_rahang" name="keluhan_rahang" class="form-control sel2">
                          <option value=""></option>
                           <option value="Ya" <?=$get_kunjungan->keluhan_rahang=='Ya'?'selected':''?>>Ya</option>      
                           <option value="Tidak" <?=$get_kunjungan->keluhan_rahang=='Tidak'?'selected':''?>>Tidak</option>                
                        </select>
                        <span id="error_alergi" class="help-block requireds_error"></span>
                      </div>
                    </div>
                    <div class="col-md-6">
                      <div class="form-group requireds alergi" id="form_alergi">
                        <label for="alergi" class="control-label">Penyakit Sistematik Lain</label>
                        <select required id="penyakit_sistematik_lain" name="penyakit_sistematik_lain" class="form-control sel2">
                          <option value=""></option>
                           <option value="Ya" <?=$get_kunjungan->penyakit_sistematik_lain=='Ya'?'selected':''?>>Ya</option>      
                           <option value="Tidak" <?=$get_kunjungan->penyakit_sistematik_lain=='Tidak'?'selected':''?>>Tidak</option>                
                        </select>
                        <span id="error_alergi" class="help-block requireds_error"></span>
                      </div>
                    </div>


                    <div class="col-md-6 deskripsi_penyakit_sistematik_lainnya" style="<?=$get_kunjungan->deskripsi_penyakit_sistematik_lainnya!=''?'display: block':'display: none'?>">
                      <div class="form-group" id="form_id_t">
                        <label for="id_t" class="control-label">Deskripsi Penyakit Sistematik Lainnya</label>
                        <input type="text" id="id_t" name="deskripsi_penyakit_sistematik_lainnya" class="form-control" placeholder="" value="<?=$get_kunjungan->deskripsi_penyakit_sistematik_lainnya?>">
                        <span id="error_id_t" class="help-block"></span>
                      </div>
                    </div>  


                    <script type="text/javascript">
                       $('#penyakit_sistematik_lain').change(function(){
                          var valu = $(this).val();
                          if(valu == 'Ya'){
                            $('.deskripsi_penyakit_sistematik_lainnya').css('display','block');
                          }else{
                            $('.deskripsi_penyakit_sistematik_lainnya').css('display','none');
                          }
                      });
                    </script>


                  </div>


                  <h4 class="form-section" style="margin:10px 0px 0px 0px !important; padding-bottom:0px !important; font-size:13px !important"><strong> KETERANGAN LAINNYA </strong><hr style="margin-top:10px !important"> </h4>
                  <div class="row">  
                    <div class="col-md-6">
                      <div class="form-group requireds" id="form_id_dokter_jaga">
                        <label for="id_dokter_jaga" class="control-label">Dokter Jaga <span class="required">* </span></label>                        
                        <select required id="dokter_jaga" name="id_dokter_jaga" class="form-control" >
                            <option value=""></option>
                            <?php 
                            if($active == 'gigi'){
                              $array = array('2');
                            }else{
                              $array = array('1');
                            }
                            
                            $this->db->where_in('id_bidang',$array);
                            foreach ($this->Content_m->select_db('bbmc_re_staff_medis')->result() as $key ) { ?>
                              <option value="<?=$key->id_staff_medis?>" <?=$key->id_staff_medis==$get_kunjungan->id_dokter_jaga?'selected':''?>><?=$key->staff_medis?></option>
                            <?php }?>    
                            <option value="-1" <?=$get_kunjungan->id_dokter_jaga=='-1'?'selected':''?>>Dokter Tidak Tetap</option>
                        </select>
                        <span id="error_id_dokter_jaga" class="help-block requireds_error"></span>
                      </div>                   
                    </div>    
                    <div class="col-md-6" id="dokter_tidak_tetap" style="<?=$get_kunjungan->id_dokter_jaga=='-1'?'display: block':'display: none'?>">
                      <div class="form-group" id="form_obat">
                        <label for="obat" class="control-label">Nama Dokter  </label>
                        <input type="text" id="nama_dokter" name="nama_dokter_tidak_tetap" class="form-control" placeholder="" value="<?=$get_kunjungan->nama_dokter_tidak_tetap?>">
                        <span id="error_obat" class="help-block"></span>
                      </div>    
                    </div>         
                    
                  </div>
                  <div class="row">
                    <div class="col-md-6">  
                      <div class="form-group requireds" id="form_id_perawat_bidan_jaga">
                        <label for="id_perawat_bidan_jaga" class="control-label">Perawat / Bidan Jaga <span class="required">* </span></label>
                        <div class="table-responsive">
                          <select required id="perawat_bidan_jaga" name="id_perawat_bidan_jaga" class="form-control" >
                            <option value=""></option>
                            <?php 
                            if($active == 'gigi'){
                              $array = array('5');
                            }else{
                              $array = array('3','4');
                            }
                            
                            $this->db->where_in('id_bidang',$array);
                            $q = $this->Content_m->select_db('bbmc_re_staff_medis');
                            
                            foreach ($q->result() as $key ) { ?>
                              <option value="<?=$key->id_staff_medis?>" <?=$key->id_staff_medis==$get_kunjungan->id_perawat_bidan_jaga?'selected':''?>><?=$key->staff_medis?></option>
                            <?php }?>    
                          </select>      
                          <span id="error_id_perawat_bidan_jaga" class="help-block requireds_error"></span>        
                        </div> 
                      </div>       
                    </div>
                    <div class="col-md-6">
                      <div class="form-group" id="form_pemeriksaan_khusus">
                        <label for="pemeriksaan_khusus" class="control-label">Pemeriksaan Penunjang </label>
                        <select id="pemeriksaan_khusus" name="pemeriksaan_khusus[]" style="width:100%" multiple>
                          <option value="cek_laboratorium">Cek Laboratorium</option>
                          <option value="cek_radiologi">Cek Radiologi</option>
                        </select>
                        <span id="error_pemeriksaan_khusus" class="help-block"></span>
                      </div>
                    </div>
                  </div>
                  <div class="row" >
                    <div class="col-md-3" style="display: none;">
                      <div class="form-group" id="form_keluar_ugd">
                        <label for="keluar_ugd" class="control-label">Pasien Keluar dari Poli </label>

                          <input type="text" id="datepicker_keluar_ugd" name="tgl_keluar_ugd" class="form-control" placeholder="" value="<?=$get_kunjungan->tgl_keluar_ugd==null?date('Y-m-d'):$get_kunjungan->tgl_keluar_ugd?>" >
                                      
                        <span id="error_keluar_ugd" class="help-block"></span>
                      </div>
                    </div>
                    <div class="col-md-6">
                      <div class="form-group requireds" id="form_id_alasan_keluar">
                        <label for="id_alasan_keluar" class="control-label">Status keluar poli <span class="required">* </span></label>
                        <select required id="dgn_alasan" name="id_alasan_keluar" class="form-control">
                          <option value=""></option>
                            <?php 
                            foreach ($this->Content_m->select_db('bbmc_re_alasan_keluar')->result() as $key ) { ?>
                              <option value="<?=$key->id_alasan_keluar?>" <?=$key->id_alasan_keluar==$get_kunjungan->id_alasan_keluar?'selected':''?>>
                               
                                <?=$key->alasan_keluar=='Konsul Poli Gigi'?'Konsul Poli Umum':$key->alasan_keluar?>
                                
                              </option>
                            <?php }?>                         
                        </select>
                        <span id="error_id_alasan_keluar" class="help-block requireds_error"></span>
                      </div>
                    </div>

                    
                 

                   <script type="text/javascript">
                    $("#dokter_jaga").change(function(){
                        var valu = $(this).val();
                        if(valu == '-1'){
                            $("#dokter_tidak_tetap").css('display','block');
                        }else{
                            $("#dokter_tidak_tetap").css('display','none');
                        }
                    });  
                    </script>
               

                           


             

                 
               
                    <script type="text/javascript">
                    $("#dgn_alasan").change(function(){
                        var valu = $(this).val();
                        if(valu == '3'){
                            $("#form_konsul_spesialis").css('display','block');
                        }else{
                            $("#form_konsul_spesialis").css('display','none');
                        }

                        if(valu == '4'){
                            $("#rujuk_rumah_sakit").css('display','block');
                        }else{
                            $("#rujuk_rumah_sakit").css('display','none');
                        }

                        if(valu == '2'){
                            $("#rawat_inap").css('display','block');
                        }else{
                            $("#rawat_inap").css('display','none');
                        } 
                    });  
                    </script>

                    <div class="col-md-6" id="rawat_inap" style="<?=$get_kunjungan->id_alasan_keluar=='2'?'display: block':'display: none'?>">
                      <div class="form-group" id="form_bangsal" style="display: none;">
                        <label for="bangsal" class="control-label">Kamar </label>
                        <select id="bangsal" name="id_tipe_kamar" class="form-control">
                          <option value=""></option>
                          <?php 
                          foreach ($this->Content_m->select_db('bbmc_re_tipe_kamar')->result() as $key ) { ?>
                            <option value="<?=$key->id_tipe_kamar?>" <?=$key->id_tipe_kamar==$get_kunjungan->id_tipe_kamar?'selected':''?>><?=$key->tipe_kamar?></option>
                          <?php }?>                   
                        </select>
                        <span id="error_bangsal" class="help-block"></span>
                      </div>
                    </div>    
                    <div class="col-md-6" id="rujuk_rumah_sakit" style="<?=$get_kunjungan->id_alasan_keluar=='4'?'display: block':'display: none'?>">
                      <div class="form-group" id="form_keluar_ugd">
                        <label for="keluar_ugd" class="control-label">Rumah Sakit </label>
                        <input type="text" id="rumah_sakit" name="rumah_sakit" class="form-control" placeholder="" value="<?=$get_kunjungan->rumah_sakit?>">
                        <span id="error_keluar_ugd" class="help-block"></span>
                      </div>
                    </div>                
                
               
                    <div class="col-md-6" id="form_konsul_spesialis" style="<?=$get_kunjungan->id_alasan_keluar=='3'?'display: block':'display: none'?>">  
                      <div class="form-group" id="form_perawat_jaga">
                        <label for="perawat_jaga" class="control-label">Konsultasi Dokter Spesialis </label>
                        <div class="table-responsive">
                          <select id="id_dokter_spesialis" name="id_dokter_spesialis" class="form-control" >
                            <option value=""></option>
                            <?php 
                            $array = array('6','7','8','9');
                            $this->db->where_in('id_bidang',$array);
                            foreach ($this->Content_m->select_db('bbmc_re_staff_medis')->result() as $key ) { ?>
                              <option value="<?=$key->id_staff_medis?>" <?=$key->id_staff_medis==$get_kunjungan->id_dokter_spesialis?'selected':''?>><?=$key->staff_medis?></option>
                            <?php }?>    
                          </select>              
                        </div> 
                      </div>       
                    </div>
                </div>
                <div class="form-actions right">
                  <a type="button" class="btn default" href="<?= site_url('front_office/'.$controller_dir.$controller) ?>">Kembali</a>
                  <button type="submit" class="btn blue"><i class="fa fa-check"></i> Simpan</button>
                </div>
              </form>
            </div>
            <?php $this->load->view('front_office/include/loading');?>
        </div>
    </div>
</div>
<script type="text/javascript">
	$(document).ready(function() {
     /*-------------Datepicker-------------*/
     $('#datepicker_keluar_ugd').datepicker({
      changeMonth: true,
      changeYear: true,
      yearRange: "-60:+0",
      dateFormat: 'yy-mm-dd'
    });

     
     $(".sel2").select2({
      placeholder: "",
      language: "id"
    });

    $("#id_dokter_spesialis").select2({
      placeholder: "",
      language: "id"
    });

    $("#keadaan_tiba").select2({
      placeholder: "",
      language: "id"
    });
    
    $("#kesadaran").select2({
      placeholder: "",
      language: "id"
    });    

    $("#gol_penyakit").select2({
      placeholder: "",
      language: "id",
    });

    $("#jns_pelayanan").select2({
      placeholder: "",
      language: "id"
    });

    $("#pemeriksaan_fisik").select2({
      placeholder: "",
      language: "id"
    });    

    $("#dokter_jaga").select2({
      placeholder: "",
      language: "id"
    });

    $("#dgn_alasan").select2({
      placeholder: "",
      language: "id"
    }); 
    
    $("#bangsal").select2({
      placeholder: "",
      language: "id",
    });    

    $("#id_perusahaan").select2({
      placeholder: "",
      language: "id"
    });

    $("#type_pasien").select2({
      placeholder: "",
      language: "id"
    }); 
    
    $("#rujuk_dari").select2({
      placeholder: "",
      language: "id"
    });              

    $("#id_wil_kec").select2({
      placeholder: "",
      language: "id"
    }); 

    $("#perawat_bidan_jaga").select2({
      placeholder: "",
      language: "id"
    }); 


    $("#pemeriksaan_khusus").select2({
      placeholder: "",
      language: "id"
    });

     <?php 
     $a = explode(",", $get_kunjungan->pemeriksaan_khusus);
     $b = count($a);
     if($b == 2){ ?>
       $("#pemeriksaan_khusus").val(["cek_radiologi","cek_laboratorium"]).change();
     <?php }else{ ?>
       $("#pemeriksaan_khusus").val("<?=$get_kunjungan->pemeriksaan_khusus?>").trigger('change');
     <?php }?>
    

    $("#id_wil_kab").select2({
      placeholder: "",
      language: "id"
    }); 

    $("#id_wil_prov").select2({
      placeholder: "",
      language: "id"
    }); 

    $("#id_wil_kec").select2({
          placeholder: "Kecamatan",
          language: "id",
          ajax: {
            url: "<?=site_url('front_office/ajax/select2_wilayah')?>",
            dataType: 'json',
            delay:500,
            type:"POST",
            data: function(params) {
                return {
                    term: params.term || '',
                    page: params.page || 1
                }
            }
          },
          escapeMarkup: function (markup) {return markup;},
          minimumInputLength: 1,
          templateResult: function(repo) {
            if(repo.loading)
                return repo.text;
            return repo.value;
          },
          templateSelection: function(repo){return repo.value || repo.text;}
        }); 

        $('#id_wil_kec').on('select2:select', function(e) {
            var value_string = e.params.data.value;
            var id_string = e.params.data.id;
            var part = value_string.split('-');
            var kec_val = part[0];
            var kab_val = part[1];
            var prov_val = part[2];
            $('#id_wil_kec').append(`<option value="${id_string}" selected> ${kec_val} </option>`);
            $('#id_wil_kab').append(`<option value="${id_string}" selected> ${kab_val} </option>`);
            $('#id_wil_prov').append(`<option value="${id_string}" selected> ${prov_val} </option>`);
        });

    $("#loading-content,#loading").fadeOut("fast", function() {
      $("#page-content").fadeIn("fast");
    });

  });
</script>
<?php $this->load->view('front_office/script/form_data'); ?>
