$tahun=date('Y');
//echo $tahun; exit;
$ambil_kode_tahun = substr ($tahun, -2);
$kode_tahun=$ambil_kode_tahun;
// 15-06-99 tahun - nomer_urut - nomer_urut
$isi_record="156794";
$potong1=substr($isi_record,2,-2); //ambil 2 tengah $kd_t //kode tengah
//echo $potong1;
$potong2=substr($isi_record,-2); //ambil 2 belakang $kd_b //kode belakang
//echo $potong2; exit;
if($potong1 == 00 and $potong2 == 00){
$kd_tengah=$potong1;
$tmp=$potong2+1;
$kd_b = sprintf("%02s", $tmp);
}elseif($potong1 == 99 and $potong2 == 99){
$tmp=00;
$kd_tengah = sprintf("%02s", $tmp); //$kd_t = Tetap
$tmp_b=00;
$kd_b = sprintf("%02s", $tmp_b); //$kd_b = 01 tambah 1
}
elseif($potong2 == 99){
$potong=00;
$tmp=$potong;
$kd_b = sprintf("%02s", $tmp); //$kd_b = 00
$tmp_b=$potong1+1;
$kd_tengah = sprintf("%02s", $tmp_b); //$kd_t = 01
//$kd_t=$potong1;
}elseif($potong1 > 0 and $potong2 >0){
$tmp_b=$potong1;
$kd_tengah = sprintf("%02s", $tmp_b); //$kd_t = 01 tetap
$tmp=$potong2+1;
$kd_b = sprintf("%02s", $tmp); //$kd_b = 00
}elseif($potong1 > 0 and $potong2 == 00){
$tmp=$potong1;
$kd_tengah = sprintf("%02s", $tmp); //$kd_t = Tetap
$tmp_b=$potong2+1;
$kd_b = sprintf("%02s", $tmp_b); //$kd_b = 01 tambah 1
}elseif($potong1 == 00 and $potong2 > 0){
$tmp=$potong1;
$kd_tengah = sprintf("%02s", $tmp); //$kd_t = Tetap
$tmp_b=$potong2+1;
$kd_b = sprintf("%02s", $tmp_b); //$kd_b = 01 tambah 1
//echo $kd;
}
$kode_baru=$kode_tahun."".$kd_tengah."".$kd_b;
echo $kode_baru;
exit();
0 Response to "kode rekam medis"
Posting Komentar