<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 Dasar</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_keadaan_tiba">
                        <label for="keadaan_tiba" class="control-label">Keadaan Saat Tiba </label>
                        <select required id="keadaan_tiba" name="id_keadaan_saat_tiba" style="width:100%">
                          <option value=""></option>
                          <?php foreach ($this->Content_m->select_db('bbmc_re_keadaan_saat_tiba')->result() as $key ) { ?>
                              <option value="<?=$key->id_keadaan_saat_tiba?>" <?=$key->id_keadaan_saat_tiba==$get_kunjungan->id_keadaan_saat_tiba?'selected':''?> ><?=$key->keadaan_saat_tiba?></option>
                          <?php }?>          
                        </select>                                              
                        <span id="error_keadaan_tiba" class="help-block"></span>
                      </div>
                    </div>  
 
                    <div class="col-md-6">
                      <div class="form-group" id="form_kesadaran">
                        <label for="kesadaran" class="control-label">Kesadaran </label>
                        <select required id="kesadaran" name="id_kesadaran" style="width:100%">
                          <option value=""></option>
                          <?php 
                          $this->db->order_by('urutan','asc');
                          foreach ($this->Content_m->select_db('bbmc_re_kesadaran')->result() as $key ) { ?>
                              <option value="<?=$key->id_kesadaran?>" <?=$key->id_kesadaran==$get_kunjungan->id_kesadaran?'selected':''?>><?=$key->kesadaran?></option>
                          <?php }?>                       
                        </select>                             
                        <span id="error_kesadaran" 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-2">
                      <div class="form-group" id="form_id_t">
                        <label for="id_t" class="control-label">Tekanan Darah </label>
                        <input required type="text" id="id_t" name="tekanan_darah" class="form-control" placeholder="" value="<?=$get_kunjungan->tekanan_darah?>">
                        <span id="error_id_t" class="help-block"></span>
                      </div>
                    </div>
                  
                    <div class="col-md-2">
                      <div class="form-group" id="form_id_r">
                        <label for="id_r" class="control-label">Respirasi </label>
                        <input required type="text" id="id_r" name="respirasi" class="form-control" placeholder="" value="<?=$get_kunjungan->respirasi?>">
                        <span id="error_id_r " class="help-block"></span>
                      </div>
                    </div>   
                    <div class="col-md-2">
                      <div class="form-group" id="form_id_n">
                        <label for="id_n" class="control-label">Nadi </label>                      
                        <div class="input-group">
                          <input required type="text" id="id_n" name="nadi" class="form-control" placeholder="" value="<?=$get_kunjungan->nadi?>"> 
                          <span class="input-group-addon"> K/mt </span>  
                        </div>                          
                        <span id="error_id_n " class="help-block"></span>
                      </div>                      
                    </div> 
                    <div class="col-md-3">
                      <div class="form-group" id="form_temperature">
                        <label for="temperature" class="control-label">Temperature </label>                      
                        <div class="input-group">
                          <input required type="text" id="temperature" name="temperature" class="form-control" placeholder="" value="<?=$get_kunjungan->temperature?>"> 
                          <span class="input-group-addon"> &deg;C </span>  
                        </div>                          
                        <span id="error_temperature " class="help-block"></span>
                      </div>                      
                    </div>  
                    <div class="col-md-3">
                      <div class="form-group" id="form_bb_pasien">
                        <label for="bb_pasien" class="control-label">Berat Badan </label>                      
                        <div class="input-group">
                          <input required type="text" id="bb_pasien" name="berat_badan" class="form-control" placeholder="" value="<?=$get_kunjungan->berat_badan?>"> 
                          <span class="input-group-addon"> Kg </span>  
                        </div>                          
                        <span id="error_bb_pasien " class="help-block"></span>
                      </div>                      
                    </div>                 
                  </div>

                  

                  <div class="row">
                    <!--
                    <div class="col-md-6">
                      <div class="form-group" id="form_gol_penyakit">
                        <label for="gol_penyakit" class="control-label">Gol Penyakit </label>
                        <select id="gol_penyakit" name="gol_penyakit" style="width:100%">
                          <option value=""></option>
                          <option value="sakit">Sakit</option>
                          <option value="tht">THT</option>
                          <option value="paru">Paru</option>
                          <option value="jantung">Jantung</option>
                          <option value="sistem_saraf">Sistem Saraf</option>
                          <option value="penyakit_dalam">Penyakit Dalam</option>                          
                        </select>  
                        <span id="error_gol_penyakit" class="help-block"></span>
                      </div>
                    </div> 
                    -->
                  
                    <div class="col-md-12">
                      <div class="form-group" id="form_jns_pelayanan">
                        <label for="jns_pelayanan" class="control-label">Jenis &amp; Pelayanan </label>
                        <select required id="jns_pelayanan" name="id_jenis_pelayanan" style="width:100%">
                          <option value=""></option>
                          <?php 
                          if($active == 'subspesialis-1'){
                              $jns_pelayanan = '3';
                          }else{
                              $jns_pelayanan = $get_kunjungan->id_jenis_pelayanan;
                          }
                          
                          foreach ($this->Content_m->select_db('bbmc_re_jenis_pelayanan')->result() as $key ) { ?>
                              <option value="<?=$key->id_jenis_pelayanan?>" <?=$key->id_jenis_pelayanan==$jns_pelayanan?'selected':''?> ><?=$key->jenis_pelayanan?></option>
                          <?php }?>     
                        </select>                         
                        <span id="error_jns_pelayanan" class="help-block"></span>
                      </div>
                    </div> 
                    

                  </div>
                  <div class="row">
                    <div class="col-md-12">
                      <div class="form-group" id="form_anamnesa">
                        <label for="anamnesa" class="control-label">Anamnesis / Riwayat Singkat </label>
                        <textarea required id="anamnesa" name="anamnesa" cols="30" rows="2" class="form-control"><?=$get_kunjungan->anamnesa?></textarea>
                        
                        <span id="error_anamnesa" class="help-block"></span>
                      </div>
                    </div>
                  </div>  
                  <div class="row">
                    <div class="col-md-12">
                      <div class="form-group" id="form_pemeriksaan_fisik">
                        <label for="pemeriksaan_fisik" class="control-label">Pemeriksaan Fisik</label><br>
                        <select required id="pemeriksaan_fisik" name="pemeriksaan_fisik" class="form-control">
                          <option value=""></option>
                          <option value="st_general" <?=$get_kunjungan->pemeriksaan_fisik=='st_general'?'selected':''?>>St. General</option>
                          <option value="st_lokalis" <?=$get_kunjungan->pemeriksaan_fisik=='st_lokalis'?'selected':''?>><?=$active == 'subspesialis-2'?'St. Psikiatri':'St. Lokalis'?></option>
                        </select>
                        <span id="error_pemeriksaan_fisik" class="help-block"></span>
                      </div>
                    </div>
                  </div>

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

                    });
                  </script>


                  <div class="st_general" style="<?=$get_kunjungan->pemeriksaan_fisik=='st_general'?'display: block':'display: none'?>">
                  <h4 class="form-section" style="margin:10px 0px 0px 0px !important; padding-bottom:0px !important; font-size:13px !important"> <strong>St. General</strong><hr style="margin-top:10px !important"> </h4>
                  <div class="row">
                    <div class="col-md-3">
                      <div class="form-group" id="form_cek_fisik_mata">
                        <label for="cek_fisik_mata" class="control-label">Mata </label>
                        <textarea id="cek_fisik_mata" name="cek_fisik_mata" cols="30" rows="2" class="form-control"><?=$get_kunjungan->cek_fisik_mata?></textarea>
                        <span id="error_cek_fisik_mata" class="help-block"></span>
                      </div>
                    </div>
                    <div class="col-md-3">
                      <div class="form-group" id="form_cek_fisik_tht">
                        <label for="cek_fisik_tht" class="control-label">THT </label>
                        <textarea id="cek_fisik_tht" name="cek_fisik_tht" cols="30" rows="2" class="form-control"><?=$get_kunjungan->cek_fisik_tht?></textarea>
                        <span id="error_cek_fisik_tht" class="help-block"></span>
                      </div>    
                    </div>
                    <div class="col-md-3">
                      <div class="form-group" id="form_cek_fisik_abdomen">
                        <label for="cek_fisik_abdomen" class="control-label">Abdomen </label>
                        <textarea id="cek_fisik_abdomen" name="cek_fisik_abdomen" cols="30" rows="2" class="form-control"><?=$get_kunjungan->cek_fisik_abdomen?></textarea>
                        <span id="error_cek_fisik_abdomen" class="help-block"></span>
                      </div>
                    </div>
                    <div class="col-md-3">
                      <div class="form-group" id="form_cek_fisik_ekstrimitas">
                        <label for="cek_fisik_ekstrimitas" class="control-label">Ekstrimitas </label>
                        <textarea id="cek_fisik_ekstrimitas" name="cek_fisik_ekstrimitas" cols="30" rows="2" class="form-control"><?=$get_kunjungan->cek_fisik_ekstrimitas?></textarea>
                        <span id="error_cek_fisik_ekstrimitas" class="help-block"></span>
                      </div>    
                    </div>                    
                  </div>     
                  
                  <div class="row">
                    <div class="col-md-12" style="margin-bottom:5px !important">
                      <div class="form-group" id="form_cek_fisik_thorax">
                        <label class="control-label">Thorax </label>

                        <div class="row"> 
                          <div class="col-md-1" style="padding:7px 0px 7px 15px !important;">
                            <label for="thorax_cor" class="control-label" style="float:left !important">Cor</label>
                            <span style="float:right !important"> : </span>
                          </div>  
                          <div class="col-md-5">
                            <input type="text" id="thorax_cor" name="thorax_cor" class="form-control" placeholder="" value="<?=$get_kunjungan->thorax_cor?>">
                            <span id="error_thorax_cor" class="help-block"></span>
                          </div> 
                          <div class="col-md-1" style="padding:7px 0px 7px 15px !important;">
                            <label for="thorax_pulmo" class="control-label" style="float:left !important">Pulmo</label>
                            <span style="float:right !important"> : </span>
                          </div>  
                          <div class="col-md-5">
                            <input type="text" id="thorax_pulmo" name="thorax_pulmo" class="form-control" placeholder="" value="<?=$get_kunjungan->thorax_pulmo?>">
                            <span id="error_thorax_pulmo" class="help-block"></span>
                          </div>  
                        </div>                      

                      </div>
                    </div>                  
                  </div>      
                  </div>                

                  <div class="st_lokalis" style="<?=$get_kunjungan->pemeriksaan_fisik=='st_lokalis'?'display: block':'display: none'?>">
                    <h4 class="form-section" style="margin:10px 0px 0px 0px !important; padding-bottom:0px !important; font-size:13px !important"> <strong>St. Lokalis</strong><hr style="margin-top:10px !important"> </h4>
                    <textarea class="form-control" name="detail_lokalis" style="width: 100%; height: 80px;"><?=$get_kunjungan->detail_lokalis?></textarea><br><br>
                  </div>

                  <div class="row">
                    <div class="col-md-12">
                      <div class="form-group" id="form_alergi_makanan">
                        <label for="alergi_makanan" class="control-label">Riwayat Alergi</label>
                        <textarea required id="alergi_makanan" name="alergi_makanan" cols="30" rows="2" class="form-control"><?=$get_kunjungan->alergi_makanan?></textarea>
                        <span id="error_alergi_makanan" class="help-block"></span>
                      </div>
                    </div>
                  </div>
                   <div class="row">
                    <div class="col-md-12">
                      <div class="form-group" id="form_obat">
                        <label for="obat" class="control-label">Riwayat Pengobatan </label>
                        <textarea required id="obat" name="riwayat_pengobatan" cols="30" rows="2" class="form-control"><?=$get_kunjungan->riwayat_pengobatan?></textarea>
                        <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_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');
                            }
                            */
                            if($active == 'gigi'){
                              $array = array('2');
                            }else if($active == 'subspesialis-1'){
                              $array = array('6');
                            }else if($active == 'subspesialis-2'){
                              $array = array('7');
                            }else if($active == 'subspesialis-3'){
                              $array = array('8');
                            }else if($active == 'subspesialis-4'){
                              $array = array('9');
                            }else{
                              $array = array('1');
                            }


                            if($active == 'subspesialis-1'){
                                $id_dkr_jaga = '20';
                            }else{
                                $id_dkr_jaga = $get_kunjungan->id_dokter_jaga;
                            }
                            
                            
                            $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==$id_dkr_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" style="display: none;">  
                      <div class="form-group requireds" id="form_id_perawat_bidan_jaga">
                        <label for="id_perawat_bidan_jaga" class="control-label">Perawat / Bidan Jaga Lainnya </label>
                        <div class="table-responsive">
                          <select id="perawat_bidan_jaga2" name="id_perawat_bidan_jaga2" 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_jaga2?'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?></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'
    });

     
    $("#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"
    }); 

    $("#perawat_bidan_jaga2").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'); ?>
