871 lines
38 KiB
PHP
871 lines
38 KiB
PHP
<?php
|
|
class M_anjungan extends CI_Model {
|
|
|
|
function cekanjungan(){
|
|
$tanggalsekarang = date("Y-m-d");
|
|
$hari = date ("D");
|
|
$query = $this->db->get('master_klinik');
|
|
foreach ($query->result() as $datklinik){
|
|
$reset_klinik = array(
|
|
'mk_status_shift' => 1,
|
|
'mk_aktif' => 0,
|
|
);
|
|
$this->db->where('mk_id', $datklinik->mk_id);
|
|
$this->db->update('master_klinik', $reset_klinik);
|
|
|
|
$aktif=0;//----------aktif 0 maka klinik tutup
|
|
$setaktifdb=0;//----------setaktif 0 maka klinik buka
|
|
$setpenuh=0;//----------setpenuh 1 maka klinik penuh
|
|
$shiftcek = $datklinik->mk_shift;
|
|
//----------------start cek hari sekarang klinik buka atau tidak----------------//
|
|
switch($hari){
|
|
case 'Sun':$hari_ini = "minggu";break;case 'Mon':$hari_ini = "senin";break;case 'Tue':$hari_ini = "selasa";break;
|
|
case 'Wed':$hari_ini = "rabu";break;case 'Thu':$hari_ini = "kamis";break;case 'Fri':$hari_ini = "jumat";break;
|
|
case 'Sat':$hari_ini = "sabtu";break;default:$hari_ini = "Tidak di ketahui";break;
|
|
}
|
|
$pecahjadwal = explode("|",$datklinik->mk_jadwal);
|
|
$jumdat = count($pecahjadwal);
|
|
for ($x = 0; $x <= $jumdat; $x++){
|
|
if(isset($pecahjadwal[$x])){
|
|
if($pecahjadwal[$x]==$hari_ini){$aktif=$aktif+1;}
|
|
}
|
|
}
|
|
if($aktif==0){$setaktifdb=1;}
|
|
//----------------end cek hari sekarang klinik buka atau tidak----------------//
|
|
//----------------start cek quota pasien per shift----------------//
|
|
for ($i = 1; $i <= $datklinik->mk_shift; $i++){
|
|
$this->db->where('pp_klinik_id', $datklinik->mk_id);
|
|
$this->db->where('pp_shift', $i);
|
|
$this->db->where('pp_tanggal_periksa', $tanggalsekarang);
|
|
$query_pp = $this->db->get('proses_pengunjung');
|
|
$jum_row = $query_pp->num_rows();
|
|
$next_shift = $i+1;
|
|
//-----------start cek quota shift jika penuh ke shift selanjutnya---------//
|
|
if($datklinik->mk_quota<=$jum_row){
|
|
//-----------start cek klinik tidak bisa lebih dari jumlah shift klinik---------//
|
|
if($next_shift<=$shiftcek){
|
|
$update_klinik = array(
|
|
'mk_status_shift' => $next_shift,
|
|
);
|
|
$this->db->where('mk_id', $datklinik->mk_id);
|
|
$this->db->update('master_klinik', $update_klinik);
|
|
}else{
|
|
// $update_klinik = array();
|
|
$setaktifdb=1;
|
|
$setpenuh=1;
|
|
}
|
|
// $this->db->where('mk_id', $datklinik->mk_id);
|
|
// $this->db->update('master_klinik', $update_klinik);
|
|
//-----------end cek klinik tidak bisa lebih dari jumlah shift klinik---------//
|
|
}
|
|
//-----------start cek quota shift jika penuh ke shift selanjutnya---------//
|
|
}
|
|
//----------------end cek quota pasien per shift----------------//
|
|
$update_mk = array(
|
|
'mk_tanggal_sekarang' => $tanggalsekarang,
|
|
'mk_aktif' => $setaktifdb,
|
|
'mk_shift_penuh' => $setpenuh,
|
|
);
|
|
$this->db->where('mk_id', $datklinik->mk_id);
|
|
$this->db->update('master_klinik', $update_mk);
|
|
}
|
|
|
|
$this->db->where('pp_tanggal_periksa', date('Y-m-d'));
|
|
$this->db->where('pp_pendaftaran_online is NOT NULL', NULL, FALSE);
|
|
$this->db->where('pp_loket is NULL', NULL, TRUE);
|
|
$query_pp = $this->db->get('proses_pengunjung');
|
|
foreach ($query_pp->result() as $datapp){
|
|
$loket = null;
|
|
$this->db->order_by("ml_id", "RANDOM");
|
|
$this->db->where('ml_pembayaran', $datapp->pp_pembayaran);
|
|
$query_loket = $this->db->get('master_loket');
|
|
foreach ($query_loket->result() as $datloket){
|
|
$loketexplode = explode(",",$datloket->ml_pelayanan);
|
|
$count = count($loketexplode);
|
|
for ($x = 0; $x <= $count; $x++) {
|
|
if(isset($loketexplode[$x])){
|
|
if($datapp->pp_klinik_id==$loketexplode[$x]){
|
|
$update_pp = array(
|
|
'pp_loket' => $datloket->ml_id,
|
|
);
|
|
$this->db->where('pp_id', $datapp->pp_id);
|
|
$this->db->update('proses_pengunjung', $update_pp);
|
|
//$loket = $datloket->ml_id;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//-----------------digunakan untuk cek buka shift apabila sudah jam nya....(jika autoshift)
|
|
function cek_shift_jam(){
|
|
$jamnow = date("H");
|
|
$menitnow = date("m");
|
|
$this->db->where('mk_aktif', '0');
|
|
$query = $this->db->get('master_klinik');
|
|
foreach ($query->result() as $datklinik){
|
|
if($datklinik->mk_auto_shift==1){
|
|
$jumwaktu=0;
|
|
$pecahwaktu = explode("|",$datklinik->mk_jam_shift);
|
|
$jumwaktu = count($pecahwaktu);
|
|
$ketshift = 1;
|
|
for ($x = 0; $x < $jumwaktu; $x++){
|
|
$waktu_awal =strtotime(date("Y-m-d ").$pecahwaktu[$x]);
|
|
$waktu_akhir =strtotime(date("Y-m-d H:i"));
|
|
$diff =$waktu_akhir-$waktu_awal;
|
|
$hasil = number_format($diff,0,",",".");
|
|
if($hasil>=0){
|
|
if($pecahwaktu[$x]!=0){
|
|
$update_mk = array(
|
|
'mk_shift_buka' => $ketshift,
|
|
);
|
|
$this->db->where('mk_id', $datklinik->mk_id);
|
|
$this->db->update('master_klinik', $update_mk);
|
|
}
|
|
}else{
|
|
if($ketshift==1){
|
|
$update_mk = array(
|
|
'mk_shift_buka' => 1,
|
|
);
|
|
$this->db->where('mk_id', $datklinik->mk_id);
|
|
$this->db->update('master_klinik', $update_mk);
|
|
}
|
|
}
|
|
|
|
$ketshift++;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function insert_sekarang($idk, $shift, $ket , $pembayaran){
|
|
//--------start get kode master klinik-----------//
|
|
$kodeklinik="";
|
|
$barcode="";$urutanbar=0;
|
|
$this->db->where('mk_id', $idk);
|
|
$query = $this->db->get('master_klinik');
|
|
foreach ($query->result() as $datklinik){
|
|
if($pembayaran==1){
|
|
$kodeklinik="UM";
|
|
}else{
|
|
$kodeklinik= $datklinik->mk_kode;
|
|
}
|
|
}
|
|
//--------end get kode master klinik-----------//
|
|
//--------start nomor antrian------------------//
|
|
$no_antrian;
|
|
$hasil_nomor = "";
|
|
$query_pengunjung = $this->db->query("select MAX(pp_nomor_antrian) AS maxnomorantrian from proses_pengunjung WHERE pp_tanggal_periksa = '".date("Y-m-d")."' AND pp_nomor_antrian LIKE '".$kodeklinik."%' ");
|
|
// $this->db->like('pp_nomor_antrian', $kodeklinik, 'after');
|
|
// $this->db->where('pp_tanggal_periksa', date("Y-m-d"));
|
|
// $query_pengunjung = $this->db->get('proses_pengunjung');
|
|
foreach ($query_pengunjung->result() as $datpengunjung){
|
|
$no_antrian = $datpengunjung->maxnomorantrian;
|
|
}
|
|
|
|
if(isset($no_antrian)){
|
|
$urutan = (int) substr($no_antrian, 3, 3);
|
|
$urutan++;
|
|
$hasil_nomor = $kodeklinik.$shift.sprintf("%03s", $urutan);
|
|
}else {
|
|
$hasil_nomor=$kodeklinik.$shift."001";
|
|
|
|
}
|
|
//--------end nomor antrian--------------------//
|
|
//-------start nomor barcode------------------//
|
|
$no_barcode;
|
|
$hasil_barcode = "";
|
|
$this->db->where('pp_tanggal_periksa', date("Y-m-d"));
|
|
$query_barcode = $this->db->get('proses_pengunjung');
|
|
foreach ($query_barcode->result() as $datbarcode){
|
|
$no_barcode = $datbarcode->pp_barcode;
|
|
}
|
|
if(isset($no_barcode)){
|
|
$urutan = (int) substr($no_barcode, 7, 5);
|
|
$urutan++;
|
|
$barcode=date("ymd").$shift.sprintf("%05s", $urutan);
|
|
$urutanbar=$urutan;
|
|
}else {
|
|
$barcode=date("ymd").$shift."00001";
|
|
$urutanbar=1;
|
|
}
|
|
//-------end nomor barcode-------------------//
|
|
if($ket==4){
|
|
$this->db->where('pp_tanggal_periksa', date('Y-m-d'));
|
|
$this->db->where('pp_nomor_antrian', $hasil_nomor);
|
|
$query_cek_nomor = $this->db->get('proses_pengunjung');
|
|
if($query_cek_nomor->num_rows()!=0){
|
|
return FALSE;
|
|
}else{
|
|
//----------------------start untuk pasien fasttrack----------------------------//
|
|
$pj = $this->input->post('penanggungjawab');
|
|
$rm = $this->input->post('norek');
|
|
$np = $this->input->post('namapas');
|
|
$ke = $this->input->post('ket');
|
|
|
|
$rafast = $pj."|".$np."|".$ke."|";
|
|
|
|
$insert_pp = array(
|
|
'pp_nomor_antrian' => $hasil_nomor,
|
|
'pp_shift' => $shift,
|
|
'pp_tanggal_periksa' => date("Y-m-d"),
|
|
'pp_tanggal_datang' => date("Y-m-d H:i:s"),
|
|
'pp_posisi_status' => 1,
|
|
'pp_pendaftaran_online' => null,
|
|
'pp_rekamedik' => $rm,
|
|
'pp_status' => 1,
|
|
'pp_aktif' => null,
|
|
'pp_klinik_id' => $idk,
|
|
'pp_barcode' => $barcode,
|
|
'pp_pembayaran' => $pembayaran,
|
|
'pp_fasttrack' => $rafast,
|
|
);
|
|
$insert = $this->db->insert('proses_pengunjung', $insert_pp);
|
|
$last_insert_id = $this->db->insert_id();
|
|
|
|
$insert_prt = array(
|
|
'prt_status' => 1,
|
|
'prt_tanggal' => date("Y-m-d H:i:s"),
|
|
'prt_aktif' => 0,
|
|
'prt_pengunjung_id' => $last_insert_id,
|
|
);
|
|
$prt = $this->db->insert('proses_ruang_tunggu', $insert_prt);
|
|
//----------------------end untuk pasien fasttrack----------------------------//
|
|
}
|
|
}else{
|
|
$this->db->where('pp_tanggal_periksa', date('Y-m-d'));
|
|
$this->db->where('pp_nomor_antrian', $hasil_nomor);
|
|
$query_cek_nomor = $this->db->get('proses_pengunjung');
|
|
if($query_cek_nomor->num_rows()!=0){
|
|
return FALSE;
|
|
}else{
|
|
$insert_pp = array(
|
|
'pp_nomor_antrian' => $hasil_nomor,
|
|
'pp_shift' => $shift,
|
|
'pp_tanggal_periksa' => date("Y-m-d"),
|
|
'pp_tanggal_datang' => date("Y-m-d H:i:s"),
|
|
'pp_posisi_status' => 1,
|
|
'pp_pendaftaran_online' => null,
|
|
'pp_rekamedik' => null,
|
|
'pp_status' => null,
|
|
'pp_aktif' => null,
|
|
'pp_klinik_id' => $idk,
|
|
'pp_barcode' => $barcode,
|
|
'pp_pembayaran' => $pembayaran,
|
|
);
|
|
$insert = $this->db->insert('proses_pengunjung', $insert_pp);
|
|
$pp_last_id = $this->db->insert_id();
|
|
//-----------start langsung masuk-------------------//
|
|
if($urutanbar<=70){
|
|
|
|
$loket = null;
|
|
$this->db->order_by("ml_id", "RANDOM");
|
|
$this->db->where('ml_pembayaran', $pembayaran);
|
|
$query_loket = $this->db->get('master_loket');
|
|
foreach ($query_loket->result() as $datloket){
|
|
$loketexplode = explode(",",$datloket->ml_pelayanan);
|
|
$count = count($loketexplode);
|
|
for ($x = 0; $x <= $count; $x++) {
|
|
if(isset($loketexplode[$x])){
|
|
if($idk==$loketexplode[$x]){
|
|
$loket = $datloket->ml_id;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$autoinsert_prt = array(
|
|
'prt_status' => 0,
|
|
'prt_tanggal' => date("Y-m-d H:i:s"),
|
|
'prt_aktif' => 0,
|
|
'prt_pengunjung_id' => $pp_last_id,
|
|
);
|
|
$prt = $this->db->insert('proses_ruang_tunggu', $autoinsert_prt);
|
|
|
|
$update_pp = array(
|
|
'pp_status' => 1,
|
|
'pp_panggil_anjungan' => date("Y-m-d H:i:s"),
|
|
'pp_loket' => $loket,
|
|
);
|
|
$this->db->where('pp_id', $pp_last_id);
|
|
$this->db->update('proses_pengunjung', $update_pp);
|
|
}
|
|
//-----------end langsung masuk-------------------//
|
|
}
|
|
}
|
|
//--------for cek data quota shift
|
|
$date=date("Y-m-d");
|
|
$this->cek_quota_shift($idk, $shift,$date);
|
|
}
|
|
|
|
function insert_pesan(){
|
|
$urutanbar=0;
|
|
$pembayaran=$this->input->post('pembayaran');
|
|
$idk = $this->input->post('idklinikpesan');
|
|
$shift = $this->input->post('shiftpesan');
|
|
$originalDate = $this->input->post('tanggalpesan');
|
|
$newDate = date("Y-m-d", strtotime($originalDate));
|
|
$newDate2 = date("ymd", strtotime($originalDate));
|
|
//--------start get kode master klinik-----------//
|
|
$kodeklinik="";
|
|
$barcode="";
|
|
$this->db->where('mk_id', $idk);
|
|
$query = $this->db->get('master_klinik');
|
|
foreach ($query->result() as $datklinik){
|
|
if($pembayaran==1){
|
|
$kodeklinik="UM";
|
|
}else{
|
|
$kodeklinik= $datklinik->mk_kode;
|
|
}
|
|
}
|
|
//--------end get kode master klinik-----------//
|
|
//--------start nomor antrian------------------//
|
|
$no_antrian;
|
|
$hasil_nomor = "";
|
|
$query_pengunjung = $this->db->query("select * from proses_pengunjung WHERE pp_tanggal_periksa = '".$newDate."' AND pp_nomor_antrian LIKE '".$kodeklinik."%' ");
|
|
//$this->db->like('pp_nomor_antrian', $kodeklinik, 'after');
|
|
//$this->db->where('pp_tanggal_periksa', $newDate);
|
|
//$query_pengunjung = $this->db->get('proses_pengunjung');
|
|
foreach ($query_pengunjung->result() as $datpengunjung){
|
|
$no_antrian = $datpengunjung->pp_nomor_antrian;
|
|
}
|
|
|
|
if(isset($no_antrian)){
|
|
$urutan = (int) substr($no_antrian, 3, 3);
|
|
$urutan++;
|
|
$hasil_nomor = $kodeklinik.$shift.sprintf("%03s", $urutan);
|
|
|
|
}else {
|
|
$hasil_nomor=$kodeklinik.$shift."001";
|
|
}
|
|
|
|
//--------end nomor antrian--------------------//
|
|
//-------start nomor barcode------------------//
|
|
$no_barcode;
|
|
$hasil_barcode = "";
|
|
$this->db->where('pp_tanggal_periksa', $newDate);
|
|
$query_barcode = $this->db->get('proses_pengunjung');
|
|
foreach ($query_barcode->result() as $datbarcode){
|
|
$no_barcode = $datbarcode->pp_barcode;
|
|
}
|
|
if(isset($no_barcode)){
|
|
$urutan = (int) substr($no_barcode, 7, 5);
|
|
$urutan++;
|
|
$barcode=$newDate2.$shift.sprintf("%05s", $urutan);
|
|
$urutanbar=$urutan;
|
|
}else {
|
|
$barcode=$newDate2.$shift."00001";
|
|
$urutanbar=1;
|
|
}
|
|
|
|
//-------end nomor barcode-------------------//
|
|
// $this->db->where('pp_tanggal_periksa', date('Y-m-d'));
|
|
// $this->db->where('pp_nomor_antrian', $hasil_nomor);
|
|
// $query_cek_nomor = $this->db->get('proses_pengunjung');
|
|
// // var_dump($query_cek_nomor->num_rows());
|
|
// // exit();
|
|
// if($query_cek_nomor->num_rows()!=0){
|
|
// return FALSE;
|
|
// }else{
|
|
$insert_pp = array(
|
|
'pp_nomor_antrian' => $hasil_nomor,
|
|
'pp_shift' => $shift,
|
|
'pp_tanggal_periksa' => $newDate,
|
|
'pp_tanggal_datang' => date("Y-m-d H:i:s"),
|
|
'pp_posisi_status' => 1,
|
|
'pp_pendaftaran_online' => null,
|
|
'pp_rekamedik' => null,
|
|
'pp_status' => null,
|
|
'pp_aktif' => null,
|
|
'pp_klinik_id' => $idk,
|
|
'pp_barcode' => $barcode,
|
|
'pp_pembayaran' => $pembayaran,
|
|
);
|
|
$insert = $this->db->insert('proses_pengunjung', $insert_pp);
|
|
$pp_last_id = $this->db->insert_id();
|
|
// var_dump($pp_last_id);
|
|
// exit();
|
|
//-----------start langsung masuk-------------------//
|
|
if($urutanbar<=70){
|
|
$loket = null;
|
|
$this->db->order_by("ml_id", "RANDOM");
|
|
$this->db->where('ml_pembayaran', $pembayaran);
|
|
$query_loket = $this->db->get('master_loket');
|
|
foreach ($query_loket->result() as $datloket){
|
|
$loketexplode = explode(",",$datloket->ml_pelayanan);
|
|
$count = count($loketexplode);
|
|
for ($x = 0; $x <= $count; $x++) {
|
|
if(isset($loketexplode[$x])){
|
|
if($idk==$loketexplode[$x]){
|
|
$loket = $datloket->ml_id;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$autoinsert_prt = array(
|
|
'prt_status' => 0,
|
|
'prt_tanggal' => $newDate.date(" 05:00:00"),
|
|
'prt_aktif' => 0,
|
|
'prt_pengunjung_id' => $pp_last_id,
|
|
);
|
|
$prt = $this->db->insert('proses_ruang_tunggu', $autoinsert_prt);
|
|
|
|
$update_pp = array(
|
|
'pp_status' => 1,
|
|
'pp_panggil_anjungan' => $newDate.date(" 05:10:00"),
|
|
'pp_loket' => $loket,
|
|
);
|
|
$this->db->where('pp_id', $pp_last_id);
|
|
$this->db->update('proses_pengunjung', $update_pp);
|
|
}
|
|
//-----------end langsung masuk-------------------//
|
|
//}
|
|
|
|
$date=$newDate;
|
|
$this->cek_quota_shift($idk, $shift,$date);
|
|
}
|
|
|
|
function insert_daftar_online(){
|
|
$urutanbar=0;
|
|
$pembayaran=$this->input->post('pembayaran');
|
|
$idk = $this->input->post('klinik');
|
|
$shift = $this->input->post('shiftonline');
|
|
//--------start get kode master klinik-----------//
|
|
$kodeklinik="";
|
|
$barcode="";
|
|
$this->db->where('mk_id', $idk);
|
|
$query = $this->db->get('master_klinik');
|
|
foreach ($query->result() as $datklinik){
|
|
if($pembayaran==1){
|
|
$kodeklinik="UM";
|
|
}else{
|
|
$kodeklinik= $datklinik->mk_kode;
|
|
}
|
|
}
|
|
//--------end get kode master klinik-----------//
|
|
//--------start nomor antrian------------------//
|
|
$no_antrian;
|
|
$hasil_nomor = "";
|
|
$query_pengunjung = $this->db->query("select * from proses_pengunjung WHERE pp_tanggal_periksa = '".date("Y-m-d")."' AND pp_nomor_antrian LIKE '".$kodeklinik."%' ");
|
|
// $this->db->like('pp_nomor_antrian', $kodeklinik, 'after');
|
|
// $this->db->where('pp_tanggal_periksa', date("Y-m-d"));
|
|
// $query_pengunjung = $this->db->get('proses_pengunjung');
|
|
foreach ($query_pengunjung->result() as $datpengunjung){
|
|
$no_antrian = $datpengunjung->pp_nomor_antrian;
|
|
}
|
|
if(isset($no_antrian)){
|
|
$urutan = (int) substr($no_antrian, 3, 3);
|
|
$urutan++;
|
|
$hasil_nomor = $kodeklinik.$shift.sprintf("%03s", $urutan);
|
|
}else {
|
|
$hasil_nomor=$kodeklinik.$shift."001";
|
|
}
|
|
//--------end nomor antrian--------------------//
|
|
//-------start nomor barcode------------------//
|
|
$no_barcode;
|
|
$hasil_barcode = "";
|
|
$this->db->where('pp_tanggal_periksa', date("Y-m-d"));
|
|
$query_barcode = $this->db->get('proses_pengunjung');
|
|
foreach ($query_barcode->result() as $datbarcode){
|
|
$no_barcode = $datbarcode->pp_barcode;
|
|
}
|
|
if(isset($no_barcode)){
|
|
$urutan = (int) substr($no_barcode, 7, 5);
|
|
$urutan++;
|
|
$barcode=date("ymd").$shift.sprintf("%05s", $urutan);
|
|
$urutanbar=$urutan;
|
|
}else {
|
|
$barcode=date("ymd").$shift."00001";
|
|
$urutanbar=1;
|
|
}
|
|
|
|
//-------end nomor barcode-------------------//
|
|
$loket = null;
|
|
$this->db->order_by("ml_id", "RANDOM");
|
|
$this->db->where('ml_pembayaran', $pembayaran);
|
|
$query_loket = $this->db->get('master_loket');
|
|
foreach ($query_loket->result() as $datloket){
|
|
$loketexplode = explode(",",$datloket->ml_pelayanan);
|
|
$count = count($loketexplode);
|
|
for ($x = 0; $x <= $count; $x++) {
|
|
if(isset($loketexplode[$x])){
|
|
if($idk==$loketexplode[$x]){
|
|
$loket = $datloket->ml_id;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->db->where('pp_nomor_antrian', $hasil_nomor);
|
|
$query_cek_nomor = $this->db->get('proses_pengunjung');
|
|
if($query_cek_nomor->num_rows()!=0){
|
|
return FALSE;
|
|
}else{
|
|
$insert_pp = array(
|
|
'pp_nomor_antrian' => $hasil_nomor,
|
|
'pp_shift' => $shift,
|
|
'pp_tanggal_periksa' => date("Y-m-d"),
|
|
'pp_tanggal_datang' => date("Y-m-d H:i:s"),
|
|
'pp_posisi_status' => 1,
|
|
'pp_pendaftaran_online' => $this->input->post('nopendaftaran'),
|
|
'pp_rekamedik' => $this->input->post('norm'),
|
|
'pp_status' => 1,
|
|
'pp_aktif' => null,
|
|
'pp_klinik_id' => $idk,
|
|
'pp_barcode' => $barcode,
|
|
'pp_pembayaran' => $pembayaran,
|
|
'pp_loket' => $loket,
|
|
);
|
|
$insert = $this->db->insert('proses_pengunjung', $insert_pp);
|
|
|
|
$last_insert_id = $this->db->insert_id();
|
|
$insert_prt = array(
|
|
'prt_status' => 1,
|
|
'prt_tanggal' => date("Y-m-d H:i:s"),
|
|
'prt_aktif' => 0,
|
|
'prt_pengunjung_id' => $last_insert_id,
|
|
);
|
|
$insert_prt = $this->db->insert('proses_ruang_tunggu', $insert_prt);
|
|
}
|
|
//--------for cek data quota shift
|
|
$date=date("Y-m-d");
|
|
$this->cek_quota_shift($idk, $shift,$date);
|
|
}
|
|
|
|
function cek_quota_shift($idk,$shift,$date){
|
|
$quota_shift;
|
|
$jum_pp;
|
|
$shiftcek;
|
|
|
|
$this->db->where('mk_id', $idk);
|
|
$query = $this->db->get('master_klinik');
|
|
foreach ($query->result() as $datklinik){
|
|
$quota_shift = $datklinik->mk_quota;
|
|
$shiftcek = $datklinik->mk_shift;
|
|
}
|
|
|
|
for($i=1;$i<=$shiftcek;$i++){
|
|
$this->db->where('pp_klinik_id', $idk);
|
|
$this->db->where('pp_shift', $i);
|
|
$this->db->where('pp_tanggal_periksa', $date);
|
|
$query_pp = $this->db->get('proses_pengunjung');
|
|
$jum_row = $query_pp->num_rows();
|
|
$next_shift = $i+1;
|
|
//-----------start cek quota shift jika penuh ke shift selanjutnya---------//
|
|
if($quota_shift<=$jum_row){
|
|
//-----------start cek klinik tidak bisa lebih dari jumlah shift klinik---------//
|
|
if($next_shift<=$shiftcek){
|
|
$update_klinik = array(
|
|
'mk_status_shift' => $next_shift,
|
|
);
|
|
}else{
|
|
$update_klinik = array(
|
|
'mk_aktif' => 1,
|
|
'mk_shift_penuh'=> 1,
|
|
);
|
|
}
|
|
$this->db->where('mk_id', $idk);
|
|
$this->db->update('master_klinik', $update_klinik);
|
|
//-----------end cek klinik tidak bisa lebih dari jumlah shift klinik---------//
|
|
}
|
|
//-----------start cek quota shift jika penuh ke shift selanjutnya---------//
|
|
}
|
|
|
|
}
|
|
|
|
function info_pengunjung(){
|
|
$this->db->order_by('pp_panggil_anjungan', 'ASC');
|
|
$this->db->join('proses_pengunjung', 'pp_id = prt_pengunjung_id');
|
|
$this->db->join('master_klinik', 'mk_id = pp_klinik_id');
|
|
$this->db->where('pp_tanggal_periksa', date("Y-m-d"));
|
|
$this->db->where('prt_status', 0);
|
|
$this->db->where('prt_aktif', 0);
|
|
$query = $this->db->get('proses_ruang_tunggu');
|
|
return $query->result();
|
|
|
|
$this->cekanjungan();
|
|
}
|
|
|
|
function info_pengunjung2(){
|
|
$this->db->order_by('mk_nama', 'ASC');
|
|
$this->db->order_by('pp_panggil_anjungan', 'ASC');
|
|
$this->db->join('proses_pengunjung', 'pp_id = prt_pengunjung_id');
|
|
$this->db->join('master_klinik', 'mk_id = pp_klinik_id');
|
|
$this->db->where('pp_tanggal_periksa', date("Y-m-d"));
|
|
$this->db->where('prt_status', 0);
|
|
$this->db->where('prt_aktif', 0);
|
|
$query = $this->db->get('proses_ruang_tunggu');
|
|
return $query->result();
|
|
|
|
$this->cekanjungan();
|
|
}
|
|
|
|
function barcode($barcode){
|
|
$barcode = date("y").substr($barcode,2);
|
|
$this->db->join('proses_ruang_tunggu', 'prt_pengunjung_id = pp_id', 'LEFT');
|
|
$this->db->where('pp_barcode', $barcode);
|
|
$this->db->where('pp_tanggal_periksa', date("Y-m-d"));
|
|
//$this->db->where('prt_status', 0);
|
|
$querypp = $this->db->get('proses_pengunjung');
|
|
$rowcount = $querypp->num_rows();
|
|
|
|
if($rowcount!=0){
|
|
foreach ($querypp->result() as $datpp){
|
|
|
|
if($datpp->pp_status!=null){
|
|
if($datpp->prt_aktif!=2){
|
|
if($datpp->prt_aktif==0){
|
|
if($datpp->prt_status==0){
|
|
$update_prt = array(
|
|
'prt_status' => 1,
|
|
);
|
|
$this->db->where('prt_id', $datpp->prt_id);
|
|
$this->db->update('proses_ruang_tunggu', $update_prt);
|
|
|
|
$update_pp = array(
|
|
'pp_panggil_anjungan' => null,
|
|
// 'pp_panggil_loket' => null,
|
|
// 'pp_panggil' => null,
|
|
);
|
|
$this->db->where('pp_id', $datpp->pp_id);
|
|
$this->db->update('proses_pengunjung', $update_pp);
|
|
|
|
$this->checkin($datpp->prt_id, $datpp->pp_id);
|
|
|
|
$this->session->set_flashdata('message', 'Anda berhasil input barcode, Silahkan Masuk');
|
|
}else{
|
|
|
|
$this->checkin($datpp->prt_id, $datpp->pp_id);
|
|
|
|
$this->session->set_flashdata('message', 'Pengunjung Ditemukan, Silahkan Masuk');
|
|
}
|
|
}else{
|
|
$this->datang($datpp->prt_id);
|
|
$this->session->set_flashdata('messageblue', 'Anda dinyatakan terlambat, tunggu panggilan selanjutnya diruang tunggu');
|
|
}
|
|
}else{
|
|
$this->session->set_flashdata('messagewarning', 'Anda belum di panggil!!!');
|
|
}
|
|
}else{
|
|
$this->session->set_flashdata('messagewarning', 'Anda belum di panggil!!!');
|
|
}
|
|
|
|
}
|
|
}else{
|
|
$this->session->set_flashdata('messagefail', 'Barcode Tidak Ditemukan!!');
|
|
}
|
|
}
|
|
|
|
function anjunganterlambat(){
|
|
$this->db->join('proses_pengunjung', 'pp_id = prt_pengunjung_id');
|
|
$this->db->where('pp_tanggal_periksa', date("Y-m-d"));
|
|
$this->db->where('prt_status', 0);
|
|
$this->db->where('prt_aktif', 1);
|
|
$query = $this->db->get('proses_ruang_tunggu');
|
|
return $query->result();
|
|
}
|
|
|
|
function datang($id){
|
|
$update_prt = array(
|
|
'prt_aktif' => 2,
|
|
);
|
|
$this->db->where('prt_id', $id);
|
|
$this->db->update('proses_ruang_tunggu', $update_prt);
|
|
|
|
//$this->session->set_flashdata('message', 'Anda berhasil input pasien terlambat');
|
|
}
|
|
|
|
function bypass($id){
|
|
$autoinsert_prt = array(
|
|
'prt_status' => 1,
|
|
'prt_tanggal' => date("Y-m-d H:i:s"),
|
|
'prt_aktif' => 0,
|
|
'prt_pengunjung_id' => $id,
|
|
);
|
|
$prt = $this->db->insert('proses_ruang_tunggu', $autoinsert_prt);
|
|
|
|
$update_pp = array(
|
|
'pp_status' => 1,
|
|
);
|
|
$this->db->where('pp_id', $id);
|
|
$this->db->update('proses_pengunjung', $update_pp);
|
|
|
|
$this->session->set_flashdata('message', 'Anda berhasil proses pasien bypass');
|
|
}
|
|
|
|
function info_klinik(){
|
|
$this->db->join('proses_pengunjung', 'pp_id = prt_pengunjung_id');
|
|
$this->db->where('pp_tanggal_periksa', date("Y-m-d"));
|
|
$this->db->where('prt_status', 5);
|
|
$this->db->where('prt_aktif', 0);
|
|
$query = $this->db->get('proses_ruang_tunggu');
|
|
return $query->result();
|
|
}
|
|
|
|
function datapengunjung($idklinik){
|
|
$this->db->join('master_klinik', 'mk_id = pp_klinik_id');
|
|
$this->db->where('pp_tanggal_periksa', date("Y-m-d"));
|
|
$this->db->where('pp_klinik_id', $idklinik);
|
|
$query = $this->db->get('proses_pengunjung');
|
|
return $query->result();
|
|
}
|
|
|
|
function datapengunjungthis($idpp){
|
|
$this->db->join('master_klinik', 'mk_id = pp_klinik_id');
|
|
//$this->db->where('pp_tanggal_periksa', date("Y-m-d"));
|
|
$this->db->where('pp_id', $idpp);
|
|
$query = $this->db->get('proses_pengunjung');
|
|
return $query->result();
|
|
}
|
|
|
|
function datapengunjungpesan($idklinik,$tgl,$shift){
|
|
$newDate = date("Y-m-d", strtotime($tgl));
|
|
$this->db->join('master_klinik', 'mk_id = pp_klinik_id');
|
|
$this->db->where('pp_tanggal_periksa', $newDate);
|
|
$this->db->where('pp_klinik_id', $idklinik);
|
|
$this->db->where('pp_shift', $shift);
|
|
$query = $this->db->get('proses_pengunjung');
|
|
return $query->result();
|
|
}
|
|
|
|
function panggilpasien(){
|
|
$this->db->order_by('pp_panggil', 'desc');
|
|
$this->db->like('pp_panggil', date("Y-m-d"), 'both');// %a%
|
|
$query = $this->db->get('proses_pengunjung');
|
|
return $query->result();
|
|
}
|
|
|
|
function cetakulang($id) {
|
|
$this->db->join('master_klinik', 'mk_id = pp_klinik_id');
|
|
$this->db->where('pp_id', $id);
|
|
$this->db->where('pp_tanggal_periksa', date("Y-m-d"));
|
|
$query = $this->db->get('proses_pengunjung');
|
|
return $query->result();
|
|
}
|
|
|
|
function allpasien() {
|
|
$this->db->order_by('pp_tanggal_datang', 'desc');
|
|
$this->db->join('master_klinik', 'mk_id = pp_klinik_id');
|
|
//$this->db->where('pp_tanggal_periksa', date("Y-m-d"));
|
|
$query = $this->db->get('proses_pengunjung');
|
|
return $query->result();
|
|
}
|
|
|
|
function batasallpasien() {
|
|
$this->db->order_by('pp_tanggal_datang', 'desc');
|
|
$this->db->join('proses_ruang_tunggu', 'prt_pengunjung_id = pp_id','LEFT');
|
|
$this->db->join('master_klinik', 'mk_id = pp_klinik_id');
|
|
$this->db->where('pp_tanggal_periksa', date("Y-m-d"));
|
|
$query = $this->db->get('proses_pengunjung');
|
|
return $query->result();
|
|
}
|
|
|
|
public function checkin($idprt, $idpp){
|
|
$this->load->model('m_loket');
|
|
$this->m_loket->proses_checkin($idprt,$idpp);
|
|
|
|
$this->db->join('proses_ruang_tunggu', 'prt_pengunjung_id = pp_id');
|
|
$this->db->where('pp_id', $idpp);
|
|
$query = $this->db->get('proses_pengunjung');
|
|
//var_dump("ij");
|
|
//exit();
|
|
foreach($query->result() as $dat){
|
|
$dataObj = new stdClass();
|
|
$dataObj->jenislayanan = 'antrian'; //// JENIS LAYANAN 1: simrs 2: antrian
|
|
$dataObj->norm = ''; //// Nomor Rekam Medik
|
|
$dataObj->instalasi = 'rajal';
|
|
$dataObj->kodebooking = $dat->pp_barcode;//'230119100001'; //// Nomor Booking / Barcode
|
|
$dataObj->nomorpendaftaran = ''; //// Nomor Billing Atau idx Pendaftaran
|
|
$dataObj->waktu = strtotime(date('Y-m-d H:i:s'));// strtotime('Ymdhis'); //// INstalasi Medik 1:rajal 2:ranap
|
|
$dataObj->tasktime = strtotime(date('Y-m-d H:i:s')); //'1674178500'; //// Time by sortime
|
|
$dataObj->taskid = '1'; //// Task Id Proses
|
|
$dataJSON = json_encode($dataObj);
|
|
//var_dump($dataJSON);
|
|
$response_array = array(
|
|
'url' => "http://10.10.150.170:8080/gomed-api/restapi/taskid",
|
|
'action' => "proses",
|
|
'method' => "POST",
|
|
'data' => $dataJSON,
|
|
'header' => array(
|
|
'X-Username: antrian@onsite',
|
|
'X-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlIjp7InJvbGUiOiJ1c2VyIiwidXNlcm5hbWUiOiJhbnRyaWFuQG9uc2l0ZSIsInBhc3N3b3JkIjoiYW50cmlhbkAyMDIzIn0sImV4cCI6MTY4MzUxNzcyMywiaWF0IjoxNjc0NzkxMzIzfQ.KAjJTxDkC6cP8KqQJQUzwgJLlU5gWNLdHSj-43TcVfA',
|
|
'Content-Type: application/json'
|
|
)
|
|
);
|
|
//var_dump($dataJSON);
|
|
// //var_dump($response_array);
|
|
$respose_data = $this->sendRequest($response_array);
|
|
//var_dump($respose_data);
|
|
|
|
}
|
|
|
|
// redirect('index.php/ps_loket_admin');
|
|
}
|
|
|
|
protected function sendRequest($options = []){
|
|
$curl = curl_init();
|
|
|
|
$action = isset($options["action"]) ? (trim($options["action"]) != "" ? "/" . $options["action"] : "") : "";
|
|
$headers = array(
|
|
"Content-type: application/json"
|
|
);
|
|
|
|
$data = isset($options["data"]) ? $options["data"] : "";
|
|
|
|
//var_dump($data);
|
|
$headers = $options["header"];
|
|
|
|
// if (isset($options["header"])) {
|
|
// $headers = array_merge($headers, $options["header"]);
|
|
// }
|
|
//var_dump($headers);
|
|
/** GET URL ACCES IP REST API */
|
|
// $id = $this->writeBridgeLog([
|
|
// "URL" => $options["url"] . $action,
|
|
// "REQUEST" => $data,
|
|
// "ACCESS_FROM_IP" => $_SERVER['REMOTE_ADDR']
|
|
// ]);
|
|
curl_setopt($curl, CURLOPT_URL, $options["url"] . $action);
|
|
curl_setopt($curl, CURLOPT_HEADER, false);
|
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $options["method"]);
|
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
|
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
|
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
|
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
|
$result = curl_exec($curl);
|
|
|
|
var_dump($result);
|
|
|
|
|
|
curl_close($curl);
|
|
|
|
|
|
|
|
// /** GET URL ACCES IP REST API */
|
|
// // $this->writeBridgeLog([
|
|
// // "ID" => $id,
|
|
// // "RESPONSE" => $result
|
|
// // ]);
|
|
|
|
//return json_decode($result);
|
|
|
|
$result = json_decode($result);
|
|
// var_dump($result);
|
|
//exit();
|
|
// if($result['metadata']['code']=='200'){
|
|
// $this->session->set_flashdata('message', 'Anda berhasil check in pasien M-JKN');
|
|
// redirect('index.php/ps_loket_admin');
|
|
// }else{
|
|
// $this->session->set_flashdata('message', 'Anda gagal check in pasien M-JKN');
|
|
// redirect('index.php/ps_loket_admin');
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
}
|
|
?>
|