154 lines
5.6 KiB
PHP
154 lines
5.6 KiB
PHP
<?php
|
|
include '../core/main.php';
|
|
|
|
$post = $_REQUEST['pk']['main'];
|
|
$pemerisaan = isset($_REQUEST['pk']['pemeriksaan']['form_id']) ? $_REQUEST['pk']['pemeriksaan']['form_id'] : '';
|
|
|
|
function HexadecimalToASCII($in, $to_num = false, $pad_up = false, $pass_key = null)
|
|
{
|
|
$out = '';
|
|
$index = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
$base = strlen($index);
|
|
|
|
if ($pass_key !== null) {
|
|
// Although this function's purpose is to just make the
|
|
// ID short - and not so much secure,
|
|
// with this patch by Simon Franz (http://blog.snaky.org/)
|
|
// you can optionally supply a password to make it harder
|
|
// to calculate the corresponding numeric ID
|
|
|
|
for ($n = 0; $n < strlen($index); $n++) {
|
|
$i[] = substr($index, $n, 1);
|
|
}
|
|
|
|
$pass_hash = hash('sha256',$pass_key);
|
|
$pass_hash = (strlen($pass_hash) < strlen($index) ? hash('sha512', $pass_key) : $pass_hash);
|
|
|
|
for ($n = 0; $n < strlen($index); $n++) {
|
|
$p[] = substr($pass_hash, $n, 1);
|
|
}
|
|
|
|
array_multisort($p, SORT_DESC, $i);
|
|
$index = implode($i);
|
|
}
|
|
|
|
if ($to_num) {
|
|
// Digital number <<-- alphabet letter code
|
|
$len = strlen($in) - 1;
|
|
|
|
for ($t = $len; $t >= 0; $t--) {
|
|
$bcp = bcpow($base, $len - $t);
|
|
$out = $out + strpos($index, substr($in, $t, 1)) * $bcp;
|
|
}
|
|
|
|
if (is_numeric($pad_up)) {
|
|
$pad_up--;
|
|
|
|
if ($pad_up > 0) {
|
|
$out -= pow($base, $pad_up);
|
|
}
|
|
}
|
|
} else {
|
|
// Digital number -->> alphabet letter code
|
|
if (is_numeric($pad_up)) {
|
|
$pad_up--;
|
|
|
|
if ($pad_up > 0) {
|
|
$in += pow($base, $pad_up);
|
|
}
|
|
}
|
|
|
|
for ($t = ($in != 0 ? floor(log($in, $base)) : 0); $t >= 0; $t--) {
|
|
$bcp = bcpow($base, $t);
|
|
$a = floor($in / $bcp) % $base;
|
|
$out = $out . substr($index, $a, 1);
|
|
$in = $in - ($a * $bcp);
|
|
}
|
|
}
|
|
|
|
return $out;
|
|
}
|
|
|
|
if ($pemerisaan != '') {
|
|
//validasi nomer pemeriksaan lagi
|
|
$datenow = date('Y-m-d');
|
|
$max_pemeriksaan = "select max(no_pemeriksaan) as code from order_poct where norm = '" . $post['norm'] . "' ";
|
|
$tmp_poct = $db->query($max_pemeriksaan);
|
|
|
|
$max_number = $tmp_poct->fetchAll()[0];
|
|
|
|
$tanggal = date_create_from_format('Y-m-d', $datenow);
|
|
|
|
//cek display_barcode_poct
|
|
$sql_display = "select var_value from global_var where var_name = 'display_barcode_poct'";
|
|
$display = $db->query($sql_display)->fetchAll();
|
|
|
|
if (!empty($max_number['code'])) {
|
|
$substr = (int)substr($max_number['code'], 16, 4) + 1;
|
|
if ($display[0]['var_value'] == 1) {
|
|
$code = date("His").$post['norm'] . date_format($tanggal, 'Ymd') . sprintf('%04d', $substr);
|
|
}else{
|
|
$code = $post['norm'] . date_format($tanggal, 'Ymd') . sprintf('%04d', $substr);
|
|
}
|
|
} else {
|
|
if ($display[0]['var_value'] == 1) {
|
|
$code = date("His").$post['norm'] . date_format($tanggal, 'Ymd') . '0001';
|
|
}else{
|
|
$code = $post['norm'] . date_format($tanggal, 'Ymd') . '0001';
|
|
}
|
|
|
|
}
|
|
|
|
$code_hex = HexadecimalToASCII($code);
|
|
|
|
//hitung total order
|
|
$total_order = 0;
|
|
$created_at = date('Y-m-d h:i:s');
|
|
foreach ($pemerisaan as $item) {
|
|
$poct_list = "select a.jenis_pemeriksaan, a.pemeriksaan, a.tarif_rs_id, b.jumlah as harga from order_poct_list a
|
|
join m_tarif_rs b on a.tarif_rs_id = b.id_tarif where a.id = {$item}";
|
|
$tmp_list = $db->query($poct_list);
|
|
|
|
$data = $tmp_list->fetchAll()[0];
|
|
$total_order += $data['harga'];
|
|
}
|
|
|
|
//simpan ke table order_poct
|
|
$insert_poct = "INSERT INTO order_poct(norm, operator_id, dokter_id, ruang_id, no_pemeriksaan, tanggal, total_order, status, created_at, no_billing, idxdaftar, flag, carabayar_id, order_number)
|
|
VALUES ({$post['norm']}, {$post['id_operator']}, {$post['kd_dokter']}, {$post['ruang_id']}, {$code}, '{$post['tanggal']}', {$total_order}, 1,'{$created_at}', '{$post['nobill']}', '{$post['idxdaftar']}' ,'1', '{$post['carabayar_id']}', '{$code_hex}')";
|
|
|
|
if (_DBTYPE_ == 'mysqli') {
|
|
$execute_poct = execute($insert_poct);
|
|
$id_poct = $execute_poct->insertid;
|
|
} else {
|
|
$insert_poct .= " RETURNING id";
|
|
$execute_poct = execute($insert_poct);
|
|
$id_poct = $execute_poct->fetchFirst()['id'];
|
|
}
|
|
|
|
//insert ke table order_poct_detail
|
|
$keterangan = '';
|
|
foreach ($pemerisaan as $item) {
|
|
$poct_list = "select a.jenis_pemeriksaan, a.pemeriksaan, a.tarif_rs_id, a.kode_tarif_rs as kode_tarif, a.kode_tarif_rs, b.jumlah as harga from order_poct_list a
|
|
join m_tarif_rs b on a.tarif_rs_id = b.id_tarif where a.id = {$item}";
|
|
$tmp_list = $db->query($poct_list);
|
|
|
|
$data = $tmp_list->fetchAll()[0];
|
|
$total_order += $data['harga'];
|
|
|
|
$keterangan = isset($post['ket_pemeriksaan'][$data['jenis_pemeriksaan']]) ? $post['ket_pemeriksaan'][$data['jenis_pemeriksaan']] : '';
|
|
|
|
$insert_detail = "INSERT INTO order_poct_detail(order_poct_id, order_poct_list, jenis_pemeriksaan, pemeriksaan, harga, keterangan, tarif_rs_id, kode_tarif_rs)
|
|
VALUES ({$id_poct}, {$item},'{$data['jenis_pemeriksaan']}', '{$data['pemeriksaan']}' , {$data['harga']}, '{$keterangan}', '{$data['tarif_rs_id']}', '{$data['kode_tarif_rs']}')";
|
|
$execute_poct_detail = execute($insert_detail);
|
|
}
|
|
|
|
$row = $db->query("SELECT id from order_poct where id='$id_poct'");
|
|
|
|
$affected = $row->numRows();
|
|
} else {
|
|
$affected = 'Gagal Simpan, Pilih Pemeriksaan POCT';
|
|
}
|
|
|
|
echo $affected;
|