<div class="row" id="tab-content">
    <div class="col-md-12">
        <div class="tabbable tabbable-custom">
            <ul class="nav nav-tabs">
                <li class="active">
                    <a href="#" aria-expanded="false">
                    <i class="fa fa-edit"></i> <?= $judul ?> </a>
                </li> 
            </ul>
            <div class="tab-content">
                <div class="tab-pane active">

                  <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">
                                              <label class="form-control-static col-md-2">Nomor Rekam Medis </label>
                                              <p class="form-control-static col-md-10">
                                                  : &nbsp; BBMC-<?= $re_pasien->nrm ?> 
                                              </p>
                                              <label class="form-control-static col-md-2">Nama Pasien </label>
                                              <p class="form-control-static col-md-10">
                                                  : &nbsp; <?=strtoupper($re_pasien->nama_pasien) ?>  
                                              </p>
                                             
                                          </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.'/edit_data_proses') ?>" method="post" id="<?=$controller?>" enctype="multipart/form-data" class="horizontal-form">
                            <div class="form-body">
                              <input value="<?=$re_kunjungan->id_re_kunjungan?>" type="hidden" name="id_re_kunjungan">
                              <input value="<?=$re_kunjungan->id_re_pasien?>" type="hidden" name="id_re_pasien">
                              <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:0px 0px 20px 0px !important; padding-bottom:0px !important">
                                <i class="fa fa-align-justify"></i> <strong> Registrasi Poliklinik <hr style="margin:10px 0px !important" > </strong>
                              </h4>
                              <div class="row">
                                <div class="col-md-6">
                                  <div class="form-group" id="form_no_kunjungan">
                                    <label for="no_kunjungan" class="control-label">Nomor Kunjungan </label>
                                    <input type="text" id="no_kunjungan" name="no_kunjungan" class="form-control" placeholder="Auto Generate" readonly value="<?= $re_kunjungan->id_kunjungan ?>">
                                    <span id="error_no_kunjungan" class="help-block"></span>
                                  </div>
                                </div>
                              
                                <div class="col-md-6">
                                  <div class="form-group" id="form_tgl_kunjungan">
                                    <label for="tgl_kunjungan" class="control-label">Tanggal Kunjungan </label>
                                    <div class="input-group date">
                                        <span class="input-group-btn">
                                            <button class="btn default" type="button"><i class="fa fa-calendar"></i></button>
                                        </span>
                                        <input type="text" id="datepicker_tglkunjungan" name="tgl_kunjungan" class="form-control" placeholder="Tanggal Kunjungan" value="<?= $re_kunjungan->tgl_kunjungan ?>" readonly>
                                    </div>                                                                                       
                                    <span id="error_tgl_kunjungan" class="help-block"></span>
                                  </div>
                                </div>                    
                              </div>

                              <div class="row">
                                <div class="col-md-6">
                                  <div class="form-group" id="form_rujuk_dari">
                                    <label for="rujuk_dari" class="control-label">Rujuk Dari </label>
                                    <select id="rujuk_dari" name="rujuk_dari" style="width:100%">
                                      <option value=""></option>
                                      <?php foreach ($this->Content_m->select_db('bbmc_re_rujukan_dari')->result() as $key ) { ?>
                                        <option value="<?=$key->id_rujukan_dari?>"><?=$key->rujukan_dari?></option>
                                      <?php }?>
                                      
                                    </select> 
                                    <span id="error_rujuk_dari" class="help-block"></span>
                                  </div>

                                </div>

                                <div class="col-md-6 dirujuk_oleh" style="<?=$re_kunjungan->rujuk_dari=='2'?'display: block':'display: none'?>">
                                  <div class="form-group" id="form_rujuk_dari">
                                    <label for="rujuk_dari" class="control-label">Dirujuk Oleh</label>
                                    
                                    <input type="text" id="datepicker_tglkunjungan" name="nama_dokter_atau_rumah_sakit_rujukan" class="form-control" placeholder="Nama Dokter / Rumah Sakit" value="<?=$re_kunjungan->nama_dokter_atau_rumah_sakit_rujukan?>">
                                    <span id="error_rujuk_dari" class="help-block"></span>
                                  </div>
                                </div>

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

                                


                                <div class="col-md-6">
                                  <div class="form-group" id="form_status_rawat">
                                    <label for="status_rawat" class="control-label">Status Perawatan </label>
                                    <select id="status_rawat" name="status_rawat" style="width:100%">
                                      <option value=""></option>
                                      <?php foreach ($this->Content_m->select_db('bbmc_re_status_perawatan')->result() as $key ) { ?>
                                        <option value="<?=$key->id_status_perawatan?>"><?=$key->status_perawatan?></option>
                                      <?php }?>
                                    </select> 
                                    <span id="error_status_rawat" class="help-block"></span>
                                  </div>
                                </div>     

                             


                             
                                
                                <div class="col-md-6">
                                  <div class="form-group" id="form_type_rawat">
                                    <label for="type_rawat" class="control-label">Type Perawatan </label>
                                    <select id="type_rawat" name="type_rawat" style="width:100%">
                                      <option value=""></option>
                                      <?php foreach ($this->Content_m->select_db('bbmc_re_tipe_perawatan')->result() as $key ) { ?>
                                        <option value="<?=$key->id_tipe_perawatan?>"><?=$key->tipe_perawatan?></option>
                                      <?php }?>
                                    </select> 
                                    <span id="error_type_rawat" class="help-block"></span>
                                  </div>
                                </div>
                                       
                              
                                 <div class="col-md-6">
                                  <div class="form-group" id="form_bangsal" style="<?=$re_kunjungan->type_perawatan=='2'?'display: block':'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->tipe_kamar?></option>
                                      <?php }?>                   
                                    </select>
                                    <span id="error_bangsal" class="help-block"></span>
                                  </div>
                                </div>

                              </div>  
                              
                              <div class="row" style="display: none;">
                                <div class="col-md-6">
                                  <div class="form-group" id="form_pemeriksaan_khusus">
                                    <label for="pemeriksaan_khusus" class="control-label">Pemeriksaan Khusus </label>
                                    <select id="pemeriksaan_khusus" name="pemeriksaan_khusus" style="width:100%" multiple>
                                      <option value=""></option>
                                      <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 class="col-md-6">
                                  <div class="form-group" id="form_keluhan">
                                    <label for="keluhan" class="control-label">Keluhan </label>
                                    <input type="text" id="keluhan" name="keluhan" class="form-control" placeholder="Keluhan Pasien" value="<?= $re_kunjungan->keluhan ?>">
                                    <span id="error_keluhan" class="help-block"></span>
                                  </div>
                                </div>      
                                <div class="col-md-6">
                                  <div class="form-group" id="form_surat_no">
                                    <label for="surat_no" class="control-label">Surat Nomor </label>
                                    <input type="text" id="surat_no" name="surat_no" class="form-control" placeholder="Nomor Surat" value="<?= $re_kunjungan->no_surat ?>">                                                         
                                    <span id="error_surat_no" class="help-block"></span>
                                  </div>
                                </div>                        
                              </div>            

                              <div style="<?=$re_kunjungan->type_perawatan=='3'?'display: none;':'display: block;'?>" class="sub_spesialis">
                                  <h4 class="form-section" style="margin:20px 0px 10px 0px !important; padding-bottom:0px !important">
                                      <i class="fa fa-align-justify"></i> <strong> Poli Spesialis Tujuan <hr style="margin:10px 0px !important" > </strong>
                                  </h4>
                                  <div class="row" >
                                    <div class="col-md-12">
                                      <select id="id_sub_spesialis" name="id_sub_spesialis" class="form-control">
                                        <option value=""></option>
                                        <?php 
                                        foreach ($this->Content_m->select_db('bbmc_re_sub_spesialis')->result() as $key ) { ?>
                                          <option value="<?=$key->id_sub_spesialis?>" <?=$re_kunjungan->id_sub_spesialis==$key->id_sub_spesialis?'selected':''?>><?=$key->sub_spesialis?></option>
                                        <?php }?>                   
                                      </select>
                                    </div>
                                  </div>
                              </div>        

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


                              <div style="<?=$re_kunjungan->type_perawatan=='2'?'display: block':'display: none '?>" class="penanggung_jawab_rawat_inap">
                                  <h4 class="form-section" style="margin:20px 0px 10px 0px !important; padding-bottom:0px !important">
                                      <i class="fa fa-align-justify"></i> <strong> Penanggung Jawab <hr style="margin:10px 0px !important" > </strong>
                                  </h4>
                                  <div class="row">
                                    <div class="col-md-6">
                                      <div class="form-group" id="form_nama_penanggung">
                                        <label for="nama_penanggung" class="control-label">Nama Penanggung </label>
                                        <input type="text" id="nama_penanggung" name="nama_penanggung" class="form-control" placeholder="Nama Penanggung" value="<?= $re_kunjungan->nama_penanggung ?>">
                                        <span id="error_nama_penanggung" class="help-block"></span>
                                      </div>
                                    </div>
                                    <div class="col-md-6">
                                      <div class="form-group" id="form_alamat_penanggung">
                                        <label for="alamat_penanggung" class="control-label">Alamat Penanggung </label>
                                        <input type="text" id="alamat_penanggung" name="alamat_penanggung" class="form-control" placeholder="Alamat Penanggung" value="<?= $re_kunjungan->alamat_penanggung ?>">
                                        
                                        <span id="error_alamat_penanggung" class="help-block"></span>
                                      </div>
                                    </div>
                                  </div>

                                  <div class="row">
                                    <div class="col-md-6">
                                      <div class="form-group" id="form_tlp_penanggung">
                                        <label for="tlp_penanggung" class="control-label">Telepon Penanggung </label>
                                        <input type="text" id="tlp_penanggung" name="tlp_penanggung" class="form-control" placeholder="Telepon Penanggung" value="<?= $re_kunjungan->tlp_penanggung ?>">
                                        <span id="error_tlp_penanggung" class="help-block"></span>
                                      </div>
                                    </div>
                                    <div class="col-md-6">
                                      <div class="form-group" id="form_hub_dgn_pasien">
                                        <label for="hub_dgn_pasien" class="control-label">Hubungan dengan Pasien </label>
                                        <select id="hub_dgn_pasien" name="hub_dgn_pasien" class="form-control" placeholder="Hubungan dengan Pasien">
                                          <option value=""></option>
                                          <option value="1">Ayah Kandung</option>
                                          <option value="2">Ibu Kandung </option>
                                          <option value="3">Anak Kandung </option>
                                          <option value="4">Saudara Kandung</option>
                                          <option value="5">Saudara </option>
                                          <option value="6">Teman </option>
                                          <option value="7">Tetangga </option>
                                        </select>
                                        <span id="error_hub_dgn_pasien" class="help-block"></span>
                                      </div>
                                    </div>
                                </div>
                              </div>

                              
                              <?php $this->load->view('front_office/registrasi/kunjungan/table_tindakan_edit');?>
                             

                            </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 green"><i class="fa fa-refresh"></i> Update</button>
                            </div>
                          </form>
                        </div>
                        <?php $this->load->view('front_office/include/loading'); ?>
                      </div>
                    </div>
                  </div>

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

<script type="text/javascript">
  $(document).ready(function() {
     /*-------------Datepicker-------------*/
   
    $( "#datepicker_tglkunjungan" ).datepicker({
        changeMonth: true,
        changeYear: true,
        yearRange: "-60:+0",
        dateFormat: 'yy-mm-dd'
    });

    $("#rujuk_dari").select2({
      placeholder: "Pilih Rujukan Dari",
      
      language: "id"
    });
    $("#rujuk_dari").val("<?=$re_kunjungan->rujuk_dari?>").trigger('change');
    
    $("#type_rawat").select2({
      placeholder: "Pilih Type Perawatan",
      
      language: "id"
    });    
    $("#type_rawat").val("<?=$re_kunjungan->type_perawatan?>").trigger('change');

    
    $("#type_rawat").change(function(){
        
        var id_tipe_perawatan = $(this).val();

        if(id_tipe_perawatan == '2'){
          $(".penanggung_jawab_rawat_inap").css('display','block');
          $("#form_bangsal").css('display','block');    
        }else{
          $(".penanggung_jawab_rawat_inap").css('display','none');
          $("#form_bangsal").css('display','none');
        }
        //alert(id_tipe_perawatan);
    });

     $("#id_sub_spesialis").select2({
      placeholder: "Pilih Poli Spesialis Tujuan",      
      language: "id"
    });
    
    $("#bangsal").select2({
      placeholder: "Pilih Kamar",      
      language: "id"
    });
    $("#bangsal").val("<?=$re_kunjungan->id_tipe_kamar?>").trigger('change');


    $("#status_rawat").select2({
      placeholder: "Pilih Status Perawatan",
      
      language: "id"
    });
    $("#status_rawat").val("<?=$re_kunjungan->status_perawatan?>").trigger('change');

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

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

    $("#hub_dgn_pasien").select2({
      placeholder: "Pilih Hubungan Dengan Pasien",
      
      language: "id"
    });
    $("#hub_dgn_pasien").val("<?=$re_kunjungan->hub_dgn_pasien?>").trigger('change');

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

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