<?php $id_type_pasien = $this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'id_type_pasien');?>

<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-plus"></i> <?= $judul ?> </a>
                </li> 
            </ul>
            <div class="tab-content">
                <div class="tab-pane active">

                  <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.'/tambah_data_proses_standard') ?>" method="post" id="<?=$controller?>" enctype="multipart/form-data" class="horizontal-form">
                            <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:0px 0px 20px 0px !important; padding-bottom:0px !important">
                                <i class="fa fa-align-justify"></i> <strong> Informasi Pasien <hr style="margin:10px 0px !important" > </strong>
                              </h4>
                              <?php if($id_type_pasien == '1'){ ?>
                              <div style="float:right;">
                                  <input type="checkbox" name="is_free" value="2"> FREE PEGAWAI  
                              </div>
                              <?php }?>
                              <div class="row">                                
                                <div class="col-md-12">
                                  <div class="form-group" id="form_id_re_pasien">
                                    <label for="id_re_pasien" class="control-label">Nama Pasien</label>
                                    <select id="id_re_pasien" name="id_re_pasien" class="form-control" style="width:100%" disabled>
                                        <?php if($id_re_pasien != null){ ?>
                                        <option value="<?=$id_re_pasien?>">BBMC-<?=$this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'nrm')?> - <?=$this->Content_m->get_value('bbmc_tr_pasien','id_re_pasien',$id_re_pasien,'nama_pasien')?> - <?=$this->Content_m->get_value('bbmc_re_tipe_pasien','id_tipe_pasien',$id_type_pasien,'tipe_pasien')?></option>
                                        <?php }else{ ?>
                                        <option value=""></option>
                                        <?php }?>
                                    </select>
                                    <input type="hidden" name="id_re_pasien" value="<?=$id_re_pasien?>">
                                    <span id="error_id_re_pasien" class="help-block"></span>
                                  </div>
                                </div>                                
                              </div> 

                              <script type="text/javascript">
                                $('#id_re_pasien').change(function(){
                                  
                                });
                              </script>

                              <h4 class="form-section" style="margin:20px 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>
                                    <?php 
                                      $varDate = date("d-m-y");
                                      $arrTgl = explode("-", $varDate);
                                      $tglkunjungan = $arrTgl[0].$arrTgl[1].$arrTgl[2];
                                    ?>
                                    <input type="text" id="no_kunjungan" name="no_kunjungan" class="form-control" readonly value="<?php echo $tglkunjungan.'-'.date('his'); ?>" >
                                    <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="<?php echo date("Y-m-d"); ?>" 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="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="">
                                    <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>  


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

                              
                              
                                <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="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="" selected></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" >
                                    <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" >                                                         
                                    <span id="error_surat_no" class="help-block"></span>
                                  </div>
                                  </div>                              
                              </div>     

                              <div style="display: none;" 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?>" ><?=$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="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">
                                        <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">

                                       
                                        <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">
                                        <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>

                             
                              
  
                              <div class="item_tindakan_umum" style="display: none;">
                              <?php 
                              if($id_type_pasien == '1'){
                                  $this->load->view('front_office/registrasi/kunjungan/table_tindakan_umum_add');
                              }else if($id_type_pasien == '2'){
                                  $this->load->view('front_office/registrasi/kunjungan/table_tindakan_bpjs_add');
                              }else if($id_type_pasien == '3'){
                                  $this->load->view('front_office/registrasi/kunjungan/table_tindakan_shhc_add');
                              }else if($id_type_pasien == '4'){
                                  $this->load->view('front_office/registrasi/kunjungan/table_tindakan_inhealth_add');
                              }else if($id_type_pasien == '5'){
                                  $this->load->view('front_office/registrasi/kunjungan/table_tindakan_mega_add');
                              }?>
                              </div>
                              <div class="item_tindakan_lainnya" style="display: none;">
                              <?php $this->load->view('front_office/registrasi/kunjungan/table_tindakan_lainnya_add')?>
                              </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> Tambah</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-------------*/

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

    $( "#datepicker_tglkunjungan" ).datepicker({
        changeMonth: true,
        changeYear: true,
        yearRange: "-60:+0",
        dateFormat: 'yy-mm-dd'
    });

    /*-------------Select2-------------*/
    $("#id_re_pasien").select2({
      placeholder: "No. Rekam Medis / Nama Pasien ..",
      language: "id",
      ajax: {
        url: "<?=site_url('front_office/ajax/select2_nama_pasien')?>",
        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; }
    });    

    $("#rujuk_dari").select2({
      placeholder: "Pilih Rujukan Dari",
      language: "id"
    });
    
    $("#type_rawat").select2({
      placeholder: "Pilih Type Perawatan",
      language: "id"
    });    

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

    $("#status_rawat").select2({
      placeholder: "Pilih Status Perawatan",
      
      language: "id"
    });

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

    $("#hub_dgn_pasien").select2({
      placeholder: "Pilih Hubungan Dengan Pasien",
      
      language: "id"
    });

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

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