diff --git a/app/Controllers/PrintLabel.php b/app/Controllers/PrintLabel.php index d5096f0..44ea7a1 100644 --- a/app/Controllers/PrintLabel.php +++ b/app/Controllers/PrintLabel.php @@ -3,7 +3,7 @@ namespace App\Controllers; class PrintLabel extends BaseController { - public function labelPostek($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv ) { + public function labelPostek($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv, $collection_date) { // Printer Posteck $sampleLabel ="N OD @@ -14,19 +14,19 @@ D10 A4,3,0,2,1,1,N,\"$title.$name\" A4,25,0,2,1,1,N,\"$sex {$age}Y\" A4,55,0,2,1,1,N,\"$sample\" -A4,75,0,2,1,1,N,\"\" +A4,75,0,2,1,1,N,\"Chapter\" B149,35,0,1,3,8,70,N,\"$barcode\" -A199,110,0,2,1,1,N,\"LAB $barcode\" -A4,140,0,2,1,1,N,\"UH : $uhid\" -A4,160,0,2,1,1,N,\"BV : $bv\" -A195,156,0,2,1,1,N,\"Tgl Coll\" +A195,110,0,2,1,1,N,\"SAM# $barcode\" +A4,140,0,2,1,1,N,\"RM : $uhid\" +A4,160,0,2,1,1,N,\"VN : $bv\" +A195,156,0,2,1,1,N,\"$collection_date\" P1 "; return $sampleLabel; } - public function labelZebra($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv ) { + public function labelZebra($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv, $collection_date) { $sampleLabel ="N OD q400 @@ -36,12 +36,12 @@ D10 A4,3,0,2,1,1,N,\"$title.$name\" A4,25,0,2,1,1,N,\"$sex {$age}Y\" A4,55,0,2,1,1,N,\"$sample\" -A4,75,0,2,1,1,N,\"\" +A4,75,0,2,1,1,N,\"Chapter\" B149,35,0,1,3,8,70,N,\"$barcode\" -A199,110,0,2,1,1,N,\"LAB $barcode\" -A4,140,0,2,1,1,N,\"UH : $uhid\" -A4,160,0,2,1,1,N,\"BV : $bv\" -A195,156,0,2,1,1,N,\"Tgl Coll\" +A195,110,0,2,1,1,N,\"SAM# $barcode\" +A4,140,0,2,1,1,N,\"RM : $uhid\" +A4,160,0,2,1,1,N,\"VN : $bv\" +A195,156,0,2,1,1,N,\"$collection_date\" P1 "; @@ -71,16 +71,16 @@ P1 $networkPath = ""; $db = \Config\Database::connect(); - $sql = "select p.PATNUMBER as UHID, sr.HOSTORDERNUMBER as BV, p.NAME, p.SEX, -DATEDIFF(YEAR, BirthDate, GETDATE()) - - CASE WHEN MONTH(BirthDate) > MONTH(GETDATE()) OR (MONTH(BirthDate) = MONTH(GETDATE()) AND DAY(BirthDate) > DAY(GETDATE())) THEN 1 - ELSE 0 END AS AGE, -ds.FULLTEXT, st.SAMPLETYPE+right(sr.SP_ACCESSNUMBER,5) as BARCODE, getdate() as COLLDATE -from SP_TUBES st -left join SP_REQUESTS sr on st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER -left join PATIENTS p on p.PATID=sr.PATID -left join DICT_SAMPLES_TYPES ds on ds.SAMPCODE=st.SAMPLETYPE -where st.SP_ACCESSNUMBER='$access' AND ds.SAMPCODE = '$sampletype'"; + $sql = "select p.PATNUMBER as UHID, sr.HOSTORDERNUMBER as BV, p.NAME, p.SEX, + DATEDIFF(YEAR, BirthDate, GETDATE()) - + CASE WHEN MONTH(BirthDate) > MONTH(GETDATE()) OR (MONTH(BirthDate) = MONTH(GETDATE()) AND DAY(BirthDate) > DAY(GETDATE())) THEN 1 + ELSE 0 END AS AGE, + ds.FULLTEXT, st.SAMPLETYPE+right(sr.SP_ACCESSNUMBER,5) as BARCODE, sr.COLLECTIONDATE + from SP_TUBES st + left join SP_REQUESTS sr on st.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER + left join PATIENTS p on p.PATID=sr.PATID + left join DICT_SAMPLES_TYPES ds on ds.SAMPCODE=st.SAMPLETYPE + where st.SP_ACCESSNUMBER='$access' AND ds.SAMPCODE = '$sampletype'"; $query = $db->query($sql); $results = $query->getResultArray(); @@ -94,15 +94,21 @@ where st.SP_ACCESSNUMBER='$access' AND ds.SAMPCODE = '$sampletype'"; $sample = $item['FULLTEXT']; $barcode = $item['BARCODE']; $age = $item['AGE']; - $colldate = $item['COLLDATE']; + $collectiondate = $item['COLLECTIONDATE']; + $date = \DateTime::createFromFormat('Y-m-d H:i:s.v', $collectiondate); + if ($date) { + $collectiondate = $date->format('d/m/Y H:i'); + } else { + $collectiondate = ""; + } // Ruang Analis Printer POSTEK C168/200s if ($role === 'admin' || $role === 'user') { $printer = $this->printerLab(); - $label = $this->labelPostek($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv ); + $label = $this->labelPostek($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv, $collectiondate); } else if ($role === 'sampling') { $printer = $this->printerSampling(); - $label = $this->labelZebra($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv ); + $label = $this->labelZebra($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv, $collectiondate); } else { // Eksekusi Kode Berikut Apabila Role Bukan Analis atau Sampling return $this->response->setJSON([ @@ -133,7 +139,7 @@ where st.SP_ACCESSNUMBER='$access' AND ds.SAMPCODE = '$sampletype'"; // Hapus Koneksi //exec('net use '. $letterPath .' /delete 2>&1', $output, $return_var); return $this->response->setJSON( [ - 'message' => "Print Berhasil", + 'message' => "Print Berhasil!" , 'status' => true, ]); } diff --git a/app/Controllers/PrintResult.php b/app/Controllers/PrintResult.php index 5d0d0dd..af6b6af 100644 --- a/app/Controllers/PrintResult.php +++ b/app/Controllers/PrintResult.php @@ -169,7 +169,7 @@ class PrintResult extends BaseController {